diff --git a/source/Applications/AcousticPulse/CMakeLists.txt b/source/Applications/AcousticPulse/CMakeLists.txt
index a7148e05a589ffa90269cf0ec796cc572f4ab862..abafdc458023fa7b144f71465330bdfd646e5922 100644
--- a/source/Applications/AcousticPulse/CMakeLists.txt
+++ b/source/Applications/AcousticPulse/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(AcousticPulse)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications.cmake b/source/Applications/Applications.cmake
similarity index 97%
rename from source/Applications.cmake
rename to source/Applications/Applications.cmake
index eb161441e5b9c6c0352c42202db589d1d12a9d06..c307637124ebc82d3f22a7b337908be53f7a8df3 100644
--- a/source/Applications.cmake
+++ b/source/Applications/Applications.cmake
@@ -1,59 +1,60 @@
-#add_subdirectory(tests)
-#add_subdirectory(Applications/gridRf)
-#add_subdirectory(Applications/greenvortex)
-# add_subdirectory(Applications/micropart)
-add_subdirectory(Applications/sphere)
-#add_subdirectory(Applications/vfscript)
-#add_subdirectory(Applications/reefer)
-#add_subdirectory(Applications/bananas)
-#add_subdirectory(Applications/test1)
-#add_subdirectory(Applications/test2)
-#add_subdirectory(Applications/bananas2)
-# add_subdirectory(Applications/plate)
-# add_subdirectory(Applications/plate2)
-add_subdirectory(Applications/FlowAroundCylinder)
-add_subdirectory(Applications/LaminarTubeFlow)
-# add_subdirectory(Applications/LaminarTubeFlowConv)
-#add_subdirectory(Applications/cylinderSt)
-#add_subdirectory(Applications/mpichTest)
-# add_subdirectory(Applications/block_test)
-# add_subdirectory(Applications/bond_test)
-# add_subdirectory(Applications/bond_benchmark)
-# add_subdirectory(Applications/musis)
-add_subdirectory(Applications/Hagen_Poiseuille_flow)
-add_subdirectory(Applications/Hagen_Poiseuille_flow2)
-add_subdirectory(Applications/mpi_benchmark)
-# add_subdirectory(Applications/shear)
-# add_subdirectory(Applications/wing)
-# add_subdirectory(Applications/bKanal)
-# add_subdirectory(Applications/bKanal2)
-# add_subdirectory(Applications/bKanalAv)
-# add_subdirectory(Applications/fetol_demo)
-# add_subdirectory(Applications/insitu_demo)
-# add_subdirectory(Applications/insitu_demoserver)
-# add_subdirectory(Applications/PlateWithPorousInlay)
-# add_subdirectory(Applications/stick)
-# add_subdirectory(Applications/band)
-# add_subdirectory(Applications/bone)
-# add_subdirectory(Applications/sbone)
-# add_subdirectory(Applications/bbone)
-# add_subdirectory(Applications/porplate2)
-# add_subdirectory(Applications/BeadPack)
-# add_subdirectory(Applications/town)
-# add_subdirectory(Applications/perm)
-add_subdirectory(Applications/pChannel)
-#add_subdirectory(Applications/pDisk)
-add_subdirectory(Applications/BoxBenchmark)
-add_subdirectory(Applications/DHIT)
-add_subdirectory(Applications/DLR-F16)
-add_subdirectory(Applications/DLR-F16-Solid)
-add_subdirectory(Applications/DLR-F16-Porous)
-add_subdirectory(Applications/aperm)
-add_subdirectory(Applications/f16test)
-add_subdirectory(Applications/mirror)
-add_subdirectory(Applications/levels)
-add_subdirectory(Applications/AcousticPulse)
-add_subdirectory(Applications/screw)
-add_subdirectory(Applications/PoiseuilleFlow)
-add_subdirectory(Applications/InterfaceTest)
-add_subdirectory(Applications/teperm)
+#add_subdirectory(tests)
+#add_subdirectory(Applications/gridRf)
+#add_subdirectory(Applications/greenvortex)
+# add_subdirectory(Applications/micropart)
+add_subdirectory(Applications/sphere)
+#add_subdirectory(Applications/vfscript)
+#add_subdirectory(Applications/reefer)
+#add_subdirectory(Applications/bananas)
+#add_subdirectory(Applications/test1)
+#add_subdirectory(Applications/test2)
+#add_subdirectory(Applications/bananas2)
+# add_subdirectory(Applications/plate)
+# add_subdirectory(Applications/plate2)
+add_subdirectory(Applications/FlowAroundCylinder)
+add_subdirectory(Applications/LaminarTubeFlow)
+# add_subdirectory(Applications/LaminarTubeFlowConv)
+#add_subdirectory(Applications/cylinderSt)
+#add_subdirectory(Applications/mpichTest)
+# add_subdirectory(Applications/block_test)
+# add_subdirectory(Applications/bond_test)
+# add_subdirectory(Applications/bond_benchmark)
+# add_subdirectory(Applications/musis)
+add_subdirectory(Applications/Hagen_Poiseuille_flow)
+add_subdirectory(Applications/Hagen_Poiseuille_flow2)
+add_subdirectory(Applications/mpi_benchmark)
+# add_subdirectory(Applications/shear)
+# add_subdirectory(Applications/wing)
+# add_subdirectory(Applications/bKanal)
+# add_subdirectory(Applications/bKanal2)
+# add_subdirectory(Applications/bKanalAv)
+# add_subdirectory(Applications/fetol_demo)
+# add_subdirectory(Applications/insitu_demo)
+# add_subdirectory(Applications/insitu_demoserver)
+# add_subdirectory(Applications/PlateWithPorousInlay)
+# add_subdirectory(Applications/stick)
+# add_subdirectory(Applications/band)
+# add_subdirectory(Applications/bone)
+# add_subdirectory(Applications/sbone)
+# add_subdirectory(Applications/bbone)
+# add_subdirectory(Applications/porplate2)
+# add_subdirectory(Applications/BeadPack)
+# add_subdirectory(Applications/town)
+# add_subdirectory(Applications/perm)
+add_subdirectory(Applications/pChannel)
+#add_subdirectory(Applications/pDisk)
+add_subdirectory(Applications/BoxBenchmark)
+add_subdirectory(Applications/DHIT)
+add_subdirectory(Applications/DLR-F16)
+add_subdirectory(Applications/DLR-F16-Solid)
+add_subdirectory(Applications/DLR-F16-Porous)
+add_subdirectory(Applications/aperm)
+add_subdirectory(Applications/f16test)
+add_subdirectory(Applications/mirror)
+add_subdirectory(Applications/levels)
+add_subdirectory(Applications/AcousticPulse)
+add_subdirectory(Applications/screw)
+add_subdirectory(Applications/PoiseuilleFlow)
+add_subdirectory(Applications/InterfaceTest)
+add_subdirectory(Applications/teperm)
+add_subdirectory(Applications/Thermoplast)
diff --git a/source/Applications/BoxBenchmark/CMakeLists.txt b/source/Applications/BoxBenchmark/CMakeLists.txt
index e54279829a7ff3d44893f355ad10968259fca79a..ddae32fc951e23ba59082c74efa55d861fd814f3 100644
--- a/source/Applications/BoxBenchmark/CMakeLists.txt
+++ b/source/Applications/BoxBenchmark/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(BoxBenchmark)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/DHIT/CMakeLists.txt b/source/Applications/DHIT/CMakeLists.txt
index f0264bd094b279f54f78c36166c5ed8b390860a1..e1ffbe8e27f2b9260b10381ec0d29988248cbcd0 100644
--- a/source/Applications/DHIT/CMakeLists.txt
+++ b/source/Applications/DHIT/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(dhit)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/DLR-F16-Porous/CMakeLists.txt b/source/Applications/DLR-F16-Porous/CMakeLists.txt
index 3038576536800a6259ac766447c69489e439bc73..915b463bc2ae8dd535dff489381544b904c7a85e 100644
--- a/source/Applications/DLR-F16-Porous/CMakeLists.txt
+++ b/source/Applications/DLR-F16-Porous/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(f16porous)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/DLR-F16-Porous/f16.cpp b/source/Applications/DLR-F16-Porous/f16.cpp
index 39b92015270cec0d7641865b1f1bcb44a29bd51d..5f08df3e1f70d64b123ce3b801004a949aa09ef1 100644
--- a/source/Applications/DLR-F16-Porous/f16.cpp
+++ b/source/Applications/DLR-F16-Porous/f16.cpp
@@ -174,9 +174,9 @@ void initPteBC(SPtr<Grid3D> grid, vector<SPtr<Block3D>>& vectorTE, string fngFil
 //////////////////////////////////////////////////////////////////////////
 void initPte(SPtr<Grid3D> grid, SPtr<Interactor3D> fngIntrTE, SPtr<Interactor3D> fngIntrTEmesh, string pathOut, SPtr<Communicator> comm)
 {
-   SetSolidOrBoundaryBlockVisitor v1(fngIntrTE, SetSolidOrBoundaryBlockVisitor::SOLID);
+   SetSolidBlocksBlockVisitor v1(fngIntrTE);
    grid->accept(v1);
-   SetSolidOrBoundaryBlockVisitor v2(fngIntrTE, SetSolidOrBoundaryBlockVisitor::BC);
+   SetBcBlocksBlockVisitor v2(fngIntrTE);
    grid->accept(v2);
    std::vector<SPtr<Block3D>>& sb = fngIntrTE->getSolidBlockSet();
    std::vector<SPtr<Block3D>>& bb = fngIntrTE->getBcBlocks();
@@ -649,7 +649,7 @@ void run(string configname)
 
             SPtr<Interactor3D> fngIntrNoTapeBody = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(fngMeshNoTapeBody, grid, noSlipBCAdapter, Interactor3D::SOLID, (Interactor3D::Accuracy)accuracy));//, Interactor3D::POINTS));
 
-            SetSolidOrBoundaryBlockVisitor v(fngIntrNoTapeBody, SetSolidOrBoundaryBlockVisitor::SOLID);
+            SetSolidBlocksBlockVisitor v(fngIntrNoTapeBody);
             grid->accept(v);
             std::vector<SPtr<Block3D>>& sb = fngIntrNoTapeBody->getSolidBlockSet();
             for (SPtr<Block3D> block : sb)
@@ -892,9 +892,9 @@ void run(string configname)
          if (myid==0) UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB");
 
          if (myid==0) UBLOG(logINFO, "initPteBC:start");
-         SetSolidOrBoundaryBlockVisitor v1(fngIntrTE, SetSolidOrBoundaryBlockVisitor::SOLID);
+         SetSolidBlocksBlockVisitor v1(fngIntrTE);
          grid->accept(v1);
-         SetSolidOrBoundaryBlockVisitor v2(fngIntrTE, SetSolidOrBoundaryBlockVisitor::BC);
+         SetBcBlocksBlockVisitor v2(fngIntrTE);
          grid->accept(v2);
          std::vector<SPtr<Block3D>>& vectorTE = fngIntrTE->getSolidBlockSet();
          std::vector<SPtr<Block3D>>& bb = fngIntrTE->getBcBlocks();
@@ -959,7 +959,7 @@ void run(string configname)
          //Post process
          {
             SPtr<UbScheduler> geoSch(new UbScheduler(1));
-            WriteBoundaryConditionsCoProcessor ppgeo(grid, geoSch, pathOut, WbWriterVtkXmlBinary::getInstance(), conv, comm);
+            WriteBoundaryConditionsCoProcessor ppgeo(grid, geoSch, pathOut, WbWriterVtkXmlBinary::getInstance(), comm);
             ppgeo.process(0);
          }
 
@@ -1008,7 +1008,22 @@ void run(string configname)
          SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor);
          grid->accept(setConnsVisitor);
 
-         if (reinit)
         {
            //InitDistributionsBlockVisitor initVisitor1;
            //grid->accept(initVisitor1);
            SPtr<Grid3D> oldGrid(new Grid3D(comm));
            SPtr<UbScheduler> iSch(new UbScheduler());
            SPtr<MPIIORestartCoProcessor> rcp(new MPIIORestartCoProcessor(oldGrid, iSch, pathReInit, comm));
            rcp->setLBMKernel(kernel);
            rcp->setBCProcessor(bcProc);
            rcp->restart(stepReInit);
            InitDistributionsWithInterpolationGridVisitor initVisitor2(oldGrid, iProcessor, nuLB);
            grid->accept(initVisitor2);
            //if (myid==0) UBLOG(logINFO, "reinitGrid:start");
            //reinitGrid(grid);
            //if (myid==0) UBLOG(logINFO, "reinitGrid:end");
         }
+         if (reinit)
+         {
+            //InitDistributionsBlockVisitor initVisitor1;
+            //grid->accept(initVisitor1);
+            SPtr<Grid3D> oldGrid(new Grid3D(comm));
+            SPtr<UbScheduler> iSch(new UbScheduler());
+            SPtr<MPIIORestartCoProcessor> rcp(new MPIIORestartCoProcessor(oldGrid, iSch, pathReInit, comm));
+            rcp->setLBMKernel(kernel);
+            rcp->setBCProcessor(bcProc);
+            rcp->restart(stepReInit);
+            InitDistributionsWithInterpolationGridVisitor initVisitor2(oldGrid, iProcessor, nuLB);
+            grid->accept(initVisitor2);
+            //if (myid==0) UBLOG(logINFO, "reinitGrid:start");
+            //reinitGrid(grid);
+            //if (myid==0) UBLOG(logINFO, "reinitGrid:end");
+         }
 
          //if (myid==0) UBLOG(logINFO, "setPointsTE:start");
          //SPtr<GbTriFaceMesh3D> fngMeshTE;
@@ -1040,7 +1055,7 @@ void run(string configname)
          fngMeshBody->translate(0.0, 0.0, -0.00011);
          if (myid==0) GbSystem3D::writeGeoObject(fngMeshBody.get(), pathOut+"/geo/fngMeshBody2", WbWriterVtkXmlBinary::getInstance());
          SPtr<Interactor3D> fngIntrBody = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(fngMeshBody, grid, noSlipBCAdapter, Interactor3D::SOLID, (Interactor3D::Accuracy)accuracy));
-         SetSolidOrBoundaryBlockVisitor v(fngIntrBody, SetSolidOrBoundaryBlockVisitor::BC);
+         SetBcBlocksBlockVisitor v(fngIntrBody);
          grid->accept(v);
          fngIntrBody->initInteractor();
 //////////////////////////////////////////////////////////////////////////
diff --git a/source/Applications/DLR-F16-Solid/CMakeLists.txt b/source/Applications/DLR-F16-Solid/CMakeLists.txt
index 451efeff8603e5dcf2b7a0b8ad52960281388070..f7a6686b451de9e72a280b6f52287ba70e8df092 100644
--- a/source/Applications/DLR-F16-Solid/CMakeLists.txt
+++ b/source/Applications/DLR-F16-Solid/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(f16solid)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake)  
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/DLR-F16-Solid/f16-solid.cfg b/source/Applications/DLR-F16-Solid/f16-solid.cfg
index 570058aec947ec8c0362b5cae447a9d1a66f618f..304613a23faf1df6ddfd2e964ce7c4199607634a 100644
--- a/source/Applications/DLR-F16-Solid/f16-solid.cfg
+++ b/source/Applications/DLR-F16-Solid/f16-solid.cfg
@@ -1,4 +1,4 @@
-pathOut = d:/temp/DLR-F16-Solid-tttt
+pathOut = d:/temp/DLR-F16-Solid-comp
 pathGeo = d:/Projects/SFB880/DLR-F16/Geometry
 
 fngFileWhole1 = F16_broad_Quad_noTape_full.stl
@@ -11,7 +11,7 @@ pathReInit = /work/koskuche/DLR-F16_L7
 stepReInit = 10000
 
 numOfThreads = 4
-availMem = 3.5e9
+availMem = 10e9
 
 logToFile = false
 
@@ -21,30 +21,30 @@ boundingBox = -0.90 1.5 0.0 0.03 -0.66 0.66
 
 blockNx = 10 10 10
 
-refineLevel = 5
+refineLevel = 0
 
-#deltaXfine = 0.003
+deltaXfine = 0.003
 #deltaXfine = 0.0015
 #deltaXfine = 0.00075 #level 0
 #deltaXfine = 0.000375 #level 1
 #deltaXfine = 0.0001875 #level 2
 #deltaXfine = 0.00009375 #level 3
 #deltaXfine = 0.000046875 #level 4
-deltaXfine = 0.0000234375 #level 5
+#deltaXfine = 0.0000234375 #level 5
 
 startDistance = -1.0e-3
 refineDistance = 0.6e-3
 
-writeBlocks = true
+writeBlocks = false
 
-newStart = false
+newStart = true
 restartStep = 2000
 
 cpStep = 1000
 cpStart = 3000
 
 outTimeStep = 100
-outTimeStart = 3000
+outTimeStart = 100
 
 endTime = 10000
 
diff --git a/source/Applications/DLR-F16-Solid/f16.cpp b/source/Applications/DLR-F16-Solid/f16.cpp
index a5f49560ed11ea04b2406ebea38b061d5592bada..27b7bc62350c7568f95092d778efeaafbc01e7dc 100644
--- a/source/Applications/DLR-F16-Solid/f16.cpp
+++ b/source/Applications/DLR-F16-Solid/f16.cpp
@@ -169,9 +169,12 @@ void run(string configname)
       SPtr<LBMKernel> kernel = SPtr<LBMKernel>(new CompressibleCumulant4thOrderViscosityLBMKernel());
       //dynamicPointerCast<CompressibleCumulant4thOrderViscosityLBMKernel>(kernel)->setBulkViscosity(nuLB*2.0e3);
 
+      //SPtr<LBMKernel> kernel = SPtr<LBMKernel>(new IncompressibleCumulantLBMKernel());
+
       kernel->setBCProcessor(bcProc);
 
       SPtr<LBMKernel> spKernel = SPtr<LBMKernel>(new CompressibleCumulantLBMKernel());
+      //SPtr<LBMKernel> spKernel = SPtr<LBMKernel>(new IncompressibleCumulantLBMKernel());
       spKernel->setBCProcessor(bcProc);
       //////////////////////////////////////////////////////////////////////////
       //restart
@@ -361,7 +364,7 @@ void run(string configname)
             /////delete solid blocks
             if (myid==0) UBLOG(logINFO, "deleteSolidBlocks - start");
 
-            SetSolidOrBoundaryBlockVisitor v(fngIntrWhole1, SetSolidOrBoundaryBlockVisitor::SOLID);
+            SetSolidBlocksBlockVisitor v(fngIntrWhole1);
             grid->accept(v);
             std::vector<SPtr<Block3D>>& sb = fngIntrWhole1->getSolidBlockSet();
             for (SPtr<Block3D> block : sb)
@@ -487,6 +490,11 @@ void run(string configname)
             ppblocks.process(2);
          }
 
+         GbCuboid3DPtr mic6(new GbCuboid3D( 0.3, 0.015, -0.46+4.25*deltaXcoarse, 0.3+deltaXcoarse, 0.015+deltaXcoarse, -0.46+5.25*deltaXcoarse));
+         if (myid==0) GbSystem3D::writeGeoObject(mic6.get(), pathOut+"/geo/mic6", WbWriterVtkXmlBinary::getInstance());
+         GbCuboid3DPtr mic7(new GbCuboid3D(0.3, 0.015, -0.3+4.25*deltaXcoarse, 0.3+deltaXcoarse, 0.015+deltaXcoarse, -0.3+5.25*deltaXcoarse));
+         if (myid==0) GbSystem3D::writeGeoObject(mic7.get(), pathOut+"/geo/mic7", WbWriterVtkXmlBinary::getInstance());
+ 
          unsigned long long numberOfBlocks = (unsigned long long)grid->getNumberOfBlocks();
          int ghostLayer = 3;
          unsigned long long numberOfNodesPerBlock = (unsigned long long)(blockNx[0])* (unsigned long long)(blockNx[1])* (unsigned long long)(blockNx[2]);
@@ -594,7 +602,7 @@ void run(string configname)
          //Post process
          {
             SPtr<UbScheduler> geoSch(new UbScheduler(1));
-            WriteBoundaryConditionsCoProcessor ppgeo(grid, geoSch, pathOut, WbWriterVtkXmlBinary::getInstance(), conv, comm);
+            WriteBoundaryConditionsCoProcessor ppgeo(grid, geoSch, pathOut, WbWriterVtkXmlBinary::getInstance(), comm);
             ppgeo.process(0);
          }
 
@@ -653,7 +661,7 @@ void run(string configname)
          fngMeshWhole2->rotate(0.0, 0.5, 0.0);
          if (myid==0) GbSystem3D::writeGeoObject(fngMeshWhole2.get(), pathOut+"/geo/fngMeshWhole3", WbWriterVtkXmlBinary::getInstance());
          SPtr<Interactor3D> fngIntrWhole2 = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(fngMeshWhole2, grid, noSlipBCAdapter, Interactor3D::SOLID, (Interactor3D::Accuracy)accuracy));
-         SetSolidOrBoundaryBlockVisitor v(fngIntrWhole2, SetSolidOrBoundaryBlockVisitor::BC);
+         SetBcBlocksBlockVisitor v(fngIntrWhole2);
          grid->accept(v);
          fngIntrWhole2->initInteractor();
 ///////////////////////////////////////////////////////////////////////////////////////////////
@@ -727,24 +735,28 @@ void run(string configname)
       if (myid==0) GbSystem3D::writeGeoObject(mic5->getBoundingBox().get(), pathOut+"/geo/mic5", WbWriterVtkXmlBinary::getInstance());
       SPtr<TimeseriesCoProcessor> tsp5(new TimeseriesCoProcessor(grid, stepMV, mic5, pathOut+"/mic/mic5", comm));
 
-      SPtr<IntegrateValuesHelper> mic6(new IntegrateValuesHelper(grid, comm, 0.3, 0.015,  -0.46+4.25*deltaXcoarse, 0.3+deltaXcoarse, 0.015+deltaXcoarse, -0.46+5.25*deltaXcoarse));
-      if (myid==0) GbSystem3D::writeGeoObject(mic6->getBoundingBox().get(), pathOut+"/geo/mic6", WbWriterVtkXmlBinary::getInstance());
-      SPtr<TimeseriesCoProcessor> tsp6(new TimeseriesCoProcessor(grid, stepMV, mic6, pathOut+"/mic/mic6", comm));
+      //SPtr<IntegrateValuesHelper> mic6(new IntegrateValuesHelper(grid, comm, 0.3, 0.015,  -0.46+4.25*deltaXcoarse, 0.3+deltaXcoarse, 0.015+deltaXcoarse, -0.46+5.25*deltaXcoarse));
+      //if (myid==0) GbSystem3D::writeGeoObject(mic6->getBoundingBox().get(), pathOut+"/geo/mic6", WbWriterVtkXmlBinary::getInstance());
+      //SPtr<TimeseriesCoProcessor> tsp6(new TimeseriesCoProcessor(grid, stepMV, mic6, pathOut+"/mic/mic6", comm));
+
+      //SPtr<IntegrateValuesHelper> mic7(new IntegrateValuesHelper(grid, comm, 0.3, 0.015, -0.3+4.25*deltaXcoarse, 0.3+deltaXcoarse, 0.015+deltaXcoarse, -0.3+5.25*deltaXcoarse));
+      //if (myid==0) GbSystem3D::writeGeoObject(mic7->getBoundingBox().get(), pathOut+"/geo/mic7", WbWriterVtkXmlBinary::getInstance());
+      //SPtr<TimeseriesCoProcessor> tsp7(new TimeseriesCoProcessor(grid, stepMV, mic7, pathOut+"/mic/mic7", comm));
 
       omp_set_num_threads(numOfThreads);
       SPtr<UbScheduler> stepGhostLayer(new UbScheduler(1));
       SPtr<Calculator> calculator(new BasicCalculator(grid, stepGhostLayer, endTime));
       calculator->addCoProcessor(nupsCoProcessor);
       calculator->addCoProcessor(restartCoProcessor);
-      calculator->addCoProcessor(writeMQSelectCoProcessor);
+      //calculator->addCoProcessor(writeMQSelectCoProcessor);
       calculator->addCoProcessor(writeMQCoProcessor);
-      calculator->addCoProcessor(tsp1);
-      calculator->addCoProcessor(tsp2);
-      calculator->addCoProcessor(tsp3);
-      calculator->addCoProcessor(tsp4);
-      calculator->addCoProcessor(tsp5);
-      calculator->addCoProcessor(tsp6);
-      calculator->addCoProcessor(tav);
+      //calculator->addCoProcessor(tsp1);
+      //calculator->addCoProcessor(tsp2);
+      //calculator->addCoProcessor(tsp3);
+      //calculator->addCoProcessor(tsp4);
+      //calculator->addCoProcessor(tsp5);
+      //calculator->addCoProcessor(tsp6);
+      //calculator->addCoProcessor(tav);
 
 
       if (myid==0) UBLOG(logINFO, "Simulation-start");
diff --git a/source/Applications/DLR-F16/CMakeLists.txt b/source/Applications/DLR-F16/CMakeLists.txt
index ca92147afba6b55c0ba6495079659e7951cc7480..3ed3128e03a02a782427078f73ec49c5cca5d805 100644
--- a/source/Applications/DLR-F16/CMakeLists.txt
+++ b/source/Applications/DLR-F16/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(f16)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/FlowAroundCylinder/CMakeLists.txt b/source/Applications/FlowAroundCylinder/CMakeLists.txt
index 505649ac5c67f252d7df50200279a1c0121cbae4..f90461ae0426645645aee95d7861b12817464445 100644
--- a/source/Applications/FlowAroundCylinder/CMakeLists.txt
+++ b/source/Applications/FlowAroundCylinder/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(cylinder)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake)  
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/Hagen_Poiseuille_flow/CMakeLists.txt b/source/Applications/Hagen_Poiseuille_flow/CMakeLists.txt
index a74bd8e6452ca5e82a67064a9384c958fb673f0c..a08cabcebb8ad5a1bbc9279c8acd9f1577cdfd36 100644
--- a/source/Applications/Hagen_Poiseuille_flow/CMakeLists.txt
+++ b/source/Applications/Hagen_Poiseuille_flow/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(pflow)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/Hagen_Poiseuille_flow2/CMakeLists.txt b/source/Applications/Hagen_Poiseuille_flow2/CMakeLists.txt
index f59b6c279c654fefb8e26fd34123ea9e8f941ee8..89a138ea268f1b62abda3e9d472e656fcf28f8cb 100644
--- a/source/Applications/Hagen_Poiseuille_flow2/CMakeLists.txt
+++ b/source/Applications/Hagen_Poiseuille_flow2/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(pflow2)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/IncludsList.cmake b/source/Applications/IncludsList.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..c0479fc3afb94c32a554b54ecfe6674e796ebd94
--- /dev/null
+++ b/source/Applications/IncludsList.cmake
@@ -0,0 +1,3 @@
+INCLUDE_DIRECTORIES(${APPS_ROOT})
+INCLUDE(${SOURCE_ROOT}/VirtualFluidsBasic/IncludsList.cmake)
+INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/IncludsList.cmake) 
diff --git a/source/Applications/InterfaceTest/CMakeLists.txt b/source/Applications/InterfaceTest/CMakeLists.txt
index 23e303ca018fb29b9a8836d6ac95c2cf50a540b9..f98f769a042768ee014aa7001873d88e0212240b 100644
--- a/source/Applications/InterfaceTest/CMakeLists.txt
+++ b/source/Applications/InterfaceTest/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(InterfaceTest)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/LaminarTubeFlow/CMakeLists.txt b/source/Applications/LaminarTubeFlow/CMakeLists.txt
index 2c85f27b2566754af1b25609c3ed022f3c2fa7e6..ab7d30c95c3264d86b2609ce33a8b0911fef8167 100644
--- a/source/Applications/LaminarTubeFlow/CMakeLists.txt
+++ b/source/Applications/LaminarTubeFlow/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(ltf)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/LaminarTubeFlow/ltf.cfg b/source/Applications/LaminarTubeFlow/ltf.cfg
index 27aadee92985170cfbaedeb66fafeba7a1bf0cd8..7f2b8c724b3fa6fee5d376d548fce21123db161a 100644
--- a/source/Applications/LaminarTubeFlow/ltf.cfg
+++ b/source/Applications/LaminarTubeFlow/ltf.cfg
@@ -1,4 +1,4 @@
-pathname = d:/temp/LaminarTubeFlow_non_ref_inc
+pathname = d:/temp/LaminarTubeFlow
 numOfThreads = 4
 availMem = 10e9
 
@@ -10,7 +10,7 @@ dx = 1
 refineLevel = 0
 
 #Simulation
-uLB = 0.05
+uLB = 0.1
 Re = 10
 
 
@@ -23,4 +23,4 @@ cpStart = 100000
 cpStep = 100000
 
 outTime = 1
-endTime = 10000000
\ No newline at end of file
+endTime = 100
\ No newline at end of file
diff --git a/source/Applications/LaminarTubeFlow/ltf.cpp b/source/Applications/LaminarTubeFlow/ltf.cpp
index 5dbeb4fd29037f3fc3d00b38f9287d97aab5b29c..00e05aea74cc9a50d9e1793126ff50267f373c0a 100644
--- a/source/Applications/LaminarTubeFlow/ltf.cpp
+++ b/source/Applications/LaminarTubeFlow/ltf.cpp
@@ -277,7 +277,7 @@ void run(string configname)
          //boundary conditions grid
          {
             SPtr<UbScheduler> geoSch(new UbScheduler(1));
-            SPtr<CoProcessor> ppgeo(new WriteBoundaryConditionsCoProcessor(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm));
+            SPtr<CoProcessor> ppgeo(new WriteBoundaryConditionsCoProcessor(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), comm));
             ppgeo->process(0);
             ppgeo.reset();
          }
diff --git a/source/Applications/PoiseuilleFlow/CMakeLists.txt b/source/Applications/PoiseuilleFlow/CMakeLists.txt
index 3ae1d3b634ca9d17159a4a1905cfe4387a8934cc..43ea7697a846d3453bcdf8e53f6b5a9622ee9e71 100644
--- a/source/Applications/PoiseuilleFlow/CMakeLists.txt
+++ b/source/Applications/PoiseuilleFlow/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(pf)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/PoiseuilleFlow/pf1.cpp b/source/Applications/PoiseuilleFlow/pf1.cpp
index 85582c56f2025de146a7858fe03397aaa04bc3b9..1df2bffaae1ad6649cfb06bc98901e810ac7e168 100644
--- a/source/Applications/PoiseuilleFlow/pf1.cpp
+++ b/source/Applications/PoiseuilleFlow/pf1.cpp
@@ -139,7 +139,7 @@ void pf1()
    //write data for visualization of boundary conditions
    {
       SPtr<UbScheduler> geoSch(new UbScheduler(1));
-      WriteBoundaryConditionsCoProcessor ppgeo(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), SPtr<LBMUnitConverter>(new LBMUnitConverter()), comm);
+      WriteBoundaryConditionsCoProcessor ppgeo(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), comm);
       ppgeo.process(0);
    }
    
diff --git a/source/Applications/Thermoplast/CMakeLists.txt b/source/Applications/Thermoplast/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..5624b03136a7c901d1fe69fa224464104d3a08a6
--- /dev/null
+++ b/source/Applications/Thermoplast/CMakeLists.txt
@@ -0,0 +1,29 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+
+########################################################
+## C++ PROJECT                                       ###
+########################################################
+PROJECT(thermoplast)
+IF(${USE_DEM_COUPLING})
+	INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
+	INCLUDE(${SOURCE_ROOT}/DemCoupling/IncludsList.cmake)
+
+	#################################################################
+	###   LOCAL FILES                                             ###
+	#################################################################
+	FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h
+							 ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
+							 ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp  )
+	 
+	SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES})
+	SOURCE_GROUP(src FILES ${SPECIFIC_FILES})
+	  
+	SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} VirtualFluids)
+	
+	#message("CAB_ADDITIONAL_LINK_LIBRARIES: " ${CAB_ADDITIONAL_LINK_LIBRARIES})
+
+	#################################################################
+	###   CREATE PROJECT                                          ###
+	#################################################################
+	CREATE_CAB_PROJECT(thermoplast BINARY)
+ENDIF()
\ No newline at end of file
diff --git a/source/Applications/Thermoplast/config.txt b/source/Applications/Thermoplast/config.txt
new file mode 100644
index 0000000000000000000000000000000000000000..954ed682104a5a01602f668369a953a0d4f7315d
--- /dev/null
+++ b/source/Applications/Thermoplast/config.txt
@@ -0,0 +1,32 @@
+#simulation parameters
+#boundingBox = 0 0 0 300 1520 2320
+
+boundingBox = 60 1370 10 190 1530 320 #test bb
+
+#boundingBox = 60 0 10 190 1530 2320  #production bb
+ 
+blocknx = 10 10 10 
+#blocknx = 300 420 320
+endTime = 100000
+outTime = 500
+availMem = 25e9
+uLB = 0.1
+
+#PE parameters
+peMinOffset = 46 2 2
+peMaxOffset = -8 -25 -2
+sphereTime = 10
+
+#geometry files
+pathGeo = d:/Projects/ThermoPlast/SimGeo
+michel = /michel.stl
+plexiglas = /plexiglas.stl
+
+pathOut = g:/temp/thermoplastCluster5
+
+#restart
+cpStart = 20000000
+cpStep =  20000000
+restart = false
+
+nupsStep = 1000 1000 10000000
\ No newline at end of file
diff --git a/source/Applications/Thermoplast/thermoplast.cpp b/source/Applications/Thermoplast/thermoplast.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fac556f3c0fefc2f1ca7fbe34793ec89b6dd9655
--- /dev/null
+++ b/source/Applications/Thermoplast/thermoplast.cpp
@@ -0,0 +1,503 @@
+#include <iostream>
+#include <string>
+
+#include "PointerDefinitions.h"
+
+#include <iostream>
+#include <string>
+#include <memory>
+#include <array>
+
+#include "VirtualFluids.h"
+#include <MuParser/include/muParser.h>
+#include "ForceCalculator.h"
+
+
+#include <MovableObjectInteractor.h>
+#include <DemCoProcessor.h>
+#include <PePartitioningGridVisitor.h>
+
+#include <PePhysicsEngineMaterialAdapter.h>
+#include <PePhysicsEngineGeometryAdapter.h>
+#include <PePhysicsEngineSolverAdapter.h>
+
+#include <VelocityBcReconstructor.h>
+#include <EquilibriumReconstructor.h>
+#include <ExtrapolationReconstructor.h>
+
+#include <DummyPhysicsEngineSolverAdapter.h>
+#include <DummyPhysicsEngineMaterialAdapter.h>
+#include <DummyPhysicsEngineGeometryAdapter.h>
+#include <WriteDemObjectsCoProcessor.h>
+
+#include "CreateDemObjectsCoProcessor.h"
+#include "RestartDemObjectsCoProcessor.h"
+
+using namespace std;
+
+//simulation bounding box
+double g_minX1 = 0;
+double g_minX2 = 0;
+double g_minX3 = 0;
+
+double g_maxX1 = 0;
+double g_maxX2 = 0;
+double g_maxX3 = 0;
+
+vector<double> peMinOffset;
+vector<double> peMaxOffset;
+
+string          pathOut;// = "d:/temp/thermoplastCluster";
+string          pathGeo;// = "d:/Projects/ThermoPlast/Geometrie";
+
+std::shared_ptr<DemCoProcessor> makePeCoProcessor(SPtr<Grid3D> grid, SPtr<Communicator> comm, const SPtr<UbScheduler> peScheduler, const std::shared_ptr<LBMUnitConverter> lbmUnitConverter, int maxpeIterations)
+{
+   double peRelaxtion = 0.7;
+   //int maxpeIterations = 10000;
+   //Beschleunigung g
+   double g = 9.81 * lbmUnitConverter->getFactorAccWToLb();
+   //Vector3D globalLinearAcc(0.0, -g, 0.0);
+   Vector3D globalLinearAcc(0.0, 0.0, -g);
+
+   std::shared_ptr<PePhysicsEngineMaterialAdapter> planeMaterial = std::make_shared<PePhysicsEngineMaterialAdapter>("granular", 1.0, 0, 0.1 / 2, 0.1 / 2, 0.5, 1, 1, 0, 0);
+
+   const int gridNx = val<1>(grid->getBlockNX()) * grid->getNX1();
+   const int gridNy = val<2>(grid->getBlockNX()) * grid->getNX2();
+   const int gridNz = val<3>(grid->getBlockNX()) * grid->getNX3();
+
+   //UbTupleInt3 simulationDomain(gridNx, gridNy, gridNz);
+   //std::array<double, 6> simulationDomain = {1, 1, 1, 30, 30, 30};
+   std::array<double, 6> simulationDomain ={ g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3 };
+   UbTupleInt3 numberOfBlocks(grid->getNX1(), grid->getNX2(), grid->getNX3());
+   //UbTupleInt3 numberOfBlocks((simulationDomain[3]-simulationDomain[0])/val<1>(grid->getBlockNX()), (simulationDomain[4]-simulationDomain[1])/val<2>(grid->getBlockNX()), (simulationDomain[5]-simulationDomain[2])/val<3>(grid->getBlockNX()));
+   UbTupleBool3 isPeriodic(grid->isPeriodicX1(), grid->isPeriodicX2(), grid->isPeriodicX3());
+   Vector3D minOffset(peMinOffset[0], peMinOffset[1], peMinOffset[2]);
+   Vector3D maxOffset(peMaxOffset[0], peMaxOffset[1], peMaxOffset[2]);
+
+   SPtr<GbObject3D> boxPE(new GbCuboid3D(simulationDomain[0]+minOffset[0], simulationDomain[1]+minOffset[1], simulationDomain[2]+minOffset[2], simulationDomain[3]+maxOffset[0], simulationDomain[4]+maxOffset[1], simulationDomain[5]+maxOffset[2]));
+   GbSystem3D::writeGeoObject(boxPE.get(), pathOut + "/geo/boxPE", WbWriterVtkXmlBinary::getInstance());
+
+   std::shared_ptr<PeParameter> peParamter = std::make_shared<PeParameter>(peRelaxtion, maxpeIterations, globalLinearAcc,
+      planeMaterial, simulationDomain, numberOfBlocks, isPeriodic, minOffset, maxOffset);
+   std::shared_ptr<PhysicsEngineSolverAdapter> peSolver = std::make_shared<PePhysicsEngineSolverAdapter>(peParamter);
+
+   const std::shared_ptr<ForceCalculator> forceCalculator = std::make_shared<ForceCalculator>(comm);
+
+   return std::make_shared<DemCoProcessor>(grid, peScheduler, comm, forceCalculator, peSolver);
+}
+
+//pipe flow with forcing
+void thermoplast(string configname)
+{
+   SPtr<Communicator> comm = MPICommunicator::getInstance();
+   int myid = comm->getProcessID();
+
+   ConfigurationFile   config;
+   config.load(configname);
+
+   vector<int>     blocknx = config.getVector<int>("blocknx");
+   vector<double>  boundingBox = config.getVector<double>("boundingBox");
+
+   int             endTime = config.getValue<int>("endTime");
+   double          outTime = config.getValue<double>("outTime");
+   double          availMem = config.getValue<double>("availMem");
+   double          uLB = config.getValue<double>("uLB");
+
+   string          michel = config.getValue<string>("michel");
+   string          plexiglas = config.getValue<string>("plexiglas");
+   double          sphereTime = config.getValue<double>("sphereTime");
+
+   double          cpStart = config.getValue<double>("cpStart");
+   double          cpStep = config.getValue<double>("cpStep");
+   bool            restart = config.getValue<bool>("restart");
+
+   peMinOffset = config.getVector<double>("peMinOffset");
+   peMaxOffset = config.getVector<double>("peMaxOffset");
+
+   pathOut = config.getValue<string>("pathOut");
+   pathGeo = config.getValue<string>("pathGeo");
+
+   //parameters
+   //string          pathOut = "d:/temp/thermoplast3";
+   //string          pathGeo = "d:/Projects/ThermoPlast/Geometrie";
+   int             numOfThreads = 1;
+   //int             blocknx[3] ={ 10,10,10 };
+   //double          endTime = 1000000;
+   //double          outTime = 300;
+   //double          availMem = 8e9;
+   double          deltax = 1;
+   double          rhoLB = 0.0;
+   //double          uLB =  0.1;
+   double          radius = 5;
+   double          Re = 300;
+   double          nuLB = (uLB*2.0*radius)/Re;
+
+   //geometry definition
+
+   //simulation bounding box
+   g_minX1 = boundingBox[0];
+   g_minX2 = boundingBox[1];
+   g_minX3 = boundingBox[2];
+
+   g_maxX1 = boundingBox[3];
+   g_maxX2 = boundingBox[4];
+   g_maxX3 = boundingBox[5];
+
+   double blockLength = blocknx[0]*deltax;
+
+   //Grid definition
+   SPtr<Grid3D> grid(new Grid3D(comm));
+   grid->setDeltaX(deltax);
+   grid->setBlockNX(blocknx[0], blocknx[1], blocknx[2]);
+   grid->setPeriodicX1(false);
+   grid->setPeriodicX2(false);
+   grid->setPeriodicX3(false);
+
+   //boundary conditions definition 
+   //////////////////////////////////////////////////////////////////////////////
+   SPtr<BCAdapter> noSlipBCAdapter(new NoSlipBCAdapter());
+   noSlipBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new NoSlipBCAlgorithm()));
+
+   mu::Parser fct;
+   fct.SetExpr("U");
+   fct.DefineConst("U", uLB);
+   SPtr<BCAdapter> inflowAdapter(new VelocityBCAdapter(true, false, false, fct, 0, BCFunction::INFCONST));
+   inflowAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new VelocityBCAlgorithm()));
+   //inflowAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new VelocityWithDensityBCAlgorithm()));
+
+   SPtr<BCAdapter> outflowAdapter(new DensityBCAdapter(rhoLB));
+   outflowAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new EqDensityBCAlgorithm()));
+   //outflowAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new NonEqDensityBCAlgorithm()));
+   //outflowAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new NonReflectingOutflowBCAlgorithm()));
+
+   //sphere BC
+   mu::Parser fct2;
+   fct2.SetExpr("U");
+   fct2.DefineConst("U", 0.0);
+   SPtr<BCAdapter> velocityBcParticleAdapter(new VelocityBCAdapter(true, false, false, fct2, 0, BCFunction::INFCONST));
+   velocityBcParticleAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new VelocityWithDensityBCAlgorithm()));
+
+   //boundary conditions visitor
+   SPtr<BoundaryConditionsBlockVisitor> bcVisitor(new BoundaryConditionsBlockVisitor());
+   bcVisitor->addBC(noSlipBCAdapter);
+   bcVisitor->addBC(inflowAdapter);
+   bcVisitor->addBC(outflowAdapter);
+   bcVisitor->addBC(velocityBcParticleAdapter);
+   //////////////////////////////////////////////////////////////////////////////////
+
+   //LBM kernel definition
+   SPtr<LBMKernel> kernel;
+   kernel = SPtr<LBMKernel>(new IncompressibleCumulantLBMKernel());
+   SPtr<BCProcessor> bcProc(new BCProcessor());
+   kernel->setBCProcessor(bcProc);
+
+   //blocks generating
+   SPtr<GbObject3D> gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3));
+   if (myid == 0) GbSystem3D::writeGeoObject(gridCube.get(), pathOut + "/geo/gridCube", WbWriterVtkXmlBinary::getInstance());
+   GenBlocksGridVisitor genBlocks(gridCube);
+   grid->accept(genBlocks);
+
+   //PE initialization
+   double refLengthLb = radius*2.0;
+   double refLengthWorld = refLengthLb * deltax;
+   const std::shared_ptr<LBMUnitConverter> lbmUnitConverter = std::make_shared<LBMUnitConverter>(refLengthWorld, LBMUnitConverter::WORLD_MATERIAL::AIR_20C, refLengthLb);
+   if (myid == 0) std::cout << lbmUnitConverter->toString() << std::endl;
+   double rhoSphere = 915 * lbmUnitConverter->getFactorDensityWToLb();  // kg/m^3
+   if (myid == 0) UBLOG(logINFO, "rhoSphere = "<<rhoSphere);
+   SPtr<PhysicsEngineMaterialAdapter> sphereMaterial(new PePhysicsEngineMaterialAdapter("Polypropylen", rhoSphere, 0, 0.15, 0.1, 0.45, 0.5, 1, 0, 0));
+   const int timestep = 2;
+   const SPtr<UbScheduler> peScheduler(new UbScheduler(timestep));
+   int maxpeIterations = 10;//endTime/2;
+   SPtr<DemCoProcessor> demCoProcessor = makePeCoProcessor(grid, comm, peScheduler, lbmUnitConverter, maxpeIterations);
+   demCoProcessor->setBlockVisitor(bcVisitor);
+
+   if (myid == 0)
+   {
+      UBLOG(logINFO, "Parameters:");
+      UBLOG(logINFO, "* uLB    = " << uLB);
+      UBLOG(logINFO, "* rhoLB  = " << rhoLB);
+      UBLOG(logINFO, "* nuLB   = " << nuLB);
+      UBLOG(logINFO, "* deltaX = " << deltax);
+      UBLOG(logINFO, "* radius = " << radius);
+      UBLOG(logINFO, "* Re     = " << Re);
+      UBLOG(logINFO, "* number of threads   = "<<numOfThreads);
+      UBLOG(logINFO, "* number of processes = "<<comm->getNumberOfProcesses());
+      UBLOG(logINFO, "* path = "<<pathOut);
+      UBLOG(logINFO, "Preprocess - start");
+   }
+
+   GbCuboid3DPtr geoInflow1(new GbCuboid3D(g_minX1-blockLength, g_maxX2-120.0, g_minX3+190.0, g_minX1+1, g_maxX2+20.0, g_minX3+320.0));
+   if (myid == 0) GbSystem3D::writeGeoObject(geoInflow1.get(), pathOut + "/geo/geoInflow1", WbWriterVtkXmlASCII::getInstance());
+
+   if (!restart)
+   {
+      //box
+      SPtr<GbObject3D> box(new GbCuboid3D(g_minX1-blockLength, g_minX2, g_minX3, g_maxX1+blockLength, g_maxX2, g_maxX3));
+      GbSystem3D::writeGeoObject(box.get(), pathOut + "/geo/box", WbWriterVtkXmlBinary::getInstance());
+
+      //michel
+      if (myid==0) UBLOG(logINFO, "Read michelGeo:start");
+      SPtr<GbTriFaceMesh3D> michelGeo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+michel, "michelGeo", GbTriFaceMesh3D::KDTREE_SAHPLIT, false));
+      if (myid==0) UBLOG(logINFO, "Read michelGeo:end");
+      if (myid==0) GbSystem3D::writeGeoObject(michelGeo.get(), pathOut+"/geo/michelGeo", WbWriterVtkXmlBinary::getInstance());
+
+      //plexiglas
+      if (myid==0) UBLOG(logINFO, "Read plexiglasGeo:start");
+      SPtr<GbTriFaceMesh3D> plexiglasGeo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+plexiglas, "plexiglasGeo", GbTriFaceMesh3D::KDTREE_SAHPLIT, false));
+      if (myid==0) UBLOG(logINFO, "Read plexiglasGeo:end");
+      if (myid==0) GbSystem3D::writeGeoObject(plexiglasGeo.get(), pathOut+"/geo/plexiglasGeo", WbWriterVtkXmlBinary::getInstance());
+
+      //Duese
+      if (myid==0) UBLOG(logINFO, "Read Duese:start");
+      SPtr<GbTriFaceMesh3D> s1Geo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+"/Duese/s1.stl", "plexiglasGeo", GbTriFaceMesh3D::KDTREE_SAHPLIT, false));
+      SPtr<GbTriFaceMesh3D> b1Geo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+"/Duese/b1.stl", "plexiglasGeo", GbTriFaceMesh3D::KDTREE_SAHPLIT, false));
+      SPtr<GbTriFaceMesh3D> p1Geo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+"/Duese/p1.stl", "plexiglasGeo", GbTriFaceMesh3D::KDTREE_SAHPLIT, false));
+      SPtr<GbTriFaceMesh3D> p2Geo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+"/Duese/p2.stl", "plexiglasGeo", GbTriFaceMesh3D::KDTREE_SAHPLIT, false));
+      if (myid==0) UBLOG(logINFO, "Read Duese:end");
+
+
+
+      //inflow
+      GbCuboid3DPtr geoInflow2(new GbCuboid3D(g_minX1-blockLength, g_minX2 - blockLength, g_minX3 - blockLength, g_minX1, g_maxX2 + blockLength, g_maxX3 + blockLength));
+      if (myid == 0) GbSystem3D::writeGeoObject(geoInflow2.get(), pathOut + "/geo/geoInflow2", WbWriterVtkXmlASCII::getInstance());
+
+      //GbCuboid3DPtr geoInflow3(new GbCuboid3D(g_minX1-blockLength, g_minX2-radius, g_maxX3-4.0*radius-1, g_minX1+1, g_maxX2+radius, g_maxX3-4.0*radius));
+      //if (myid == 0) GbSystem3D::writeGeoObject(geoInflow3.get(), pathOut + "/geo/geoInflow3", WbWriterVtkXmlASCII::getInstance());
+
+      //GbCuboid3DPtr geoInflow4(new GbCuboid3D(g_minX1-blockLength, g_minX2+4.0*radius, g_maxX3-4.0*radius-1.0, g_minX1+1, g_minX2+4.0*radius+1.0, g_maxX3+radius));
+      //if (myid == 0) GbSystem3D::writeGeoObject(geoInflow4.get(), pathOut + "/geo/geoInflow4", WbWriterVtkXmlASCII::getInstance());
+
+      //outflow
+      GbCuboid3DPtr geoOutflow(new GbCuboid3D(g_maxX1, g_minX2 - blockLength, g_minX3 - blockLength, g_maxX1 + blockLength, g_maxX2 + blockLength, g_maxX3 + blockLength));
+      if (myid == 0) GbSystem3D::writeGeoObject(geoOutflow.get(), pathOut + "/geo/geoOutflow", WbWriterVtkXmlASCII::getInstance());
+
+      //set boundary conditions for blocks and create process decomposition for MPI
+      SPtr<D3Q27Interactor> boxInt(new D3Q27Interactor(box, grid, noSlipBCAdapter, Interactor3D::INVERSESOLID));
+
+      //inflow
+      SPtr<D3Q27Interactor> inflowInt1 = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoInflow1, grid, inflowAdapter, Interactor3D::SOLID));
+      SPtr<D3Q27Interactor> inflowInt2 = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoInflow2, grid, outflowAdapter, Interactor3D::SOLID));
+
+      //SPtr<D3Q27Interactor> inflowInt3 = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoInflow3, grid, noSlipBCAdapter, Interactor3D::SOLID));
+      //SPtr<D3Q27Interactor> inflowInt4 = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoInflow4, grid, noSlipBCAdapter, Interactor3D::SOLID));
+
+      //outflow
+      SPtr<D3Q27Interactor> outflowInt = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoOutflow, grid, outflowAdapter, Interactor3D::SOLID));
+
+      //michel
+      SPtr<Interactor3D> michelInt = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(michelGeo, grid, noSlipBCAdapter, Interactor3D::SOLID));
+
+      //plexiglas
+      SPtr<Interactor3D> plexiglasInt = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(plexiglasGeo, grid, noSlipBCAdapter, Interactor3D::SOLID));
+
+      //Duese
+      SPtr<Interactor3D> s1Int = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(s1Geo, grid, noSlipBCAdapter, Interactor3D::SOLID));
+      SPtr<Interactor3D> b1Int = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(b1Geo, grid, noSlipBCAdapter, Interactor3D::SOLID));
+      SPtr<Interactor3D> p1Int = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(p1Geo, grid, noSlipBCAdapter, Interactor3D::SOLID));
+      SPtr<Interactor3D> p2Int = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(p2Geo, grid, noSlipBCAdapter, Interactor3D::SOLID));
+
+      //////////////////////////////////////////////////////////////////////////
+      SPtr<Grid3DVisitor> peVisitor(new PePartitioningGridVisitor(comm, demCoProcessor));
+      //SPtr<Grid3DVisitor> peVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY));
+      InteractorsHelper intHelper(grid, peVisitor);
+      intHelper.addInteractor(boxInt);
+      intHelper.addInteractor(michelInt);
+      intHelper.addInteractor(plexiglasInt);
+      intHelper.addInteractor(s1Int);
+      intHelper.addInteractor(b1Int);
+      intHelper.addInteractor(p1Int);
+      intHelper.addInteractor(p2Int);
+      intHelper.addInteractor(inflowInt1);
+      intHelper.addInteractor(outflowInt);
+      intHelper.addInteractor(inflowInt2);
+      intHelper.selectBlocks();
+
+      //write data for visualization of block grid
+      SPtr<CoProcessor> ppblocks(new WriteBlocksCoProcessor(grid, SPtr<UbScheduler>(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm));
+      ppblocks->process(0);
+      ppblocks.reset();
+
+      unsigned long long numberOfBlocks = (unsigned long long)grid->getNumberOfBlocks();
+      int ghostLayer = 3;
+      unsigned long long numberOfNodesPerBlock = (unsigned long long)(blocknx[0])* (unsigned long long)(blocknx[1])* (unsigned long long)(blocknx[2]);
+      unsigned long long numberOfNodes = numberOfBlocks * numberOfNodesPerBlock;
+      unsigned long long numberOfNodesPerBlockWithGhostLayer = numberOfBlocks * (blocknx[0] + ghostLayer) * (blocknx[1] + ghostLayer) * (blocknx[2] + ghostLayer);
+      double needMemAll = double(numberOfNodesPerBlockWithGhostLayer*(27 * sizeof(double) + sizeof(int) + sizeof(float) * 4));
+      double needMem = needMemAll / double(comm->getNumberOfProcesses());
+
+      if (myid == 0)
+      {
+         UBLOG(logINFO, "Number of blocks = " << numberOfBlocks);
+         UBLOG(logINFO, "Number of nodes  = " << numberOfNodes);
+         int minInitLevel = grid->getCoarsestInitializedLevel();
+         int maxInitLevel = grid->getFinestInitializedLevel();
+         for (int level = minInitLevel; level <= maxInitLevel; level++)
+         {
+            int nobl = grid->getNumberOfBlocks(level);
+            UBLOG(logINFO, "Number of blocks for level " << level << " = " << nobl);
+            UBLOG(logINFO, "Number of nodes for level " << level << " = " << nobl*numberOfNodesPerBlock);
+         }
+         UBLOG(logINFO, "Necessary memory  = " << needMemAll << " bytes");
+         UBLOG(logINFO, "Necessary memory per process = " << needMem << " bytes");
+         UBLOG(logINFO, "Available memory per process = " << availMem << " bytes");
+      }
+
+      //create LBM kernel
+      SetKernelBlockVisitor kernelVisitor(kernel, nuLB, availMem, needMem);
+      grid->accept(kernelVisitor);
+
+      intHelper.setBC();
+
+
+      //initialization of distributions
+      InitDistributionsBlockVisitor initVisitor;
+      //initVisitor.setVx1(uLB);
+      grid->accept(initVisitor);
+
+      //write data for visualization of boundary conditions
+      {
+         SPtr<UbScheduler> geoSch(new UbScheduler(1));
+         WriteBoundaryConditionsCoProcessor ppgeo(grid, geoSch, pathOut, WbWriterVtkXmlBinary::getInstance(), comm);
+         ppgeo.process(0);
+
+         WriteMacroscopicQuantitiesCoProcessor ppInit(grid, geoSch, pathOut, WbWriterVtkXmlBinary::getInstance(), SPtr<LBMUnitConverter>(new LBMUnitConverter()), comm);
+         ppInit.process(0);
+      }
+
+      if (myid == 0) UBLOG(logINFO, "Preprocess - end");
+   }
+
+   ////////////////////////////////////////////////////////////////////////////
+   ////generating spheres 
+   //UBLOG(logINFO, "generating spheres - start, rank="<<myid);
+   SPtr<UbScheduler> sphereScheduler(new UbScheduler(sphereTime));
+   SPtr<CreateDemObjectsCoProcessor> createSphereCoProcessor(new CreateDemObjectsCoProcessor(grid, sphereScheduler, comm, demCoProcessor, sphereMaterial));
+   //UBLOG(logINFO, "generating spheres - stop, rank="<<myid);
+
+   //restart
+   //UBLOG(logINFO, "restart definition - start, rank="<<myid);
+   SPtr<UbScheduler> restartSch(new UbScheduler(cpStep, cpStart));
+   SPtr<MPIIORestartCoProcessor> restartCoProcessor(new MPIIORestartCoProcessor(grid, restartSch, pathOut, comm));
+   restartCoProcessor->setLBMKernel(kernel);
+   restartCoProcessor->setBCProcessor(bcProc);
+   SPtr<RestartDemObjectsCoProcessor> restartDemObjectsCoProcessor(new RestartDemObjectsCoProcessor(grid, restartSch, pathOut, demCoProcessor, createSphereCoProcessor, radius, comm));
+   //UBLOG(logINFO, "restart definition - stop, rank="<<myid);
+
+   if (restart)
+   {
+      int startStep = restartCoProcessor->readCpTimeStep();
+      restartCoProcessor->restart(startStep);
+      restartDemObjectsCoProcessor->restart(startStep);
+   }
+
+   //set connectors
+   //UBLOG(logINFO, "set connectors - start, rank="<<myid);
+   InterpolationProcessorPtr iProcessor(new IncompressibleOffsetInterpolationProcessor());
+   SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor);
+   grid->accept(setConnsVisitor);
+   //UBLOG(logINFO, "set connectors - stop, rank="<<myid);
+
+   //BC visitor
+   //UBLOG(logINFO, "BC visitor - start, rank="<<myid);
+   grid->accept(*bcVisitor.get());
+   //UBLOG(logINFO, "BC visitor - stop, rank="<<myid);
+
+   //sphere prototypes
+   //UBLOG(logINFO, "sphere prototypes - start, rank="<<myid);
+   double d = 2.0*radius;
+   Vector3D origin(g_minX1+peMinOffset[0]+radius, geoInflow1->getX2Minimum()+4.0*d, geoInflow1->getX3Minimum()+2.0*d);
+   for (int x3 = 0; x3 < 2; x3++)
+      for (int x2 = 0; x2 < 2; x2++)
+         for (int x1 = 0; x1 < 1; x1++)
+         {
+            //SPtr<GbObject3D> sphere(new GbSphere3D(origin[0]+x1*d, origin[1]+x2*2.0*d, origin[2]+x3*2.0*d, radius));
+            SPtr<GbObject3D> sphere(new GbSphere3D(origin[0]+2.0*d, origin[1]+x2*1.5*d, origin[2]+x3*1.5*d, radius));
+            if (myid == 0) GbSystem3D::writeGeoObject(sphere.get(), pathOut + "/geo/sphere"+UbSystem::toString(x1)+UbSystem::toString(x2)+UbSystem::toString(x3), WbWriterVtkXmlASCII::getInstance());
+            createSphereCoProcessor->addGeoObject(sphere, Vector3D(uLB, 0.0, 0.0));
+         }
+   //UBLOG(logINFO, "sphere prototypes - stop, rank="<<myid);
+
+   //Vector3D origin(106+radius, 1372+radius, 12+radius);
+   //for (int x3 = 0; x3 < 28; x3++)
+   //   for (int x2 = 0; x2 < 12; x2++)
+   //      for (int x1 = 0; x1 < 7; x1++)
+   //      {
+   //         //SPtr<GbObject3D> sphere(new GbSphere3D(origin[0]+x1*d, origin[1]+x2*2.0*d, origin[2]+x3*2.0*d, radius));
+   //         SPtr<GbObject3D> sphere(new GbSphere3D(origin[0]+x1*1.1*d, origin[1]+x2*1.1*d, origin[2]+x3*1.1*d, radius));
+   //         //if (myid == 0) GbSystem3D::writeGeoObject(sphere.get(), pathOut + "/geo/sphere"+UbSystem::toString(x1)+UbSystem::toString(x2)+UbSystem::toString(x3), WbWriterVtkXmlASCII::getInstance());
+   //         createSphereCoProcessor->addGeoObject(sphere, Vector3D(uLB, 0.0, 0.0));
+   //      }
+
+   createSphereCoProcessor->process(0);
+
+   //write data for visualization of macroscopic quantities
+   SPtr<UbScheduler> visSch(new UbScheduler(outTime));
+   SPtr<WriteMacroscopicQuantitiesCoProcessor> writeMQCoProcessor(new WriteMacroscopicQuantitiesCoProcessor(grid, visSch, pathOut,
+      WbWriterVtkXmlBinary::getInstance(), SPtr<LBMUnitConverter>(new LBMUnitConverter()), comm));
+   writeMQCoProcessor->process(0);
+
+   SPtr<WriteBoundaryConditionsCoProcessor> writeBCCoProcessor(new WriteBoundaryConditionsCoProcessor(grid, visSch, pathOut,
+      WbWriterVtkXmlBinary::getInstance(), comm));
+   writeBCCoProcessor->process(0);
+
+   SPtr<WriteDemObjectsCoProcessor> writeDemObjectsCoProcessor(new WriteDemObjectsCoProcessor(grid, visSch, pathOut, WbWriterVtkXmlBinary::getInstance(), demCoProcessor, comm));
+   writeDemObjectsCoProcessor->process(0);
+
+   ////performance control
+   SPtr<UbScheduler> nupsSch(new UbScheduler(10, 30, 100));
+   SPtr<NUPSCounterCoProcessor> npr(new NUPSCounterCoProcessor(grid, nupsSch, numOfThreads, comm));
+
+   //start simulation 
+   omp_set_num_threads(numOfThreads);
+   SPtr<UbScheduler> stepGhostLayer(peScheduler);
+   SPtr<Calculator> calculator(new BasicCalculator(grid, stepGhostLayer, endTime));
+   calculator->addCoProcessor(npr);
+
+   calculator->addCoProcessor(createSphereCoProcessor);
+   calculator->addCoProcessor(demCoProcessor);
+   calculator->addCoProcessor(writeBCCoProcessor);
+   calculator->addCoProcessor(writeDemObjectsCoProcessor);
+   calculator->addCoProcessor(writeMQCoProcessor);
+   //calculator->addCoProcessor(restartDemObjectsCoProcessor);
+   //calculator->addCoProcessor(restartCoProcessor);
+
+   if (myid == 0) UBLOG(logINFO, "Simulation-start");
+   calculator->calculate();
+   if (myid == 0) UBLOG(logINFO, "Simulation-end");
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+int main(int argc, char* argv[])
+{
+   try
+   {
+      //Sleep(30000);
+      walberla::Environment env(argc, argv);
+
+      if (argv!=NULL)
+      {
+         if (argv[1]!=NULL)
+         {
+            thermoplast(string(argv[1]));
+         }
+         else
+         {
+            cout<<"Configuration file must be set!: "<<argv[0]<<" <config file>"<<endl<<std::flush;
+         }
+      }
+      return 0;
+   }
+   catch (std::exception& e)
+   {
+      UBLOG(logERROR, e.what());
+   }
+   catch (std::string& s)
+   {
+      UBLOG(logERROR, s);
+   }
+   catch (...)
+   {
+      UBLOG(logERROR, "unknown exception");
+   }
+}
diff --git a/source/VirtualFluids.h b/source/Applications/VirtualFluids.h
similarity index 97%
rename from source/VirtualFluids.h
rename to source/Applications/VirtualFluids.h
index 451dba3bf10a0345053f4daffaae62aa94257093..95a3197eef0fffa99cd7d033317bb7d2bd3c80f9 100644
--- a/source/VirtualFluids.h
+++ b/source/Applications/VirtualFluids.h
@@ -1,298 +1,299 @@
-#ifndef VirtualFluids_h__
-#define VirtualFluids_h__
-
-//VirtualFluids header files
- 
-#if defined VF_FETOL
-#define WIN32_LEAN_AND_MEAN
-#include <JM.h>
-#endif
-
-#ifdef _OPENMP
-#include <omp.h>
-#endif 
-
-#include <MuParser/include/muParser.h>
-#include <MuParser/include/muParserBase.h>
-#include <MuParser/include/muParserBytecode.h>
-#include <MuParser/include/muParserCallback.h>
-#include <MuParser/include/muParserDef.h>
-#include <MuParser/include/muParserDLL.h>
-#include <MuParser/include/muParserError.h>
-#include <MuParser/include/muParserFixes.h>
-#include <MuParser/include/muParserInt.h>
-#include <MuParser/include/muParserStack.h>
-#include <MuParser/include/muParserTemplateMagic.h>
-#include <MuParser/include/muParserTest.h>
-#include <MuParser/include/muParserToken.h>
-#include <MuParser/include/muParserTokenReader.h>
-#include <basics/container/CbArray2D.h>
-#include <basics/container/CbArray3D.h>
-#include <basics/container/CbArray4D.h>
-#include <basics/container/CbVector.h>
-#include <basics/container/CbVectorPool.h>
-#include <basics/memory/MbMemPool.h>
-#include <basics/memory/MbSharedPointerDefines.h>
-#include <basics/memory/MbSmartPtr.h>
-#include <basics/memory/MbSmartPtrBase.h>
-#include <basics/objects/ObCreator.h>
-#include <basics/objects/ObFactory.h>
-#include <basics/objects/ObObject.h>
-#include <basics/objects/ObObjectCreator.h>
-#include <basics/objects/ObObjectFactory.h>
-#include <basics/objects/ObObjectManager.h>
-#include <basics/transmitter/TbTransmitter.h>
-#include <basics/transmitter/TbTransmitterLocal.h>
-#include <basics/transmitter/TbTransmitterMpiPool.h>
-#include <basics/utilities/UbAutoRun.hpp>
-#include <basics/utilities/UbComparators.h>
-#include <basics/utilities/UbConverter.h>
-#include <basics/utilities/UbEqual.h>
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbFileInput.h>
-#include <basics/utilities/UbFileInputASCII.h>
-#include <basics/utilities/UbFileInputBinary.h>
-#include <basics/utilities/UbFileOutput.h>
-#include <basics/utilities/UbFileOutputASCII.h>
-#include <basics/utilities/UbFileOutputBinary.h>
-#include <basics/utilities/UbInfinity.h>
-#include <basics/utilities/UbKeys.h>
-#include <basics/utilities/UbLimits.h>
-#include <basics/utilities/UbLogger.h>
-#include <basics/utilities/UbMath.h>
-#include <basics/utilities/UbNupsTimer.h>
-#include <basics/utilities/UbObservable.h>
-#include <basics/utilities/UbObserver.h>
-#include <basics/utilities/UbPointerWrapper.h>
-#include <basics/utilities/UbRandom.h>
-#include <basics/utilities/UbScheduler.h>
-#include <basics/utilities/UbStaticPathMap.h>
-#include <basics/utilities/UbString.h>
-#include <basics/utilities/UbStringInputASCII.h>
-#include <basics/utilities/UbSystem.h>
-#include <basics/utilities/UbTableModel.h>
-#include <basics/utilities/UbTiming.h>
-#include <basics/utilities/UbTuple.h>
-#include <basics/writer/WbWriter.h>
-#include <basics/writer/WbWriterAvsASCII.h>
-#include <basics/writer/WbWriterAvsBinary.h>
-#include <basics/writer/WbWriterBOBJ.h>
-#include <basics/writer/WbWriterSunflow.h>
-#include <basics/writer/WbWriterTecPlotASCII.h>
-#include <basics/writer/WbWriterVtkASCII.h>
-#include <basics/writer/WbWriterVtkBinary.h>
-#include <basics/writer/WbWriterVtkXmlASCII.h>
-#include <basics/writer/WbWriterVtkXmlBinary.h>
-#include <basics/writer/WbWriterX3D.h>
-
-#include <BoundaryConditions/BCArray3D.h>
-#include <BoundaryConditions/BCProcessor.h>
-#include <BoundaryConditions/BCAlgorithm.h>
-#include <BoundaryConditions/BCFunction.h>
-#include <BoundaryConditions/BoundaryConditions.h>
-#include <BoundaryConditions/BCAdapter.h>
-#include <BoundaryConditions/DensityBCAdapter.h>
-#include <BoundaryConditions/BCProcessor.h>
-#include <BoundaryConditions/ThinWallBCProcessor.h>
-#include <BoundaryConditions/NoSlipBCAdapter.h>
-#include <BoundaryConditions/SlipBCAdapter.h>
-#include <BoundaryConditions/VelocityBCAdapter.h>
-#include <BoundaryConditions/BCAlgorithm.h>
-#include <BoundaryConditions/VelocityBCAlgorithm.h>
-#include <BoundaryConditions/NonEqDensityBCAlgorithm.h>
-#include <BoundaryConditions/EqDensityBCAlgorithm.h>
-#include <BoundaryConditions/NoSlipBCAlgorithm.h>
-#include <BoundaryConditions/ThinWallNoSlipBCAlgorithm.h>
-#include <BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h>
-#include <BoundaryConditions/SlipBCAlgorithm.h>
-#include <BoundaryConditions/NonReflectingOutflowBCAlgorithm.h>
-#include <BoundaryConditions/VelocityWithDensityBCAlgorithm.h>
-
-#include <Connectors/Block3DConnector.h>
-#include <Connectors/D3Q27ETCFOffVectorConnector.h>
-#include <Connectors/D3Q27ETFCOffVectorConnector.h>
-#include <Connectors/D3Q27ETFullDirectConnector.h>
-#include <Connectors/D3Q27ETFullVectorConnector.h>
-#include <Connectors/LocalBlock3DConnector.h>
-#include <Connectors/RemoteBlock3DConnector.h>
-#include <Connectors/CoarseToFineBlock3DConnector.h>
-#include <Connectors/CoarseToFineNodeSetBlock3DConnector.h>
-#include <Connectors/FineToCoarseBlock3DConnector.h>
-#include <Connectors/FineToCoarseNodeSetBlock3DConnector.h>
-#include <Connectors/ConnectorFactory.h>
-#include <Connectors/Block3DConnectorFactory.h>
-
-#include <Data/D3Q27EsoTwist3DSplittedVector.h>
-#include <Data/D3Q27EsoTwist3DSplittedVectorEx.h>
-#include <Data/DataSet3D.h>
-#include <Data/DistributionArray3D.h>
-#include <Data/EsoTwist3D.h>
-#include <Data/EsoTwistD3Q27System.h>
-#include <Data/VoidData3D.h>
-
-#include <Grid/Block3D.h>
-#include <Grid/Calculator.h>
-#include <Grid/BasicCalculator.h>
-#include <Grid/Grid3D.h>
-#include <Grid/Grid3DSystem.h>
-
-#include <Interactors/D3Q27Interactor.h>
-#include <Interactors/D3Q27TriFaceMeshInteractor.h>
-#include <Interactors/Interactor3D.h>
-#include <Interactors/InteractorsHelper.h>
-
-#include <CoProcessors/WriteBlocksCoProcessor.h>
-#include <CoProcessors/AdjustForcingCoProcessor.h>
-#include <CoProcessors/CalculateForcesCoProcessor.h>
-#include <CoProcessors/WriteMacroscopicQuantitiesCoProcessor.h>
-#include <CoProcessors/WriteMQFromSelectionCoProcessor.h>
-#include <CoProcessors/WriteBoundaryConditionsCoProcessor.h>
-//#include <CoProcessors/PathLineCoProcessor.h>
-//#include <CoProcessors/PathLineCoProcessorMcpart.h>
-#include <CoProcessors/PressureDifferenceCoProcessor.h>
-#include <CoProcessors/EmergencyExitCoProcessor.h>
-#include <CoProcessors/NUPSCounterCoProcessor.h>
-//#include <CoProcessors/Particles.h>
-#include <CoProcessors/CoProcessor.h>
-#include <CoProcessors/TurbulenceIntensityCoProcessor.h>
-#include <CoProcessors/AverageValuesCoProcessor.h>
-#include <CoProcessors/DecreaseViscosityCoProcessor.h>
-#include <CoProcessors/TimeseriesCoProcessor.h>
-#include <CoProcessors/ShearStressCoProcessor.h>
-#include <CoProcessors/QCriterionCoProcessor.h>
-#include <CoProcessors/InSituVTKCoProcessor.h>
-//#include <CoProcessors/MeanValuesCoProcessor.h>
-#include <CoProcessors/TimeAveragedValuesCoProcessor.h>
-#include <CoProcessors/InSituCatalystCoProcessor.h>
-#include <CoProcessors/MPIIORestartCoProcessor.h>
-#include <CoProcessors/MPIIOMigrationCoProcessor.h>
-#include <CoProcessors/PressureCoefficientCoProcessor.h>
-#include <LineTimeSeriesCoProcessor.h>
-
-#include <IntegrateValuesHelper.h>
-//#include <LBM/D3Q27CompactInterpolationProcessor.h>
-#include <LBM/IncompressibleOffsetInterpolationProcessor.h>
-#include <LBM/CompressibleOffsetInterpolationProcessor.h>
-#include <LBM/CompressibleOffsetMomentsInterpolationProcessor.h>
-#include <LBM/InterpolationHelper.h>
-#include <LBM/InterpolationProcessor.h>
-//#include <LBM/D3Q27OffsetInterpolationProcessor.h>
-#include <LBM/D3Q27System.h>
-#include <LBM/ICell.h>
-#include <LBM/InterpolationProcessor.h>
-#include <LBM/LBMKernel.h>
-#include <IncompressibleCumulantWithSpongeLayerLBMKernel.h>
-#include <LBM/LBMKernel.h>
-#include <LBM/IncompressibleCumulantLBMKernel.h>
-#include <LBM/CompressibleCumulantLBMKernel.h>
-#include <LBM/CompressibleCumulant4thOrderViscosityLBMKernel.h>
-#include <LBM/InitDensityLBMKernel.h>
-#include <LBM/VoidLBMKernel.h>
-#include <LBM/LBMSystem.h>
-#include <LBM/LBMUnitConverter.h>
-
-#include <numerics/geometry3d/CoordinateTransformation3D.h>
-#include <numerics/geometry3d/GbCuboid3D.h>
-#include <numerics/geometry3d/GbCylinder3D.h>
-#include <numerics/geometry3d/GbHalfSpace3D.h>
-#include <numerics/geometry3d/GbHalfSpaceKrischan3D.h>
-#include <numerics/geometry3d/GbLine3D.h>
-#include <numerics/geometry3d/GbMeshTools3D.h>
-#include <numerics/geometry3d/GbObject3D.h>
-#include <numerics/geometry3d/GbObject3DManager.h>
-#include <numerics/geometry3d/GbObjectGroup3D.h>
-#include <numerics/geometry3d/GbPoint3D.h>
-#include <numerics/geometry3d/GbPolygon3D.h>
-#include <numerics/geometry3d/GbQuadFaceMesh3D.h>
-#include <numerics/geometry3d/GbSphere3D.h>
-#include <numerics/geometry3d/GbSystem3D.h>
-#include <numerics/geometry3d/GbTriangle3D.h>
-#include <numerics/geometry3d/GbTriangularMesh3D.h>
-#include <numerics/geometry3d/GbTriFaceMesh3D.h>
-#include <numerics/geometry3d/GbVector3D.h>
-#include <numerics/geometry3d/GbVoxelMatrix3D.h>
-#include <numerics/geometry3d/creator/GbCuboid3DCreator.h>
-#include <numerics/geometry3d/creator/GbCylinder3DCreator.h>
-#include <numerics/geometry3d/creator/GbLine3DCreator.h>
-#include <numerics/geometry3d/creator/GbObject3DCreator.h>
-#include <numerics/geometry3d/creator/GbObject3DFactory.h>
-#include <numerics/geometry3d/creator/GbPoint3DCreator.h>
-#include <numerics/geometry3d/creator/GbPolygon3DCreator.h>
-#include <numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h>
-#include <numerics/geometry3d/creator/GbSphere3DCreator.h>
-#include <numerics/geometry3d/creator/GbTriangle3DCreator.h>
-#include <numerics/geometry3d/creator/GbTriangularMesh3DCreator.h>
-#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h>
-#include <numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h>
-#include <numerics/geometry3d/KdTree/KdNode.h>
-#include <numerics/geometry3d/KdTree/KdRay.h>
-#include <numerics/geometry3d/KdTree/KdSplitCandidate.h>
-#include <numerics/geometry3d/KdTree/KdSplitCandidateManager.h>
-#include <numerics/geometry3d/KdTree/KdTree.h>
-#include <numerics/geometry3d/KdTree/KdUtilities.h>
-#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h>
-#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h>
-#include <numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h>
-#include <numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h>
-#include <numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h>
-#include <numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h>
-#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h>
-
-#include <Parallel/Communicator.h>
-#include <Parallel/MetisPartitioner.h>
-#include <Parallel/MPICommunicator.h>
-#include <Parallel/NullCommunicator.h>
-#include <Parallel/PriorityQueueDecompositor.h>
-#include <Parallel/SimpleGeometricPartitioner.h>
-#include <Parallel/ZoltanPartitioner.h>
-#include <Parallel/BlocksDistributor.h>
-
-#include <Utilities/MathUtil.hpp>
-#include <Utilities/MemoryUtil.h>
-#include <Utilities/ConfigurationFile.hpp>
-#include <Utilities/VoxelMatrixUtil.hpp>
-#include <Utilities/ChangeRandomQs.hpp>
-
-#include <Visitors/Block3DVisitor.h>
-#include <Visitors/CreateTransmittersHelper.h>
-#include <Visitors/InitDistributionsBlockVisitor.h>
-#include <Visitors/SetConnectorsBlockVisitor.h>
-#include <Visitors/SetUndefinedNodesBlockVisitor.h>
-#include <Visitors/GenBlocksGridVisitor.h>
-#include <Visitors/Grid3DVisitor.h>
-#include <Visitors/MetisPartitioningGridVisitor.h>
-#include <Visitors/OverlapBlockVisitor.h>
-#include <Visitors/PQueuePartitioningGridVisitor.h>
-#include <Visitors/RatioBlockVisitor.h>
-#include <Visitors/RatioSmoothBlockVisitor.h>
-#include <Visitors/RefineCrossAndInsideGbObjectBlockVisitor.h>
-#include <Visitors/RefineInterGbObjectsVisitor.h>
-#include <Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.h>
-#include <Visitors/SetInterpolationDirsBlockVisitor.h>
-#include <Visitors/SetKernelBlockVisitor.h>
-#include <Visitors/SetForcingBlockVisitor.h>
-#include <Visitors/SetSpongeLayerBlockVisitor.h>
-#include <Visitors/SetSolidOrBoundaryBlockVisitor.h>
-#include <Visitors/RenumberBlockVisitor.h>
-#include <Visitors/ConnectorBlockVisitor.h>
-#include <Visitors/ViscosityBlockVisitor.h>
-#include <Visitors/BoundaryConditionsBlockVisitor.h>
-#include <Visitors/BoundaryConditionsBlockVisitor.h>
-#include <Visitors/ChangeBoundaryDensityBlockVisitor.h>
-#include <InitDistributionsFromFileBlockVisitor.h>
-#include <InitDistributionsWithInterpolationGridVisitor.h>
-#include <CheckRatioBlockVisitor.h>
-#include <SpongeLayerBlockVisitor.h>
-#include <ZoltanPartitioningGridVisitor.h>
-
-#include <Visitors/RefineCrossAndInsideGbObjectHelper.h>
-#include <RefineAroundGbObjectHelper.h>
-
-#if defined VF_FETOL
-   #include <FETOL/FETOLCalculator.h>
-   #include <FETOL/FETOLCommunicator.h>
-   #include <FETOL/FETOLSetConnectorsBlockVisitor.h>
-   #include <FETOL/FETOLTransmitterBondPool.h>   
-#endif
-
-#endif // VirtualFluids_h__
+#ifndef VirtualFluids_h__
+#define VirtualFluids_h__
+
+//VirtualFluids header files
+ 
+#if defined VF_FETOL
+#define WIN32_LEAN_AND_MEAN
+#include <JM.h>
+#endif
+
+#ifdef _OPENMP
+#include <omp.h>
+#endif 
+
+#include <MuParser/include/muParser.h>
+#include <MuParser/include/muParserBase.h>
+#include <MuParser/include/muParserBytecode.h>
+#include <MuParser/include/muParserCallback.h>
+#include <MuParser/include/muParserDef.h>
+#include <MuParser/include/muParserDLL.h>
+#include <MuParser/include/muParserError.h>
+#include <MuParser/include/muParserFixes.h>
+#include <MuParser/include/muParserInt.h>
+#include <MuParser/include/muParserStack.h>
+#include <MuParser/include/muParserTemplateMagic.h>
+#include <MuParser/include/muParserTest.h>
+#include <MuParser/include/muParserToken.h>
+#include <MuParser/include/muParserTokenReader.h>
+#include <basics/container/CbArray2D.h>
+#include <basics/container/CbArray3D.h>
+#include <basics/container/CbArray4D.h>
+#include <basics/container/CbVector.h>
+#include <basics/container/CbVectorPool.h>
+#include <basics/memory/MbMemPool.h>
+#include <basics/memory/MbSharedPointerDefines.h>
+#include <basics/memory/MbSmartPtr.h>
+#include <basics/memory/MbSmartPtrBase.h>
+#include <basics/objects/ObCreator.h>
+#include <basics/objects/ObFactory.h>
+#include <basics/objects/ObObject.h>
+#include <basics/objects/ObObjectCreator.h>
+#include <basics/objects/ObObjectFactory.h>
+#include <basics/objects/ObObjectManager.h>
+#include <basics/transmitter/TbTransmitter.h>
+#include <basics/transmitter/TbTransmitterLocal.h>
+#include <basics/transmitter/TbTransmitterMpiPool.h>
+#include <basics/utilities/UbAutoRun.hpp>
+#include <basics/utilities/UbComparators.h>
+#include <basics/utilities/UbConverter.h>
+#include <basics/utilities/UbEqual.h>
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbFileInput.h>
+#include <basics/utilities/UbFileInputASCII.h>
+#include <basics/utilities/UbFileInputBinary.h>
+#include <basics/utilities/UbFileOutput.h>
+#include <basics/utilities/UbFileOutputASCII.h>
+#include <basics/utilities/UbFileOutputBinary.h>
+#include <basics/utilities/UbInfinity.h>
+#include <basics/utilities/UbKeys.h>
+#include <basics/utilities/UbLimits.h>
+#include <basics/utilities/UbLogger.h>
+#include <basics/utilities/UbMath.h>
+#include <basics/utilities/UbNupsTimer.h>
+#include <basics/utilities/UbObservable.h>
+#include <basics/utilities/UbObserver.h>
+#include <basics/utilities/UbPointerWrapper.h>
+#include <basics/utilities/UbRandom.h>
+#include <basics/utilities/UbScheduler.h>
+#include <basics/utilities/UbStaticPathMap.h>
+#include <basics/utilities/UbString.h>
+#include <basics/utilities/UbStringInputASCII.h>
+#include <basics/utilities/UbSystem.h>
+#include <basics/utilities/UbTableModel.h>
+#include <basics/utilities/UbTiming.h>
+#include <basics/utilities/UbTuple.h>
+#include <basics/writer/WbWriter.h>
+#include <basics/writer/WbWriterAvsASCII.h>
+#include <basics/writer/WbWriterAvsBinary.h>
+#include <basics/writer/WbWriterBOBJ.h>
+#include <basics/writer/WbWriterSunflow.h>
+#include <basics/writer/WbWriterTecPlotASCII.h>
+#include <basics/writer/WbWriterVtkASCII.h>
+#include <basics/writer/WbWriterVtkBinary.h>
+#include <basics/writer/WbWriterVtkXmlASCII.h>
+#include <basics/writer/WbWriterVtkXmlBinary.h>
+#include <basics/writer/WbWriterX3D.h>
+
+#include <BoundaryConditions/BCArray3D.h>
+#include <BoundaryConditions/BCProcessor.h>
+#include <BoundaryConditions/BCAlgorithm.h>
+#include <BoundaryConditions/BCFunction.h>
+#include <BoundaryConditions/BoundaryConditions.h>
+#include <BoundaryConditions/BCAdapter.h>
+#include <BoundaryConditions/DensityBCAdapter.h>
+#include <BoundaryConditions/BCProcessor.h>
+#include <BoundaryConditions/ThinWallBCProcessor.h>
+#include <BoundaryConditions/NoSlipBCAdapter.h>
+#include <BoundaryConditions/SlipBCAdapter.h>
+#include <BoundaryConditions/VelocityBCAdapter.h>
+#include <BoundaryConditions/BCAlgorithm.h>
+#include <BoundaryConditions/VelocityBCAlgorithm.h>
+#include <BoundaryConditions/NonEqDensityBCAlgorithm.h>
+#include <BoundaryConditions/EqDensityBCAlgorithm.h>
+#include <BoundaryConditions/NoSlipBCAlgorithm.h>
+#include <BoundaryConditions/ThinWallNoSlipBCAlgorithm.h>
+#include <BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h>
+#include <BoundaryConditions/SlipBCAlgorithm.h>
+#include <BoundaryConditions/NonReflectingOutflowBCAlgorithm.h>
+#include <BoundaryConditions/VelocityWithDensityBCAlgorithm.h>
+
+#include <Connectors/Block3DConnector.h>
+#include <Connectors/D3Q27ETCFOffVectorConnector.h>
+#include <Connectors/D3Q27ETFCOffVectorConnector.h>
+#include <Connectors/D3Q27ETFullDirectConnector.h>
+#include <Connectors/D3Q27ETFullVectorConnector.h>
+#include <Connectors/LocalBlock3DConnector.h>
+#include <Connectors/RemoteBlock3DConnector.h>
+#include <Connectors/CoarseToFineBlock3DConnector.h>
+#include <Connectors/CoarseToFineNodeSetBlock3DConnector.h>
+#include <Connectors/FineToCoarseBlock3DConnector.h>
+#include <Connectors/FineToCoarseNodeSetBlock3DConnector.h>
+#include <Connectors/ConnectorFactory.h>
+#include <Connectors/Block3DConnectorFactory.h>
+
+#include <Data/D3Q27EsoTwist3DSplittedVector.h>
+#include <Data/D3Q27EsoTwist3DSplittedVectorEx.h>
+#include <Data/DataSet3D.h>
+#include <Data/DistributionArray3D.h>
+#include <Data/EsoTwist3D.h>
+#include <Data/EsoTwistD3Q27System.h>
+#include <Data/VoidData3D.h>
+
+#include <Grid/Block3D.h>
+#include <Grid/Calculator.h>
+#include <Grid/BasicCalculator.h>
+#include <Grid/Grid3D.h>
+#include <Grid/Grid3DSystem.h>
+
+#include <Interactors/D3Q27Interactor.h>
+#include <Interactors/D3Q27TriFaceMeshInteractor.h>
+#include <Interactors/Interactor3D.h>
+#include <Interactors/InteractorsHelper.h>
+
+#include <CoProcessors/WriteBlocksCoProcessor.h>
+#include <CoProcessors/AdjustForcingCoProcessor.h>
+#include <CoProcessors/CalculateForcesCoProcessor.h>
+#include <CoProcessors/WriteMacroscopicQuantitiesCoProcessor.h>
+#include <CoProcessors/WriteMQFromSelectionCoProcessor.h>
+#include <CoProcessors/WriteBoundaryConditionsCoProcessor.h>
+//#include <CoProcessors/PathLineCoProcessor.h>
+//#include <CoProcessors/PathLineCoProcessorMcpart.h>
+#include <CoProcessors/PressureDifferenceCoProcessor.h>
+#include <CoProcessors/EmergencyExitCoProcessor.h>
+#include <CoProcessors/NUPSCounterCoProcessor.h>
+//#include <CoProcessors/Particles.h>
+#include <CoProcessors/CoProcessor.h>
+#include <CoProcessors/TurbulenceIntensityCoProcessor.h>
+#include <CoProcessors/AverageValuesCoProcessor.h>
+#include <CoProcessors/DecreaseViscosityCoProcessor.h>
+#include <CoProcessors/TimeseriesCoProcessor.h>
+#include <CoProcessors/ShearStressCoProcessor.h>
+#include <CoProcessors/QCriterionCoProcessor.h>
+#include <CoProcessors/InSituVTKCoProcessor.h>
+//#include <CoProcessors/MeanValuesCoProcessor.h>
+#include <CoProcessors/TimeAveragedValuesCoProcessor.h>
+#include <CoProcessors/InSituCatalystCoProcessor.h>
+#include <CoProcessors/MPIIORestartCoProcessor.h>
+#include <CoProcessors/MPIIOMigrationCoProcessor.h>
+#include <CoProcessors/PressureCoefficientCoProcessor.h>
+#include <LineTimeSeriesCoProcessor.h>
+
+#include <IntegrateValuesHelper.h>
+//#include <LBM/D3Q27CompactInterpolationProcessor.h>
+#include <LBM/IncompressibleOffsetInterpolationProcessor.h>
+#include <LBM/CompressibleOffsetInterpolationProcessor.h>
+#include <LBM/CompressibleOffsetMomentsInterpolationProcessor.h>
+#include <LBM/InterpolationHelper.h>
+#include <LBM/InterpolationProcessor.h>
+//#include <LBM/D3Q27OffsetInterpolationProcessor.h>
+#include <LBM/D3Q27System.h>
+#include <LBM/ICell.h>
+#include <LBM/InterpolationProcessor.h>
+#include <LBM/LBMKernel.h>
+#include <IncompressibleCumulantWithSpongeLayerLBMKernel.h>
+#include <LBM/LBMKernel.h>
+#include <LBM/IncompressibleCumulantLBMKernel.h>
+#include <LBM/CompressibleCumulantLBMKernel.h>
+#include <LBM/CompressibleCumulant4thOrderViscosityLBMKernel.h>
+#include <LBM/InitDensityLBMKernel.h>
+#include <LBM/VoidLBMKernel.h>
+#include <LBM/LBMSystem.h>
+#include <LBM/LBMUnitConverter.h>
+
+#include <numerics/geometry3d/CoordinateTransformation3D.h>
+#include <numerics/geometry3d/GbCuboid3D.h>
+#include <numerics/geometry3d/GbCylinder3D.h>
+#include <numerics/geometry3d/GbHalfSpace3D.h>
+#include <numerics/geometry3d/GbHalfSpaceKrischan3D.h>
+#include <numerics/geometry3d/GbLine3D.h>
+#include <numerics/geometry3d/GbMeshTools3D.h>
+#include <numerics/geometry3d/GbObject3D.h>
+#include <numerics/geometry3d/GbObject3DManager.h>
+#include <numerics/geometry3d/GbObjectGroup3D.h>
+#include <numerics/geometry3d/GbPoint3D.h>
+#include <numerics/geometry3d/GbPolygon3D.h>
+#include <numerics/geometry3d/GbQuadFaceMesh3D.h>
+#include <numerics/geometry3d/GbSphere3D.h>
+#include <numerics/geometry3d/GbSystem3D.h>
+#include <numerics/geometry3d/GbTriangle3D.h>
+#include <numerics/geometry3d/GbTriangularMesh3D.h>
+#include <numerics/geometry3d/GbTriFaceMesh3D.h>
+#include <numerics/geometry3d/GbVector3D.h>
+#include <numerics/geometry3d/GbVoxelMatrix3D.h>
+#include <numerics/geometry3d/creator/GbCuboid3DCreator.h>
+#include <numerics/geometry3d/creator/GbCylinder3DCreator.h>
+#include <numerics/geometry3d/creator/GbLine3DCreator.h>
+#include <numerics/geometry3d/creator/GbObject3DCreator.h>
+#include <numerics/geometry3d/creator/GbObject3DFactory.h>
+#include <numerics/geometry3d/creator/GbPoint3DCreator.h>
+#include <numerics/geometry3d/creator/GbPolygon3DCreator.h>
+#include <numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h>
+#include <numerics/geometry3d/creator/GbSphere3DCreator.h>
+#include <numerics/geometry3d/creator/GbTriangle3DCreator.h>
+#include <numerics/geometry3d/creator/GbTriangularMesh3DCreator.h>
+#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h>
+#include <numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h>
+#include <numerics/geometry3d/KdTree/KdNode.h>
+#include <numerics/geometry3d/KdTree/KdRay.h>
+#include <numerics/geometry3d/KdTree/KdSplitCandidate.h>
+#include <numerics/geometry3d/KdTree/KdSplitCandidateManager.h>
+#include <numerics/geometry3d/KdTree/KdTree.h>
+#include <numerics/geometry3d/KdTree/KdUtilities.h>
+#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h>
+#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h>
+#include <numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h>
+#include <numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h>
+#include <numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h>
+#include <numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h>
+#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h>
+
+#include <Parallel/Communicator.h>
+#include <Parallel/MetisPartitioner.h>
+#include <Parallel/MPICommunicator.h>
+#include <Parallel/NullCommunicator.h>
+#include <Parallel/PriorityQueueDecompositor.h>
+#include <Parallel/SimpleGeometricPartitioner.h>
+#include <Parallel/ZoltanPartitioner.h>
+#include <Parallel/BlocksDistributor.h>
+
+#include <Utilities/MathUtil.hpp>
+#include <Utilities/MemoryUtil.h>
+#include <Utilities/ConfigurationFile.hpp>
+#include <Utilities/VoxelMatrixUtil.hpp>
+#include <Utilities/ChangeRandomQs.hpp>
+
+#include <Visitors/Block3DVisitor.h>
+#include <Visitors/CreateTransmittersHelper.h>
+#include <Visitors/InitDistributionsBlockVisitor.h>
+#include <Visitors/SetConnectorsBlockVisitor.h>
+#include <Visitors/SetUndefinedNodesBlockVisitor.h>
+#include <Visitors/GenBlocksGridVisitor.h>
+#include <Visitors/Grid3DVisitor.h>
+#include <Visitors/MetisPartitioningGridVisitor.h>
+#include <Visitors/OverlapBlockVisitor.h>
+#include <Visitors/PQueuePartitioningGridVisitor.h>
+#include <Visitors/RatioBlockVisitor.h>
+#include <Visitors/RatioSmoothBlockVisitor.h>
+#include <Visitors/RefineCrossAndInsideGbObjectBlockVisitor.h>
+#include <Visitors/RefineInterGbObjectsVisitor.h>
+#include <Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.h>
+#include <Visitors/SetInterpolationDirsBlockVisitor.h>
+#include <Visitors/SetKernelBlockVisitor.h>
+#include <Visitors/SetForcingBlockVisitor.h>
+#include <Visitors/SetSpongeLayerBlockVisitor.h>
+#include <Visitors/SetSolidBlocksBlockVisitor.h>
+#include <Visitors/SetBcBlocksBlockVisitor.h>
+#include <Visitors/RenumberBlockVisitor.h>
+#include <Visitors/ConnectorBlockVisitor.h>
+#include <Visitors/ViscosityBlockVisitor.h>
+#include <Visitors/BoundaryConditionsBlockVisitor.h>
+#include <Visitors/BoundaryConditionsBlockVisitor.h>
+#include <Visitors/ChangeBoundaryDensityBlockVisitor.h>
+#include <InitDistributionsFromFileBlockVisitor.h>
+#include <InitDistributionsWithInterpolationGridVisitor.h>
+#include <CheckRatioBlockVisitor.h>
+#include <SpongeLayerBlockVisitor.h>
+#include <ZoltanPartitioningGridVisitor.h>
+
+#include <Visitors/RefineCrossAndInsideGbObjectHelper.h>
+#include <RefineAroundGbObjectHelper.h>
+
+#if defined VF_FETOL
+   #include <FETOL/FETOLCalculator.h>
+   #include <FETOL/FETOLCommunicator.h>
+   #include <FETOL/FETOLSetConnectorsBlockVisitor.h>
+   #include <FETOL/FETOLTransmitterBondPool.h>   
+#endif
+
+#endif // VirtualFluids_h__
diff --git a/source/Applications/aperm/CMakeLists.txt b/source/Applications/aperm/CMakeLists.txt
index 673364ed8283715b7644df46b6fce1bb967ec44b..f2439bd5db69073faf1df2457c43717fb950f4c7 100644
--- a/source/Applications/aperm/CMakeLists.txt
+++ b/source/Applications/aperm/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(aperm)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake)  
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/f16Test/CMakeLists.txt b/source/Applications/f16Test/CMakeLists.txt
index d6760fe88169f42d2930abfbceb2ad073bbee5f7..f8cfe5f4bb024c2cf4036b54a67d378fdc37721e 100644
--- a/source/Applications/f16Test/CMakeLists.txt
+++ b/source/Applications/f16Test/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(f16test)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/levels/CMakeLists.txt b/source/Applications/levels/CMakeLists.txt
index 726654984bbb0d93c0d41a003f3b3697b5921793..7ec1d4c64be0c1d71551ed1ee86d071e1f47af50 100644
--- a/source/Applications/levels/CMakeLists.txt
+++ b/source/Applications/levels/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(levels)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/mirror/CMakeLists.txt b/source/Applications/mirror/CMakeLists.txt
index 08f1c7f5c90965d91367ffaf3b2d2570944d92f4..b0ff5d5943e630b9544b7dfdcec5f4e780452db8 100644
--- a/source/Applications/mirror/CMakeLists.txt
+++ b/source/Applications/mirror/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(mirror)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/mpi_benchmark/CMakeLists.txt b/source/Applications/mpi_benchmark/CMakeLists.txt
index 51933653f9ed6866d6f514a12f5863e4fb5167e1..05bc1f64a91adb4477b9bf552f31cfafa18381d9 100644
--- a/source/Applications/mpi_benchmark/CMakeLists.txt
+++ b/source/Applications/mpi_benchmark/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(mpib)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/pChannel/CMakeLists.txt b/source/Applications/pChannel/CMakeLists.txt
index 81ea739ecd58e2b018caa808bac8d8bc6909dfbb..14d4bb23d2f185bc64319cb18a5ac0317b9283ae 100644
--- a/source/Applications/pChannel/CMakeLists.txt
+++ b/source/Applications/pChannel/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(pchannel)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/pChannel/configBombadilpChannel.cfg b/source/Applications/pChannel/configBombadilpChannel.cfg
index a45e4d59a3f1810c1c36d71f0b6e29cbe5f70d5f..dd54b3a2205528538993061f46507ef915631bf7 100644
--- a/source/Applications/pChannel/configBombadilpChannel.cfg
+++ b/source/Applications/pChannel/configBombadilpChannel.cfg
@@ -56,7 +56,7 @@ pmL = 1e-3 1e-3 1e-3
 #pmL = 4e-3 4e-3 1e-3
 
 #grid
-refineLevel = 1
+refineLevel = 0
 deltaXfine  = 10e-6
 #deltaXfine  = 20e-6
 #deltaXfine  = 32e-6 #level 2
diff --git a/source/Applications/screw/CMakeLists.txt b/source/Applications/screw/CMakeLists.txt
index 077a53907bedcc81ddb5b8c3dd8df291093f03ae..c2fb4e44f90332302a1c6918b31223664b6e539a 100644
--- a/source/Applications/screw/CMakeLists.txt
+++ b/source/Applications/screw/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(screw)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/sphere/CMakeLists.txt b/source/Applications/sphere/CMakeLists.txt
index a2ec13053334f34e5c80e3c39551aedd4b9c3d41..77d7e0a41ea36fef0813ace18ee699da481d2ddd 100644
--- a/source/Applications/sphere/CMakeLists.txt
+++ b/source/Applications/sphere/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(sphere)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/Applications/teperm/CMakeLists.txt b/source/Applications/teperm/CMakeLists.txt
index 12227aac4b3f9ee66397a704f02cd84a354718eb..848ac938ec07d34eb90797de7bdecdcc38728396 100644
--- a/source/Applications/teperm/CMakeLists.txt
+++ b/source/Applications/teperm/CMakeLists.txt
@@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 ########################################################
 PROJECT(teperm)
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) 
+INCLUDE(${APPS_ROOT}/IncludsList.cmake) 
 
 #################################################################
 ###   LOCAL FILES                                             ###
diff --git a/source/CMake/cmake_config_files/BOMBADIL.config.cmake b/source/CMake/cmake_config_files/BOMBADIL.config.cmake
index c410eae506d52fb1291967096811dd1a399d10ae..465fecbe85dcefa633b8c24e65835148acdd1319 100644
--- a/source/CMake/cmake_config_files/BOMBADIL.config.cmake
+++ b/source/CMake/cmake_config_files/BOMBADIL.config.cmake
@@ -45,6 +45,24 @@ IF(${USE_METIS})
   SET(METIS_RELEASE_LIBRARY "d:/Tools/metis-5.1.0/build/libmetis/Release/metis.lib") 
 ENDIF()
 
+#################################################################################
+#  PE  
+#################################################################################
+IF(${USE_DEM_COUPLING})
+  SET(PE_BINARY_DIR "d:/Tools/waLBerla/walberlaGit/build" CACHE PATH "pe binary dir")
+  SET(PE_ROOT "d:/Tools/waLBerla/walberlaGit" CACHE PATH "pe root")
+ 
+  SET(PE_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/pe/Debug/pe.lib) 
+  SET(PE_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/pe/Release/pe.lib)
+  SET(BLOCKFOREST_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/blockforest/Debug/blockforest.lib) 
+  SET(BLOCKFOREST_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/blockforest/Release/blockforest.lib)
+  SET(DOMAIN_DECOMPOSITION_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/domain_decomposition/Debug/domain_decomposition.lib) 
+  SET(DOMAIN_DECOMPOSITION_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/domain_decomposition/Release/domain_decomposition.lib)
+  SET(CORE_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/core/Debug/core.lib) 
+  SET(CORE_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/core/Release/core.lib)
+
+ ENDIF()
+
 ##################################################################################
 #  FETOL
 ##################################################################################
diff --git a/source/CMake/cmake_config_files/PHOENIX.config.cmake b/source/CMake/cmake_config_files/PHOENIX.config.cmake
index 22227b43fdeae5cad9d562a6224f8d1ec631df56..ce204f104eb27aba236a2c9b5f1d563cb9978d95 100644
--- a/source/CMake/cmake_config_files/PHOENIX.config.cmake
+++ b/source/CMake/cmake_config_files/PHOENIX.config.cmake
@@ -11,3 +11,21 @@ IF(${USE_METIS})
   SET(METIS_DEBUG_LIBRARY "/cluster/lib/metis/5.1.0/intel/lib/libmetis.a") 
   SET(METIS_RELEASE_LIBRARY "/cluster/lib/metis/5.1.0/intel/lib/libmetis.a") 
 ENDIF()
+
+#################################################################################
+#  PE  
+#################################################################################
+IF(${USE_DEM_COUPLING})
+  SET(PE_BINARY_DIR "/home/irmb/walberla-git/build" CACHE PATH "pe binary dir")
+  SET(PE_ROOT "/home/irmb/walberla-git" CACHE PATH "pe root")
+ 
+  SET(PE_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/pe/libpe.a) 
+  SET(PE_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/pe/libpe.a)
+  SET(BLOCKFOREST_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/blockforest/libblockforest.a) 
+  SET(BLOCKFOREST_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/blockforest/libblockforest.a)
+  SET(DOMAIN_DECOMPOSITION_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/domain_decomposition/libdomain_decomposition.a) 
+  SET(DOMAIN_DECOMPOSITION_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/domain_decomposition/libdomain_decomposition.a)
+  SET(CORE_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/core/libcore.a) 
+  SET(CORE_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/core/libcore.a)
+  
+ENDIF()
\ No newline at end of file
diff --git a/source/CMake/compilerflags/gcc63.cmake b/source/CMake/compilerflags/gcc63.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..c624265fa66e7c73bc9e7ad980f1ac5e9b6a670a
--- /dev/null
+++ b/source/CMake/compilerflags/gcc63.cmake
@@ -0,0 +1,52 @@
+###############################################################################################################
+## 
+##  gcc63
+##
+###############################################################################################################
+
+MACRO(SET_COMPILER_SPECIFIC_FLAGS_INTERN build_type use64BitOptions)
+   #############################################################################################################
+   # Flags
+   #############################################################################################################
+   LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-O3 -fomit-frame-pointer -finline-functions -funroll-all-loops -fPIC")
+   LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-Wno-deprecated") #deprecated header warning (jarl benutzt sstream weil schneller und so) 
+
+   LIST(APPEND CAB_COMPILER_ADDTIONAL_C_COMPILER_FLAGS "-O3 -fomit-frame-pointer -finline-functions -funroll-all-loops -fPIC")
+
+   #############################################################################################################
+   # 64Bit support
+   #############################################################################################################
+   IF( ${use64BitOptions} ) 
+     LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-m64" )
+     LIST(APPEND CAB_COMPILER_ADDTIONAL_C_COMPILER_FLAGS   "-m64" )
+   ENDIF()
+
+   #############################################################################################################
+   # OpenMP support
+   #############################################################################################################
+   IF(USE_OPENMP)
+     LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-fopenmp")
+     LIST(APPEND CAB_COMPILER_ADDTIONAL_C_COMPILER_FLAGS "-fopenmp")
+   ENDIF()
+
+   #############################################################################################################
+   # mt support
+   #############################################################################################################
+   LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-pthread")
+   LIST(APPEND CAB_COMPILER_ADDTIONAL_C_COMPILER_FLAGS "-pthread")
+   
+   #############################################################################################################
+   # c++ 17 support
+   #############################################################################################################
+   LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-std=c++17")
+   LIST(APPEND CAB_COMPILER_ADDTIONAL_C_COMPILER_FLAGS "-std=c++17")
+   
+   LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-fext-numeric-literals")
+   LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-D_GLIBCXX_USE_CXX11_ABI=0")
+   
+
+   IF(NOT APPLE)
+      LIST(APPEND CAB_ADDITIONAL_LINK_PROPS "-lrt")
+   ENDIF()
+
+ENDMACRO(SET_COMPILER_SPECIFIC_FLAGS_INTERN build_type use64BitOptions)
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 994e2c6aedcb9d7003f0c039dd2414e341625a73..69698e580bcd63f4410429d3743f1c16a99cc3d1 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -39,6 +39,7 @@ SET(USE_BOOST OFF CACHE BOOL "include Boost support")
 SET(USE_INTEL OFF CACHE BOOL "include Intel compiler support")
 SET(USE_GCC OFF CACHE BOOL "include gcc compiler support")
 SET(USE_HLRN_LUSTRE OFF CACHE BOOL "include HLRN Lustre support")
+SET(USE_DEM_COUPLING OFF CACHE BOOL "PE plugin")
 
 #CAB
 INCLUDE("CMake/CMakeCABMacros.txt")
@@ -149,7 +150,13 @@ ENDIF()
    #message("MPI_LIBRARY: " ${MPI_LIBRARY})
 #ENDIF() 
 
+
+#IF(${USE_DEM_COUPLING})
+#    add_subdirectory(Plugins/dem_coupling)
+#ENDIF()
+
 add_subdirectory(VirtualFluidsCore)
 
-INCLUDE("Applications.cmake")
+set(APPS_ROOT "${SOURCE_ROOT}/Applications")
+INCLUDE(${APPS_ROOT}/Applications.cmake)
 
diff --git a/source/ThirdParty/Library/basics/memory/CMakePackage.txt b/source/DemCoupling/CMakePackage.txt
similarity index 98%
rename from source/ThirdParty/Library/basics/memory/CMakePackage.txt
rename to source/DemCoupling/CMakePackage.txt
index 9354d3d0084922c7abd6f1b22823c5c47e0befb4..1b8416f010d2a7de30b8f70c9abf19a96dd8cf8f 100644
--- a/source/ThirdParty/Library/basics/memory/CMakePackage.txt
+++ b/source/DemCoupling/CMakePackage.txt
@@ -1,2 +1,2 @@
-GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
-COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
diff --git a/source/DemCoupling/CreateDemObjectsCoProcessor.cpp b/source/DemCoupling/CreateDemObjectsCoProcessor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..146e611601266345f0f8041c83815a73d262588e
--- /dev/null
+++ b/source/DemCoupling/CreateDemObjectsCoProcessor.cpp
@@ -0,0 +1,125 @@
+#include "CreateDemObjectsCoProcessor.h"
+#include "UbScheduler.h"
+#include "DemCoProcessor.h"
+#include "GbSphere3D.h"
+#include "NoSlipBCAlgorithm.h"
+#include "VelocityBCAdapter.h"
+#include "VelocityWithDensityBCAlgorithm.h"
+#include "VelocityBCAlgorithm.h"
+#include "MovableObjectInteractor.h"
+#include "LBMReconstructor.h"
+#include "EquilibriumReconstructor.h"
+#include "VelocityBcReconstructor.h"
+#include "ExtrapolationReconstructor.h"
+#include "PePhysicsEngineMaterialAdapter.h"
+#include "muParser.h"
+#include "PhysicsEngineMaterialAdapter.h"
+#include "SetBcBlocksBlockVisitor.h"
+#include "Grid3D.h"
+#include "Communicator.h"
+
+
+
+CreateDemObjectsCoProcessor::CreateDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s,  std::shared_ptr<Communicator> comm, SPtr<DemCoProcessor> demCoProcessor, SPtr<PhysicsEngineMaterialAdapter> demObjectMaterial) : 
+   CoProcessor(grid, s),
+   comm(comm),
+   demCoProcessor(demCoProcessor), 
+   demObjectMaterial(demObjectMaterial)
+{
+   mu::Parser fct;
+   fct.SetExpr("U");
+   fct.DefineConst("U", 0.0);
+   velocityBcParticleAdapter = SPtr<BCAdapter>(new VelocityBCAdapter(true, false, false, fct, 0, BCFunction::INFCONST));
+   velocityBcParticleAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new VelocityWithDensityBCAlgorithm()));
+
+   //const std::shared_ptr<Reconstructor> velocityReconstructor(new VelocityBcReconstructor());
+   std::shared_ptr<Reconstructor> equilibriumReconstructor(new EquilibriumReconstructor());
+   //const std::shared_ptr<Reconstructor> lbmReconstructor(new LBMReconstructor(false));
+   extrapolationReconstructor = SPtr<Reconstructor>(new ExtrapolationReconstructor(equilibriumReconstructor));
+}
+//////////////////////////////////////////////////////////////////////////
+void CreateDemObjectsCoProcessor::process(double step)
+{
+   if (scheduler->isDue(step))
+   {
+      int istep = static_cast<int>(step);
+      
+
+#ifdef TIMING
+      if (comm->isRoot()) UBLOG(logINFO, "CreateDemObjectsCoProcessor::process start step: " << istep);
+      timer.resetAndStart();
+#endif
+
+      createGeoObjects();
+
+#ifdef TIMING
+      if (comm->isRoot()) UBLOG(logINFO, "createGeoObjects() time = "<<timer.stop()<<" s");
+      if (comm->isRoot()) UBLOG(logINFO, "number of objects = "<<(int)(geoObjectPrototypeVector.size()));
+      if (comm->isRoot()) UBLOG(logINFO, "CreateDemObjectsCoProcessor::process stop step: " << istep);
+#endif
+      
+      //demCoProcessor->distributeIDs();
+//
+//#ifdef TIMING
+//      if (comm->isRoot()) UBLOG(logINFO, "demCoProcessor->distributeIDs() time = "<<timer.stop()<<" s");
+//#endif
+
+      
+   }
+}
+//////////////////////////////////////////////////////////////////////////
+void CreateDemObjectsCoProcessor::addGeoObject(SPtr<GbObject3D> geoObjectPrototype,  Vector3D  initalVelocity)
+{
+   geoObjectPrototypeVector.push_back(geoObjectPrototype);
+   this->initalVelocity.push_back(initalVelocity);
+}
+
+void CreateDemObjectsCoProcessor::clearGeoObjects()
+{
+   geoObjectPrototypeVector.clear();
+   initalVelocity.clear();
+}
+
+void CreateDemObjectsCoProcessor::createGeoObjects()
+{
+   int size =  (int)(geoObjectPrototypeVector.size());
+
+   std::vector< std::shared_ptr<Block3D> > blockVector;
+
+   for (int i = 0; i < size; i++)
+   {
+      //timer.resetAndStart();
+      std::array<double, 6> AABB ={ geoObjectPrototypeVector[i]->getX1Minimum(),geoObjectPrototypeVector[i]->getX2Minimum(),geoObjectPrototypeVector[i]->getX3Minimum(),geoObjectPrototypeVector[i]->getX1Maximum(),geoObjectPrototypeVector[i]->getX2Maximum(),geoObjectPrototypeVector[i]->getX3Maximum() };
+      //UBLOG(logINFO, "demCoProcessor->isGeoObjectInAABB(AABB) = " << demCoProcessor->isGeoObjectInAABB(AABB));
+      //if (demCoProcessor->isDemObjectInAABB(AABB))
+      //{
+      //   continue;
+      //}
+      SPtr<GbSphere3D> sphere = std::dynamic_pointer_cast<GbSphere3D>(geoObjectPrototypeVector[i]);
+      if (demCoProcessor->isSpheresIntersection(sphere->getX1Centroid(), sphere->getX2Centroid(), sphere->getX3Centroid(), sphere->getRadius()*2.0))
+      {
+         continue;
+      }
+
+      SPtr<GbObject3D> geoObject((GbObject3D*)(geoObjectPrototypeVector[i]->clone()));
+      SPtr<MovableObjectInteractor> geoObjectInt = SPtr<MovableObjectInteractor>(new MovableObjectInteractor(geoObject, grid, velocityBcParticleAdapter, Interactor3D::SOLID, extrapolationReconstructor, State::UNPIN));
+
+      //SetBcBlocksBlockVisitor setBcVisitor(geoObjectInt);
+      //grid->accept(setBcVisitor);
+
+      //std::vector< std::shared_ptr<Block3D> > blockVector;
+      //blockVector.clear();
+      //UbTupleInt3 blockNX=grid->getBlockNX();
+      //grid->getAllBlocksByCuboid(AABB[0]-(double)val<1>(blockNX)*2.0, AABB[1]-(double)val<2>(blockNX)*2.0, AABB[2]-(double)val<3>(blockNX)*2.0, AABB[3]+(double)val<1>(blockNX)*2.0, AABB[4]+(double)val<2>(blockNX)*2.0, AABB[5]+(double)val<3>(blockNX)*2.0, blockVector);
+      //for (std::shared_ptr<Block3D> block : blockVector)
+      //   geoObjectInt->setBCBlock(block);
+
+
+      ////UBLOG(logINFO, "grid->accept(setBcVisitor) time = "<<timer.stop());
+      //geoObjectInt->initInteractor();
+      //UBLOG(logINFO, "geoObjectInt->initInteractor() time = "<<timer.stop());
+      demCoProcessor->addInteractor(geoObjectInt, demObjectMaterial, initalVelocity[i]);
+      //UBLOG(logINFO, "demCoProcessor->addInteractor() time = "<<timer.stop());
+   }
+}
+
diff --git a/source/DemCoupling/CreateDemObjectsCoProcessor.h b/source/DemCoupling/CreateDemObjectsCoProcessor.h
new file mode 100644
index 0000000000000000000000000000000000000000..ffb26a35d10b5c7a6d469d5fdfa8d44da195221c
--- /dev/null
+++ b/source/DemCoupling/CreateDemObjectsCoProcessor.h
@@ -0,0 +1,48 @@
+#ifndef CreateSphereCoProcessor_h__
+#define CreateSphereCoProcessor_h__
+
+#include "CoProcessor.h"
+#include "Vector3D.h"
+#include <vector>
+#include <array>
+
+
+//#define TIMING
+
+#ifdef TIMING
+#include "UbTiming.h"
+#endif
+
+
+class Grid3D;
+class UbScheduler;
+class Communicator;
+class DemCoProcessor;
+class GbObject3D;
+class BCAdapter;
+class Reconstructor;
+class PhysicsEngineMaterialAdapter;
+
+
+class CreateDemObjectsCoProcessor : public CoProcessor
+{
+public:
+   CreateDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s,  std::shared_ptr<Communicator> comm, SPtr<DemCoProcessor> demCoProcessor,  SPtr<PhysicsEngineMaterialAdapter> geoObjectMaterial);
+   void process(double step) override;
+   void addGeoObject(SPtr<GbObject3D> geoObjectPrototype, Vector3D  initalVelocity);
+   void clearGeoObjects();
+   void createGeoObjects();
+protected:
+private:
+   SPtr<Communicator> comm;
+   SPtr<DemCoProcessor> demCoProcessor;
+   std::vector< SPtr<GbObject3D> > geoObjectPrototypeVector;
+   SPtr<PhysicsEngineMaterialAdapter> demObjectMaterial; 
+   std::vector<Vector3D>  initalVelocity;
+   SPtr<BCAdapter> velocityBcParticleAdapter;
+   SPtr<Reconstructor> extrapolationReconstructor;
+#ifdef TIMING
+   UbTimer timer;
+#endif
+};
+#endif // CreateSphereCoProcessor_h__
diff --git a/source/DemCoupling/DemCoProcessor.cpp b/source/DemCoupling/DemCoProcessor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b779534df1a59bd6f0b4479f4b2ae7dbaa36dcb6
--- /dev/null
+++ b/source/DemCoupling/DemCoProcessor.cpp
@@ -0,0 +1,491 @@
+#include "DemCoProcessor.h"
+
+#include "GbSphere3D.h"
+#include "MovableObjectInteractor.h"
+#include "Communicator.h"
+#include "ForceCalculator.h"
+#include "Grid3D.h"
+#include "UbScheduler.h"
+#include "ILBMKernel.h"
+#include "DistributionArray3D.h"
+#include "BCProcessor.h"
+#include "DataSet3D.h"
+
+#include "PhysicsEngineMaterialAdapter.h"
+#include "PhysicsEngineGeometryAdapter.h"
+#include "PhysicsEngineSolverAdapter.h"
+#include "PePhysicsEngineSolverAdapter.h"
+#include "PePhysicsEngineGeometryAdapter.h"
+
+#include "BoundaryConditions.h"
+#include "Block3D.h"
+#include "BCArray3D.h"
+#include "MPICommunicator.h"
+#include "BoundaryConditionsBlockVisitor.h"
+
+#include "UbLogger.h"
+
+
+#include <array>
+#include <functional>
+
+DemCoProcessor::DemCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<Communicator> comm, std::shared_ptr<ForceCalculator> forceCalculator, std::shared_ptr<PhysicsEngineSolverAdapter> physicsEngineSolver, double intermediatePeSteps) :
+   CoProcessor(grid, s), comm(comm), forceCalculator(forceCalculator), physicsEngineSolver(physicsEngineSolver), intermediateDemSteps(intermediatePeSteps)
+{
+#ifdef TIMING
+   timer.resetAndStart();
+#endif
+
+   std::shared_ptr<walberla::blockforest::BlockForest> forest = std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getBlockForest();
+   std::shared_ptr<walberla::domain_decomposition::BlockDataID> storageId = std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getStorageId();
+
+
+   for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt)
+   {
+      walberla::pe::Storage* storage = blockIt->getData< walberla::pe::Storage >(*storageId.get());
+      walberla::pe::BodyStorage* bodyStorage = &(*storage)[0];
+
+      bodyStorage->registerAddCallback("DemCoProcessor", std::bind1st(std::mem_fun(&DemCoProcessor::addPeGeo), this));
+      bodyStorage->registerRemoveCallback("DemCoProcessor", std::bind1st(std::mem_fun(&DemCoProcessor::removePeGeo), this));
+   }
+}
+
+DemCoProcessor::~DemCoProcessor()
+{
+
+}
+
+void DemCoProcessor::addInteractor(std::shared_ptr<MovableObjectInteractor> interactor, std::shared_ptr<PhysicsEngineMaterialAdapter> physicsEngineMaterial, Vector3D initalVelocity)
+{
+   interactors.push_back(interactor);
+   const int id = static_cast<int>(interactors.size()) - 1;
+   interactor->setID(id);
+   const auto peGeometryAdapter = this->createPhysicsEngineGeometryAdapter(interactor, physicsEngineMaterial);
+   if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(peGeometryAdapter)->isActive())
+   {
+      peGeometryAdapter->setLinearVelolocity(initalVelocity);
+      
+      std::vector< std::shared_ptr<Block3D> > blockVector;
+      UbTupleInt3 blockNX=grid->getBlockNX();
+      SPtr<GbObject3D> geoObject(interactor->getGbObject3D());
+      double ext = 0.0;
+      std::array<double, 6> AABB ={ geoObject->getX1Minimum(),geoObject->getX2Minimum(),geoObject->getX3Minimum(),geoObject->getX1Maximum(),geoObject->getX2Maximum(),geoObject->getX3Maximum() };
+      grid->getBlocksByCuboid(AABB[0]-(double)val<1>(blockNX)*ext, AABB[1]-(double)val<2>(blockNX)*ext, AABB[2]-(double)val<3>(blockNX)*ext, AABB[3]+(double)val<1>(blockNX)*ext, AABB[4]+(double)val<2>(blockNX)*ext, AABB[5]+(double)val<3>(blockNX)*ext, blockVector);
+      for (std::shared_ptr<Block3D> block : blockVector)
+      {
+         if (block->getKernel())
+         {
+            interactor->setBCBlock(block);
+            //UBLOG(logINFO, "DemCoProcessor::addInteractor() rank = "<<comm->getProcessID());
+         }
+      }
+      interactor->initInteractor();
+   }
+   physicsEngineGeometrieAdapters.push_back(peGeometryAdapter);
+}
+
+
+std::shared_ptr<PhysicsEngineGeometryAdapter> DemCoProcessor::createPhysicsEngineGeometryAdapter(std::shared_ptr<MovableObjectInteractor> interactor, std::shared_ptr<PhysicsEngineMaterialAdapter> physicsEngineMaterial) const
+{
+   const int id = static_cast<int>(interactors.size()) - 1;
+   SPtr<GbSphere3D> vfSphere = std::static_pointer_cast<GbSphere3D>(interactor->getGbObject3D());
+   const Vector3D position(vfSphere->getX1Centroid(), vfSphere->getX2Centroid(), vfSphere->getX3Centroid());
+
+   auto peGeometryAdapter = this->physicsEngineSolver->createPhysicsEngineGeometryAdapter(id, position, vfSphere->getRadius(), physicsEngineMaterial);
+   //if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(peGeometry)->isActive())
+   //{
+      interactor->setPhysicsEngineGeometry(peGeometryAdapter);
+      return peGeometryAdapter;
+   //}
+   //else
+   //{
+   //   return peGeometry;
+   //}
+}
+
+
+void DemCoProcessor::process(double actualTimeStep)
+{
+#ifdef TIMING
+   timer.resetAndStart();
+#endif
+
+   this->applyForcesOnGeometries();
+
+#ifdef TIMING
+   if (comm->isRoot()) UBLOG(logINFO, "DemCoProcessor::process start step: " << actualTimeStep);
+   if (comm->isRoot()) UBLOG(logINFO, "DemCoProcessor::applyForcesOnGeometries() time = "<<timer.stop()<<" s");
+#endif
+
+   if (scheduler->isDue(actualTimeStep))
+   {
+      //UBLOG(logINFO, "DemCoProcessor::update - START - timestep = " << actualTimeStep);
+      const double demTimeStepsPerIteration = scheduler->getMinStep();
+
+      if (demTimeStepsPerIteration != 1)
+         this->scaleForcesAndTorques(1.0 / demTimeStepsPerIteration);
+
+#ifdef TIMING
+      if (comm->isRoot()) UBLOG(logINFO, "DemCoProcessor::scaleForcesAndTorques() time = "<<timer.stop()<<" s");
+      if (comm->isRoot()) UBLOG(logINFO, "DemCoProcessor::calculateDemTimeStep():");
+#endif
+
+      if (this->intermediateDemSteps == 1)
+         this->calculateDemTimeStep(demTimeStepsPerIteration);
+      
+//#ifdef TIMING
+//      if (comm->isRoot()) UBLOG(logINFO, "DemCoProcessor::calculateDemTimeStep() time = "<<timer.stop()<<" s");
+//#endif
+      //if ((int)actualTimeStep % 100 == 0)
+      //{
+      //    if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometries[0])->isActive())
+      //    {
+      //        //UBLOG(logINFO, "v: (x,y,z) " << physicsEngineGeometries[0]->getLinearVelocity() << " actualTimeStep = " << UbSystem::toString(actualTimeStep));
+      //    }
+      //}
+      
+      // during the intermediate time steps of the collision response, the currently acting forces
+      // (interaction forces, gravitational force, ...) have to remain constant.
+      // Since they are reset after the call to collision response, they have to be stored explicitly before.
+      // Then they are set again after each intermediate step.
+
+      this->moveVfGeoObject();
+
+#ifdef TIMING
+      if (comm->isRoot()) UBLOG(logINFO, "DemCoProcessor::moveVfGeoObject() time = "<<timer.stop()<<" s");
+#endif
+
+      grid->accept(*boundaryConditionsBlockVisitor.get());
+
+#ifdef TIMING
+      if (comm->isRoot()) UBLOG(logINFO, "grid->accept(*boundaryConditionsBlockVisitor.get()) time = "<<timer.stop()<<" s");
+#endif
+
+      //UBLOG(logINFO, "DemCoProcessor::update - END - timestep = " << actualTimeStep);
+   }
+
+#ifdef TIMING
+   if (comm->isRoot()) UBLOG(logINFO, "DemCoProcessor::process stop step: " << actualTimeStep);
+#endif
+}
+//////////////////////////////////////////////////////////////////////////
+std::shared_ptr<PhysicsEngineSolverAdapter> DemCoProcessor::getPhysicsEngineSolver()
+{
+   return physicsEngineSolver;
+}
+
+void DemCoProcessor::applyForcesOnGeometries()
+{
+   for (int i = 0; i < physicsEngineGeometrieAdapters.size(); i++)
+   {
+      if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive())
+      {
+         this->setForcesToObject(grid, interactors[i], physicsEngineGeometrieAdapters[i]);
+
+         //physicsEngineGeometries[i]->setLinearVelolocity(Vector3D(-0.001, 0.0, 0.0));
+         //physicsEngineGeometries[i]->setAngularVelocity(Vector3D(0.01, 0.01, 0.01));
+         //UBLOG(logINFO, "v: (x,y,z) " << physicsEngineGeometries[i]->getLinearVelocity());
+      }
+   }
+}
+
+void DemCoProcessor::setForcesToObject(SPtr<Grid3D> grid, SPtr<MovableObjectInteractor> interactor, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry)
+{
+   for (BcNodeIndicesMap::value_type t : interactor->getBcNodeIndicesMap())
+   {
+      SPtr<Block3D> block = t.first;
+      SPtr<ILBMKernel> kernel = block->getKernel();
+      SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray();
+      SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions();
+      distributions->swap();
+
+      std::set< std::vector<int> >& transNodeIndicesSet = t.second;
+      for (std::vector<int> node : transNodeIndicesSet)
+      {
+         int x1 = node[0];
+         int x2 = node[1];
+         int x3 = node[2];
+
+         if (kernel->isInsideOfDomain(x1, x2, x3) && bcArray->isFluid(x1, x2, x3))
+         {
+            //TODO: calculate assumed boundary position 
+
+            const Vector3D worldCoordinates = grid->getNodeCoordinates(block, x1, x2, x3);
+            const auto boundaryVelocity = physicsEngineGeometry->getVelocityAtPosition(worldCoordinates);
+
+            SPtr<BoundaryConditions> bc = bcArray->getBC(x1, x2, x3);
+            const Vector3D force = forceCalculator->getForces(x1, x2, x3, distributions, bc, boundaryVelocity);
+            physicsEngineGeometry->addForceAtPosition(force, worldCoordinates);
+         }
+      }
+      distributions->swap();
+   }
+}
+
+
+void DemCoProcessor::scaleForcesAndTorques(double scalingFactor)
+{
+   for (int i = 0; i < physicsEngineGeometrieAdapters.size(); i++)
+   {
+      if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive())
+      {
+         const Vector3D force = physicsEngineGeometrieAdapters[i]->getForce() * scalingFactor;
+         const Vector3D torque = physicsEngineGeometrieAdapters[i]->getTorque() * scalingFactor;
+
+         physicsEngineGeometrieAdapters[i]->resetForceAndTorque();
+
+         physicsEngineGeometrieAdapters[i]->setForce(force);
+         physicsEngineGeometrieAdapters[i]->setTorque(torque);
+
+         //UBLOG(logINFO, "F: (x,y,z) " << force);
+         //UBLOG(logINFO, "T: (x,y,z) " << torque);
+      }
+   }
+}
+
+
+void DemCoProcessor::calculateDemTimeStep(double step)
+{
+   physicsEngineSolver->runTimestep(step);
+
+#ifdef TIMING
+   if (comm->isRoot()) UBLOG(logINFO, "  physicsEngineSolver->runTimestep() time = "<< timer.stop() <<" s");
+#endif
+
+   //for (int i = 0; i < physicsEngineGeometries.size(); i++)
+   //{
+   //   if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometries[i])->isActive())
+   //   {
+   //      interactors[i]->setPhysicsEngineGeometry(physicsEngineGeometries[i]);
+   //   }
+   //}
+
+//#ifdef TIMING
+//   if (comm->isRoot()) UBLOG(logINFO, "  physicsEngineSolver->updateGeometry() time = "<<timer.stop()<<" s");
+//#endif
+}
+
+void DemCoProcessor::moveVfGeoObject()
+{
+   for (int i = 0; i < interactors.size(); i++)
+   {
+      if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive())
+      {
+         interactors[i]->moveGbObjectTo(physicsEngineGeometrieAdapters[i]->getPosition());
+         //UBLOG(logINFO, "DemCoProcessor::moveVfGeoObject() id = "<<std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->getId()<<"  position="<<physicsEngineGeometrieAdapters[i]->getPosition()<<" rank="<<comm->getProcessID());
+      }
+   }
+}
+
+bool  DemCoProcessor::isDemObjectInAABB(std::array<double, 6> AABB)
+{
+   bool result = false;
+   for (int i = 0; i < interactors.size(); i++)
+   {
+      if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive())
+      {
+         SPtr<GbObject3D> geoObject = interactors[i]->getGbObject3D();
+         std::array <double, 2> minMax1;
+         std::array <double, 2> minMax2;
+         std::array <double, 2> minMax3;
+         minMax1[0] = geoObject->getX1Minimum();
+         minMax2[0] = geoObject->getX2Minimum();
+         minMax3[0] = geoObject->getX3Minimum();
+         minMax1[1] = geoObject->getX1Maximum();
+         minMax2[1] = geoObject->getX2Maximum();
+         minMax3[1] = geoObject->getX3Maximum();
+
+         for (int x3 = 0; x3 < 2; x3++)
+            for (int x2 = 0; x2 < 2; x2++)
+               for (int x1 = 0; x1 < 2; x1++)
+               {
+                  result = result || (minMax1[x1] >= AABB[0] && minMax2[x2] >= AABB[1] && minMax3[x3] >= AABB[2] && minMax1[x1] <= AABB[3] && minMax2[x2] <= AABB[4] && minMax3[x3] <= AABB[5]);
+               }
+      }
+   }
+   
+   std::vector<int> values;
+   values.push_back((int)result);
+   std::vector<int> rvalues = comm->gather(values);
+
+   if (comm->isRoot())
+   {
+      for (int i = 0; i < (int)rvalues.size(); i ++)
+      {
+         result = result || (bool)rvalues[i];
+      }
+   }
+   int iresult = (int)result;
+   comm->broadcast(iresult);
+   result = (bool)iresult;
+
+   return result;
+}
+
+void DemCoProcessor::addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles)
+{
+   for (int i = 0; i < interactors.size(); i++)
+   {
+      //UBLOG(logINFO, "DemCoProcessor::addSurfaceTriangleSet()1");
+      if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive())
+      {
+         //UBLOG(logINFO, "DemCoProcessor::addSurfaceTriangleSet()2");
+         interactors[i]->getGbObject3D()->addSurfaceTriangleSet(nodes, triangles);
+      }
+   }
+}
+
+void DemCoProcessor::getObjectsPropertiesVector(std::vector<double>& p)
+{
+   for (int i = 0; i < interactors.size(); i++)
+   {
+      if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive())
+      {
+         p.push_back(interactors[i]->getGbObject3D()->getX1Centroid());
+         p.push_back(interactors[i]->getGbObject3D()->getX2Centroid());
+         p.push_back(interactors[i]->getGbObject3D()->getX3Centroid());
+         Vector3D v = physicsEngineGeometrieAdapters[i]->getLinearVelocity();
+         p.push_back(v[0]);
+         p.push_back(v[1]);
+         p.push_back(v[2]);
+      }
+   }
+}
+
+void DemCoProcessor::addPeGeo(walberla::pe::RigidBody * peGeo)
+{
+   //UBLOG(logINFO, "DemCoProcessor::addPeGeo()");
+   //for (int i = 0; i < physicsEngineGeometries.size(); i++)
+   //{
+   //   auto geometry = std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometries[i]);
+   //   if (geometry->getId() == peGeo->getID())
+   //   {
+   //      geometry->setActive();
+   //      geometry->setGeometry(peGeo);
+   //      return;
+   //   }
+   //}
+
+   if (peGeo->getID() < 0 || peGeo->getID() >= physicsEngineGeometrieAdapters.size()) return;
+
+   auto geometry = std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[peGeo->getID()]);
+   if (geometry->getId() == peGeo->getID())
+   {
+      geometry->setActive();
+      geometry->setGeometry(peGeo);
+      return;
+   }
+   else
+      throw UbException(UB_EXARGS, "PeGeo ID is not matching!");
+}
+
+void DemCoProcessor::removePeGeo(walberla::pe::RigidBody * peGeo)
+{
+   //UBLOG(logINFO, "DemCoProcessor::removePeGeo()");
+   //for (int i = 0; i < physicsEngineGeometries.size(); i++)
+   //{
+   //   auto geometry = std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometries[i]);
+   //   if (geometry->getId() == peGeo->getID())
+   //   {
+   //      geometry->setInactive();
+   //      geometry->setGeometry(NULL);
+   //      return;
+   //   }
+   //}
+
+   if (peGeo->getID() < 0 || peGeo->getID() >= physicsEngineGeometrieAdapters.size()) return;
+
+   auto geometry = std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[peGeo->getID()]);
+   if (geometry->getId() == peGeo->getID())
+   {
+      geometry->setInactive();
+      geometry->setGeometry(NULL);
+      return;
+   }
+   else
+      throw UbException(UB_EXARGS, "PeGeo ID is not matching!");
+}
+
+bool DemCoProcessor::isSpheresIntersection(double centerX1, double centerX2, double centerX3, double d)
+{
+   bool result = false;
+   for (int i = 0; i < interactors.size(); i++)
+   {
+      if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive())
+      {
+         SPtr<GbObject3D> sphere = interactors[i]->getGbObject3D();
+         result = result || ( sqrt(pow(sphere->getX1Centroid()-centerX1, 2)+pow(sphere->getX2Centroid()-centerX2, 2)+pow(sphere->getX3Centroid()-centerX3, 2)) < d );
+      }
+   }
+   std::vector<int> values;
+   values.push_back((int)result);
+   std::vector<int> rvalues = comm->gather(values);
+
+   if (comm->isRoot())
+   {
+      for (int i = 0; i < (int)rvalues.size(); i++)
+      {
+         result = result || (bool)rvalues[i];
+      }
+   }
+   int iresult = (int)result;
+   comm->broadcast(iresult);
+   result = (bool)iresult;
+
+   return result;
+}
+
+void DemCoProcessor::distributeIDs()
+{
+   std::vector<int> peIDsSend;
+   std::vector<int> vfIDsSend;
+
+   for (int i = 0; i < interactors.size(); i++)
+   {
+      if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive())
+      {
+         peIDsSend.push_back(std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->getId());
+         vfIDsSend.push_back(interactors[i]->getID());
+      }
+   }
+
+   std::vector<int> peIDsRecv;
+   std::vector<int> vfIDsRecv;
+
+   comm->allGather(peIDsSend, peIDsRecv);
+   comm->allGather(vfIDsSend, vfIDsRecv);
+
+   std::map<int, int> idMap;
+
+   for (int i = 0; i < peIDsRecv.size(); i++)
+   {
+      idMap.insert(std::make_pair(vfIDsRecv[i], peIDsRecv[i]));
+   }
+
+   for (int i = 0; i < interactors.size(); i++)
+   {
+       std::map<int, int>::const_iterator it;
+      if ((it=idMap.find(interactors[i]->getID())) == idMap.end())
+      {
+         throw UbException(UB_EXARGS, "Interactor ID is invalid! The DEM object may be not in PE domain!");
+      }
+      
+
+      std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->setId(it->second);
+      //std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometries[i])->setId(idMap.find(interactors[i]->getID())->second);
+   }
+
+   for (int i = 0; i < physicsEngineGeometrieAdapters.size(); i++)
+   {
+         //physicsEngineSolver->updateGeometry(physicsEngineGeometries[i]);
+         if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive())
+         {
+            interactors[i]->setPhysicsEngineGeometry(physicsEngineGeometrieAdapters[i]);
+         }
+   }
+}
+
+void DemCoProcessor::setBlockVisitor(std::shared_ptr<BoundaryConditionsBlockVisitor> boundaryConditionsBlockVisitor)
+{
+   this->boundaryConditionsBlockVisitor = boundaryConditionsBlockVisitor;
+}
diff --git a/source/DemCoupling/DemCoProcessor.h b/source/DemCoupling/DemCoProcessor.h
new file mode 100644
index 0000000000000000000000000000000000000000..9071084e358ef1fd9295ca1f462fdf1b24820f41
--- /dev/null
+++ b/source/DemCoupling/DemCoProcessor.h
@@ -0,0 +1,80 @@
+/*
+ *  Author: S. Peters
+ *  mail: peters@irmb.tu-bs.de
+ */
+#ifndef DEM_CO_PROCESSOR_H
+#define DEM_CO_PROCESSOR_H
+
+#include <memory>
+#include <vector>
+#include <map>
+
+#include "Vector3D.h"
+
+#include "CoProcessor.h"
+#include "UbTuple.h"
+
+#include <pe/basic.h>
+
+//#define TIMING
+
+#ifdef TIMING
+   #include "UbTiming.h"
+#endif
+ 
+
+class PhysicsEngineGeometryAdapter;
+class PhysicsEngineSolverAdapter;
+class PhysicsEngineMaterialAdapter;
+
+class UbScheduler;
+class Grid3D;
+class ForceCalculator;
+class Communicator;
+class MovableObjectInteractor;
+class Communicator;
+class BoundaryConditionsBlockVisitor;
+
+
+class DemCoProcessor : public CoProcessor
+{
+public:
+    DemCoProcessor(std::shared_ptr<Grid3D> grid, std::shared_ptr<UbScheduler> s, std::shared_ptr<Communicator> comm, std::shared_ptr<ForceCalculator> forceCalculator, std::shared_ptr<PhysicsEngineSolverAdapter> physicsEngineSolver, double intermediatePeSteps = 1.0);
+    virtual ~DemCoProcessor();
+
+    void addInteractor(std::shared_ptr<MovableObjectInteractor> interactor, std::shared_ptr<PhysicsEngineMaterialAdapter> physicsEngineMaterial, Vector3D initalVelocity = Vector3D(0.0, 0.0, 0.0));
+    void process(double step) override;
+    std::shared_ptr<PhysicsEngineSolverAdapter> getPhysicsEngineSolver();
+    void distributeIDs();
+    void setBlockVisitor(std::shared_ptr<BoundaryConditionsBlockVisitor> blockVisitor);
+    bool isDemObjectInAABB(std::array<double,6> AABB);
+    void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles);
+    void getObjectsPropertiesVector(std::vector<double>& p);
+    void addPeGeo(walberla::pe::RigidBody* peGeo);
+    void removePeGeo(walberla::pe::RigidBody* peGeo);
+    bool isSpheresIntersection(double centerX1, double centerX2, double centerX3, double d);
+  
+private:
+    std::shared_ptr<PhysicsEngineGeometryAdapter> createPhysicsEngineGeometryAdapter(std::shared_ptr<MovableObjectInteractor> interactor, std::shared_ptr<PhysicsEngineMaterialAdapter> physicsEngineMaterial) const;
+    void applyForcesOnGeometries();
+    void setForcesToObject(SPtr<Grid3D> grid, std::shared_ptr<MovableObjectInteractor> interactor, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry);
+    void scaleForcesAndTorques(double scalingFactor);
+    void calculateDemTimeStep(double step);
+    void moveVfGeoObject();
+private:
+    std::shared_ptr<Communicator> comm;
+    std::vector<std::shared_ptr<MovableObjectInteractor> > interactors;
+    std::shared_ptr<ForceCalculator> forceCalculator;
+    std::shared_ptr<PhysicsEngineSolverAdapter> physicsEngineSolver;
+    std::vector<std::shared_ptr<PhysicsEngineGeometryAdapter> > physicsEngineGeometrieAdapters;
+    double intermediateDemSteps;
+    SPtr<BoundaryConditionsBlockVisitor> boundaryConditionsBlockVisitor;
+
+#ifdef TIMING
+    UbTimer timer;
+#endif
+};
+
+
+#endif
+
diff --git a/source/DemCoupling/DemCoupling.cmake b/source/DemCoupling/DemCoupling.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..0fa6b211ba4b2281242eeb0f59843d1fa69fa9fd
--- /dev/null
+++ b/source/DemCoupling/DemCoupling.cmake
@@ -0,0 +1,28 @@
+INCLUDE(${SOURCE_ROOT}/DemCoupling/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter/dummy/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter/pe/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/DemCoupling/reconstructor/CMakePackage.txt)
+
+INCLUDE(${SOURCE_ROOT}/DemCoupling/IncludsList.cmake)
+
+SET(LINK_LIBRARY optimized ${PE_RELEASE_LIBRARY} debug ${PE_DEBUG_LIBRARY})
+SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY})
+
+SET(LINK_LIBRARY optimized ${BLOCKFOREST_RELEASE_LIBRARY} debug ${BLOCKFOREST_DEBUG_LIBRARY})
+SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY})
+
+SET(LINK_LIBRARY optimized ${DOMAIN_DECOMPOSITION_RELEASE_LIBRARY} debug ${DOMAIN_DECOMPOSITION_DEBUG_LIBRARY})
+SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY})
+
+SET(LINK_LIBRARY optimized ${CORE_RELEASE_LIBRARY} debug ${CORE_DEBUG_LIBRARY})
+SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY})
+
+IF(${USE_GCC})
+   SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} "stdc++fs")
+ENDIF()
+
+IF(${USE_METIS})
+   SET(LINK_LIBRARY optimized ${METIS_RELEASE_LIBRARY} debug ${METIS_DEBUG_LIBRARY})
+   SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY})
+ENDIF()
\ No newline at end of file
diff --git a/source/DemCoupling/IncludsList.cmake b/source/DemCoupling/IncludsList.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..7ebf198e6082131956d5c1e146031394f39e37d5
--- /dev/null
+++ b/source/DemCoupling/IncludsList.cmake
@@ -0,0 +1,8 @@
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/DemCoupling)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter/dummy)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter/pe)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/DemCoupling/reconstructor)
+
+INCLUDE_DIRECTORIES(${PE_ROOT}/src)
+INCLUDE_DIRECTORIES(${PE_BINARY_DIR}/src)
\ No newline at end of file
diff --git a/source/DemCoupling/MovableObjectInteractor.cpp b/source/DemCoupling/MovableObjectInteractor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c6a2b6933c108c0f906e2e8190d049e1047c8b27
--- /dev/null
+++ b/source/DemCoupling/MovableObjectInteractor.cpp
@@ -0,0 +1,210 @@
+#include "MovableObjectInteractor.h"
+
+#include "UbLogger.h"
+#include "GbObject3D.h"
+#include "Vector3D.h"
+
+#include "Block3D.h"
+#include "Grid3D.h"
+#include "BCArray3D.h"
+#include "BCAdapter.h"
+#include "BCProcessor.h"
+#include "ILBMKernel.h"
+
+#include "SetBcBlocksBlockVisitor.h"
+#include "BoundaryConditionsBlockVisitor.h"
+
+#include "PhysicsEngineGeometryAdapter.h"
+#include "Reconstructor.h"
+
+#include <array>
+
+//#define TIMING
+
+#ifdef TIMING
+   #include "UbTiming.h"
+#endif
+
+
+MovableObjectInteractor::MovableObjectInteractor(std::shared_ptr<GbObject3D> geoObject3D, std::shared_ptr<Grid3D> grid, std::shared_ptr<BCAdapter> bcAdapter, int type, std::shared_ptr<Reconstructor> reconstructor, State state)
+   : D3Q27Interactor(geoObject3D, grid, bcAdapter, type), reconstructor(reconstructor), state(state)
+{
+   //grid->getBlocks(0, grid->getRank(), true, blockVector);
+}
+
+MovableObjectInteractor::~MovableObjectInteractor()
+{
+
+}
+
+void MovableObjectInteractor::setPhysicsEngineGeometry(std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry)
+{
+    this->physicsEngineGeometry = physicsEngineGeometry;
+    physicsEngineGeometry->changeState(this->state);
+}
+
+void MovableObjectInteractor::moveGbObjectTo(const Vector3D& position)
+{
+    //UBLOG(logINFO, "new position: (x,y,z) " << val<1>(position) << ", " << val<2>(position) << ", " << val<3>(position));
+
+    this->getGbObject3D()->setCenterCoordinates(UbTupleDouble3(position[0], position[1], position[2]));
+    this->rearrangeGrid();
+}
+
+void MovableObjectInteractor::rearrangeGrid()
+{
+#ifdef TIMING
+   UbTimer timer;
+   timer.resetAndStart();
+#endif
+
+#ifdef TIMING
+   UBLOG(logINFO, "MovableObjectInteractor::rearrangeGrid():start");
+#endif
+
+    this->reconstructDistributionOnSolidNodes();
+
+#ifdef TIMING
+    UBLOG(logINFO, "reconstructDistributionOnSolidNodes() time = "<<timer.stop()<<" s");
+#endif
+
+    this->setSolidNodesToFluid();
+
+#ifdef TIMING
+    UBLOG(logINFO, "setSolidNodesToFluid() time = "<<timer.stop()<<" s");
+#endif
+
+    this->setBcNodesToFluid();
+
+#ifdef TIMING
+    UBLOG(logINFO, "setBcNodesToFluid() time = "<<timer.stop()<<" s");
+#endif
+
+    this->removeSolidBlocks();
+
+#ifdef TIMING
+    UBLOG(logINFO, "removeSolidBlocks() time = "<<timer.stop()<<" s");
+#endif
+
+    this->removeBcBlocks();
+
+#ifdef TIMING
+    UBLOG(logINFO, "removeBcBlocks() time = "<<timer.stop()<<" s");
+#endif
+
+    this->setBcBlocks();
+
+#ifdef TIMING
+    UBLOG(logINFO, "setBcBlocks() time = "<<timer.stop()<<" s");
+#endif
+
+    this->initInteractor();
+
+#ifdef TIMING
+    UBLOG(logINFO, "initInteractor() time = "<<timer.stop()<<" s");
+#endif
+
+    this->updateVelocityBc();
+
+#ifdef TIMING
+    UBLOG(logINFO, "updateVelocityBc() time = "<<timer.stop()<<" s");
+#endif
+}
+
+void MovableObjectInteractor::reconstructDistributionOnSolidNodes()
+{
+    for(SolidNodeIndicesMap::value_type t : solidNodeIndicesMap)
+    {
+        SPtr<Block3D> block = t.first;
+        std::set< UbTupleInt3 >& solidNodeIndices = t.second;
+
+        
+        SPtr<ILBMKernel> kernel = block->getKernel();
+
+        for (UbTupleInt3 node : solidNodeIndices)
+        {
+            const int x1 = val<1>(node);
+            const int x2 = val<2>(node);
+            const int x3 = val<3>(node);
+
+            const Vector3D worldCoordinates = this->grid.lock()->getNodeCoordinates(block, x1, x2, x3);
+    
+            if (kernel->isInsideOfDomain(x1, x2, x3))
+                reconstructor->reconstructNode(x1, x2, x3, worldCoordinates, physicsEngineGeometry, kernel);
+        }
+    }
+}
+
+void MovableObjectInteractor::setSolidNodesToFluid()
+{
+    for (SolidNodeIndicesMap::value_type t : solidNodeIndicesMap)
+    {
+        SPtr<Block3D> block = t.first;
+        std::set< UbTupleInt3 >& solidNodeIndices = t.second;
+
+        SPtr<ILBMKernel> kernel = block->getKernel();
+        SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray();
+
+        for (UbTupleInt3 node : solidNodeIndices)
+            bcArray->setFluid(val<1>(node), val<2>(node), val<3>(node));
+    }
+}
+
+void MovableObjectInteractor::setBcNodesToFluid()
+{
+   for (BcNodeIndicesMap::value_type t : bcNodeIndicesMap)
+   {
+      SPtr<Block3D> block = t.first;
+      std::set< std::vector<int> >& bcNodeIndices = t.second;
+
+      SPtr<ILBMKernel> kernel = block->getKernel();
+      SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray();
+
+      for (std::vector<int> node : bcNodeIndices)
+         bcArray->setFluid(node[0], node[1], node[2]);
+   }
+}
+
+void MovableObjectInteractor::setBcBlocks()
+{
+    //SetBcBlocksBlockVisitor v(shared_from_this());
+    //this->grid.lock()->accept(v);
+   SPtr<GbObject3D> geoObject = this->getGbObject3D();
+   std::array<double, 6> AABB ={ geoObject->getX1Minimum(),geoObject->getX2Minimum(),geoObject->getX3Minimum(),geoObject->getX1Maximum(),geoObject->getX2Maximum(),geoObject->getX3Maximum() };
+   blockVector.clear();
+   UbTupleInt3 blockNX=grid.lock()->getBlockNX();
+   double ext = 0.0;
+   grid.lock()->getBlocksByCuboid(AABB[0]-(double)val<1>(blockNX)*ext, AABB[1]-(double)val<2>(blockNX)*ext, AABB[2]-(double)val<3>(blockNX)*ext, AABB[3]+(double)val<1>(blockNX)*ext, AABB[4]+(double)val<2>(blockNX)*ext, AABB[5]+(double)val<3>(blockNX)*ext, blockVector);
+
+   for(std::shared_ptr<Block3D> block : this->blockVector)
+   {
+      if (block->getKernel())
+      {
+         setBCBlock(block);
+      }
+   }
+}
+
+void MovableObjectInteractor::updateVelocityBc()
+{
+    for(BcNodeIndicesMap::value_type t : this->getBcNodeIndicesMap())
+    {
+        SPtr<Block3D> block = t.first;
+        std::set< std::vector<int> >& bcNodeIndices = t.second;
+
+        SPtr<BCArray3D> bcArray = block->getKernel()->getBCProcessor()->getBCArray();
+
+        for(std::vector<int> node : bcNodeIndices)
+            setGeometryVelocityToBoundaryCondition(node, block, bcArray);
+    }
+}
+
+
+void MovableObjectInteractor::setGeometryVelocityToBoundaryCondition(std::vector<int> node, SPtr<Block3D> block, SPtr<BCArray3D> bcArray) const
+{
+    const SPtr<BoundaryConditions> bc = bcArray->getBC(node[0], node[1], node[2]);
+    const Vector3D worldCoordinates = this->grid.lock()->getNodeCoordinates(block, node[0], node[1], node[2]);
+    const Vector3D velocity = this->physicsEngineGeometry->getVelocityAtPosition(worldCoordinates);
+
+    bc->setBoundaryVelocity(velocity);
+}
diff --git a/source/DemCoupling/MovableObjectInteractor.h b/source/DemCoupling/MovableObjectInteractor.h
new file mode 100644
index 0000000000000000000000000000000000000000..a77fb4502de03f91a85997885de1813232461aa4
--- /dev/null
+++ b/source/DemCoupling/MovableObjectInteractor.h
@@ -0,0 +1,54 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef D3Q27_MOVABLE_OBJECT_INTERACTOR_H
+#define D3Q27_MOVABLE_OBJECT_INTERACTOR_H
+
+#include <memory>
+#include <vector>
+
+#include "D3Q27Interactor.h"
+
+#include "Vector3D.h"
+#include "PhysicsEngineGeometryAdapter.h"
+
+
+class Grid3D;
+class Block3D;
+class BCArray3D;
+class BCAdapter;
+class GbObject3D;
+
+class PhysicsEngineGeometryAdapter;
+class Reconstructor;
+
+class MovableObjectInteractor : public D3Q27Interactor
+{
+public:
+    MovableObjectInteractor(std::shared_ptr<GbObject3D> geoObject3D, std::shared_ptr<Grid3D> grid, std::shared_ptr<BCAdapter> bcAdapter, int type, std::shared_ptr<Reconstructor> reconstructor, State isPinned);
+    virtual ~MovableObjectInteractor();
+
+    void setPhysicsEngineGeometry(std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry);
+
+    void moveGbObjectTo(const Vector3D& position);
+
+private:
+    void rearrangeGrid();
+    void setSolidNodesToFluid();
+    void setBcNodesToFluid();
+    void reconstructDistributionOnSolidNodes();
+    void setBcBlocks();
+
+    void updateVelocityBc();
+    void setGeometryVelocityToBoundaryCondition(std::vector<int> node, std::shared_ptr<Block3D> block, std::shared_ptr<BCArray3D> bcArray) const;
+
+    std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry;
+
+    std::shared_ptr<Reconstructor> reconstructor;
+    State state;
+    std::vector< std::shared_ptr<Block3D> > blockVector;
+};
+
+
+#endif
diff --git a/source/DemCoupling/PePartitioningGridVisitor.cpp b/source/DemCoupling/PePartitioningGridVisitor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..df05d5ef2aa9241ddeec6ebee5d506d7304c2663
--- /dev/null
+++ b/source/DemCoupling/PePartitioningGridVisitor.cpp
@@ -0,0 +1,156 @@
+#if defined VF_METIS && defined VF_MPI
+
+#include <shared_mutex>
+#include "PePartitioningGridVisitor.h"
+#include <math.h>
+#include "Block3D.h"
+#include "Grid3D.h"
+#include "Communicator.h"
+#include "UbLogger.h"
+#include "CoordinateTransformation3D.h"
+
+#include "DemCoProcessor.h"
+
+using namespace std;
+
+PePartitioningGridVisitor::PePartitioningGridVisitor(SPtr<Communicator> comm, std::shared_ptr<DemCoProcessor> dem)
+   : Grid3DVisitor(),
+   comm(comm),
+   dem(dem)
+{
+   forest = dynamicPointerCast<PePhysicsEngineSolverAdapter>(dem->getPhysicsEngineSolver())->getForest();
+}
+//////////////////////////////////////////////////////////////////////////
+PePartitioningGridVisitor::~PePartitioningGridVisitor()
+{
+
+}
+//////////////////////////////////////////////////////////////////////////
+void PePartitioningGridVisitor::visit(SPtr<Grid3D> grid)
+{
+   UBLOG(logDEBUG1, "PePartitioningGridVisitor::visit() - start");
+
+   collectData(grid);
+   distributePartitionData(grid);
+
+   UBLOG(logDEBUG1, "PePartitioningGridVisitor::visit() - end");
+}
+//////////////////////////////////////////////////////////////////////////
+void PePartitioningGridVisitor::collectData(SPtr<Grid3D> grid)
+{
+   int minInitLevel = grid->getCoarsestInitializedLevel();
+   int maxInitLevel = grid->getFinestInitializedLevel();
+
+   walberla::uint_t peRank;
+
+   for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt)
+   {
+      forest->getProcessRank(peRank, blockIt->getId());
+      vector<SPtr<Block3D>> blocks;
+      walberla::AABB aabb = blockIt->getAABB();
+
+      //getBlocksByCuboid((double)aabb.xMin(), (double)aabb.yMin(), (double)aabb.zMin(), (double)aabb.xMax(), (double)aabb.yMax(), (double)aabb.zMax(), blocks, grid);
+      //for (SPtr<Block3D> block : blocks)
+      //{
+      //   ids.push_back(block->getGlobalID());
+      //   ranks.push_back((int)peRank);
+      //}
+      SPtr<Block3D> block = getBlockByMinUniform((double)aabb.xMin(), (double)aabb.yMin(), (double)aabb.zMin(), grid);
+      if (block)
+      {
+         ids.push_back(block->getGlobalID());
+         ranks.push_back((int)peRank);
+      }
+   }
+}
+//////////////////////////////////////////////////////////////////////////
+//void PePartitioningGridVisitor::getBlocksByCuboid(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, std::vector<SPtr<Block3D>>& blocks, SPtr<Grid3D> grid)
+//{
+//   int coarsestLevel = grid->getCoarsestInitializedLevel();
+//   int finestLevel   = grid->getFinestInitializedLevel();
+//
+//   SPtr<CoordinateTransformation3D> trafo = grid->getCoordinateTransformator();
+//
+//   //////////////////////////////////////////////////////////////////////////
+//   //MINIMALE BLOCK-INDIZES BESTIMMEN
+//   //  
+//   //min:
+//   double dMinX1 = trafo->transformForwardToX1Coordinate(minX1, minX2, minX3)*(1<<finestLevel);
+//   double dMinX2 = trafo->transformForwardToX2Coordinate(minX1, minX2, minX3)*(1<<finestLevel);
+//   double dMinX3 = trafo->transformForwardToX3Coordinate(minX1, minX2, minX3)*(1<<finestLevel);
+//
+//   //Achtung, wenn minX1 genau auf grenze zwischen zwei bloecken -> der "kleinere" muss genommen werden,
+//   //da beim Transformieren der "groessere" Index rauskommt
+//   int iMinX1 = (int)dMinX1; //if (UbMath::zero(dMinX1-iMinX1)) iMinX1-=1;
+//   int iMinX2 = (int)dMinX2; //if (UbMath::zero(dMinX2-iMinX2)) iMinX2-=1;
+//   int iMinX3 = (int)dMinX3; //if (UbMath::zero(dMinX3-iMinX3)) iMinX3-=1;
+//
+//   //max (hier kann die Zusatzabfrage vernachlaessigt werden):
+//   int iMaxX1 = (int)(trafo->transformForwardToX1Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel));
+//   int iMaxX2 = (int)(trafo->transformForwardToX2Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel));
+//   int iMaxX3 = (int)(trafo->transformForwardToX3Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel));
+//
+//   SPtr<Block3D> block;
+//
+//   //set, um doppelte bloecke zu vermeiden, die u.U. bei periodic auftreten koennen
+//   std::set<SPtr<Block3D>> blockset;
+//   for (int level=coarsestLevel; level<=finestLevel; level++)
+//   {
+//      //damit bei negativen werten auch der "kleinere" genommen wird -> floor!
+//      int minx1 = (int)std::floor((double)iMinX1/(1<<(finestLevel-level)));
+//      int minx2 = (int)std::floor((double)iMinX2/(1<<(finestLevel-level)));
+//      int minx3 = (int)std::floor((double)iMinX3/(1<<(finestLevel-level)));
+//
+//      int maxx1 = iMaxX1/(1<<(finestLevel-level));
+//      int maxx2 = iMaxX2/(1<<(finestLevel-level));
+//      int maxx3 = iMaxX3/(1<<(finestLevel-level));
+//
+//      for (int ix1=minx1; ix1<maxx1; ix1++)
+//         for (int ix2=minx2; ix2<maxx2; ix2++)
+//            for (int ix3=minx3; ix3<maxx3; ix3++)
+//               if ((block=grid->getBlock(ix1, ix2, ix3, level)))
+//               {
+//                  blockset.insert(block);
+//               }
+//   }
+//
+//   blocks.resize(blockset.size());
+//   std::copy(blockset.begin(), blockset.end(), blocks.begin());
+//}
+
+SPtr<Block3D> PePartitioningGridVisitor::getBlockByMinUniform(double minX1, double minX2, double minX3, SPtr<Grid3D> grid)
+{
+   SPtr<CoordinateTransformation3D> trafo = grid->getCoordinateTransformator();
+
+   int ix1 = (int)trafo->transformForwardToX1Coordinate(minX1, minX2, minX3);
+   int ix2 = (int)trafo->transformForwardToX2Coordinate(minX1, minX2, minX3);
+   int ix3 = (int)trafo->transformForwardToX3Coordinate(minX1, minX2, minX3);
+
+   return grid->getBlock(ix1, ix2, ix3, 0);
+}
+
+//////////////////////////////////////////////////////////////////////////
+void PePartitioningGridVisitor::distributePartitionData(SPtr<Grid3D> grid)
+{
+   std::vector<int> totalIDs;
+   std::vector<int> totalRanks;
+
+   assert(ids.size() != 0);
+   assert(ranks.size() != 0);
+
+   comm->allGather(ids, totalIDs);
+   comm->allGather(ranks, totalRanks);
+
+
+   assert(totalIDs.size() == totalRanks.size());
+   for (int i = 0; i < totalIDs.size(); i++)
+   {
+      SPtr<Block3D> block = grid->getBlock(totalIDs[i]);
+      if (block) block->setRank(totalRanks[i]);
+   }
+}
+//////////////////////////////////////////////////////////////////////////
+
+
+
+#endif  //VF_METIS
diff --git a/source/DemCoupling/PePartitioningGridVisitor.h b/source/DemCoupling/PePartitioningGridVisitor.h
new file mode 100644
index 0000000000000000000000000000000000000000..bce2ca0d2059b4c2915ab30fc4baa87b09cf9bf8
--- /dev/null
+++ b/source/DemCoupling/PePartitioningGridVisitor.h
@@ -0,0 +1,56 @@
+#ifndef PePartitioningGridVisitor_h 
+#define PePartitioningGridVisitor_h
+
+#if defined VF_MPI
+
+#include <vector>
+#include <PointerDefinitions.h>
+
+#include "Grid3DVisitor.h"
+
+#include "PePhysicsEngineSolverAdapter.h"
+
+#include <array>
+
+////////////////////////////////////////////////////////////////////////
+//! \brief The class implements domain decomposition with PE library
+//! \author Konstantin Kutscher
+//////////////////////////////////////////////////////////////////////////
+class Communicator;
+class Grid3D;
+class Block3D;
+class DemCoProcessor;
+//class walberla::blockforest::BlockForest;
+
+class PePartitioningGridVisitor : public Grid3DVisitor
+{                                             
+public:
+   //! This describe different types of decomposition   
+   enum GraphType{LevelIntersected, LevelBased};
+
+public:
+   //! Constructor
+   //! \param comm - communicator
+
+   PePartitioningGridVisitor(SPtr<Communicator> comm, std::shared_ptr<DemCoProcessor> dem);
+   virtual ~PePartitioningGridVisitor();
+   void visit(SPtr<Grid3D> grid) override;
+
+protected:
+   void collectData(SPtr<Grid3D> grid);
+   void distributePartitionData(SPtr<Grid3D> grid);
+   //void getBlocksByCuboid(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, std::vector<SPtr<Block3D>>& blocks, SPtr<Grid3D> grid);
+   SPtr<Block3D> getBlockByMinUniform(double minX1, double minX2, double minX3, SPtr<Grid3D> grid);
+
+private:
+   SPtr<Communicator> comm;
+   std::shared_ptr<DemCoProcessor> dem;
+
+   std::vector<int> ids;
+   std::vector<int> ranks;
+
+   std::shared_ptr< walberla::blockforest::BlockForest > forest;
+};
+
+#endif  //VF_MPI
+#endif 
diff --git a/source/DemCoupling/RestartDemObjectsCoProcessor.cpp b/source/DemCoupling/RestartDemObjectsCoProcessor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1a63501b20e1fd3783271bc83af9bb2f2e80a092
--- /dev/null
+++ b/source/DemCoupling/RestartDemObjectsCoProcessor.cpp
@@ -0,0 +1,99 @@
+#include "RestartDemObjectsCoProcessor.h"
+
+#include "Vector3D.h"
+#include "Communicator.h"
+#include "UbScheduler.h"
+#include "Grid3D.h"
+#include "UbSystem.h"
+#include "GbSphere3D.h"
+#include "DemCoProcessor.h"
+#include "UbFileInputBinary.h"
+#include "UbFileOutputBinary.h"
+#include "CreateDemObjectsCoProcessor.h"
+
+RestartDemObjectsCoProcessor::RestartDemObjectsCoProcessor()
+{
+}
+
+RestartDemObjectsCoProcessor::RestartDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string & path, SPtr<DemCoProcessor> demCoProcessor, SPtr<CreateDemObjectsCoProcessor> createDemObjectsCoProcessor, double radius, SPtr<Communicator> comm)  : CoProcessor(grid, s), path(path), demCoProcessor(demCoProcessor), createDemObjectsCoProcessor(createDemObjectsCoProcessor), radius(radius), comm(comm)
+{
+}
+
+void RestartDemObjectsCoProcessor::process(double step)
+{
+   if (scheduler->isDue(step))
+   {
+      int istep = static_cast<int>(step);
+
+      if (comm->isRoot())
+         UBLOG(logINFO, "RestartDemObjectsCoProcessor::write step: " << istep);
+
+      write(istep);
+   }
+}
+
+void RestartDemObjectsCoProcessor::restart(double step)
+{
+   if (comm->isRoot())
+      UBLOG(logINFO, "RestartDemObjectsCoProcessor::read step: " << (int)step);
+
+   read((int)step);
+}
+
+void RestartDemObjectsCoProcessor::write(int step)
+{
+   if (comm->isRoot()) UBLOG(logINFO, "RestartDemObjectsCoProcessor::write start ");
+   std::vector<double> p;
+
+   demCoProcessor->getObjectsPropertiesVector(p);
+
+   //TODO implement getherv 
+   std::vector<double> rvalues;
+   comm->allGather(p, rvalues);
+
+   if (comm->isRoot())
+   {
+      std::string subfolder = "dem_cp_"+UbSystem::toString(step);
+      std::string filePath =  path+"/dem_cp/"+subfolder+"/dem_cp.bin";
+      UbFileOutputBinary fo(filePath);
+      fo.writeInteger((int)rvalues.size());
+      fo.writeVector<double>(rvalues);
+      UBLOG(logINFO, "RestartDemObjectsCoProcessor::write number of objects = " << rvalues.size()/6);
+   }
+   if (comm->isRoot()) UBLOG(logINFO, "RestartDemObjectsCoProcessor::write stop ");
+}
+
+void RestartDemObjectsCoProcessor::read(int step)
+{
+   if (comm->isRoot()) UBLOG(logINFO, "RestartDemObjectsCoProcessor::read start ");
+   std::vector<double> p;
+
+   if (comm->isRoot())
+   {
+      std::string subfolder = "dem_cp_"+UbSystem::toString(step);
+      std::string filePath =  path+"/dem_cp/"+subfolder+"/dem_cp.bin";
+      UbFileInputBinary fi(filePath);
+      int size = fi.readInteger();
+      p.resize(size);
+      fi.readVector<double>(p);
+   }
+   comm->broadcast(p);
+
+   if (comm->isRoot()) UBLOG(logINFO, "RestartDemObjectsCoProcessor::read number of objects = " << p.size()/6);
+
+   createDemObjectsCoProcessor->clearGeoObjects();
+
+   int size =  (int)p.size();
+
+   for (int i = 0; i < size; i += 6)
+   {
+      SPtr<GbObject3D> sphere(new GbSphere3D(p[i], p[i+1], p[i+2], radius));
+      createDemObjectsCoProcessor->addGeoObject(sphere, Vector3D(p[i+3], p[i+4], p[i+5]));
+   }
+
+   createDemObjectsCoProcessor->createGeoObjects();
+
+   createDemObjectsCoProcessor->clearGeoObjects();
+
+   if (comm->isRoot()) UBLOG(logINFO, "RestartDemObjectsCoProcessor::read stop ");
+}
diff --git a/source/DemCoupling/RestartDemObjectsCoProcessor.h b/source/DemCoupling/RestartDemObjectsCoProcessor.h
new file mode 100644
index 0000000000000000000000000000000000000000..8a1fdb72177ae18624f87d1508cbad7576cac860
--- /dev/null
+++ b/source/DemCoupling/RestartDemObjectsCoProcessor.h
@@ -0,0 +1,38 @@
+/*
+*  Author: K. Kutscher
+*  mail: kutscher@irmb.tu-bs.de
+*/
+#ifndef RestartDemObjectsCoProcessor_H
+#define RestartDemObjectsCoProcessor_H
+
+#include <PointerDefinitions.h>
+#include <string>
+#include <vector>
+
+#include "CoProcessor.h"
+
+class Communicator;
+class Grid3D;
+class UbScheduler;
+class DemCoProcessor;
+class CreateDemObjectsCoProcessor;
+
+class RestartDemObjectsCoProcessor : public  CoProcessor
+{
+public:
+   RestartDemObjectsCoProcessor();
+   RestartDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, SPtr<DemCoProcessor> demCoProcessor, SPtr<CreateDemObjectsCoProcessor> createDemObjectsCoProcessor, double radius, SPtr<Communicator> comm);
+   ~RestartDemObjectsCoProcessor() {}
+   void process(double step) override;
+   void restart(double step);
+   void write(int step);
+   void read(int step);
+
+private:
+   std::string path;
+   double radius;
+   SPtr<Communicator> comm;
+   SPtr<DemCoProcessor> demCoProcessor;
+   SPtr<CreateDemObjectsCoProcessor> createDemObjectsCoProcessor;
+};
+#endif
diff --git a/source/DemCoupling/WriteDemObjectsCoProcessor.cpp b/source/DemCoupling/WriteDemObjectsCoProcessor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..130cd302755f2b3f433c88ad09e7734d3ec0da7d
--- /dev/null
+++ b/source/DemCoupling/WriteDemObjectsCoProcessor.cpp
@@ -0,0 +1,73 @@
+#include "WriteDemObjectsCoProcessor.h"
+
+#include "basics/writer/WbWriterVtkXmlBinary.h"
+#include "basics/writer/WbWriterVtkXmlASCII.h"
+
+#include "Communicator.h"
+#include "UbScheduler.h"
+#include "Grid3D.h"
+#include "UbSystem.h"
+#include "DemCoProcessor.h"
+
+WriteDemObjectsCoProcessor::WriteDemObjectsCoProcessor()
+{
+
+}
+//////////////////////////////////////////////////////////////////////////
+WriteDemObjectsCoProcessor::WriteDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<DemCoProcessor> demCoProcessor, SPtr<Communicator> comm)
+   : CoProcessor(grid, s),
+   path(path),
+   writer(writer),
+   demCoProcessor(demCoProcessor),
+   comm(comm)
+{
+    
+}
+//////////////////////////////////////////////////////////////////////////
+void WriteDemObjectsCoProcessor::process(double step)
+{
+   if (scheduler->isDue(step))
+   {
+       std::vector<UbTupleFloat3> nodes;
+       std::vector<UbTupleInt3>   triangles;
+
+       demCoProcessor->addSurfaceTriangleSet(nodes, triangles);
+
+       int istep = static_cast<int>(step);
+
+       std::string pfilePath, partPath, subfolder, cfilePath;
+
+       subfolder = "dem"+UbSystem::toString(istep);
+       pfilePath =  path+"/dem/"+subfolder;
+       cfilePath =  path+"/dem/dem_collection";
+       partPath = pfilePath+"/dem"+UbSystem::toString(comm->getProcessID())+ "_" + UbSystem::toString(istep);
+
+
+       std::string partName = writer->writeTriangles(partPath, nodes, triangles);
+       size_t found=partName.find_last_of("/");
+       std::string piece = partName.substr(found+1);
+       piece = subfolder + "/" + piece;
+
+       std::vector<std::string> datanames;
+       std::vector<std::string> cellDataNames;
+       std::vector<std::string> pieces = comm->gather(piece);
+       if (comm->isRoot())
+       {
+          std::string pname = WbWriterVtkXmlASCII::getInstance()->writeParallelFile(pfilePath, pieces, datanames, cellDataNames);
+          found=pname.find_last_of("/");
+          piece = pname.substr(found+1);
+
+          std::vector<std::string> filenames;
+          filenames.push_back(piece);
+          if (step == CoProcessor::scheduler->getMinBegin())
+          {
+             WbWriterVtkXmlASCII::getInstance()->writeCollection(cfilePath, filenames, istep, false);
+          }
+          else
+          {
+             WbWriterVtkXmlASCII::getInstance()->addFilesToCollection(cfilePath, filenames, istep, false);
+          }
+          UBLOG(logINFO, "WriteDemObjectsCoProcessor step: " << istep);
+       }
+   }
+}
diff --git a/source/DemCoupling/WriteDemObjectsCoProcessor.h b/source/DemCoupling/WriteDemObjectsCoProcessor.h
new file mode 100644
index 0000000000000000000000000000000000000000..93d87bcf88d0e90d14c407df76472bd07525181d
--- /dev/null
+++ b/source/DemCoupling/WriteDemObjectsCoProcessor.h
@@ -0,0 +1,34 @@
+/*
+*  Author: K. Kutscher
+*  mail: kutscher@irmb.tu-bs.de
+*/
+#ifndef WriteDemObjectsCoProcessor_H
+#define WriteDemObjectsCoProcessor_H
+
+#include <PointerDefinitions.h>
+#include <string>
+#include <vector>
+
+#include "CoProcessor.h"
+
+class Communicator;
+class Grid3D;
+class UbScheduler;
+class DemCoProcessor;
+class WbWriter;
+
+class WriteDemObjectsCoProcessor : public  CoProcessor
+{
+public:
+    WriteDemObjectsCoProcessor();
+    WriteDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<DemCoProcessor> demCoProcessor, SPtr<Communicator> comm);
+   ~WriteDemObjectsCoProcessor() {}
+   void process(double step) override;
+
+private:
+    std::string path;
+    WbWriter* writer;
+    SPtr<Communicator> comm;
+    SPtr<DemCoProcessor> demCoProcessor;
+};
+#endif
diff --git a/source/DemCoupling/package.include b/source/DemCoupling/package.include
new file mode 100644
index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc
--- /dev/null
+++ b/source/DemCoupling/package.include
@@ -0,0 +1 @@
+
diff --git a/source/ThirdParty/Library/basics/relation/CMakePackage.txt b/source/DemCoupling/physicsEngineAdapter/CMakePackage.txt
similarity index 98%
rename from source/ThirdParty/Library/basics/relation/CMakePackage.txt
rename to source/DemCoupling/physicsEngineAdapter/CMakePackage.txt
index 9354d3d0084922c7abd6f1b22823c5c47e0befb4..1b8416f010d2a7de30b8f70c9abf19a96dd8cf8f 100644
--- a/source/ThirdParty/Library/basics/relation/CMakePackage.txt
+++ b/source/DemCoupling/physicsEngineAdapter/CMakePackage.txt
@@ -1,2 +1,2 @@
-GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
-COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
diff --git a/source/DemCoupling/physicsEngineAdapter/PhysicsEngineGeometryAdapter.h b/source/DemCoupling/physicsEngineAdapter/PhysicsEngineGeometryAdapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..a7eb5c6bcc0cee7c38aaa3d191c3f887644c1177
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/PhysicsEngineGeometryAdapter.h
@@ -0,0 +1,45 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef PHYSICS_ENGINE_GEOMETRY_ADAPTER_H
+#define PHYSICS_ENGINE_GEOMETRY_ADAPTER_H
+
+#include "Vector3D.h"
+
+enum class State
+{
+    PIN, UNPIN
+};
+
+class PhysicsEngineGeometryAdapter
+{
+public:
+    virtual ~PhysicsEngineGeometryAdapter() {}
+
+    virtual void addForce(const Vector3D& force) = 0;
+    virtual void addTorque(const Vector3D& torque) = 0;
+
+    virtual void setForce(const Vector3D& force) = 0;
+    virtual void setTorque(const Vector3D& torque) = 0;
+
+    virtual void addForceAtPosition(const Vector3D& force, const Vector3D& position) = 0;
+    virtual void setLinearVelolocity(const Vector3D& velocity) = 0;
+    virtual void setAngularVelocity(const Vector3D& velocity) = 0;
+
+    virtual void resetForceAndTorque() = 0;
+
+    virtual Vector3D getPosition() const = 0;
+    virtual Vector3D getVelocityAtPosition(const Vector3D& position) const = 0;
+    virtual Vector3D getLinearVelocity() const = 0;
+    virtual Vector3D getAngularVelocity() const = 0;
+
+    virtual Vector3D getForce() const = 0;
+    virtual Vector3D getTorque() const = 0;
+
+    virtual void changeState(State state) = 0;
+};
+
+
+#endif
+
diff --git a/source/DemCoupling/physicsEngineAdapter/PhysicsEngineMaterialAdapter.h b/source/DemCoupling/physicsEngineAdapter/PhysicsEngineMaterialAdapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..1b887cda1cb5d5b28711d1f004223b7750c55151
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/PhysicsEngineMaterialAdapter.h
@@ -0,0 +1,33 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef PHYSICS_ENGINE_MATERIAL_ADAPTER_H
+#define PHYSICS_ENGINE_MATERIAL_ADAPTER_H
+
+#include <string>
+
+class PhysicsEngineMaterialAdapter
+{
+public:
+    PhysicsEngineMaterialAdapter(std::string name, double density, double restitution, double staticFriction, double dynamicFriction, double poissonRatio, double youngModul, double stiffnessInNormalDirection, double dampingoefficientNormalDirection, double dampingTangentialDirection)
+        : name(name), density(density), restitution(restitution), staticFriction(staticFriction), dynamicFriction(dynamicFriction), poissonRatio(poissonRatio), youngModul(youngModul), stiffnessInNormalDirection(stiffnessInNormalDirection), dampingoefficientNormalDirection(dampingoefficientNormalDirection), dampingTangentialDirection(dampingTangentialDirection)
+    {}
+    virtual ~PhysicsEngineMaterialAdapter() {}
+
+protected:
+    std::string name;
+    double density;
+    double restitution;
+    double staticFriction; // Note: pe doubles the input coefficient of friction for material-material contacts.
+    double dynamicFriction; //  Similar to static friction for low speed friction.
+    double poissonRatio;
+    double youngModul;
+    double stiffnessInNormalDirection;
+    double dampingoefficientNormalDirection;
+    double dampingTangentialDirection;
+};
+
+
+#endif
+
diff --git a/source/DemCoupling/physicsEngineAdapter/PhysicsEngineSolverAdapter.h b/source/DemCoupling/physicsEngineAdapter/PhysicsEngineSolverAdapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..bb035ab312961294998d6ae55383c2d3450c98c8
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/PhysicsEngineSolverAdapter.h
@@ -0,0 +1,26 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef PHYSICS_ENGINE_SOLVER_ADAPTER_H
+#define PHYSICS_ENGINE_SOLVER_ADAPTER_H
+
+#include "Vector3D.h"
+
+
+class PhysicsEngineGeometryAdapter;
+class PhysicsEngineMaterialAdapter;
+
+class PhysicsEngineSolverAdapter
+{
+public:
+    virtual ~PhysicsEngineSolverAdapter() {}
+
+    virtual std::shared_ptr<PhysicsEngineGeometryAdapter> createPhysicsEngineGeometryAdapter(int id, const Vector3D& position, double radius, std::shared_ptr<PhysicsEngineMaterialAdapter> material)  const = 0;
+    virtual void runTimestep(double step) = 0;
+};
+
+
+
+#endif
+
diff --git a/source/ThirdParty/Library/basics/objects/CMakePackage.txt b/source/DemCoupling/physicsEngineAdapter/dummy/CMakePackage.txt
similarity index 98%
rename from source/ThirdParty/Library/basics/objects/CMakePackage.txt
rename to source/DemCoupling/physicsEngineAdapter/dummy/CMakePackage.txt
index 9354d3d0084922c7abd6f1b22823c5c47e0befb4..1b8416f010d2a7de30b8f70c9abf19a96dd8cf8f 100644
--- a/source/ThirdParty/Library/basics/objects/CMakePackage.txt
+++ b/source/DemCoupling/physicsEngineAdapter/dummy/CMakePackage.txt
@@ -1,2 +1,2 @@
-GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
-COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
diff --git a/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.cpp b/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ababa676a26f2c0e7070368ac3b2b3b10aad3148
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.cpp
@@ -0,0 +1,79 @@
+#include "DummyPhysicsEngineGeometryAdapter.h"
+
+
+
+void DummyPhysicsEngineGeometryAdapter::addForce(const Vector3D& force)
+{
+
+}
+
+void DummyPhysicsEngineGeometryAdapter::addTorque(const Vector3D& torque)
+{
+
+}
+
+void DummyPhysicsEngineGeometryAdapter::setForce(const Vector3D& force)
+{
+
+}
+
+void DummyPhysicsEngineGeometryAdapter::setTorque(const Vector3D& torque)
+{
+
+}
+
+void DummyPhysicsEngineGeometryAdapter::addForceAtPosition(const Vector3D& force, const Vector3D& position)
+{
+
+}
+
+void DummyPhysicsEngineGeometryAdapter::setLinearVelolocity(const Vector3D& velocity)
+{
+    this->velocity = velocity;
+}
+
+void DummyPhysicsEngineGeometryAdapter::setAngularVelocity(const Vector3D& velocity)
+{
+
+}
+
+void DummyPhysicsEngineGeometryAdapter::resetForceAndTorque()
+{
+
+}
+
+Vector3D DummyPhysicsEngineGeometryAdapter::getVelocityAtPosition(const Vector3D& position) const
+{
+    return velocity;
+}
+
+Vector3D DummyPhysicsEngineGeometryAdapter::getLinearVelocity() const
+{
+    return Vector3D();
+}
+
+Vector3D DummyPhysicsEngineGeometryAdapter::getAngularVelocity() const
+{
+    return Vector3D();
+}
+
+Vector3D DummyPhysicsEngineGeometryAdapter::getPosition() const
+{
+    return Vector3D();
+}
+
+Vector3D DummyPhysicsEngineGeometryAdapter::getForce() const
+{
+    return Vector3D();
+}
+
+Vector3D DummyPhysicsEngineGeometryAdapter::getTorque() const
+{
+    return Vector3D();
+}
+
+void DummyPhysicsEngineGeometryAdapter::changeState(State state)
+{
+
+}
+
diff --git a/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.h b/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..2f37f466b5eb2fc356c567d0b33f71c7acb342fe
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.h
@@ -0,0 +1,45 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef DUMMY_PHYSICS_ENGINE_GEOMETRY_ADAPTER_H
+#define DUMMY_PHYSICS_ENGINE_GEOMETRY_ADAPTER_H
+
+#include "UbTuple.h"
+
+#include "PhysicsEngineGeometryAdapter.h"
+
+
+
+class DummyPhysicsEngineGeometryAdapter : public PhysicsEngineGeometryAdapter
+{
+public:
+    DummyPhysicsEngineGeometryAdapter() {}
+    virtual ~DummyPhysicsEngineGeometryAdapter() {}
+
+    void addForce(const Vector3D& force) override;
+    void addTorque(const Vector3D& torque) override;
+
+    void setForce(const Vector3D& force) override;
+    void setTorque(const Vector3D& torque) override;
+
+    void addForceAtPosition(const Vector3D& force, const Vector3D& position) override;
+    void setLinearVelolocity(const Vector3D& velocity) override;
+    void setAngularVelocity(const Vector3D& velocity) override;
+
+    void resetForceAndTorque() override;
+
+    Vector3D getVelocityAtPosition(const Vector3D& position) const override;
+    Vector3D getLinearVelocity() const override;
+    Vector3D getAngularVelocity() const override;
+    Vector3D getPosition() const override;
+    Vector3D getForce() const override;
+    Vector3D getTorque() const override;
+
+    void changeState(State state) override;
+private:
+    Vector3D velocity;
+};
+
+#endif
+
diff --git a/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.cpp b/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7890f966872d5433efa5b40b6358ca0b5a25a40d
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.cpp
@@ -0,0 +1 @@
+#include "DummyPhysicsEngineMaterialAdapter.h"
diff --git a/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.h b/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..c9b8a44a1b5bdaca5ed8b8194a122471ccc76bbf
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.h
@@ -0,0 +1,23 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef DUMMY_PHYSICS_ENGINE_MATERIAL_ADAPTER
+#define DUMMY_PHYSICS_ENGINE_MATERIAL_ADAPTER
+
+#include "PhysicsEngineMaterialAdapter.h"
+
+
+class DummyPhysicsEngineMaterialAdapter : public PhysicsEngineMaterialAdapter
+{
+public:
+    DummyPhysicsEngineMaterialAdapter(std::string name, double density, double restitution, double staticFriction, double dynamicFriction, double poissonRatio, double youngModul, double stiffnessInNormalDirection, double dampingoefficientNormalDirection, double dampingTangentialDirection)
+        : PhysicsEngineMaterialAdapter(name, density, restitution, staticFriction, dynamicFriction, poissonRatio, youngModul, stiffnessInNormalDirection, dampingoefficientNormalDirection, dampingTangentialDirection)
+    {
+    }
+    virtual ~DummyPhysicsEngineMaterialAdapter() {}
+
+};
+
+#endif
+
diff --git a/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.cpp b/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8053942b916b4b45f7f906518fcaf1e295852817
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.cpp
@@ -0,0 +1,14 @@
+#include "DummyPhysicsEngineSolverAdapter.h"
+
+#include "DummyPhysicsEngineGeometryAdapter.h"
+
+
+std::shared_ptr<PhysicsEngineGeometryAdapter> DummyPhysicsEngineSolverAdapter::createPhysicsEngineGeometryAdapter(int id, const Vector3D& position, double radius, std::shared_ptr<PhysicsEngineMaterialAdapter> material) const
+{
+    return std::static_pointer_cast<PhysicsEngineGeometryAdapter>(std::make_shared<DummyPhysicsEngineGeometryAdapter>());
+}
+
+void DummyPhysicsEngineSolverAdapter::runTimestep(double step)
+{
+
+}
diff --git a/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.h b/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..38975727e8fc9761fb05d9ab0a80c23b1c1b40a4
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.h
@@ -0,0 +1,28 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef DUMMY_PHYSICS_ENGINE_SOLVER_ADAPTER_H
+#define DUMMY_PHYSICS_ENGINE_SOLVER_ADAPTER_H
+
+#include <memory>
+
+#include "UbTuple.h"
+
+#include "PhysicsEngineSolverAdapter.h"
+
+
+
+class DummyPhysicsEngineSolverAdapter : public PhysicsEngineSolverAdapter
+{
+public:
+    DummyPhysicsEngineSolverAdapter() {};
+    virtual ~DummyPhysicsEngineSolverAdapter() {}
+
+    std::shared_ptr<PhysicsEngineGeometryAdapter> createPhysicsEngineGeometryAdapter(int id, const Vector3D& position, double radius, std::shared_ptr<PhysicsEngineMaterialAdapter> material) const override;
+    void runTimestep(double step) override;
+
+};
+
+#endif
+
diff --git a/source/DemCoupling/physicsEngineAdapter/dummy/package.include b/source/DemCoupling/physicsEngineAdapter/dummy/package.include
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/source/DemCoupling/physicsEngineAdapter/package.include b/source/DemCoupling/physicsEngineAdapter/package.include
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/source/ThirdParty/Library/basics/parallel/CMakePackage.txt b/source/DemCoupling/physicsEngineAdapter/pe/CMakePackage.txt
similarity index 98%
rename from source/ThirdParty/Library/basics/parallel/CMakePackage.txt
rename to source/DemCoupling/physicsEngineAdapter/pe/CMakePackage.txt
index 9354d3d0084922c7abd6f1b22823c5c47e0befb4..1b8416f010d2a7de30b8f70c9abf19a96dd8cf8f 100644
--- a/source/ThirdParty/Library/basics/parallel/CMakePackage.txt
+++ b/source/DemCoupling/physicsEngineAdapter/pe/CMakePackage.txt
@@ -1,2 +1,2 @@
-GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
-COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
diff --git a/source/DemCoupling/physicsEngineAdapter/pe/PeAdapter.h b/source/DemCoupling/physicsEngineAdapter/pe/PeAdapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..6f041668521fff8c00ec3cd4bbc5b47f0838e7ab
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/pe/PeAdapter.h
@@ -0,0 +1,28 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef PE_ADAPTER_H
+#define PE_ADAPTER_H
+
+#include <pe/basic.h>
+#include "Vector3D.h"
+
+
+class PeConverter
+{
+public:  
+    static Vector3D convert(walberla::pe::Vec3 vec3)
+    {
+        return Vector3D(vec3[0], vec3[1], vec3[2]);
+    }
+
+    static walberla::pe::Vec3 convert(const Vector3D& vec3)
+    {
+        return walberla::pe::Vec3(vec3[0], vec3[1], vec3[2]);
+    }
+};
+
+
+#endif
+
diff --git a/source/DemCoupling/physicsEngineAdapter/pe/PeAdapterTest.cpp b/source/DemCoupling/physicsEngineAdapter/pe/PeAdapterTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1deffe629efa72670a8a485241032636f2134de5
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/pe/PeAdapterTest.cpp
@@ -0,0 +1,28 @@
+//#include "gmock/gmock.h"
+//
+//#include "PeAdapter.h"
+//#include <pe/basic.h>
+//
+//#include "UbTuple.h"
+//
+//
+//TEST(PeAdapterTest, convert_WalberlaVec3_to_Vector3D)
+//{
+//    walberla::pe::Vec3 walberlaVec(1.0, -2.0, 3.4);
+//    Vector3D ubTuple = PeConverter::convert(walberlaVec);
+//
+//    EXPECT_THAT(ubTuple[0], testing::DoubleEq(walberlaVec[0]));
+//    EXPECT_THAT(ubTuple[1], testing::DoubleEq(walberlaVec[1]));
+//    EXPECT_THAT(ubTuple[2], testing::DoubleEq(walberlaVec[2]));
+//}
+//
+//TEST(PeAdapterTest, convert_Vector3D_to_WalberlaVec3)
+//{
+//    Vector3D ubTuple(1.0, -2.0, 3.4);
+//    walberla::pe::Vec3 walberlaVec = PeConverter::convert(ubTuple);
+//
+//    EXPECT_THAT(ubTuple[0], testing::DoubleEq(walberlaVec[0]));
+//    EXPECT_THAT(ubTuple[1], testing::DoubleEq(walberlaVec[1]));
+//    EXPECT_THAT(ubTuple[2], testing::DoubleEq(walberlaVec[2]));
+//}
+
diff --git a/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.cpp b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ba87d3bfaf1ee40593ee9a8a1d328ae63073b67d
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.cpp
@@ -0,0 +1,125 @@
+#include "PePhysicsEngineGeometryAdapter.h"
+
+#include <pe/basic.h>
+
+#include "PeAdapter.h"
+
+
+//PePhysicsEngineGeometryAdapter::PePhysicsEngineGeometryAdapter(walberla::pe::RigidBody* peGeoObject) : peGeoObject(peGeoObject)
+//{
+//    this->id = peGeoObject->getID();
+//    this->active = true;
+//}
+
+PePhysicsEngineGeometryAdapter::PePhysicsEngineGeometryAdapter()
+{
+   this->id = -999;
+   this->active = false;
+}
+
+void PePhysicsEngineGeometryAdapter::addForce(const Vector3D& force)
+{
+    peGeoObject->addForce(PeConverter::convert(force));
+}
+
+void PePhysicsEngineGeometryAdapter::addTorque(const Vector3D& torque)
+{
+    peGeoObject->addTorque(PeConverter::convert(torque));
+}
+
+void PePhysicsEngineGeometryAdapter::setForce(const Vector3D& force)
+{
+    peGeoObject->setForce(PeConverter::convert(force));
+}
+
+void PePhysicsEngineGeometryAdapter::setTorque(const Vector3D& torque)
+{
+    peGeoObject->setTorque(PeConverter::convert(torque));
+}
+
+void PePhysicsEngineGeometryAdapter::addForceAtPosition(const Vector3D& force, const Vector3D& position)
+{
+    peGeoObject->addForceAtPos(PeConverter::convert(force), PeConverter::convert(position));
+}
+
+void PePhysicsEngineGeometryAdapter::setLinearVelolocity(const Vector3D& velocity)
+{
+    peGeoObject->setLinearVel(PeConverter::convert(velocity));
+}
+
+void PePhysicsEngineGeometryAdapter::setAngularVelocity(const Vector3D& velocity)
+{
+    peGeoObject->setAngularVel(PeConverter::convert(velocity));
+}
+
+void PePhysicsEngineGeometryAdapter::resetForceAndTorque()
+{
+    peGeoObject->resetForceAndTorque();
+}
+
+Vector3D PePhysicsEngineGeometryAdapter::getVelocityAtPosition(const Vector3D& position) const
+{
+    return PeConverter::convert(peGeoObject->velFromWF(PeConverter::convert(position)));
+}
+
+Vector3D PePhysicsEngineGeometryAdapter::getLinearVelocity() const
+{
+    return PeConverter::convert(peGeoObject->getLinearVel());
+}
+
+Vector3D PePhysicsEngineGeometryAdapter::getAngularVelocity() const
+{
+    return PeConverter::convert(peGeoObject->getAngularVel());
+}
+
+Vector3D PePhysicsEngineGeometryAdapter::getPosition() const
+{
+    return PeConverter::convert(peGeoObject->getPosition());
+}
+
+Vector3D PePhysicsEngineGeometryAdapter::getForce() const
+{
+    return PeConverter::convert(peGeoObject->getForce());
+}
+
+Vector3D PePhysicsEngineGeometryAdapter::getTorque() const
+{
+    return PeConverter::convert(peGeoObject->getTorque());
+}
+
+void PePhysicsEngineGeometryAdapter::changeState(State state)
+{
+    if (state == State::PIN)
+       peGeoObject->setMassAndInertiaToInfinity();
+}
+
+int PePhysicsEngineGeometryAdapter::getId() const
+{
+    return id;
+}
+
+void PePhysicsEngineGeometryAdapter::setId(int id)
+{
+   this->id = id;
+}
+
+void PePhysicsEngineGeometryAdapter::setGeometry(walberla::pe::RigidBody* peGeoObject)
+{
+    this->peGeoObject = peGeoObject;
+}
+
+//////////////////////////////////////////////////////////////////////////
+void PePhysicsEngineGeometryAdapter::setActive()
+{
+   active = true;
+}
+//////////////////////////////////////////////////////////////////////////
+void PePhysicsEngineGeometryAdapter::setInactive()
+{
+   active = false;
+}
+//////////////////////////////////////////////////////////////////////////
+bool PePhysicsEngineGeometryAdapter::isActive()
+{
+   return active;
+}
\ No newline at end of file
diff --git a/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.h b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..415b73a600265b4e96753c2ea14ddf917e395915
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.h
@@ -0,0 +1,63 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef PE_PHYSICS_ENGINE_GEOMETRY_ADAPTER_H
+#define PE_PHYSICS_ENGINE_GEOMETRY_ADAPTER_H
+
+
+#include "PhysicsEngineGeometryAdapter.h"
+
+namespace walberla
+{
+    namespace pe
+    {
+        class RigidBody;
+    }
+}
+
+class PePhysicsEngineGeometryAdapter : public PhysicsEngineGeometryAdapter
+{
+public:
+    PePhysicsEngineGeometryAdapter();
+    //PePhysicsEngineGeometryAdapter(walberla::pe::RigidBody* peGeoObject);
+    virtual ~PePhysicsEngineGeometryAdapter() {}
+
+    void addForce(const Vector3D& force) override;
+    void addTorque(const Vector3D& torque) override;
+
+    void setForce(const Vector3D& force) override;
+    void setTorque(const Vector3D& torque) override;
+
+    void addForceAtPosition(const Vector3D& force, const Vector3D& position) override;
+    void setLinearVelolocity(const Vector3D& velocity) override;
+    void setAngularVelocity(const Vector3D& velocity) override;
+
+    void resetForceAndTorque() override;
+
+    Vector3D getVelocityAtPosition(const Vector3D& position) const override;
+    Vector3D getLinearVelocity() const override;
+    Vector3D getAngularVelocity() const override;
+    Vector3D getPosition() const override;
+    Vector3D getForce() const override;
+    Vector3D getTorque() const override;
+
+    void changeState(State state) override;
+
+    int getId() const;
+    void setId(int id);
+    void setGeometry(walberla::pe::RigidBody* peGeoObject);
+
+    void setActive();
+    void setInactive();
+    bool isActive();
+
+private:
+    walberla::pe::RigidBody* peGeoObject;
+    //unsigned long long id;
+    int id;
+    bool active;
+};
+
+#endif
+
diff --git a/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.cpp b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fcd4e6eee82d07856d97b003cbfca710b2c0f80c
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.cpp
@@ -0,0 +1,10 @@
+#include "PePhysicsEngineMaterialAdapter.h"
+
+
+walberla::pe::MaterialID PePhysicsEngineMaterialAdapter::getPeMaterial() const
+{
+    if (walberla::pe::Material::find(name) != -1)
+        return walberla::pe::Material::find(name);
+
+    return walberla::pe::createMaterial(name, density, restitution, staticFriction, dynamicFriction, poissonRatio, youngModul, stiffnessInNormalDirection, dampingoefficientNormalDirection, dampingTangentialDirection);
+}
diff --git a/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.h b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..b99afaa38e86c9a1d5da335ff61a60879a14a835
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.h
@@ -0,0 +1,26 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef PE_PHYSICS_ENGINE_MATERIAL_ADAPTER
+#define PE_PHYSICS_ENGINE_MATERIAL_ADAPTER
+
+#include "../PhysicsEngineMaterialAdapter.h"
+#include <pe/basic.h>
+
+
+class PePhysicsEngineMaterialAdapter : public PhysicsEngineMaterialAdapter
+{
+public:
+    PePhysicsEngineMaterialAdapter(std::string name, double density, double restitution, double staticFriction, double dynamicFriction, double poissonRatio, double youngModul, double stiffnessInNormalDirection, double dampingoefficientNormalDirection, double dampingTangentialDirection)
+        : PhysicsEngineMaterialAdapter(name, density, restitution, staticFriction, dynamicFriction, poissonRatio, youngModul, stiffnessInNormalDirection, dampingoefficientNormalDirection, dampingTangentialDirection)
+    {
+    }
+    virtual ~PePhysicsEngineMaterialAdapter() {}
+
+    virtual walberla::pe::MaterialID getPeMaterial() const;
+
+};
+
+#endif
+
diff --git a/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..82f3ff85c6c2ef88fc172bb82c73b49ed71c9b9b
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp
@@ -0,0 +1,195 @@
+#include "PePhysicsEngineSolverAdapter.h"
+
+#include <exception>
+
+#include <pe/basic.h>
+#include "PeAdapter.h"
+#include "PePhysicsEngineGeometryAdapter.h"
+#include "PePhysicsEngineMaterialAdapter.h"
+#include "Communicator.h"
+#include "UbLogger.h"
+#include <boost/tuple/tuple.hpp>
+
+#include <memory>
+
+typedef boost::tuple<walberla::pe::Sphere, walberla::pe::Plane> BodyTypeTuple;
+
+
+PePhysicsEngineSolverAdapter::PePhysicsEngineSolverAdapter(std::shared_ptr<PeParameter> peParameter) : peParameter(peParameter)
+{
+    this->initalizePeEnvironment();
+}
+
+void PePhysicsEngineSolverAdapter::initalizePeEnvironment()
+{
+    this->initialPeBodyStorage();
+    this->initalPeBlockForest();
+    this->initalBlockData();
+    this->initalPeIntegrator();
+    this->executePeBodyTypeTuple();
+    this->initalPeChannel();
+}
+
+
+std::shared_ptr<PhysicsEngineGeometryAdapter> PePhysicsEngineSolverAdapter::createPhysicsEngineGeometryAdapter(int id, const Vector3D& position, double radius, std::shared_ptr<PhysicsEngineMaterialAdapter> material) const
+{
+    const std::shared_ptr<PePhysicsEngineMaterialAdapter> peMaterial = std::dynamic_pointer_cast<PePhysicsEngineMaterialAdapter>(material);
+
+    walberla::pe::GeomID peGeometry = createSphere(*globalBodyStorage, *forest, *storageId, id, PeConverter::convert(position), radius, peMaterial->getPeMaterial());
+
+    std::shared_ptr<PePhysicsEngineGeometryAdapter> peGeometryAdapter(new PePhysicsEngineGeometryAdapter());
+
+    if (peGeometry)
+    {
+       peGeometryAdapter->setId(id);
+       peGeometryAdapter->setActive();
+       peGeometryAdapter->setGeometry(peGeometry);
+       return peGeometryAdapter;
+    }
+    else
+    {
+       peGeometryAdapter->setId(id);
+       peGeometryAdapter->setInactive();
+       return peGeometryAdapter;
+    }
+
+    //if (peGeometry)
+    //{
+    //   return std::static_pointer_cast<PhysicsEngineGeometryAdapter>(std::make_shared<PePhysicsEngineGeometryAdapter>(peGeometry));
+    //} 
+    //else
+    //{
+    //   return std::shared_ptr<PhysicsEngineGeometryAdapter>(new PePhysicsEngineGeometryAdapter());
+    //}
+
+    walberla::pe::syncNextNeighbors<BodyTypeTuple>(*forest, *storageId);
+}
+
+void PePhysicsEngineSolverAdapter::runTimestep(double step)
+{
+    cr->timestep(walberla::real_c(step));
+    walberla::pe::syncNextNeighbors<BodyTypeTuple>(*forest, *storageId);
+}
+
+
+
+void PePhysicsEngineSolverAdapter::initialPeBodyStorage()
+{
+    globalBodyStorage = std::make_shared<walberla::pe::BodyStorage>();
+}
+
+void PePhysicsEngineSolverAdapter::initalPeBlockForest()
+{
+    forest = walberla::pe::createBlockForest
+    (
+        //walberla::AABB(0, 0, 0, val<1>(peParameter->simulationDomain), val<2>(peParameter->simulationDomain), val<3>(peParameter->simulationDomain)), // simulationDomain
+       walberla::AABB(peParameter->simulationDomain[0], peParameter->simulationDomain[1], peParameter->simulationDomain[2], 
+          peParameter->simulationDomain[3], peParameter->simulationDomain[4], peParameter->simulationDomain[5]), // simulationDomain
+        walberla::Vector3<walberla::uint_t>(val<1>(peParameter->numberOfBlocks), val<2>(peParameter->numberOfBlocks), val<3>(peParameter->numberOfBlocks)), // blocks in each direction
+        walberla::Vector3<bool>(val<1>(peParameter->isPeriodic), val<2>(peParameter->isPeriodic), val<3>(peParameter->isPeriodic)) // periodicity
+    ); 
+
+    if (!forest)
+        throw std::runtime_error("No PE BlockForest created ... ");
+}
+
+void PePhysicsEngineSolverAdapter::initalBlockData()
+{
+    storageId = std::make_shared<walberla::domain_decomposition::BlockDataID>
+    (
+        forest->addBlockData(walberla::pe::createStorageDataHandling<BodyTypeTuple>(), "Storage")
+    );
+}
+
+void PePhysicsEngineSolverAdapter::initalPeIntegrator()
+{
+    auto ccdID = forest->addBlockData(walberla::pe::ccd::createHashGridsDataHandling(globalBodyStorage, *storageId), "CCD");
+    auto fcdID = forest->addBlockData(walberla::pe::fcd::createGenericFCDDataHandling<BodyTypeTuple, walberla::pe::fcd::AnalyticCollideFunctor>(), "FCD");
+
+    cr = std::make_shared<walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers>(globalBodyStorage, forest, *storageId, ccdID, fcdID);
+    cr->setMaxIterations(peParameter->maxPeIterations);
+    cr->setRelaxationModel(walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers::ApproximateInelasticCoulombContactByDecoupling);
+    cr->setRelaxationParameter(walberla::real_t(peParameter->relaxationParameter));
+    cr->setGlobalLinearAcceleration(PeConverter::convert(peParameter->globalLinearAcceleration));
+}
+
+void PePhysicsEngineSolverAdapter::executePeBodyTypeTuple()
+{
+    walberla::pe::SetBodyTypeIDs<BodyTypeTuple>::execute();
+}
+
+void PePhysicsEngineSolverAdapter::initalPeChannel() const
+{
+    const walberla::pe::MaterialID material = peParameter->planes->getPeMaterial();
+
+    auto simulationDomain = forest->getDomain();
+
+    //createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(1, 0, 0), simulationDomain.minCorner(), material);
+    //createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(-1, 0, 0), simulationDomain.maxCorner(), material);
+    //createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, 1, 0), simulationDomain.minCorner(), material);
+    //createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, -1, 0), simulationDomain.maxCorner(), material);
+    //createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, 0, 1), simulationDomain.minCorner(), material);
+    //createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, 0, -1), simulationDomain.maxCorner(), material);
+
+    Vector3D minOffset = peParameter->minOffset;
+    Vector3D maxOffset = peParameter->maxOffset;
+
+    walberla::pe::Vec3 minX1_Offset( minOffset.X1(), 0, 0);
+    walberla::pe::Vec3 maxX1_Offset( maxOffset.X1(), 0, 0);
+    walberla::pe::Vec3 minX2_Offset( 0, minOffset.X2(), 0);
+    walberla::pe::Vec3 maxX2_Offset( 0, maxOffset.X2(), 0);
+    walberla::pe::Vec3 minX3_Offset( 0, 0, minOffset.X3());
+    walberla::pe::Vec3 maxX3_Offset( 0, 0, maxOffset.X3());
+
+    walberla::pe::Vec3 minCorner = simulationDomain.minCorner();
+    walberla::pe::Vec3 maxCorner = simulationDomain.maxCorner();
+
+    createPlane(*globalBodyStorage, 0, walberla::pe::Vec3( 1, 0, 0), minCorner + minX1_Offset, material);
+    createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(-1, 0, 0), maxCorner + maxX1_Offset, material);
+    createPlane(*globalBodyStorage, 0, walberla::pe::Vec3( 0, 1, 0), minCorner + minX2_Offset, material);
+    createPlane(*globalBodyStorage, 0, walberla::pe::Vec3( 0,-1, 0), maxCorner + maxX2_Offset, material);
+    createPlane(*globalBodyStorage, 0, walberla::pe::Vec3( 0, 0, 1), minCorner + minX3_Offset, material);
+    createPlane(*globalBodyStorage, 0, walberla::pe::Vec3( 0, 0,-1), maxCorner + maxX3_Offset, material);
+}
+
+std::shared_ptr< walberla::blockforest::BlockForest > PePhysicsEngineSolverAdapter::getForest()
+{
+   return forest;
+}
+
+void PePhysicsEngineSolverAdapter::saveToFile(const std::string & path)
+{
+   //forest->saveToFile(path+"SerializeDeserialize.sbf");
+   //forest->saveBlockData("SerializeDeserialize.dump", *storageId.get());
+}
+
+void PePhysicsEngineSolverAdapter::loadFromFile(const std::string & path)
+{
+   //forest = std::make_shared< walberla::blockforest::BlockForest >( walberla::uint_c( walberla::MPIManager::instance()->rank() ), path+"SerializeDeserialize.sbf", true, false );
+   //storageId = std::make_shared< walberla::domain_decomposition::BlockDataID >(forest->loadBlockData(path+"SerializeDeserialize.dump", walberla::pe::createStorageDataHandling<BodyTypeTuple>(), "Storage"));
+   //
+   //auto ccdID = forest->addBlockData(walberla::pe::ccd::createHashGridsDataHandling(globalBodyStorage, *storageId), "CCD");
+   //auto fcdID = forest->addBlockData(walberla::pe::fcd::createGenericFCDDataHandling<BodyTypeTuple, walberla::pe::fcd::AnalyticCollideFunctor>(), "FCD");
+
+   //cr = std::make_shared<walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers>(globalBodyStorage, forest, *storageId, ccdID, fcdID);
+   //cr->setMaxIterations(peParameter->maxPeIterations);
+   //cr->setRelaxationModel(walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers::ApproximateInelasticCoulombContactByDecoupling);
+   //cr->setRelaxationParameter(walberla::real_t(peParameter->relaxationParameter));
+   //cr->setGlobalLinearAcceleration(PeConverter::convert(peParameter->globalLinearAcceleration));
+
+   //for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt)
+   //{
+   //   walberla::pe::ccd::ICCD* ccd = blockIt->getData< walberla::pe::ccd::ICCD >(ccdID);
+   //   ccd->reloadBodies();
+   //}
+}
+
+std::shared_ptr<walberla::blockforest::BlockForest> PePhysicsEngineSolverAdapter::getBlockForest()
+{
+   return forest;
+}
+
+std::shared_ptr<walberla::domain_decomposition::BlockDataID> PePhysicsEngineSolverAdapter::getStorageId()
+{
+   return storageId;
+}
diff --git a/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.h b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..a7b699252d397080dc9e1bfeceac5edbeb02337e
--- /dev/null
+++ b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.h
@@ -0,0 +1,98 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef PE_PHYSICS_ENGINE_SOLVER_ADAPTER_H
+#define PE_PHYSICS_ENGINE_SOLVER_ADAPTER_H
+
+#include <memory>
+#include <shared_mutex>
+
+#include <pe/basic.h>
+#include "UbTuple.h"
+
+#include "PhysicsEngineSolverAdapter.h"
+#include "PePhysicsEngineSolverAdapter.h"
+
+
+class PePhysicsEngineMaterialAdapter;
+class PhysicsEngineGeometryAdapter;
+
+namespace walberla
+{
+    namespace domain_decomposition
+    {
+        class BlockDataID;
+    }
+    namespace blockforest
+    {
+        class BlockForest;
+    }
+    namespace pe
+    {
+        class BodyStorage;
+        class RigidBody;
+        namespace cr
+        {
+            class HardContactSemiImplicitTimesteppingSolvers;
+        }
+    }
+}
+
+struct PeParameter
+{
+   PeParameter(double relaxationParameter, int maxPeIterations, Vector3D globalLinearAcceleration, std::shared_ptr<PePhysicsEngineMaterialAdapter> planes, std::array<double, 6> simulationDomain, UbTupleInt3 numberOfBlocks, UbTupleBool3 isPeriodic, Vector3D minOffset, Vector3D maxOffset)
+        : relaxationParameter(relaxationParameter), maxPeIterations(maxPeIterations), globalLinearAcceleration(globalLinearAcceleration), simulationDomain(simulationDomain), numberOfBlocks(numberOfBlocks), isPeriodic(isPeriodic), planes(planes), minOffset(minOffset), maxOffset(maxOffset)
+    {
+    }
+
+    double relaxationParameter;
+    int maxPeIterations;
+    Vector3D globalLinearAcceleration;
+
+    std::array<double, 6> simulationDomain;
+    UbTupleInt3 numberOfBlocks;
+    UbTupleBool3 isPeriodic;
+
+    std::shared_ptr<PePhysicsEngineMaterialAdapter> planes;
+
+    Vector3D minOffset;
+    Vector3D maxOffset;
+
+};
+
+class PePhysicsEngineSolverAdapter : public PhysicsEngineSolverAdapter
+{
+public:
+    PePhysicsEngineSolverAdapter(std::shared_ptr<PeParameter> peParameter);
+    virtual ~PePhysicsEngineSolverAdapter() {}
+
+    std::shared_ptr<PhysicsEngineGeometryAdapter> createPhysicsEngineGeometryAdapter(int id, const Vector3D& position, double radius, std::shared_ptr<PhysicsEngineMaterialAdapter> material) const override;
+    void runTimestep(double step) override;
+    std::shared_ptr< walberla::blockforest::BlockForest > getForest();
+    void saveToFile(const std::string& path);
+    void loadFromFile(const std::string& path);
+    std::shared_ptr<walberla::blockforest::BlockForest> getBlockForest();
+    std::shared_ptr<walberla::domain_decomposition::BlockDataID> getStorageId();
+
+private:
+    void initalizePeEnvironment();
+    void initialPeBodyStorage();
+    void initalPeBlockForest();
+    void initalBlockData();
+
+    void initalPeIntegrator();
+    static void executePeBodyTypeTuple();
+    void initalPeChannel() const;
+
+private:
+    std::shared_ptr<PeParameter> peParameter;
+
+    std::shared_ptr<walberla::pe::BodyStorage> globalBodyStorage;
+    std::shared_ptr< walberla::blockforest::BlockForest > forest;
+    std::shared_ptr<walberla::domain_decomposition::BlockDataID> storageId;
+    std::shared_ptr<walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers> cr;
+};
+
+#endif
+
diff --git a/source/DemCoupling/physicsEngineAdapter/pe/package.include b/source/DemCoupling/physicsEngineAdapter/pe/package.include
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/source/DemCoupling/reconstructor/CMakePackage.txt b/source/DemCoupling/reconstructor/CMakePackage.txt
new file mode 100644
index 0000000000000000000000000000000000000000..1b8416f010d2a7de30b8f70c9abf19a96dd8cf8f
--- /dev/null
+++ b/source/DemCoupling/reconstructor/CMakePackage.txt
@@ -0,0 +1,2 @@
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
diff --git a/source/DemCoupling/reconstructor/EquilibriumReconstructor.cpp b/source/DemCoupling/reconstructor/EquilibriumReconstructor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ad4db58f174d24ecf456682bb7ed4b878afa410f
--- /dev/null
+++ b/source/DemCoupling/reconstructor/EquilibriumReconstructor.cpp
@@ -0,0 +1,56 @@
+#include "EquilibriumReconstructor.h"
+
+#include "ILBMKernel.h"
+#include "D3Q27System.h"
+#include "DataSet3D.h"
+#include "BCProcessor.h"
+#include "BCArray3D.h"
+
+#include "PhysicsEngineGeometryAdapter.h"
+
+void EquilibriumReconstructor::reconstructNode(const int& x1, const int& x2, const int& x3,
+                                               const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const
+{
+    const double averageDensity = this->getLocalAverageDensity(x1, x2, x3, kernel);
+    LBMReal feq[27];
+    const Vector3D boundaryVelocity = physicsEngineGeometry->getVelocityAtPosition(worldCoordinates);
+
+    if (kernel->getCompressible())
+        D3Q27System::calcCompFeq(feq, averageDensity, boundaryVelocity[0], boundaryVelocity[1], boundaryVelocity[2]);
+    else
+        D3Q27System::calcIncompFeq(feq, averageDensity, boundaryVelocity[0], boundaryVelocity[1], boundaryVelocity[2]);
+
+
+    SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions();
+    //distributions->setDistribution(feq, x1, x2, x3);
+    distributions->setDistributionInv(feq, x1, x2, x3);
+}
+
+
+double EquilibriumReconstructor::getLocalAverageDensity(const int &x1, const int &x2, const int &x3, std::shared_ptr<ILBMKernel> kernel) const
+{
+    int nAverage = 0;
+    double averageDensity = 0.0;
+
+    SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray();
+
+    LBMReal f[D3Q27System::ENDF + 1];
+    SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions();
+
+    int neighborX1, neighborX2, neighborX3;
+    for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++)
+    {
+        neighborX1 = x1 + D3Q27System::DX1[fDir];
+        neighborX2 = x2 + D3Q27System::DX2[fDir];
+        neighborX3 = x3 + D3Q27System::DX3[fDir];
+
+        if (bcArray->isFluid(neighborX1, neighborX2, neighborX3))
+        {
+            distributions->getDistribution(f, neighborX1, neighborX2, neighborX3);
+            averageDensity += D3Q27System::getDensity(f);
+            ++nAverage;
+        }
+    }
+    return (nAverage > 0) ? averageDensity / nAverage : 0.0;
+}
+
diff --git a/source/DemCoupling/reconstructor/EquilibriumReconstructor.h b/source/DemCoupling/reconstructor/EquilibriumReconstructor.h
new file mode 100644
index 0000000000000000000000000000000000000000..e75297ddb4844ce57c437e98538d3b3ff243e83b
--- /dev/null
+++ b/source/DemCoupling/reconstructor/EquilibriumReconstructor.h
@@ -0,0 +1,29 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef EQUILIBRIUM_RECONSTRUCTOR_H
+#define EQUILIBRIUM_RECONSTRUCTOR_H
+
+#include "UbTuple.h"
+
+#include "Reconstructor.h"
+
+class ILBMKernel;
+class PhysicsEngineGeometryAdapter;
+
+class EquilibriumReconstructor : public Reconstructor
+{
+public:
+    virtual ~EquilibriumReconstructor() {}
+
+    void reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const override;
+
+private:
+    double getLocalAverageDensity(const int &x1, const int &x2, const int &x3, std::shared_ptr<ILBMKernel> kernel) const;
+};
+
+
+
+#endif
+
diff --git a/source/DemCoupling/reconstructor/ExtrapolationReconstructor.cpp b/source/DemCoupling/reconstructor/ExtrapolationReconstructor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..72cc555a6dfaeb80e05d872090b771d7c61041e2
--- /dev/null
+++ b/source/DemCoupling/reconstructor/ExtrapolationReconstructor.cpp
@@ -0,0 +1,120 @@
+#include "ExtrapolationReconstructor.h"
+
+#include "ILBMKernel.h"
+#include "D3Q27System.h"
+#include "DataSet3D.h"
+#include "BCProcessor.h"
+#include "BCArray3D.h"
+
+#include "PhysicsEngineGeometryAdapter.h"
+#include "DistributionArray3D.h"
+
+void ExtrapolationReconstructor::setAlternativeReconstructor(std::shared_ptr<Reconstructor> alternativeReconstructor)
+{
+    this->alternativeReconstructor = alternativeReconstructor;
+}
+
+
+ExtrapolationReconstructor::ExtrapolationReconstructor(std::shared_ptr<Reconstructor> alternativeReconstructor) : alternativeReconstructor(alternativeReconstructor)
+{
+}
+
+void ExtrapolationReconstructor::reconstructNode(const int& x1, const int& x2, const int& x3,
+                                                 const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const
+{
+    const UbTupleInt3 extrapolationDirection = getSphereDirection(worldCoordinates, physicsEngineGeometry);
+    const int numberOfCellsForExtrapolation = getNumberOfExtrapolationCells(x1, x2, x3, extrapolationDirection, kernel);
+
+    //if (numberOfCellsForExtrapolation < 2)
+        alternativeReconstructor->reconstructNode(x1, x2, x3, worldCoordinates, physicsEngineGeometry, kernel);
+    //else
+    //{
+    //    //UBLOG(logINFO, "point (x,y,z) " << val<1>(worldCoordinates) << ", " << val<2>(worldCoordinates) << ", " << val<3>(worldCoordinates));
+    //    //UBLOG(logINFO, "extradir (x,y,z) " << val<1>(extrapolationDirection) << ", " << val<2>(extrapolationDirection) << ", " << val<3>(extrapolationDirection));
+    //    //UBLOG(logINFO, "numberOfCellsForExtrapolation: " << numberOfCellsForExtrapolation );
+
+    //    this->extrapolatePdFs(x1, x2, x3, extrapolationDirection, numberOfCellsForExtrapolation, kernel);
+    //}
+        
+}
+
+UbTupleInt3 ExtrapolationReconstructor::getSphereDirection(const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry) const
+{
+    const Vector3D spherePosition = physicsEngineGeometry->getPosition();
+    const Vector3D bodyNormal = worldCoordinates - spherePosition;
+    return this->getCorrespondingLatticeDirection(bodyNormal);
+}
+
+UbTupleInt3 ExtrapolationReconstructor::getCorrespondingLatticeDirection(const Vector3D& direction) const
+{
+    int correspondingDirection = 0;
+    double innerProduct = 0.0;
+    for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++)
+    {
+        // compute inner product <dir,c_i>
+        const double temporaryInnerProduct = direction[0] * D3Q27System::cNorm[0][fDir] + direction[1] * D3Q27System::cNorm[1][fDir] + direction[2] * D3Q27System::cNorm[2][fDir];
+        if (temporaryInnerProduct > innerProduct)
+        {
+            innerProduct = temporaryInnerProduct;
+            correspondingDirection = fDir;
+        }
+    }
+
+    return UbTupleInt3(D3Q27System::DX1[correspondingDirection], D3Q27System::DX2[correspondingDirection], D3Q27System::DX3[correspondingDirection]);
+}
+
+int ExtrapolationReconstructor::getNumberOfExtrapolationCells(const int x1, const int x2, const int x3, const UbTupleInt3& extrapolationDirection, std::shared_ptr<ILBMKernel> kernel) const
+{
+    if (extrapolationDirection == UbTupleInt3(0, 0, 0))
+        return 0;
+
+    const int desiredCellsInExtrapolationDirection = 3;
+   
+    for (int numCells = 1; numCells <= desiredCellsInExtrapolationDirection; ++numCells)
+    {
+        UbTupleInt3 neighbor(x1 + numCells * val<1>(extrapolationDirection), x2 + numCells * val<2>(extrapolationDirection), x3 + numCells * val<3>(extrapolationDirection));
+
+        if(!kernel->isInsideOfDomain(val<1>(neighbor), val<2>(neighbor), val<3>(neighbor)))
+            return numCells - 1;
+
+
+        if (!kernel->getBCProcessor()->getBCArray()->isFluid(val<1>(neighbor), val<2>(neighbor), val<3>(neighbor)))
+            return numCells - 1;
+    }
+    return desiredCellsInExtrapolationDirection;
+}
+
+
+void ExtrapolationReconstructor::extrapolatePdFs(const int x1, const int x2, const int x3,
+    const UbTupleInt3& extrapolationDirection, int numberOfCellsForExtrapolation, std::shared_ptr<ILBMKernel> kernel) const
+{
+    SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions();
+
+    const int nx1 = val<1>(extrapolationDirection);
+    const int nx2 = val<2>(extrapolationDirection);
+    const int nx3 = val<3>(extrapolationDirection);
+
+    LBMReal pdf[D3Q27System::ENDF + 1];
+    LBMReal pdfNeighbor1[D3Q27System::ENDF + 1];
+    LBMReal pdfNeighbor2[D3Q27System::ENDF + 1];
+
+    distributions->getDistribution(pdf, x1, x2, x3);
+    distributions->getDistribution(pdfNeighbor1, x1 + nx1, x2 + nx2, x3 + nx3);
+    distributions->getDistribution(pdfNeighbor2, x1 + 2 * nx1, x2 + 2 * nx2, x3 + 2 * nx3);
+
+    if (numberOfCellsForExtrapolation == 3) // quadratic normal extrapolation
+    {
+        LBMReal pdfNeighbor3[D3Q27System::ENDF + 1];
+        distributions->getDistribution(pdfNeighbor3, x1 + 3 * nx1, x2 + 3 * nx2, x3 + 3 * nx3);
+
+        for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++)
+            pdf[fDir] = 3 * pdfNeighbor1[fDir] - 3 * pdfNeighbor2[fDir] + pdfNeighbor3[fDir];
+    }
+    else  // numberOfCellsForExtrapolation == 2 // linear normal extrapolation
+    { 
+        for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++)
+            pdf[fDir] = 2 * pdfNeighbor1[fDir] - pdfNeighbor2[fDir];
+    }
+
+    distributions->setDistribution(pdf, x1, x2, x3);
+}
diff --git a/source/DemCoupling/reconstructor/ExtrapolationReconstructor.h b/source/DemCoupling/reconstructor/ExtrapolationReconstructor.h
new file mode 100644
index 0000000000000000000000000000000000000000..ec60da39e842b3a0498bcd0dccc77a176d2af0a7
--- /dev/null
+++ b/source/DemCoupling/reconstructor/ExtrapolationReconstructor.h
@@ -0,0 +1,42 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef EXTRAPOLATION_RECONSTRUCTOR_H
+#define EXTRAPOLATION_RECONSTRUCTOR_H
+
+#include <memory>
+
+#include "UbTuple.h"
+
+#include "Reconstructor.h"
+
+class ILBMKernel;
+class PhysicsEngineGeometryAdapter;
+
+class ExtrapolationReconstructor : public Reconstructor
+{
+public:
+    ExtrapolationReconstructor(std::shared_ptr<Reconstructor> alternativeReconstructor);
+    virtual ~ExtrapolationReconstructor() {}
+
+
+    void reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const override;
+
+    void setAlternativeReconstructor(std::shared_ptr<Reconstructor> alternativeReconstructor);
+
+private:
+    int getNumberOfExtrapolationCells(const int x1, const int x2, const int x3, const UbTupleInt3& ubTuple, std::shared_ptr<ILBMKernel> kernel) const;
+    UbTupleInt3 getSphereDirection(const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry) const;
+    UbTupleInt3 getCorrespondingLatticeDirection(const Vector3D& direction) const;
+    void extrapolatePdFs(const int x1, const int x2, const int x3, const UbTupleInt3& ubTuple, int numberOfCellsForExtrapolation, std::shared_ptr<ILBMKernel> kernel) const;
+
+
+    std::shared_ptr<Reconstructor> alternativeReconstructor;
+
+};
+
+
+
+#endif
+
diff --git a/source/DemCoupling/reconstructor/LBMReconstructor.cpp b/source/DemCoupling/reconstructor/LBMReconstructor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1cef0c2f023b2fd2c8d07a8a280aa65b82187211
--- /dev/null
+++ b/source/DemCoupling/reconstructor/LBMReconstructor.cpp
@@ -0,0 +1,149 @@
+#include "LBMReconstructor.h"
+
+#include "ILBMKernel.h"
+#include "D3Q27System.h"
+#include "DataSet3D.h"
+#include "BCProcessor.h"
+#include "BCArray3D.h"
+
+#include "PhysicsEngineGeometryAdapter.h"
+
+using namespace D3Q27System;
+
+LBMReconstructor::LBMReconstructor(bool compressible)
+{
+   if (compressible)
+   {
+      calcMacrosFct = &D3Q27System::calcCompMacroscopicValues;
+   }
+   else
+   {
+      calcMacrosFct = &D3Q27System::calcIncompMacroscopicValues;
+   }
+}
+
+void LBMReconstructor::reconstructNode(const int& x1, const int& x2, const int& x3,
+                                               const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const
+{
+   LBMReal pdf[D3Q27System::ENDF + 1];
+
+   LBMReal rho, vx1, vx2, vx3;
+   calcMacrosFct(pdf, rho, vx1, vx2, vx3);
+
+   LBMReal rho_dif = 1; 
+
+   while (rho_dif > 1e-5)
+   {
+      for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++)
+      {
+
+         UbTupleInt3 neighbor(x1 + D3Q27System::DX1[fDir], x2 + D3Q27System::DX2[fDir], x3 + D3Q27System::DX3[fDir]);
+
+         if (!kernel->getBCProcessor()->getBCArray()->isFluid(val<1>(neighbor), val<2>(neighbor), val<3>(neighbor)))
+         {
+            LBMReal pdfNeighbor[D3Q27System::ENDF + 1];
+            SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions();
+            const int invDir = D3Q27System::INVDIR[fDir];
+            distributions->getDistributionForDirection(pdfNeighbor[invDir], val<1>(neighbor), val<2>(neighbor), val<3>(neighbor));
+            distributions->setDistributionInvForDirection(pdf[invDir], x1, x2, x3, invDir);
+         }
+
+
+      }
+   }
+
+
+
+   LBMReal collFactor = kernel->getCollisionFactor();
+   collide(pdf, collFactor);
+
+
+
+
+}
+
+
+void LBMReconstructor::collide(LBMReal* f, LBMReal collFactor)
+{
+
+   LBMReal drho, vx1, vx2, vx3;
+   LBMReal feq[D3Q27System::ENDF+1];
+
+
+   drho = ((f[TNE]+f[BSW])+(f[TSE]+f[BNW]))+((f[BSE]+f[TNW])+(f[TSW]+f[BNE]))
+      +(((f[NE]+f[SW])+(f[SE]+f[NW]))+((f[TE]+f[BW])+(f[BE]+f[TW]))
+         +((f[BN]+f[TS])+(f[TN]+f[BS])))+((f[E]+f[W])+(f[N]+f[S])
+            +(f[T]+f[B]))+f[ZERO];
+
+   vx1 = ((((f[TNE]-f[BSW])+(f[TSE]-f[BNW]))+((f[BSE]-f[TNW])+(f[BNE]-f[TSW])))+
+      (((f[BE]-f[TW])+(f[TE]-f[BW]))+((f[SE]-f[NW])+(f[NE]-f[SW])))+
+      (f[E]-f[W]));
+
+   vx2 = ((((f[TNE]-f[BSW])+(f[BNW]-f[TSE]))+((f[TNW]-f[BSE])+(f[BNE]-f[TSW])))+
+      (((f[BN]-f[TS])+(f[TN]-f[BS]))+((f[NW]-f[SE])+(f[NE]-f[SW])))+
+      (f[N]-f[S]));
+
+   vx3 = ((((f[TNE]-f[BSW])+(f[TSE]-f[BNW]))+((f[TNW]-f[BSE])+(f[TSW]-f[BNE])))+
+      (((f[TS]-f[BN])+(f[TN]-f[BS]))+((f[TW]-f[BE])+(f[TE]-f[BW])))+
+      (f[T]-f[B]));
+
+   LBMReal cu_sq = 1.5*(vx1*vx1+vx2*vx2+vx3*vx3);
+
+   feq[ZERO] = c8o27*(drho-cu_sq);
+   feq[E] = c2o27*(drho+3.0*(vx1)+c9o2*(vx1)*(vx1)-cu_sq);
+   feq[W] = c2o27*(drho+3.0*(-vx1)+c9o2*(-vx1)*(-vx1)-cu_sq);
+   feq[N] = c2o27*(drho+3.0*(vx2)+c9o2*(vx2)*(vx2)-cu_sq);
+   feq[S] = c2o27*(drho+3.0*(-vx2)+c9o2*(-vx2)*(-vx2)-cu_sq);
+   feq[T] = c2o27*(drho+3.0*(vx3)+c9o2*(vx3)*(vx3)-cu_sq);
+   feq[B] = c2o27*(drho+3.0*(-vx3)+c9o2*(-vx3)*(-vx3)-cu_sq);
+   feq[NE] = c1o54*(drho+3.0*(vx1+vx2)+c9o2*(vx1+vx2)*(vx1+vx2)-cu_sq);
+   feq[SW] = c1o54*(drho+3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq);
+   feq[SE] = c1o54*(drho+3.0*(vx1-vx2)+c9o2*(vx1-vx2)*(vx1-vx2)-cu_sq);
+   feq[NW] = c1o54*(drho+3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq);
+   feq[TE] = c1o54*(drho+3.0*(vx1+vx3)+c9o2*(vx1+vx3)*(vx1+vx3)-cu_sq);
+   feq[BW] = c1o54*(drho+3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq);
+   feq[BE] = c1o54*(drho+3.0*(vx1-vx3)+c9o2*(vx1-vx3)*(vx1-vx3)-cu_sq);
+   feq[TW] = c1o54*(drho+3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq);
+   feq[TN] = c1o54*(drho+3.0*(vx2+vx3)+c9o2*(vx2+vx3)*(vx2+vx3)-cu_sq);
+   feq[BS] = c1o54*(drho+3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq);
+   feq[BN] = c1o54*(drho+3.0*(vx2-vx3)+c9o2*(vx2-vx3)*(vx2-vx3)-cu_sq);
+   feq[TS] = c1o54*(drho+3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq);
+   feq[TNE] = c1o216*(drho+3.0*(vx1+vx2+vx3)+c9o2*(vx1+vx2+vx3)*(vx1+vx2+vx3)-cu_sq);
+   feq[BSW] = c1o216*(drho+3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq);
+   feq[BNE] = c1o216*(drho+3.0*(vx1+vx2-vx3)+c9o2*(vx1+vx2-vx3)*(vx1+vx2-vx3)-cu_sq);
+   feq[TSW] = c1o216*(drho+3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq);
+   feq[TSE] = c1o216*(drho+3.0*(vx1-vx2+vx3)+c9o2*(vx1-vx2+vx3)*(vx1-vx2+vx3)-cu_sq);
+   feq[BNW] = c1o216*(drho+3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq);
+   feq[BSE] = c1o216*(drho+3.0*(vx1-vx2-vx3)+c9o2*(vx1-vx2-vx3)*(vx1-vx2-vx3)-cu_sq);
+   feq[TNW] = c1o216*(drho+3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq);
+
+   //Relaxation
+   f[ZERO] += (feq[ZERO]-f[ZERO])*collFactor;
+   f[E] += (feq[E]-f[E])*collFactor;
+   f[W] += (feq[W]-f[W])*collFactor;
+   f[N] += (feq[N]-f[N])*collFactor;
+   f[S] += (feq[S]-f[S])*collFactor;
+   f[T] += (feq[T]-f[T])*collFactor;
+   f[B] += (feq[B]-f[B])*collFactor;
+   f[NE] += (feq[NE]-f[NE])*collFactor;
+   f[SW] += (feq[SW]-f[SW])*collFactor;
+   f[SE] += (feq[SE]-f[SE])*collFactor;
+   f[NW] += (feq[NW]-f[NW])*collFactor;
+   f[TE] += (feq[TE]-f[TE])*collFactor;
+   f[BW] += (feq[BW]-f[BW])*collFactor;
+   f[BE] += (feq[BE]-f[BE])*collFactor;
+   f[TW] += (feq[TW]-f[TW])*collFactor;
+   f[TN] += (feq[TN]-f[TN])*collFactor;
+   f[BS] += (feq[BS]-f[BS])*collFactor;
+   f[BN] += (feq[BN]-f[BN])*collFactor;
+   f[TS] += (feq[TS]-f[TS])*collFactor;
+
+   f[TNE] += (feq[TNE]-f[TNE])*collFactor;
+   f[BSW] += (feq[BSW]-f[BSW])*collFactor;
+   f[BNE] += (feq[BNE]-f[BNE])*collFactor;
+   f[TSW] += (feq[TSW]-f[TSW])*collFactor;
+   f[TSE] += (feq[TSE]-f[TSE])*collFactor;
+   f[BNW] += (feq[BNW]-f[BNW])*collFactor;
+   f[BSE] += (feq[BSE]-f[BSE])*collFactor;
+   f[TNW] += (feq[TNW]-f[TNW])*collFactor;
+}
\ No newline at end of file
diff --git a/source/DemCoupling/reconstructor/LBMReconstructor.h b/source/DemCoupling/reconstructor/LBMReconstructor.h
new file mode 100644
index 0000000000000000000000000000000000000000..0ba24f89894d20b0b738fedb022fb8f34eb557d5
--- /dev/null
+++ b/source/DemCoupling/reconstructor/LBMReconstructor.h
@@ -0,0 +1,37 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef LBM_RECONSTRUCTOR_H
+#define LBM_RECONSTRUCTOR_H
+
+#include "UbTuple.h"
+
+#include "Reconstructor.h"
+
+#include "LBMSystem.h"
+
+class ILBMKernel;
+class PhysicsEngineGeometryAdapter;
+
+
+class LBMReconstructor : public Reconstructor
+{
+public:
+    LBMReconstructor(bool compressible);
+    virtual ~LBMReconstructor() {}
+    
+    void reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const override;
+
+private:
+   static void collide(LBMReal* f, LBMReal collFactor);
+
+   typedef void(*CalcMacrosFct)(const LBMReal* const& /*f[27]*/, LBMReal& /*rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/);
+   CalcMacrosFct    calcMacrosFct;
+
+};
+
+
+
+#endif
+
diff --git a/source/DemCoupling/reconstructor/Reconstructor.h b/source/DemCoupling/reconstructor/Reconstructor.h
new file mode 100644
index 0000000000000000000000000000000000000000..cbcb49ba23b4483bbca5d2c778d682fa1046dca1
--- /dev/null
+++ b/source/DemCoupling/reconstructor/Reconstructor.h
@@ -0,0 +1,27 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef RECONSTRCUTOR_H
+#define RECONSTRCUTOR_H
+
+#include <PointerDefinitions.h>
+
+#include "Vector3D.h"
+
+class ILBMKernel;
+class PhysicsEngineGeometryAdapter;
+
+class Reconstructor
+{
+public:
+    virtual ~Reconstructor() {}
+
+    virtual void reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D& worldCoordinates, SPtr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const = 0;
+
+};
+
+
+
+#endif
+
diff --git a/source/DemCoupling/reconstructor/VelocityBcReconstructor.cpp b/source/DemCoupling/reconstructor/VelocityBcReconstructor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1b928273074e1faad2deae4fe7e19c85e7d39e05
--- /dev/null
+++ b/source/DemCoupling/reconstructor/VelocityBcReconstructor.cpp
@@ -0,0 +1,102 @@
+#include "VelocityBcReconstructor.h"
+
+#include <exception>
+
+#include "ILBMKernel.h"
+#include "D3Q27System.h"
+#include "BCArray3D.h"
+#include "EsoTwist3D.h"
+#include "BCProcessor.h"
+#include "DataSet3D.h"
+
+#include "PhysicsEngineGeometryAdapter.h"
+
+void VelocityBcReconstructor::reconstructNode(const int& x1, const int& x2, const int& x3,
+                                              const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const
+{
+    if (kernel->getCompressible())
+        throw std::runtime_error("not implemented yet!");
+
+    const Vector3D boundaryVelocity = physicsEngineGeometry->getVelocityAtPosition(worldCoordinates);
+    //TODO: move to D3Q27 system
+    LBMReal wijk[D3Q27System::ENDF + 1];
+    D3Q27System::calcIncompFeq(wijk, 1, 0, 0, 0);
+
+    SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray();
+
+    SPtr<BoundaryConditions> bc = SPtr<BoundaryConditions>(new BoundaryConditions());
+    bc->setBoundaryVelocityX1((float)boundaryVelocity[0]);
+    bc->setBoundaryVelocityX2((float)boundaryVelocity[1]);
+    bc->setBoundaryVelocityX3((float)boundaryVelocity[2]);
+
+    LBMReal feqNullRho[D3Q27System::ENDF + 1];
+    D3Q27System::calcIncompFeq(feqNullRho, 0, boundaryVelocity[0], boundaryVelocity[1], boundaryVelocity[2]);
+
+    LBMReal fpre[D3Q27System::ENDF + 1];
+    LBMReal fpost[D3Q27System::ENDF + 1];
+    SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions();
+
+    distributions->swap();
+    distributions->getDistributionInv(fpost, x1, x2, x3);
+    distributions->swap();
+    distributions->getDistribution(fpre, x1, x2, x3);
+
+    int neighborX1, neighborX2, neighborX3;
+    int neighborX1Inv, neighborX2Inv, neighborX3Inv;
+
+    double sumRho = 0, sumWijk = 0;
+    double collFactor = kernel->getCollisionFactor();
+
+    for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++)
+    {
+        neighborX1 = x1 + D3Q27System::DX1[fDir];
+        neighborX2 = x2 + D3Q27System::DX2[fDir];
+        neighborX3 = x3 + D3Q27System::DX3[fDir];
+
+        if (bcArray->isFluid(neighborX1, neighborX2, neighborX3))
+        {
+            int invDir = D3Q27System::INVDIR[fDir];
+
+            neighborX1Inv = x1 + D3Q27System::DX1[invDir];
+            neighborX2Inv = x2 + D3Q27System::DX2[invDir];
+            neighborX3Inv = x3 + D3Q27System::DX3[invDir];
+            if (!bcArray->isFluid(neighborX1Inv, neighborX2Inv, neighborX3Inv))
+            {
+
+                double velocity = bc->getBoundaryVelocity(invDir);
+
+                fpre[fDir] = fpre[invDir] - velocity;
+                double Omega = fpost[fDir] - fpre[fDir];
+
+                sumRho += Omega / collFactor + fpre[fDir] - feqNullRho[fDir];
+                sumWijk += wijk[fDir];
+            }
+
+        }
+    }
+
+    double rho = 0.0;
+    if (sumWijk > 0.0)
+        rho = sumRho / sumWijk;
+
+    for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++)
+    {
+        neighborX1 = x1 + D3Q27System::DX1[fDir];
+        neighborX2 = x2 + D3Q27System::DX2[fDir];
+        neighborX3 = x3 + D3Q27System::DX3[fDir];
+
+        if (!bcArray->isFluid(neighborX1, neighborX2, neighborX3))
+        {
+            int invDir = D3Q27System::INVDIR[fDir];
+            neighborX1Inv = x1 + D3Q27System::DX1[invDir];
+            neighborX2Inv = x2 + D3Q27System::DX2[invDir];
+            neighborX3Inv = x3 + D3Q27System::DX3[invDir];
+            if (!bcArray->isFluid(neighborX1Inv, neighborX2Inv, neighborX3Inv))
+            {
+                fpre[fDir] = D3Q27System::getIncompFeqForDirection(fDir, rho, bc->getBoundaryVelocityX1(), bc->getBoundaryVelocityX2(), bc->getBoundaryVelocityX3());
+            }
+
+        }
+    }
+
+}
diff --git a/source/DemCoupling/reconstructor/VelocityBcReconstructor.h b/source/DemCoupling/reconstructor/VelocityBcReconstructor.h
new file mode 100644
index 0000000000000000000000000000000000000000..8be5bcb65d20fd1bfeb37ea333ec03223fefa51b
--- /dev/null
+++ b/source/DemCoupling/reconstructor/VelocityBcReconstructor.h
@@ -0,0 +1,27 @@
+/*
+*  Author: S. Peters
+*  mail: peters@irmb.tu-bs.de
+*/
+#ifndef VELOCITY_BC_RECONSTRUCTOR_H
+#define VELOCITY_BC_RECONSTRUCTOR_H
+
+#include "UbTuple.h"
+
+#include "Reconstructor.h"
+
+class ILBMKernel;
+class PhysicsEngineGeometryAdapter;
+
+class VelocityBcReconstructor : public Reconstructor
+{
+public:
+    virtual ~VelocityBcReconstructor() {}
+
+    void reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const override;
+
+};
+
+
+
+#endif
+
diff --git a/source/DemCoupling/reconstructor/package.include b/source/DemCoupling/reconstructor/package.include
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/source/ThirdParty/Library/basics/container/CMakePackage.txt b/source/ThirdParty/Library/basics/container/CMakePackage.txt
deleted file mode 100644
index f7766736561db92faa97bdef5d1c1a6a40533148..0000000000000000000000000000000000000000
--- a/source/ThirdParty/Library/basics/container/CMakePackage.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
-COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
-
-
diff --git a/source/ThirdParty/Library/basics/writer/CMakePackage.txt b/source/ThirdParty/Library/basics/writer/CMakePackage.txt
deleted file mode 100644
index 1222f87f3fb0a45838379cdf4345e3d11a06e575..0000000000000000000000000000000000000000
--- a/source/ThirdParty/Library/basics/writer/CMakePackage.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
-COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
-
diff --git a/source/VirtualFluidsBasic/IncludsList.cmake b/source/VirtualFluidsBasic/IncludsList.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..4b253c0ebee64fa4f4ae002f9a70601fd397c7f5
--- /dev/null
+++ b/source/VirtualFluidsBasic/IncludsList.cmake
@@ -0,0 +1,10 @@
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsBasic)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsBasic/numerics/geometry3d)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsBasic/numerics/geometry3d/Creator)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsBasic/numerics/geometry3d/KdTree)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsBasic/basics/container)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsBasic/basics/memory)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsBasic/basics/objects)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsBasic/basics/transmiitter)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsBasic/basics/utilities)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsBasic/basics/writer)
\ No newline at end of file
diff --git a/source/VirtualFluidsBasic/VirtualFluidsBasic.cmake b/source/VirtualFluidsBasic/VirtualFluidsBasic.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..c4d5cba0a99076b02430007f499cd37347a7772a
--- /dev/null
+++ b/source/VirtualFluidsBasic/VirtualFluidsBasic.cmake
@@ -0,0 +1,11 @@
+INCLUDE(${SOURCE_ROOT}/VirtualFluidsBasic/numerics/geometry3d/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/VirtualFluidsBasic/numerics/geometry3d/creator/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/VirtualFluidsBasic/numerics/geometry3d/KdTree/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/VirtualFluidsBasic/basics/objects/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/VirtualFluidsBasic/basics/memory/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/VirtualFluidsBasic/basics/utilities/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/VirtualFluidsBasic/basics/container/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/VirtualFluidsBasic/basics/writer/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/VirtualFluidsBasic/basics/transmitter/CMakePackage.txt)
+
+INCLUDE(${SOURCE_ROOT}/VirtualFluidsBasic/IncludsList.cmake)
\ No newline at end of file
diff --git a/source/VirtualFluidsBasic/basics/container/CMakePackage.txt b/source/VirtualFluidsBasic/basics/container/CMakePackage.txt
new file mode 100644
index 0000000000000000000000000000000000000000..b2d974b49ca72178a8823a1e2e06fc7087205c88
--- /dev/null
+++ b/source/VirtualFluidsBasic/basics/container/CMakePackage.txt
@@ -0,0 +1,4 @@
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
+
+
diff --git a/source/ThirdParty/Library/basics/container/CbArray2D.h b/source/VirtualFluidsBasic/basics/container/CbArray2D.h
similarity index 97%
rename from source/ThirdParty/Library/basics/container/CbArray2D.h
rename to source/VirtualFluidsBasic/basics/container/CbArray2D.h
index 2dc54329b868a760d1803d4c03ba7099c52b4b44..54df75401aafd97a3bcb95cc00d757ffce1fd745 100644
--- a/source/ThirdParty/Library/basics/container/CbArray2D.h
+++ b/source/VirtualFluidsBasic/basics/container/CbArray2D.h
@@ -1,414 +1,414 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef CBARRAY2D_H
-#define CBARRAY2D_H
-
-//////////////////////////////////////////////////////////////////////////
-// 4D Array
-// die Daten werden in einem Vector gehalten
-//
-// Ver 1.2
-// Nov. 2003 muffmolch@gmx.de
-// Ver 1.3
-// Aug. 2006 - Kosmetik
-// Ver 1.4
-// Sep. 2006 - indexer eingefuehrt
-// Ver 1.5
-// Jul. 2006 - size_t + range check bei getIndex
-// Ver 1.6
-// Mrz. 2008 - typedefs, new index checks, NO_CB_RANGECHECK, no base class
-//             assigmetcomparison between Matrices with different value_type and/or index-class
-// Oct. 2008 - +isEmpty()
-//
-// Rangecheck aktiv, wenn:
-// -debug  : not defined "NO_CB_RANGECHECK"
-// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK"
-//////////////////////////////////////////////////////////////////////////
-
-#include <iomanip>
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbEqual.h>
-#include <algorithm>
-#include <typeinfo>
-
-#ifdef CAB_RCF
-  #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-// IndexClasses
-
-//IndexerX2X1:
-//        4 5 6
-// Array  1 2 3  -->  vector 1 2 3 4 5 6
-//optimaler schleifendurchlauf
-//for(alle X2)
-//  for(alle X1)
-class IndexerX2X1
-{
-public:
-   typedef int size_type;
-public:
-   inline std::size_t getIndex(const size_type& x1, const size_type& x2, const size_type& nx1, const size_type& nx2) const
-   {
-      return nx1* x2 + x1;
-   }
-   inline std::size_t getStartIndexOfSortedArray(const size_type& x1, const size_type& x2, const size_type& nx1, const size_type& nx2) const
-   {
-      return  nx1* x2;
-   }
-};
-
-//IndexerX1X2:
-//        4 5 6
-// Array  1 2 3  -->  vector 1 4 2 5 3 6
-//optimaler schleifendurchlauf
-//for(alle X1)
-//  for(alle X2)
-class IndexerX1X2
-{
-public:
-   typedef int size_type;
-public:
-   inline std::size_t getIndex(const size_type& x1, const size_type& x2, const size_type& nx1,const size_type& nx2) const
-   {
-      return nx2* x1+ x2;
-   }
-   inline std::size_t getStartIndexOfSortedArray(const size_type& x1, const size_type& x2, const size_type& nx1, const size_type& nx2) const
-   {
-      return  nx2* x1;
-   }
-};
-
-
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-// CbArray2D
-
-template<typename T, typename IndexClass = IndexerX2X1>
-class CbArray2D
-{
-public:
-   typedef T                                                   value_type;
-   typedef IndexClass                                          indexer_type;
-   typedef typename IndexClass::size_type                      size_type;
-   typedef typename std::vector< value_type >::reference       reference;
-   typedef typename std::vector< value_type >::const_reference const_reference;
-   typedef typename std::vector< value_type >::pointer         pointer;
-   typedef typename std::vector< value_type >::const_pointer   const_pointer;
-
-private:
-   template< typename value_type2, typename IndexClass2 > friend class CbArray2D;
-
-public:
-   /*=======================================================================*/
-   CbArray2D()
-   {
-      this->resize(0,0);
-   }
-   /*=======================================================================*/
-   CbArray2D(const size_type& nx2, const size_type& nx1)
-   {
-      this->resize(nx2,nx1);
-   }
-   /*=======================================================================*/
-   CbArray2D(const size_type& nx2, const size_type& nx1, const value_type& val)
-   {
-      this->resize(nx2,nx1,val);
-   }
-   /*=======================================================================*/
-   CbArray2D(const size_type& uniformDimensionSize /*nx1==nx2*/)
-   {
-      this->resize(uniformDimensionSize,uniformDimensionSize);
-   }
-   /*=======================================================================*/
-   //übernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschließend leer, da swap verwendet wird)
-   CbArray2D(std::vector<value_type>& vec, const size_type& nx1,const size_type& nx2)
-   {
-      assert( (nx1*nx2)==vec.size() );
-      this->data.swap(vec);
-      this->resize(nx1,nx2);
-   }
-   /*=======================================================================*/
-   CbArray2D(const CbArray2D& src)
-      :  nx1(src.nx1)
-       , nx2(src.nx2)
-       , data(src.data)
-   {
-   }
-   /*=======================================================================*/
-   template< typename value_type2 >
-   CbArray2D(const CbArray2D< value_type2 >& src)
-      :  nx1(src.nx1)
-       , nx2(src.nx2)
-   {
-      //Sourcedaten kopieren
-      this->data.resize( src.data.size() );
-      for(std::size_t i=0; i<data.size(); ++i)
-         this->data[i] = src.data[i];
-   }
-   /*=======================================================================*/
-   virtual ~CbArray2D()
-   {
-      //vector wird automatisch zerstoert
-   }
-   /*=======================================================================*/
-   CbArray2D& operator= (const CbArray2D& rhs)
-   {
-      if(this == &rhs) return *this;
-
-      this->nx1 = rhs.nx1;
-      this->nx2 = rhs.nx2;
-
-      //Laenge anpassen
-      this->data.resize(rhs.data.size());
-      //gespeicherte Datenelemente loeschen
-      this->data.clear();
-
-      //Sourcedaten kopieren
-      this->data  = rhs.data;
-
-      return *this;
-   }
-   /*=======================================================================*/
-   //durch value_type2 kann man z.B. ein float array einem double array zuweisen!
-   template< typename value_type2, typename IndexClass2 >
-   CbArray2D& operator= (const CbArray2D< value_type2, IndexClass2 >& rhs)
-   {
-      this->nx1 = rhs.nx1;
-      this->nx2 = rhs.nx2;
-
-      //gespeicherte Datenelemente loeschen
-      this->data.clear();
-      //Laenge anpassen
-      this->data.resize(rhs.data.size());
-
-      //Sourcedaten kopieren (!! koennte anderen Indexer besitzen!!! -> operator() benutzen)
-      //ACHTUNG: für diese Konvertierung muss bei Klassen der demenstrechende operator
-      //         implementiert sein, e.g.: class value_type2 {public: inline operator value_type2() const { return value_type2(); }
-      for(int x1=0; x1<this->nx1; x1++)
-         for(int x2=0; x2<this->nx2; x2++)
-               this->operator()(x1,x2) = static_cast< value_type >( rhs.operator()(x1,x2) );
-
-      return *this;
-   }
-   /*=======================================================================*/
-   bool operator== (const CbArray2D& rhs) const
-   {
-      if( this == &rhs ) return true;
-
-      if(   this->nx1!=rhs.nx1
-         || this->nx2!=rhs.nx2
-         || this->data.size() != rhs.data.size() )
-      {
-         return false;
-      }
-
-      return std::equal( this->data.begin(), this->data.end(), rhs.data.begin(), UbEqual<value_type, value_type >() );
-   }
-   /*=======================================================================*/
-   template< typename value_type2, typename IndexClass2 >
-   bool operator== (const CbArray2D< value_type2, IndexClass2 >& rhs) const
-   {
-      if( this->data.size() != rhs.data.size() ) return false;
-
-      //Sourcedaten einzeln checken (!! koennte anderen Indexer besitzen!!! -> operator() benutzen)
-      for(int x1=0; x1<this->nx1; x1++)
-         for(int x2=0; x2<this->nx2; x2++)
-            if( !isUbEqual(this->operator()(x1,x2), rhs.operator()(x1,x2)) )
-               return false;
-
-      return true;
-   }
-   /*=======================================================================*/
-   bool operator!= (const CbArray2D& rhs) const
-   {
-      return !(*this==rhs);
-   }
-   /*=======================================================================*/
-   template< typename value_type2, typename IndexClass2 >
-   bool operator!= (const CbArray2D< value_type2, IndexClass2 >& rhs) const
-   {
-      return !(*this==rhs);
-   }
-   /*=======================================================================*/
-   reference operator() (const size_type& x1,const size_type& x2)
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) );
-      #endif
-
-      return this->data[indexer.getIndex(x1,x2,nx1,nx2)];
-   }
-   /*=======================================================================*/
-   const_reference operator() (const size_type& x1,const size_type& x2)	const
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) );
-      #endif
-
-      return this->data[indexer.getIndex(x1,x2,nx1,nx2)];
-   }
-   /*=======================================================================*/
-   pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2)
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) );
-      #endif
-      return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,nx1,nx2)];
-   }
-   /*=======================================================================*/
-   const_pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2) const
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) );
-      #endif
-      return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,nx1,nx2)];
-   }
-   /*=======================================================================*/
-   void setObject(const size_type& x1,const size_type& x2,const value_type& value)
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) );
-      #endif
-      this->data[indexer.getIndex(x1,x2,nx1,nx2)] = value;
-   }
-   /*=======================================================================*/
-   reference getObject(const size_type& x1, const size_type& x2)
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) );
-      #endif
-      return this->data[indexer.getIndex(x1,x2,nx1,nx2)] ;
-   }
-   /*=======================================================================*/
-   typename std::vector<value_type>::const_reference getObject(const size_type& x1, const size_type& x2) const
-   {
-      return this->operator()(x1,x2);
-   }
-   /*=======================================================================*/
-   bool      isEmpty() const { return data.empty(); }
-   size_type getNX1()  const { return this->nx1;    }
-   size_type getNX2()  const { return this->nx2;    }
-   /*=======================================================================*/
-   void reset(const T& val)
-   {
-      std::fill( this->data.begin(), this->data.end(), val );
-   }
-   /*=======================================================================*/
-   std::string toString() const
-   {
-      std::stringstream text;
-      for(size_type x2=0; x2<this->nx2; x2++)
-      {
-         for(size_type x1=0; x1<this->nx1; x1++)
-         {
-            //hier kommts zum Konflikt ab  und an ...
-            text<<this->getObject(x1,x2)<<", ";
-         }
-         text<<"\n";
-      }
-
-      return text.str();
-   }
-   /*=======================================================================*/
-   std::string getInfo() const
-   {
-      std::stringstream text;
-      text<<"CbArray2D< storageType="<<typeid(T).name()<<", indexer="<<typeid(IndexClass).name()<<" >";
-      text<<"( nx1="<<this->nx1<<", nx2="<<this->nx2<<")";
-      return text.str();
-   }
-   /*=======================================================================*/
-   void resize(const size_type& uniformDimensionSize)
-   {
-      this->resize(uniformDimensionSize,uniformDimensionSize);
-   }
-   /*=======================================================================*/
-   void resize(const size_type& nx1,const size_type& nx2)
-   {
-      this->nx1 = nx1;
-      this->nx2 = nx2;
-      this->data.resize(nx1*nx2);
-   }
-   /*=======================================================================*/
-   void resize(const size_type& nx1, const size_type& nx2, const value_type& initVal )
-   {
-      this->nx1 = nx1;
-      this->nx2 = nx2;
-      this->data.resize(nx1*nx2,initVal);
-   }
-   /*=======================================================================*/
-   void clear()
-   {
-      this->nx1 = 0;
-      this->nx2 = 0;
-      this->data.clear();
-   }
-   /*=======================================================================*/
-   std::vector< value_type >& getDataVector() { return this->data; }
-   /*=======================================================================*/
-   const std::vector< value_type >& getDataVector() const { return this->data; }
-   /*=======================================================================*/
-   inline size_type getDataVectorIndex(const size_type& x1, const size_type& x2) const
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) );
-      #endif
-
-      return indexer.getIndex(x1,x2,nx1,nx2);
-   }
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void serialize(Archive & ar, const unsigned int version)
-   {
-      ar & nx1;
-      ar & nx2;
-      ar & data;
-   }
-#endif //CAB_RCF
-
-protected:
-   /*=======================================================================*/
-   //success -> true
-   //else    -> false
-   inline bool indicesInRange(const size_type& x1, const size_type& x2) const
-   {
-      if(   x1 < 0 || x1 >= this->nx1
-         || x2 < 0 || x2 >= this->nx2 )
-      {
-         return false;
-      }
-      return true;
-   }
-   /*=======================================================================*/
-   std::string getExceptionErrorString(const size_type& x1, const size_type& x2) const
-   {
-      std::stringstream out("index out of range - ");
-      out<<"("<<x1<<","<<x2<<") not in ("<<nx1<<","<<nx2<<")";
-      return out.str();
-   }
-   /*=======================================================================*/
-
-protected:
-   size_type    nx1;
-   size_type    nx2;
-   indexer_type indexer;
-   std::vector< value_type > data;
-};
-
-#endif //CBARRAY2D_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef CBARRAY2D_H
+#define CBARRAY2D_H
+
+//////////////////////////////////////////////////////////////////////////
+// 4D Array
+// die Daten werden in einem Vector gehalten
+//
+// Ver 1.2
+// Nov. 2003 muffmolch@gmx.de
+// Ver 1.3
+// Aug. 2006 - Kosmetik
+// Ver 1.4
+// Sep. 2006 - indexer eingefuehrt
+// Ver 1.5
+// Jul. 2006 - size_t + range check bei getIndex
+// Ver 1.6
+// Mrz. 2008 - typedefs, new index checks, NO_CB_RANGECHECK, no base class
+//             assigmetcomparison between Matrices with different value_type and/or index-class
+// Oct. 2008 - +isEmpty()
+//
+// Rangecheck aktiv, wenn:
+// -debug  : not defined "NO_CB_RANGECHECK"
+// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK"
+//////////////////////////////////////////////////////////////////////////
+
+#include <iomanip>
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbEqual.h>
+#include <algorithm>
+#include <typeinfo>
+
+#ifdef CAB_RCF
+  #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+// IndexClasses
+
+//IndexerX2X1:
+//        4 5 6
+// Array  1 2 3  -->  vector 1 2 3 4 5 6
+//optimaler schleifendurchlauf
+//for(alle X2)
+//  for(alle X1)
+class IndexerX2X1
+{
+public:
+   typedef int size_type;
+public:
+   inline std::size_t getIndex(const size_type& x1, const size_type& x2, const size_type& nx1, const size_type& nx2) const
+   {
+      return nx1* x2 + x1;
+   }
+   inline std::size_t getStartIndexOfSortedArray(const size_type& x1, const size_type& x2, const size_type& nx1, const size_type& nx2) const
+   {
+      return  nx1* x2;
+   }
+};
+
+//IndexerX1X2:
+//        4 5 6
+// Array  1 2 3  -->  vector 1 4 2 5 3 6
+//optimaler schleifendurchlauf
+//for(alle X1)
+//  for(alle X2)
+class IndexerX1X2
+{
+public:
+   typedef int size_type;
+public:
+   inline std::size_t getIndex(const size_type& x1, const size_type& x2, const size_type& nx1,const size_type& nx2) const
+   {
+      return nx2* x1+ x2;
+   }
+   inline std::size_t getStartIndexOfSortedArray(const size_type& x1, const size_type& x2, const size_type& nx1, const size_type& nx2) const
+   {
+      return  nx2* x1;
+   }
+};
+
+
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+// CbArray2D
+
+template<typename T, typename IndexClass = IndexerX2X1>
+class CbArray2D
+{
+public:
+   typedef T                                                   value_type;
+   typedef IndexClass                                          indexer_type;
+   typedef typename IndexClass::size_type                      size_type;
+   typedef typename std::vector< value_type >::reference       reference;
+   typedef typename std::vector< value_type >::const_reference const_reference;
+   typedef typename std::vector< value_type >::pointer         pointer;
+   typedef typename std::vector< value_type >::const_pointer   const_pointer;
+
+private:
+   template< typename value_type2, typename IndexClass2 > friend class CbArray2D;
+
+public:
+   /*=======================================================================*/
+   CbArray2D()
+   {
+      this->resize(0,0);
+   }
+   /*=======================================================================*/
+   CbArray2D(const size_type& nx2, const size_type& nx1)
+   {
+      this->resize(nx2,nx1);
+   }
+   /*=======================================================================*/
+   CbArray2D(const size_type& nx2, const size_type& nx1, const value_type& val)
+   {
+      this->resize(nx2,nx1,val);
+   }
+   /*=======================================================================*/
+   CbArray2D(const size_type& uniformDimensionSize /*nx1==nx2*/)
+   {
+      this->resize(uniformDimensionSize,uniformDimensionSize);
+   }
+   /*=======================================================================*/
+   //übernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschließend leer, da swap verwendet wird)
+   CbArray2D(std::vector<value_type>& vec, const size_type& nx1,const size_type& nx2)
+   {
+      assert( (nx1*nx2)==vec.size() );
+      this->data.swap(vec);
+      this->resize(nx1,nx2);
+   }
+   /*=======================================================================*/
+   CbArray2D(const CbArray2D& src)
+      :  nx1(src.nx1)
+       , nx2(src.nx2)
+       , data(src.data)
+   {
+   }
+   /*=======================================================================*/
+   template< typename value_type2 >
+   CbArray2D(const CbArray2D< value_type2 >& src)
+      :  nx1(src.nx1)
+       , nx2(src.nx2)
+   {
+      //Sourcedaten kopieren
+      this->data.resize( src.data.size() );
+      for(std::size_t i=0; i<data.size(); ++i)
+         this->data[i] = src.data[i];
+   }
+   /*=======================================================================*/
+   virtual ~CbArray2D()
+   {
+      //vector wird automatisch zerstoert
+   }
+   /*=======================================================================*/
+   CbArray2D& operator= (const CbArray2D& rhs)
+   {
+      if(this == &rhs) return *this;
+
+      this->nx1 = rhs.nx1;
+      this->nx2 = rhs.nx2;
+
+      //Laenge anpassen
+      this->data.resize(rhs.data.size());
+      //gespeicherte Datenelemente loeschen
+      this->data.clear();
+
+      //Sourcedaten kopieren
+      this->data  = rhs.data;
+
+      return *this;
+   }
+   /*=======================================================================*/
+   //durch value_type2 kann man z.B. ein float array einem double array zuweisen!
+   template< typename value_type2, typename IndexClass2 >
+   CbArray2D& operator= (const CbArray2D< value_type2, IndexClass2 >& rhs)
+   {
+      this->nx1 = rhs.nx1;
+      this->nx2 = rhs.nx2;
+
+      //gespeicherte Datenelemente loeschen
+      this->data.clear();
+      //Laenge anpassen
+      this->data.resize(rhs.data.size());
+
+      //Sourcedaten kopieren (!! koennte anderen Indexer besitzen!!! -> operator() benutzen)
+      //ACHTUNG: für diese Konvertierung muss bei Klassen der demenstrechende operator
+      //         implementiert sein, e.g.: class value_type2 {public: inline operator value_type2() const { return value_type2(); }
+      for(int x1=0; x1<this->nx1; x1++)
+         for(int x2=0; x2<this->nx2; x2++)
+               this->operator()(x1,x2) = static_cast< value_type >( rhs.operator()(x1,x2) );
+
+      return *this;
+   }
+   /*=======================================================================*/
+   bool operator== (const CbArray2D& rhs) const
+   {
+      if( this == &rhs ) return true;
+
+      if(   this->nx1!=rhs.nx1
+         || this->nx2!=rhs.nx2
+         || this->data.size() != rhs.data.size() )
+      {
+         return false;
+      }
+
+      return std::equal( this->data.begin(), this->data.end(), rhs.data.begin(), UbEqual<value_type, value_type >() );
+   }
+   /*=======================================================================*/
+   template< typename value_type2, typename IndexClass2 >
+   bool operator== (const CbArray2D< value_type2, IndexClass2 >& rhs) const
+   {
+      if( this->data.size() != rhs.data.size() ) return false;
+
+      //Sourcedaten einzeln checken (!! koennte anderen Indexer besitzen!!! -> operator() benutzen)
+      for(int x1=0; x1<this->nx1; x1++)
+         for(int x2=0; x2<this->nx2; x2++)
+            if( !isUbEqual(this->operator()(x1,x2), rhs.operator()(x1,x2)) )
+               return false;
+
+      return true;
+   }
+   /*=======================================================================*/
+   bool operator!= (const CbArray2D& rhs) const
+   {
+      return !(*this==rhs);
+   }
+   /*=======================================================================*/
+   template< typename value_type2, typename IndexClass2 >
+   bool operator!= (const CbArray2D< value_type2, IndexClass2 >& rhs) const
+   {
+      return !(*this==rhs);
+   }
+   /*=======================================================================*/
+   reference operator() (const size_type& x1,const size_type& x2)
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) );
+      #endif
+
+      return this->data[indexer.getIndex(x1,x2,nx1,nx2)];
+   }
+   /*=======================================================================*/
+   const_reference operator() (const size_type& x1,const size_type& x2)	const
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) );
+      #endif
+
+      return this->data[indexer.getIndex(x1,x2,nx1,nx2)];
+   }
+   /*=======================================================================*/
+   pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2)
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) );
+      #endif
+      return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,nx1,nx2)];
+   }
+   /*=======================================================================*/
+   const_pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2) const
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) );
+      #endif
+      return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,nx1,nx2)];
+   }
+   /*=======================================================================*/
+   void setObject(const size_type& x1,const size_type& x2,const value_type& value)
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) );
+      #endif
+      this->data[indexer.getIndex(x1,x2,nx1,nx2)] = value;
+   }
+   /*=======================================================================*/
+   reference getObject(const size_type& x1, const size_type& x2)
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) );
+      #endif
+      return this->data[indexer.getIndex(x1,x2,nx1,nx2)] ;
+   }
+   /*=======================================================================*/
+   typename std::vector<value_type>::const_reference getObject(const size_type& x1, const size_type& x2) const
+   {
+      return this->operator()(x1,x2);
+   }
+   /*=======================================================================*/
+   bool      isEmpty() const { return data.empty(); }
+   size_type getNX1()  const { return this->nx1;    }
+   size_type getNX2()  const { return this->nx2;    }
+   /*=======================================================================*/
+   void reset(const T& val)
+   {
+      std::fill( this->data.begin(), this->data.end(), val );
+   }
+   /*=======================================================================*/
+   std::string toString() const
+   {
+      std::stringstream text;
+      for(size_type x2=0; x2<this->nx2; x2++)
+      {
+         for(size_type x1=0; x1<this->nx1; x1++)
+         {
+            //hier kommts zum Konflikt ab  und an ...
+            text<<this->getObject(x1,x2)<<", ";
+         }
+         text<<"\n";
+      }
+
+      return text.str();
+   }
+   /*=======================================================================*/
+   std::string getInfo() const
+   {
+      std::stringstream text;
+      text<<"CbArray2D< storageType="<<typeid(T).name()<<", indexer="<<typeid(IndexClass).name()<<" >";
+      text<<"( nx1="<<this->nx1<<", nx2="<<this->nx2<<")";
+      return text.str();
+   }
+   /*=======================================================================*/
+   void resize(const size_type& uniformDimensionSize)
+   {
+      this->resize(uniformDimensionSize,uniformDimensionSize);
+   }
+   /*=======================================================================*/
+   void resize(const size_type& nx1,const size_type& nx2)
+   {
+      this->nx1 = nx1;
+      this->nx2 = nx2;
+      this->data.resize(nx1*nx2);
+   }
+   /*=======================================================================*/
+   void resize(const size_type& nx1, const size_type& nx2, const value_type& initVal )
+   {
+      this->nx1 = nx1;
+      this->nx2 = nx2;
+      this->data.resize(nx1*nx2,initVal);
+   }
+   /*=======================================================================*/
+   void clear()
+   {
+      this->nx1 = 0;
+      this->nx2 = 0;
+      this->data.clear();
+   }
+   /*=======================================================================*/
+   std::vector< value_type >& getDataVector() { return this->data; }
+   /*=======================================================================*/
+   const std::vector< value_type >& getDataVector() const { return this->data; }
+   /*=======================================================================*/
+   inline size_type getDataVectorIndex(const size_type& x1, const size_type& x2) const
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2)) );
+      #endif
+
+      return indexer.getIndex(x1,x2,nx1,nx2);
+   }
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void serialize(Archive & ar, const unsigned int version)
+   {
+      ar & nx1;
+      ar & nx2;
+      ar & data;
+   }
+#endif //CAB_RCF
+
+protected:
+   /*=======================================================================*/
+   //success -> true
+   //else    -> false
+   inline bool indicesInRange(const size_type& x1, const size_type& x2) const
+   {
+      if(   x1 < 0 || x1 >= this->nx1
+         || x2 < 0 || x2 >= this->nx2 )
+      {
+         return false;
+      }
+      return true;
+   }
+   /*=======================================================================*/
+   std::string getExceptionErrorString(const size_type& x1, const size_type& x2) const
+   {
+      std::stringstream out("index out of range - ");
+      out<<"("<<x1<<","<<x2<<") not in ("<<nx1<<","<<nx2<<")";
+      return out.str();
+   }
+   /*=======================================================================*/
+
+protected:
+   size_type    nx1;
+   size_type    nx2;
+   indexer_type indexer;
+   std::vector< value_type > data;
+};
+
+#endif //CBARRAY2D_H
diff --git a/source/ThirdParty/Library/basics/container/CbArray3D.h b/source/VirtualFluidsBasic/basics/container/CbArray3D.h
similarity index 97%
rename from source/ThirdParty/Library/basics/container/CbArray3D.h
rename to source/VirtualFluidsBasic/basics/container/CbArray3D.h
index f72698a71056461ad3fae9fec3d77c745c6163db..36197d1f872c5f8e0193686fc7b2e89144048850 100644
--- a/source/ThirdParty/Library/basics/container/CbArray3D.h
+++ b/source/VirtualFluidsBasic/basics/container/CbArray3D.h
@@ -1,469 +1,469 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef CBARRAY3D_H
-#define CBARRAY3D_H
-
-//////////////////////////////////////////////////////////////////////////
-// 3D Array
-// die Daten werden in einem Vector gehalten
-//
-// Ver 1.2
-// Nov. 2003 muffmolch@gmx.de
-// Ver 1.3
-// Aug. 2006 - Kosmetik
-// Ver 1.4
-// Sep. 2006 - indexer eingefuehrt
-// Ver 1.5
-// Jul. 2006 - size_t + range check bei getIndex
-// Ver 1.2
-// Mrz. 2008 - typedefs, new index checks, NO_CB_RANGECHECK, no base class
-//             assigmetcomparison between Matrices with different value_type and/or index-class
-// Oct. 2008 - +isEmpty()
-//
-// Rangecheck aktiv, wenn:
-// -debug  : not defined "NO_CB_RANGECHECK"
-// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK"
-//////////////////////////////////////////////////////////////////////////
-
-#include <iomanip>
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbEqual.h>
-#include <algorithm>
-#include <typeinfo>
-#include "PointerDefinitions.h"
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-// IndexClasses
-
-//IndexerX3X2X1:
-//                4 5 6          10 11 12
-// Array  ebene A 1 2 3  ebene B  7  8  9 -->  vector 1 2 3 4 5 6 7 8 9 10 11 12
-//x1-reihen "liegen am stueck" im speicher
-//optimaler schleifendurchlauf
-//for(alle X3)
-//  for(alle X2)
-//    for(alle X1)
-class IndexerX3X2X1// FunctorX1SortedForX1X2Plane
-{
-public:
-   typedef size_t size_type;
-public:
-   inline std::size_t getIndex(  const size_type& x1 , const size_type& x2 , const size_type& x3
-                               , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const
-   {
-      return  nx1 * ( nx2 * x3 + x2) + x1 ;
-   }
-   inline std::size_t getStartIndexOfSortedArray(  const size_type& x1 , const size_type& x2 , const size_type& x3
-                                                 , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const
-   {
-      return  nx1 * ( nx2 * x3 + x2);
-   }
-};
-
-//IndexerX1X2X3:
-//                4 5 6          10 11 12
-// Array  ebene A 1 2 3  ebene B  7  8  9 -->
-//optimaler schleifendurchlauf
-//for(alle X1)
-//  for(alle X2)
-//    for(alle X3)
-class IndexerX1X2X3 //FunctorX3SortedForX3X2Plane
-{
-public:
-   typedef size_t size_type;
-public:
-   inline std::size_t getIndex(  const size_type& x1 , const size_type& x2 , const size_type& x3
-                               , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const
-   {
-      return  nx3 * ( nx2 * x1 + x2) + x3 ;
-   }
-   inline std::size_t getStartIndexOfSortedArray(  const size_type& x1 , const size_type& x2 , const size_type& x3
-                                                 , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const
-   {
-      return  nx3 * ( nx2 * x1 + x2);
-   }
-};
-
-//IndexerX2X1X3:
-//                4 5 6          10 11 12
-// Array  ebene A 1 2 3  ebene B  7  8  9 -->  vector 1 7 2 8 3 9 4 10 5 11 6 12
-//optimaler schleifendurchlauf
-//for(alle X2)
-//  for(alle X1)
-//    for(alle X3)
-class IndexerX2X1X3
-{
-public:
-   typedef size_t size_type;
-public:
-   inline std::size_t getIndex(  const size_type& x1 , const size_type& x2 , const size_type& x3
-                               , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const
-   {
-      return  nx3* ( nx1 * x2 + x1) + x3 ;
-   }
-   inline std::size_t getStartIndexOfSortedArray(  const size_type& x1 , const size_type& x2 , const size_type& x3
-                                                 , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const
-   {
-      return  nx3* ( nx1 * x2 + x1);
-   }
-};
-
-
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-// CbArray3D
-template<typename T, typename IndexClass = IndexerX3X2X1>
-class CbArray3D
-{
-public:
-   typedef SPtr< CbArray3D <T,IndexClass> > CbArray3DPtr;
-
-   typedef T                                                   value_type;
-   typedef IndexClass                                          indexer_type;
-   typedef typename IndexClass::size_type                      size_type;
-   typedef typename std::vector< value_type >::reference       reference;
-   typedef typename std::vector< value_type >::const_reference const_reference;
-   typedef typename std::vector< value_type >::pointer         pointer;
-   typedef typename std::vector< value_type >::const_pointer   const_pointer;
-
-private:
-   template< typename value_type2, typename IndexClass2 > friend class CbArray3D;
-
-public:
-   /*=======================================================================*/
-   CbArray3D()
-   {
-      this->resize(0,0,0);
-   }
-   /*=======================================================================*/
-   CbArray3D(const size_type& nx1,const size_type& nx2, const size_type& nx3, const value_type& val)
-   {
-      this->resize(nx1,nx2,nx3,val);
-   }
-   /*=======================================================================*/
-    CbArray3D(const size_type& nx1,const size_type& nx2, const size_type& nx3)
-    {
-       this->resize(nx1,nx2,nx3);
-    }
-   /*=======================================================================*/
-   CbArray3D(const size_type& uniformDimensionSize /*nx1==nx2==nx3*/)
-   {
-      this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize);
-   }
-   /*=======================================================================*/
-   //übernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschließend leer, da swap verwendet wird)
-   CbArray3D(std::vector<value_type>& vec, const size_type& nx1,const size_type& nx2, const size_type& nx3)
-   {
-      assert( (nx1*nx2*nx3)==vec.size() );
-      this->data.swap(vec);
-      this->resize(nx1,nx2,nx3);
-   }
-   /*=======================================================================*/
-   CbArray3D(const CbArray3D& src)
-      :  nx1(src.nx1)
-       , nx2(src.nx2)
-       , nx3(src.nx3)
-       , data(src.data)
-   {
-   }
-   /*=======================================================================*/
-   template< typename value_type2 >
-   CbArray3D(const CbArray3D< value_type2 >& src)
-      :  nx1(src.nx1)
-       , nx2(src.nx2)
-       , nx3(src.nx3)
-   {
-      //Sourcedaten kopieren
-      this->data.resize( src.data.size() );
-      for(std::size_t i=0; i<data.size(); ++i)
-         this->data[i] = src.data[i];
-   }
-   /*=======================================================================*/
-   virtual ~CbArray3D()
-   {
-      //vector wird automatisch zerstoert
-   }
-   /*=======================================================================*/
-   CbArray3D& operator= (const CbArray3D& rhs)
-   {
-      if(this == &rhs) return *this;
-
-      this->nx1 = rhs.nx1;
-      this->nx2 = rhs.nx2;
-      this->nx3 = rhs.nx3;
-
-      //gespeicherte Datenelemente loeschen
-      //Laenge anpassen
-      this->data.resize(rhs.data.size());
-      //gespeicherte Datenelemente loeschen
-      this->data.clear();
-
-      //Sourcedaten kopieren
-      this->data = rhs.data;
-
-      return *this;
-   }
-   /*=======================================================================*/
-   //durch value_type2 kann man z.B. ein float array einer double array zuweisen!
-   template< typename value_type2, typename IndexClass2 >
-   CbArray3D& operator= (const CbArray3D< value_type2, IndexClass2 >& rhs)
-   {
-      this->nx1 = rhs.nx1;
-      this->nx2 = rhs.nx2;
-      this->nx3 = rhs.nx3;
-
-      //gespeicherte Datenelemente loeschen
-      this->data.clear();
-      //Laenge anpassen
-      this->data.resize(rhs.data.size());
-
-      //Sourcedaten kopieren (!! koennte anderen Indexer besitzen!!! -> operator() benutzen)
-      for(int x3=0; x3<this->nx3; x3++)
-         for(int x2=0; x2<this->nx2; x2++)
-            for(int x1=0; x1<this->nx1; x1++)
-               this->operator()(x1,x2,x3) = static_cast< value_type >( rhs.operator()(x1,x2,x3) );
-
-      return *this;
-   }
-   /*=======================================================================*/
-   bool operator== (const CbArray3D& rhs) const
-   {
-      if(this == &rhs) return true;
-
-      if(   this->nx1!=rhs.nx1
-         || this->nx2!=rhs.nx2
-         || this->nx3!=rhs.nx3
-         || this->data.size() != rhs.data.size() )
-      {
-         return false;
-      }
-
-      return std::equal( this->data.begin(), this->data.end(), rhs.data.begin(), UbEqual<value_type, value_type >() );
-   }
-   /*=======================================================================*/
-   template< typename value_type2, typename IndexClass2 >
-   bool operator== (const CbArray3D< value_type2, IndexClass2 >& rhs) const
-   {
-      if( this->data.size() != rhs.data.size() ) return false;
-
-      //Sourcedaten einzeln checken (!! koennte anderen Indexer besitzen!!! -> operator() benutzen)
-      for(int x3=0; x3<this->nx3; x3++)
-         for(int x2=0; x2<this->nx2; x2++)
-            for(int x1=0; x1<this->nx1; x1++)
-               if( !isUbEqual(this->operator()(x1,x2,x3), rhs.operator()(x1,x2,x3)) )
-               return false;
-
-      return true;
-   }
-   /*=======================================================================*/
-   bool operator!= (const CbArray3D& src) const
-   {
-      return !(*this==src);
-   }
-   /*=======================================================================*/
-   template< typename value_type2, typename IndexClass2 >
-   bool operator!= (const CbArray3D< value_type2, IndexClass2 >& rhs) const
-   {
-      return !(*this==rhs);
-   }
-   /*=======================================================================*/
-   reference operator() (const size_type& x1, const size_type& x2, const size_type& x3)
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2,x3) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) );
-      #endif
-
-      return this->data[ indexer.getIndex(x1,x2,x3,nx1,nx2,nx3) ];
-   }
-   /*=======================================================================*/
-   const_reference operator() (const size_type& x1, const size_type& x2, const size_type& x3)	const
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2,x3) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) );
-      #endif
-
-      return this->data[ indexer.getIndex(x1,x2,x3,nx1,nx2,nx3) ];
-   }
-   /*=======================================================================*/
-   pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2, const size_type& x3)
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2,x3) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) );
-      #endif
-
-      return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,x3,nx1,nx2,nx3)];
-   }
-   /*=======================================================================*/
-   const_pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2, const size_type& x3)  const
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2,x3) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) );
-      #endif
-
-      return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,x3,nx1,nx2,nx3)];
-   }
-   /*=======================================================================*/
-   void setObject(const size_type& x1, const size_type& x2, const size_type& x3, const value_type& value)
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2,x3) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) );
-      #endif
-
-      this->data[ indexer.getIndex(x1,x2,x3,nx1,nx2,nx3) ] = value;
-   }
-   /*=======================================================================*/
-   reference getObject(const size_type& x1, const size_type& x2, const size_type& x3)
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2,x3) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) );
-      #endif
-
-      return this->data[ indexer.getIndex(x1,x2,x3,nx1,nx2,nx3) ] ;
-   }
-   /*=======================================================================*/
-   const_reference getObject(const size_type& x1, const size_type& x2, const size_type& x3) const
-   {
-      return (*this)(x1,x2,x3);
-   }
-   /*=======================================================================*/
-   bool      isEmpty() const { return data.empty(); }
-   size_type getNX1()  const { return this->nx1;    }
-   size_type getNX2()  const { return this->nx2;    }
-   size_type getNX3()  const { return this->nx3;    }
-   /*=======================================================================*/
-   void reset(const value_type& val)
-   {
-      std::fill( this->data.begin(), this->data.end(), val );
-   }
-   /*=======================================================================*/
-   std::string toString() const
-   {
-      std::stringstream text;
-      for(size_type x1=0; x1<this->nx1; x1++)
-      {
-      	for(size_type x2=0; x2<this->nx2; x2++)
-      	{
-         	for(size_type x3=0; x3<this->nx3; x3++)
-         	{
-            	text<<(*this)(x1,x2,x3)<<", ";
-         	}
-         	text<<std::endl;
-      	}
-      	text<<std::endl<<std::endl;
-      }
-
-      return text.str();
-   }
-   /*=======================================================================*/
-   std::string getInfo() const
-   {
-      std::stringstream text;
-      text<<"CbArray3D< storageType="<<typeid(T).name()<<", indexer="<<typeid(IndexClass).name()<<" >";
-      text<<"( nx1="<<this->nx1<<", nx2="<<this->nx2<<", nx3="<<this->nx3<<")";
-      return text.str();
-   }
-   /*=======================================================================*/
-   void resize(const int& uniformDimensionSize)
-   {
-      this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize);
-   }
-   /*=======================================================================*/
-   void resize(const size_type& nx1,const size_type& nx2, const size_type& nx3)
-   {
-      this->nx1 = nx1;
-      this->nx2 = nx2;
-      this->nx3 = nx3;
-      this->data.resize(nx1*nx2*nx3);
-   }
-   /*=======================================================================*/
-   void resize(const size_type& nx1,const size_type& nx2, const size_type& nx3,const value_type& val)
-   {
-      this->nx1 = nx1;
-      this->nx2 = nx2;
-      this->nx3 = nx3;
-      this->data.resize(nx1*nx2*nx3,val);
-   }
-   /*=======================================================================*/
-   void clear()
-   {
-      this->nx1 = 0;
-      this->nx2 = 0;
-      this->nx3 = 0;
-      this->data.clear();
-   }
-   /*=======================================================================*/
-   std::vector< value_type >& getDataVector() { return this->data; }
-   /*=======================================================================*/
-   const std::vector< value_type >& getDataVector() const { return this->data; }
-   /*=======================================================================*/
-   inline std::size_t getDataVectorIndex(const size_type& x1, const size_type& x2, const size_type& x3) const
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2,x3) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) );
-      #endif
-
-      return indexer.getIndex(x1,x2,x3,nx1,nx2,nx3);
-   }
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void serialize(Archive & ar, const unsigned int version)
-   {
-      ar & nx1;
-      ar & nx2;
-      ar & nx3;
-      ar & data;
-   }
-#endif //CAB_RCF
-
-
-   /*=======================================================================*/
-   //success -> true
-   //else    -> false
-   inline bool indicesInRange(const size_type& x1, const size_type& x2, const size_type& x3) const
-   {
-      if(   x1 < 0 || x1 >= this->nx1
-         || x2 < 0 || x2 >= this->nx2
-         || x3 < 0 || x3 >= this->nx3 )
-      {
-         return false;
-      }
-      return true;
-   }
-protected:
-   /*=======================================================================*/
-   std::string getExceptionErrorString(const size_type& x1, const size_type& x2, const size_type& x3) const
-   {
-      std::stringstream out("index out of range - ");
-      out<<"("<<x1<<","<<x2<<","<<x3<<") not in ("<<nx1<<","<<nx2<<","<<nx3<<")";
-      return out.str();
-   }
-   /*=======================================================================*/
-
-protected:
-   size_type    nx1;
-   size_type    nx2;
-   size_type    nx3;
-   indexer_type indexer;
-   std::vector< value_type > data;
-
-};
-
-#endif //CBARRAY3D_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef CBARRAY3D_H
+#define CBARRAY3D_H
+
+//////////////////////////////////////////////////////////////////////////
+// 3D Array
+// die Daten werden in einem Vector gehalten
+//
+// Ver 1.2
+// Nov. 2003 muffmolch@gmx.de
+// Ver 1.3
+// Aug. 2006 - Kosmetik
+// Ver 1.4
+// Sep. 2006 - indexer eingefuehrt
+// Ver 1.5
+// Jul. 2006 - size_t + range check bei getIndex
+// Ver 1.2
+// Mrz. 2008 - typedefs, new index checks, NO_CB_RANGECHECK, no base class
+//             assigmetcomparison between Matrices with different value_type and/or index-class
+// Oct. 2008 - +isEmpty()
+//
+// Rangecheck aktiv, wenn:
+// -debug  : not defined "NO_CB_RANGECHECK"
+// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK"
+//////////////////////////////////////////////////////////////////////////
+
+#include <iomanip>
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbEqual.h>
+#include <algorithm>
+#include <typeinfo>
+#include "PointerDefinitions.h"
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+// IndexClasses
+
+//IndexerX3X2X1:
+//                4 5 6          10 11 12
+// Array  ebene A 1 2 3  ebene B  7  8  9 -->  vector 1 2 3 4 5 6 7 8 9 10 11 12
+//x1-reihen "liegen am stueck" im speicher
+//optimaler schleifendurchlauf
+//for(alle X3)
+//  for(alle X2)
+//    for(alle X1)
+class IndexerX3X2X1// FunctorX1SortedForX1X2Plane
+{
+public:
+   typedef size_t size_type;
+public:
+   inline std::size_t getIndex(  const size_type& x1 , const size_type& x2 , const size_type& x3
+                               , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const
+   {
+      return  nx1 * ( nx2 * x3 + x2) + x1 ;
+   }
+   inline std::size_t getStartIndexOfSortedArray(  const size_type& x1 , const size_type& x2 , const size_type& x3
+                                                 , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const
+   {
+      return  nx1 * ( nx2 * x3 + x2);
+   }
+};
+
+//IndexerX1X2X3:
+//                4 5 6          10 11 12
+// Array  ebene A 1 2 3  ebene B  7  8  9 -->
+//optimaler schleifendurchlauf
+//for(alle X1)
+//  for(alle X2)
+//    for(alle X3)
+class IndexerX1X2X3 //FunctorX3SortedForX3X2Plane
+{
+public:
+   typedef size_t size_type;
+public:
+   inline std::size_t getIndex(  const size_type& x1 , const size_type& x2 , const size_type& x3
+                               , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const
+   {
+      return  nx3 * ( nx2 * x1 + x2) + x3 ;
+   }
+   inline std::size_t getStartIndexOfSortedArray(  const size_type& x1 , const size_type& x2 , const size_type& x3
+                                                 , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const
+   {
+      return  nx3 * ( nx2 * x1 + x2);
+   }
+};
+
+//IndexerX2X1X3:
+//                4 5 6          10 11 12
+// Array  ebene A 1 2 3  ebene B  7  8  9 -->  vector 1 7 2 8 3 9 4 10 5 11 6 12
+//optimaler schleifendurchlauf
+//for(alle X2)
+//  for(alle X1)
+//    for(alle X3)
+class IndexerX2X1X3
+{
+public:
+   typedef size_t size_type;
+public:
+   inline std::size_t getIndex(  const size_type& x1 , const size_type& x2 , const size_type& x3
+                               , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const
+   {
+      return  nx3* ( nx1 * x2 + x1) + x3 ;
+   }
+   inline std::size_t getStartIndexOfSortedArray(  const size_type& x1 , const size_type& x2 , const size_type& x3
+                                                 , const size_type& nx1, const size_type& nx2, const size_type& nx3 ) const
+   {
+      return  nx3* ( nx1 * x2 + x1);
+   }
+};
+
+
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+// CbArray3D
+template<typename T, typename IndexClass = IndexerX3X2X1>
+class CbArray3D
+{
+public:
+   typedef SPtr< CbArray3D <T,IndexClass> > CbArray3DPtr;
+
+   typedef T                                                   value_type;
+   typedef IndexClass                                          indexer_type;
+   typedef typename IndexClass::size_type                      size_type;
+   typedef typename std::vector< value_type >::reference       reference;
+   typedef typename std::vector< value_type >::const_reference const_reference;
+   typedef typename std::vector< value_type >::pointer         pointer;
+   typedef typename std::vector< value_type >::const_pointer   const_pointer;
+
+private:
+   template< typename value_type2, typename IndexClass2 > friend class CbArray3D;
+
+public:
+   /*=======================================================================*/
+   CbArray3D()
+   {
+      this->resize(0,0,0);
+   }
+   /*=======================================================================*/
+   CbArray3D(const size_type& nx1,const size_type& nx2, const size_type& nx3, const value_type& val)
+   {
+      this->resize(nx1,nx2,nx3,val);
+   }
+   /*=======================================================================*/
+    CbArray3D(const size_type& nx1,const size_type& nx2, const size_type& nx3)
+    {
+       this->resize(nx1,nx2,nx3);
+    }
+   /*=======================================================================*/
+   CbArray3D(const size_type& uniformDimensionSize /*nx1==nx2==nx3*/)
+   {
+      this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize);
+   }
+   /*=======================================================================*/
+   //übernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschließend leer, da swap verwendet wird)
+   CbArray3D(std::vector<value_type>& vec, const size_type& nx1,const size_type& nx2, const size_type& nx3)
+   {
+      assert( (nx1*nx2*nx3)==vec.size() );
+      this->data.swap(vec);
+      this->resize(nx1,nx2,nx3);
+   }
+   /*=======================================================================*/
+   CbArray3D(const CbArray3D& src)
+      :  nx1(src.nx1)
+       , nx2(src.nx2)
+       , nx3(src.nx3)
+       , data(src.data)
+   {
+   }
+   /*=======================================================================*/
+   template< typename value_type2 >
+   CbArray3D(const CbArray3D< value_type2 >& src)
+      :  nx1(src.nx1)
+       , nx2(src.nx2)
+       , nx3(src.nx3)
+   {
+      //Sourcedaten kopieren
+      this->data.resize( src.data.size() );
+      for(std::size_t i=0; i<data.size(); ++i)
+         this->data[i] = src.data[i];
+   }
+   /*=======================================================================*/
+   virtual ~CbArray3D()
+   {
+      //vector wird automatisch zerstoert
+   }
+   /*=======================================================================*/
+   CbArray3D& operator= (const CbArray3D& rhs)
+   {
+      if(this == &rhs) return *this;
+
+      this->nx1 = rhs.nx1;
+      this->nx2 = rhs.nx2;
+      this->nx3 = rhs.nx3;
+
+      //gespeicherte Datenelemente loeschen
+      //Laenge anpassen
+      this->data.resize(rhs.data.size());
+      //gespeicherte Datenelemente loeschen
+      this->data.clear();
+
+      //Sourcedaten kopieren
+      this->data = rhs.data;
+
+      return *this;
+   }
+   /*=======================================================================*/
+   //durch value_type2 kann man z.B. ein float array einer double array zuweisen!
+   template< typename value_type2, typename IndexClass2 >
+   CbArray3D& operator= (const CbArray3D< value_type2, IndexClass2 >& rhs)
+   {
+      this->nx1 = rhs.nx1;
+      this->nx2 = rhs.nx2;
+      this->nx3 = rhs.nx3;
+
+      //gespeicherte Datenelemente loeschen
+      this->data.clear();
+      //Laenge anpassen
+      this->data.resize(rhs.data.size());
+
+      //Sourcedaten kopieren (!! koennte anderen Indexer besitzen!!! -> operator() benutzen)
+      for(int x3=0; x3<this->nx3; x3++)
+         for(int x2=0; x2<this->nx2; x2++)
+            for(int x1=0; x1<this->nx1; x1++)
+               this->operator()(x1,x2,x3) = static_cast< value_type >( rhs.operator()(x1,x2,x3) );
+
+      return *this;
+   }
+   /*=======================================================================*/
+   bool operator== (const CbArray3D& rhs) const
+   {
+      if(this == &rhs) return true;
+
+      if(   this->nx1!=rhs.nx1
+         || this->nx2!=rhs.nx2
+         || this->nx3!=rhs.nx3
+         || this->data.size() != rhs.data.size() )
+      {
+         return false;
+      }
+
+      return std::equal( this->data.begin(), this->data.end(), rhs.data.begin(), UbEqual<value_type, value_type >() );
+   }
+   /*=======================================================================*/
+   template< typename value_type2, typename IndexClass2 >
+   bool operator== (const CbArray3D< value_type2, IndexClass2 >& rhs) const
+   {
+      if( this->data.size() != rhs.data.size() ) return false;
+
+      //Sourcedaten einzeln checken (!! koennte anderen Indexer besitzen!!! -> operator() benutzen)
+      for(int x3=0; x3<this->nx3; x3++)
+         for(int x2=0; x2<this->nx2; x2++)
+            for(int x1=0; x1<this->nx1; x1++)
+               if( !isUbEqual(this->operator()(x1,x2,x3), rhs.operator()(x1,x2,x3)) )
+               return false;
+
+      return true;
+   }
+   /*=======================================================================*/
+   bool operator!= (const CbArray3D& src) const
+   {
+      return !(*this==src);
+   }
+   /*=======================================================================*/
+   template< typename value_type2, typename IndexClass2 >
+   bool operator!= (const CbArray3D< value_type2, IndexClass2 >& rhs) const
+   {
+      return !(*this==rhs);
+   }
+   /*=======================================================================*/
+   reference operator() (const size_type& x1, const size_type& x2, const size_type& x3)
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2,x3) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) );
+      #endif
+
+      return this->data[ indexer.getIndex(x1,x2,x3,nx1,nx2,nx3) ];
+   }
+   /*=======================================================================*/
+   const_reference operator() (const size_type& x1, const size_type& x2, const size_type& x3)	const
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2,x3) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) );
+      #endif
+
+      return this->data[ indexer.getIndex(x1,x2,x3,nx1,nx2,nx3) ];
+   }
+   /*=======================================================================*/
+   pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2, const size_type& x3)
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2,x3) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) );
+      #endif
+
+      return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,x3,nx1,nx2,nx3)];
+   }
+   /*=======================================================================*/
+   const_pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2, const size_type& x3)  const
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2,x3) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) );
+      #endif
+
+      return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,x3,nx1,nx2,nx3)];
+   }
+   /*=======================================================================*/
+   void setObject(const size_type& x1, const size_type& x2, const size_type& x3, const value_type& value)
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2,x3) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) );
+      #endif
+
+      this->data[ indexer.getIndex(x1,x2,x3,nx1,nx2,nx3) ] = value;
+   }
+   /*=======================================================================*/
+   reference getObject(const size_type& x1, const size_type& x2, const size_type& x3)
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2,x3) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) );
+      #endif
+
+      return this->data[ indexer.getIndex(x1,x2,x3,nx1,nx2,nx3) ] ;
+   }
+   /*=======================================================================*/
+   const_reference getObject(const size_type& x1, const size_type& x2, const size_type& x3) const
+   {
+      return (*this)(x1,x2,x3);
+   }
+   /*=======================================================================*/
+   bool      isEmpty() const { return data.empty(); }
+   size_type getNX1()  const { return this->nx1;    }
+   size_type getNX2()  const { return this->nx2;    }
+   size_type getNX3()  const { return this->nx3;    }
+   /*=======================================================================*/
+   void reset(const value_type& val)
+   {
+      std::fill( this->data.begin(), this->data.end(), val );
+   }
+   /*=======================================================================*/
+   std::string toString() const
+   {
+      std::stringstream text;
+      for(size_type x1=0; x1<this->nx1; x1++)
+      {
+      	for(size_type x2=0; x2<this->nx2; x2++)
+      	{
+         	for(size_type x3=0; x3<this->nx3; x3++)
+         	{
+            	text<<(*this)(x1,x2,x3)<<", ";
+         	}
+         	text<<std::endl;
+      	}
+      	text<<std::endl<<std::endl;
+      }
+
+      return text.str();
+   }
+   /*=======================================================================*/
+   std::string getInfo() const
+   {
+      std::stringstream text;
+      text<<"CbArray3D< storageType="<<typeid(T).name()<<", indexer="<<typeid(IndexClass).name()<<" >";
+      text<<"( nx1="<<this->nx1<<", nx2="<<this->nx2<<", nx3="<<this->nx3<<")";
+      return text.str();
+   }
+   /*=======================================================================*/
+   void resize(const int& uniformDimensionSize)
+   {
+      this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize);
+   }
+   /*=======================================================================*/
+   void resize(const size_type& nx1,const size_type& nx2, const size_type& nx3)
+   {
+      this->nx1 = nx1;
+      this->nx2 = nx2;
+      this->nx3 = nx3;
+      this->data.resize(nx1*nx2*nx3);
+   }
+   /*=======================================================================*/
+   void resize(const size_type& nx1,const size_type& nx2, const size_type& nx3,const value_type& val)
+   {
+      this->nx1 = nx1;
+      this->nx2 = nx2;
+      this->nx3 = nx3;
+      this->data.resize(nx1*nx2*nx3,val);
+   }
+   /*=======================================================================*/
+   void clear()
+   {
+      this->nx1 = 0;
+      this->nx2 = 0;
+      this->nx3 = 0;
+      this->data.clear();
+   }
+   /*=======================================================================*/
+   std::vector< value_type >& getDataVector() { return this->data; }
+   /*=======================================================================*/
+   const std::vector< value_type >& getDataVector() const { return this->data; }
+   /*=======================================================================*/
+   inline std::size_t getDataVectorIndex(const size_type& x1, const size_type& x2, const size_type& x3) const
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2,x3) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3)) );
+      #endif
+
+      return indexer.getIndex(x1,x2,x3,nx1,nx2,nx3);
+   }
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void serialize(Archive & ar, const unsigned int version)
+   {
+      ar & nx1;
+      ar & nx2;
+      ar & nx3;
+      ar & data;
+   }
+#endif //CAB_RCF
+
+
+   /*=======================================================================*/
+   //success -> true
+   //else    -> false
+   inline bool indicesInRange(const size_type& x1, const size_type& x2, const size_type& x3) const
+   {
+      if(   x1 < 0 || x1 >= this->nx1
+         || x2 < 0 || x2 >= this->nx2
+         || x3 < 0 || x3 >= this->nx3 )
+      {
+         return false;
+      }
+      return true;
+   }
+protected:
+   /*=======================================================================*/
+   std::string getExceptionErrorString(const size_type& x1, const size_type& x2, const size_type& x3) const
+   {
+      std::stringstream out("index out of range - ");
+      out<<"("<<x1<<","<<x2<<","<<x3<<") not in ("<<nx1<<","<<nx2<<","<<nx3<<")";
+      return out.str();
+   }
+   /*=======================================================================*/
+
+protected:
+   size_type    nx1;
+   size_type    nx2;
+   size_type    nx3;
+   indexer_type indexer;
+   std::vector< value_type > data;
+
+};
+
+#endif //CBARRAY3D_H
diff --git a/source/ThirdParty/Library/basics/container/CbArray4D.h b/source/VirtualFluidsBasic/basics/container/CbArray4D.h
similarity index 97%
rename from source/ThirdParty/Library/basics/container/CbArray4D.h
rename to source/VirtualFluidsBasic/basics/container/CbArray4D.h
index 97a99a13cc78b819c671e0bf6b712be9fbd27684..372f7fd47b5551c15d6a764b38664e74d20a4d21 100644
--- a/source/ThirdParty/Library/basics/container/CbArray4D.h
+++ b/source/VirtualFluidsBasic/basics/container/CbArray4D.h
@@ -1,450 +1,450 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef CBARRAY4D_H
-#define CBARRAY4D_H
-
-//////////////////////////////////////////////////////////////////////////
-// 4D Array
-// die Daten werden in einem Vector gehalten
-//
-// Ver 1.0
-// Sept. 2006 muffmolch@gmx.de
-// Ver 1.1
-// Jul. 2006 - size_t + range check bei getIndex
-// Ver 1.2
-// Mrz. 2008 - typedefs, new index checks, NO_CB_RANGECHECK, no base class
-//             assigmetcomparison between Matrices with different value_type and/or index-class
-// Oct. 2008 - +isEmpty()
-//
-// Rangecheck aktiv, wenn:
-// -debug  : not defined "NO_CB_RANGECHECK"
-// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK"
-//////////////////////////////////////////////////////////////////////////
-
-#include <iomanip>
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbEqual.h>
-#include <algorithm>
-#include <typeinfo>
-#include "PointerDefinitions.h"
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-// IndexClasses
-
-//IndexerX1X2X3X4:
-//x4-reihen "liegen am stueck" im speicher
-//optimaler schleifendurchlauf
-//for(alle X1)
-//  for(alle X2)
-//    for(alle X3)
-//      for(alle X4)
-class IndexerX1X2X3X4
-{
-public:
-   typedef int size_type;
-public:
-   inline std::size_t getIndex( const size_type& x1 , const size_type& x2 , const size_type& x3 , const size_type& x4
-                            , const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4 )  const
-   {
-      return nx4*(nx3*(nx2*x1+ x2)+x3)+x4 ;
-   }
-   inline std::size_t getStartIndexOfSortedArray(  const size_type& x1 , const size_type& x2 , const size_type& x3 , const size_type& x4
-                                               , const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4 )  const
-   {
-      return  nx4*(nx3*(nx2*x1+ x2)+x3);
-   }
-};
-//////////////////////////////////////////////////////////////////////////
-// IndexClasses
-
-//IndexerX4X3X2X1:
-//x1-reihen "liegen am stueck" im speicher
-//optimaler schleifendurchlauf
-//for(alle X4)
-//  for(alle X3)
-//    for(alle X2)
-//      for(alle X1)
-class IndexerX4X3X2X1
-{
-public:
-   typedef size_t size_type;
-public:
-   inline std::size_t getIndex( const size_type& x1 , const size_type& x2 , const size_type& x3 , const size_type& x4
-      , const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4 )  const
-   {
-      return nx1*(nx2*(nx3*x4+ x3)+x2)+x1;
-   }
-   inline std::size_t getStartIndexOfSortedArray(  const size_type& x1 , const size_type& x2 , const size_type& x3 , const size_type& x4
-      , const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4 )  const
-   {
-      return  nx1*(nx2*(nx3*x4+ x3)+x2);
-   }
-};
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-// CbArray4D
-template<typename T, typename IndexClass = IndexerX4X3X2X1>
-class CbArray4D
-{
-public:
-   typedef SPtr< CbArray4D <T,IndexClass> > CbArray4DPtr;
-
-   typedef T                                                   value_type;
-   typedef IndexClass                                          indexer_type;
-   typedef typename IndexClass::size_type                      size_type;
-   typedef typename std::vector< value_type >::reference       reference;
-   typedef typename std::vector< value_type >::const_reference const_reference;
-   typedef typename std::vector< value_type >::pointer         pointer;
-   typedef typename std::vector< value_type >::const_pointer   const_pointer;
-
-private:
-   template< typename value_type2, typename IndexClass2 > friend class CbArray4D;
-
-public:
-   /*=======================================================================*/
-   CbArray4D()
-   {
-      this->resize(0,0,0,0);
-   }
-   /*=======================================================================*/
-   CbArray4D(const size_type& nx1,const size_type& nx2, const size_type& nx3, const size_type& nx4)
-   {
-      this->resize(nx1,nx2,nx3,nx4);
-   }
-   /*=======================================================================*/
-   CbArray4D(const size_type& nx1,const size_type& nx2, const size_type& nx3, const size_type& nx4, const value_type& val)
-   {
-      this->resize(nx1,nx2,nx3,nx4,val);
-   }
-   /*=======================================================================*/
-   CbArray4D(const size_type& uniformDimensionSize /*nx1=nx2=nx3=nx4*/)
-   {
-      this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize,uniformDimensionSize);
-   }
-   /*=======================================================================*/
-   //ubernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschließend leer, da swap verwendet wird)
-   CbArray4D(std::vector<value_type>& vec, const size_type& nx1,const size_type& nx2, const size_type& nx3, const size_type& nx4)
-   {
-      assert( (nx1*nx2*nx3*nx4)==vec.size() );
-      this->data.swap(vec);
-      this->resize(nx1,nx2,nx3,nx4);
-   }
-   /*=======================================================================*/
-   CbArray4D(const CbArray4D& src)
-      :  nx1(src.nx1)
-       , nx2(src.nx2)
-       , nx3(src.nx3)
-       , nx4(src.nx4)
-       , data(src.data)
-   {
-   }
-   /*=======================================================================*/
-   template< typename value_type2 >
-   CbArray4D(const CbArray4D< value_type2 >& src)
-      :  nx1(src.nx1)
-       , nx2(src.nx2)
-       , nx3(src.nx3)
-       , nx4(src.nx4)
-   {
-      //Sourcedaten kopieren
-      this->data.resize( src.data.size() );
-      for(std::size_t i=0; i<data.size(); ++i)
-         this->data[i] = src.data[i];
-   }
-   /*=======================================================================*/
-   virtual ~CbArray4D()
-   {
-      //vector wird automatisch zerstoert
-   }
-   /*=======================================================================*/
-   CbArray4D& operator= (const CbArray4D& rhs)
-   {
-      if(this == &rhs) return *this;
-
-      this->nx1 = rhs.nx1;
-      this->nx2 = rhs.nx2;
-      this->nx3 = rhs.nx3;
-      this->nx4 = rhs.nx4;
-
-      //gespeicherte Datenelemente loeschen
-      //Laenge anpassen
-      this->data.resize(rhs.data.size());
-      //gespeicherte Datenelemente loeschen
-      this->data.clear();
-
-      //Sourcedaten kopieren
-      this->data = rhs.data;
-
-      return *this;
-   }
-   /*=======================================================================*/
-   //durch value_type2 kann man z.B. ein float Array einem double Array zuweisen!
-   template< typename value_type2, typename IndexClass2 >
-   CbArray4D& operator= (const CbArray4D< value_type2, IndexClass2 >& rhs)
-   {
-      this->nx1 = rhs.nx1;
-      this->nx2 = rhs.nx2;
-      this->nx3 = rhs.nx3;
-      this->nx4 = rhs.nx4;
-
-      //gespeicherte Datenelemente loeschen
-      this->data.clear();
-      //Laenge anpassen
-      this->data.resize(rhs.data.size());
-
-      //Sourcedaten kopieren (!! koennte anderen Indexer besitzen!!! -> operator() benutzen)
-      for(int x1=0; x1<this->nx1; x1++)
-         for(int x2=0; x2<this->nx2; x2++)
-            for(int x3=0; x3<this->nx3; x3++)
-               for(int x4=0; x4<this->nx4; x4++)
-                  this->operator()(x1,x2,x3,x4) = static_cast< value_type >( rhs.operator()(x1,x2,x3,x4));
-
-      return *this;
-   }
-   /*=======================================================================*/
-   bool operator== (const CbArray4D& rhs) const
-   {
-      if( this == &rhs ) return true;
-
-      if(   this->nx1!=rhs.nx1
-         || this->nx2!=rhs.nx2
-         || this->nx3!=rhs.nx3
-         || this->nx4!=rhs.nx4
-         || this->data.size() != rhs.data.size() )
-      {
-         return false;
-      }
-
-      return std::equal( this->data.begin(), this->data.end(), rhs.data.begin(), UbEqual<value_type, value_type >() );
-   }
-   /*=======================================================================*/
-   template< typename value_type2, typename IndexClass2 >
-   bool operator== (const CbArray4D< value_type2, IndexClass2 >& rhs) const
-   {
-      if( this->data.size() != rhs.data.size() ) return false;
-
-      //Sourcedaten einzeln checken (!! koennte anderen Indexer besitzen!!! -> operator() benutzen)
-      for(int x4=0; x4<this->nx4; x4++)
-         for(int x3=0; x3<this->nx3; x3++)
-            for(int x2=0; x2<this->nx2; x2++)
-             for(int x1=0; x1<this->nx1; x1++)
-               if( !isUbEqual(this->operator()(x1,x2,x3,x4), rhs.operator()(x1,x2,x3,x4)) )
-                  return false;
-
-      return true;
-   }
-   /*=======================================================================*/
-   bool operator!= (const CbArray4D& rhs) const
-   {
-      return !(*this==rhs);
-   }
-   /*=======================================================================*/
-   template< typename value_type2, typename IndexClass2 >
-   bool operator!= (const CbArray4D< value_type2, IndexClass2 >& rhs) const
-   {
-      return !(*this==rhs);
-   }
-   /*=======================================================================*/
-   reference operator() (const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4)
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2,x3,x4) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
-      #endif
-
-      return this->data[indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4)];
-   }
-   /*=======================================================================*/
-   const_reference operator() (const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4)	const
-   {
-      #ifdef CbArray4D_RANGECHECKING
-         if( !this->indicesInRange(x1,x2,x3,x4) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
-      #endif
-
-      return this->data[indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4)];
-   }
-   /*=======================================================================*/
-   pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4)
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2,x3,x4) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
-      #endif
-
-      return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,x3,x4,nx1,nx2,nx3,nx4)];
-   }
-   /*=======================================================================*/
-   const_pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4)  const
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2,x3,x4) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
-      #endif
-
-      return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,x3,x4,nx1,nx2,nx3,nx4)];
-   }
-   /*=======================================================================*/
-   void setObject(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4, const value_type& value)
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2,x3,x4) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
-      #endif
-
-      this->data[indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4)] = value;
-   }
-   /*=======================================================================*/
-   reference getObject(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4)
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2,x3,x4) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
-      #endif
-
-      return this->data[indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4)];
-   }
-   /*=======================================================================*/
-   const_reference getObject(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) const
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2,x3,x4) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
-      #endif
-      return (*this)(x1,x2,x3,x4,nx1,nx2,nx3,nx4);
-   }
-   /*=======================================================================*/
-   bool      isEmpty() const { return data.empty(); }
-   size_type getNX1()  const { return this->nx1;    }
-   size_type getNX2()  const { return this->nx2;    }
-   size_type getNX3()  const { return this->nx3;    }
-   size_type getNX4()  const { return this->nx4;    }
-   /*=======================================================================*/
-   void reset(const value_type& val)
-   {
-      std::fill( this->data.begin(), this->data.end(), val );
-   }
-   /*=======================================================================*/
-   std::string toString() const
-   {
-      std::stringstream text;
-      text<<std::setprecision(19);
-      for(size_type x1=0; x1<this->nx1; x1++)
-      {
-      	for(size_type x2=0; x2<this->nx2; x2++)
-      	{
-         	for(size_type x3=0; x3<this->nx3; x3++)
-         	{
-               for(size_type x4=0; x4<this->nx4; x4++)
-               {
-                 	text<<(*this)(x1,x2,x3,x4)<<", ";
-               }
-               text<<std::endl;
-         	}
-         	text<<std::endl;
-      	}
-      	text<<std::endl<<std::endl;
-      }
-
-      return text.str();
-   }
-   /*=======================================================================*/
-   std::string getInfo() const
-   {
-      std::stringstream text;
-      text<<"CbArray4D< storageType="<<typeid(T).name()<<", indexer="<<typeid(IndexClass).name()<<" >";
-      text<<"( nx1="<<this->nx1<<", nx2="<<this->nx2<<", nx3="<<this->nx3<<", nx4="<<this->nx4<<")";
-      return text.str();
-   }
-   /*=======================================================================*/
-   void resize(const size_type& uniformDimensionSize) { this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize); }
-   /*=======================================================================*/
-   void resize(const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4)
-   {
-      this->nx1 = nx1;
-      this->nx2 = nx2;
-      this->nx3 = nx3;
-      this->nx4 = nx4;
-      this->data.resize(nx1*nx2*nx3*nx4);
-   }
-   /*=======================================================================*/
-   void resize(const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4, const value_type& val)
-   {
-      this->nx1 = nx1;
-      this->nx2 = nx2;
-      this->nx3 = nx3;
-      this->nx4 = nx4;
-      this->data.resize(nx1*nx2*nx3*nx4,val);
-   }
-   /*=======================================================================*/
-   std::vector< value_type >& getDataVector() { return this->data; }
-   /*=======================================================================*/
-   const std::vector< value_type >& getDataVector() const { return this->data; }
-   /*=======================================================================*/
-   inline std::size_t getDataVectorIndex(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) const
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if( !this->indicesInRange(x1,x2,x3,x4) )
-            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
-      #endif
-
-      return indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4);
-   }
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void serialize(Archive & ar, const unsigned int version)
-   {
-      ar & nx1;
-      ar & nx2;
-      ar & nx3;
-      ar & nx4;
-      ar & data;
-   }
-#endif //CAB_RCF
-
-protected:
-   /*=======================================================================*/
-   //success -> true
-   //else    -> false
-   inline bool indicesInRange(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) const
-   {
-      if(   x1 < 0 || x1 >= this->nx1
-         || x2 < 0 || x2 >= this->nx2
-         || x3 < 0 || x3 >= this->nx3
-         || x4 < 0 || x4 >= this->nx4 )
-      {
-         return false;
-      }
-      return true;
-   }
-   /*=======================================================================*/
-   std::string getExceptionErrorString(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) const
-   {
-      std::stringstream out("index out of range - ");
-      out<<"("<<x1<<","<<x2<<","<<x3<<","<<x4<<") not in ("<<nx1<<","<<nx2<<","<<nx3<<","<<nx4<<")";
-      return out.str();
-   }
-   /*=======================================================================*/
-
-protected:
-   size_type    nx1;
-   size_type    nx2;
-   size_type    nx3;
-   size_type    nx4;
-   indexer_type indexer;
-   std::vector< value_type > data;
-
-};
-
-#endif //CBARRAY4D_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef CBARRAY4D_H
+#define CBARRAY4D_H
+
+//////////////////////////////////////////////////////////////////////////
+// 4D Array
+// die Daten werden in einem Vector gehalten
+//
+// Ver 1.0
+// Sept. 2006 muffmolch@gmx.de
+// Ver 1.1
+// Jul. 2006 - size_t + range check bei getIndex
+// Ver 1.2
+// Mrz. 2008 - typedefs, new index checks, NO_CB_RANGECHECK, no base class
+//             assigmetcomparison between Matrices with different value_type and/or index-class
+// Oct. 2008 - +isEmpty()
+//
+// Rangecheck aktiv, wenn:
+// -debug  : not defined "NO_CB_RANGECHECK"
+// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK"
+//////////////////////////////////////////////////////////////////////////
+
+#include <iomanip>
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbEqual.h>
+#include <algorithm>
+#include <typeinfo>
+#include "PointerDefinitions.h"
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+// IndexClasses
+
+//IndexerX1X2X3X4:
+//x4-reihen "liegen am stueck" im speicher
+//optimaler schleifendurchlauf
+//for(alle X1)
+//  for(alle X2)
+//    for(alle X3)
+//      for(alle X4)
+class IndexerX1X2X3X4
+{
+public:
+   typedef int size_type;
+public:
+   inline std::size_t getIndex( const size_type& x1 , const size_type& x2 , const size_type& x3 , const size_type& x4
+                            , const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4 )  const
+   {
+      return nx4*(nx3*(nx2*x1+ x2)+x3)+x4 ;
+   }
+   inline std::size_t getStartIndexOfSortedArray(  const size_type& x1 , const size_type& x2 , const size_type& x3 , const size_type& x4
+                                               , const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4 )  const
+   {
+      return  nx4*(nx3*(nx2*x1+ x2)+x3);
+   }
+};
+//////////////////////////////////////////////////////////////////////////
+// IndexClasses
+
+//IndexerX4X3X2X1:
+//x1-reihen "liegen am stueck" im speicher
+//optimaler schleifendurchlauf
+//for(alle X4)
+//  for(alle X3)
+//    for(alle X2)
+//      for(alle X1)
+class IndexerX4X3X2X1
+{
+public:
+   typedef size_t size_type;
+public:
+   inline std::size_t getIndex( const size_type& x1 , const size_type& x2 , const size_type& x3 , const size_type& x4
+      , const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4 )  const
+   {
+      return nx1*(nx2*(nx3*x4+ x3)+x2)+x1;
+   }
+   inline std::size_t getStartIndexOfSortedArray(  const size_type& x1 , const size_type& x2 , const size_type& x3 , const size_type& x4
+      , const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4 )  const
+   {
+      return  nx1*(nx2*(nx3*x4+ x3)+x2);
+   }
+};
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+// CbArray4D
+template<typename T, typename IndexClass = IndexerX4X3X2X1>
+class CbArray4D
+{
+public:
+   typedef SPtr< CbArray4D <T,IndexClass> > CbArray4DPtr;
+
+   typedef T                                                   value_type;
+   typedef IndexClass                                          indexer_type;
+   typedef typename IndexClass::size_type                      size_type;
+   typedef typename std::vector< value_type >::reference       reference;
+   typedef typename std::vector< value_type >::const_reference const_reference;
+   typedef typename std::vector< value_type >::pointer         pointer;
+   typedef typename std::vector< value_type >::const_pointer   const_pointer;
+
+private:
+   template< typename value_type2, typename IndexClass2 > friend class CbArray4D;
+
+public:
+   /*=======================================================================*/
+   CbArray4D()
+   {
+      this->resize(0,0,0,0);
+   }
+   /*=======================================================================*/
+   CbArray4D(const size_type& nx1,const size_type& nx2, const size_type& nx3, const size_type& nx4)
+   {
+      this->resize(nx1,nx2,nx3,nx4);
+   }
+   /*=======================================================================*/
+   CbArray4D(const size_type& nx1,const size_type& nx2, const size_type& nx3, const size_type& nx4, const value_type& val)
+   {
+      this->resize(nx1,nx2,nx3,nx4,val);
+   }
+   /*=======================================================================*/
+   CbArray4D(const size_type& uniformDimensionSize /*nx1=nx2=nx3=nx4*/)
+   {
+      this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize,uniformDimensionSize);
+   }
+   /*=======================================================================*/
+   //ubernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschließend leer, da swap verwendet wird)
+   CbArray4D(std::vector<value_type>& vec, const size_type& nx1,const size_type& nx2, const size_type& nx3, const size_type& nx4)
+   {
+      assert( (nx1*nx2*nx3*nx4)==vec.size() );
+      this->data.swap(vec);
+      this->resize(nx1,nx2,nx3,nx4);
+   }
+   /*=======================================================================*/
+   CbArray4D(const CbArray4D& src)
+      :  nx1(src.nx1)
+       , nx2(src.nx2)
+       , nx3(src.nx3)
+       , nx4(src.nx4)
+       , data(src.data)
+   {
+   }
+   /*=======================================================================*/
+   template< typename value_type2 >
+   CbArray4D(const CbArray4D< value_type2 >& src)
+      :  nx1(src.nx1)
+       , nx2(src.nx2)
+       , nx3(src.nx3)
+       , nx4(src.nx4)
+   {
+      //Sourcedaten kopieren
+      this->data.resize( src.data.size() );
+      for(std::size_t i=0; i<data.size(); ++i)
+         this->data[i] = src.data[i];
+   }
+   /*=======================================================================*/
+   virtual ~CbArray4D()
+   {
+      //vector wird automatisch zerstoert
+   }
+   /*=======================================================================*/
+   CbArray4D& operator= (const CbArray4D& rhs)
+   {
+      if(this == &rhs) return *this;
+
+      this->nx1 = rhs.nx1;
+      this->nx2 = rhs.nx2;
+      this->nx3 = rhs.nx3;
+      this->nx4 = rhs.nx4;
+
+      //gespeicherte Datenelemente loeschen
+      //Laenge anpassen
+      this->data.resize(rhs.data.size());
+      //gespeicherte Datenelemente loeschen
+      this->data.clear();
+
+      //Sourcedaten kopieren
+      this->data = rhs.data;
+
+      return *this;
+   }
+   /*=======================================================================*/
+   //durch value_type2 kann man z.B. ein float Array einem double Array zuweisen!
+   template< typename value_type2, typename IndexClass2 >
+   CbArray4D& operator= (const CbArray4D< value_type2, IndexClass2 >& rhs)
+   {
+      this->nx1 = rhs.nx1;
+      this->nx2 = rhs.nx2;
+      this->nx3 = rhs.nx3;
+      this->nx4 = rhs.nx4;
+
+      //gespeicherte Datenelemente loeschen
+      this->data.clear();
+      //Laenge anpassen
+      this->data.resize(rhs.data.size());
+
+      //Sourcedaten kopieren (!! koennte anderen Indexer besitzen!!! -> operator() benutzen)
+      for(int x1=0; x1<this->nx1; x1++)
+         for(int x2=0; x2<this->nx2; x2++)
+            for(int x3=0; x3<this->nx3; x3++)
+               for(int x4=0; x4<this->nx4; x4++)
+                  this->operator()(x1,x2,x3,x4) = static_cast< value_type >( rhs.operator()(x1,x2,x3,x4));
+
+      return *this;
+   }
+   /*=======================================================================*/
+   bool operator== (const CbArray4D& rhs) const
+   {
+      if( this == &rhs ) return true;
+
+      if(   this->nx1!=rhs.nx1
+         || this->nx2!=rhs.nx2
+         || this->nx3!=rhs.nx3
+         || this->nx4!=rhs.nx4
+         || this->data.size() != rhs.data.size() )
+      {
+         return false;
+      }
+
+      return std::equal( this->data.begin(), this->data.end(), rhs.data.begin(), UbEqual<value_type, value_type >() );
+   }
+   /*=======================================================================*/
+   template< typename value_type2, typename IndexClass2 >
+   bool operator== (const CbArray4D< value_type2, IndexClass2 >& rhs) const
+   {
+      if( this->data.size() != rhs.data.size() ) return false;
+
+      //Sourcedaten einzeln checken (!! koennte anderen Indexer besitzen!!! -> operator() benutzen)
+      for(int x4=0; x4<this->nx4; x4++)
+         for(int x3=0; x3<this->nx3; x3++)
+            for(int x2=0; x2<this->nx2; x2++)
+             for(int x1=0; x1<this->nx1; x1++)
+               if( !isUbEqual(this->operator()(x1,x2,x3,x4), rhs.operator()(x1,x2,x3,x4)) )
+                  return false;
+
+      return true;
+   }
+   /*=======================================================================*/
+   bool operator!= (const CbArray4D& rhs) const
+   {
+      return !(*this==rhs);
+   }
+   /*=======================================================================*/
+   template< typename value_type2, typename IndexClass2 >
+   bool operator!= (const CbArray4D< value_type2, IndexClass2 >& rhs) const
+   {
+      return !(*this==rhs);
+   }
+   /*=======================================================================*/
+   reference operator() (const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4)
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2,x3,x4) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
+      #endif
+
+      return this->data[indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4)];
+   }
+   /*=======================================================================*/
+   const_reference operator() (const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4)	const
+   {
+      #ifdef CbArray4D_RANGECHECKING
+         if( !this->indicesInRange(x1,x2,x3,x4) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
+      #endif
+
+      return this->data[indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4)];
+   }
+   /*=======================================================================*/
+   pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4)
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2,x3,x4) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
+      #endif
+
+      return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,x3,x4,nx1,nx2,nx3,nx4)];
+   }
+   /*=======================================================================*/
+   const_pointer getStartAdressOfSortedArray(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4)  const
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2,x3,x4) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
+      #endif
+
+      return &this->data[indexer.getStartIndexOfSortedArray(x1,x2,x3,x4,nx1,nx2,nx3,nx4)];
+   }
+   /*=======================================================================*/
+   void setObject(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4, const value_type& value)
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2,x3,x4) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
+      #endif
+
+      this->data[indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4)] = value;
+   }
+   /*=======================================================================*/
+   reference getObject(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4)
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2,x3,x4) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
+      #endif
+
+      return this->data[indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4)];
+   }
+   /*=======================================================================*/
+   const_reference getObject(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) const
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2,x3,x4) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
+      #endif
+      return (*this)(x1,x2,x3,x4,nx1,nx2,nx3,nx4);
+   }
+   /*=======================================================================*/
+   bool      isEmpty() const { return data.empty(); }
+   size_type getNX1()  const { return this->nx1;    }
+   size_type getNX2()  const { return this->nx2;    }
+   size_type getNX3()  const { return this->nx3;    }
+   size_type getNX4()  const { return this->nx4;    }
+   /*=======================================================================*/
+   void reset(const value_type& val)
+   {
+      std::fill( this->data.begin(), this->data.end(), val );
+   }
+   /*=======================================================================*/
+   std::string toString() const
+   {
+      std::stringstream text;
+      text<<std::setprecision(19);
+      for(size_type x1=0; x1<this->nx1; x1++)
+      {
+      	for(size_type x2=0; x2<this->nx2; x2++)
+      	{
+         	for(size_type x3=0; x3<this->nx3; x3++)
+         	{
+               for(size_type x4=0; x4<this->nx4; x4++)
+               {
+                 	text<<(*this)(x1,x2,x3,x4)<<", ";
+               }
+               text<<std::endl;
+         	}
+         	text<<std::endl;
+      	}
+      	text<<std::endl<<std::endl;
+      }
+
+      return text.str();
+   }
+   /*=======================================================================*/
+   std::string getInfo() const
+   {
+      std::stringstream text;
+      text<<"CbArray4D< storageType="<<typeid(T).name()<<", indexer="<<typeid(IndexClass).name()<<" >";
+      text<<"( nx1="<<this->nx1<<", nx2="<<this->nx2<<", nx3="<<this->nx3<<", nx4="<<this->nx4<<")";
+      return text.str();
+   }
+   /*=======================================================================*/
+   void resize(const size_type& uniformDimensionSize) { this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize); }
+   /*=======================================================================*/
+   void resize(const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4)
+   {
+      this->nx1 = nx1;
+      this->nx2 = nx2;
+      this->nx3 = nx3;
+      this->nx4 = nx4;
+      this->data.resize(nx1*nx2*nx3*nx4);
+   }
+   /*=======================================================================*/
+   void resize(const size_type& nx1, const size_type& nx2, const size_type& nx3, const size_type& nx4, const value_type& val)
+   {
+      this->nx1 = nx1;
+      this->nx2 = nx2;
+      this->nx3 = nx3;
+      this->nx4 = nx4;
+      this->data.resize(nx1*nx2*nx3*nx4,val);
+   }
+   /*=======================================================================*/
+   std::vector< value_type >& getDataVector() { return this->data; }
+   /*=======================================================================*/
+   const std::vector< value_type >& getDataVector() const { return this->data; }
+   /*=======================================================================*/
+   inline std::size_t getDataVectorIndex(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) const
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if( !this->indicesInRange(x1,x2,x3,x4) )
+            UB_THROW( UbException(UB_EXARGS,getExceptionErrorString(x1,x2,x3,x4)) );
+      #endif
+
+      return indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4);
+   }
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void serialize(Archive & ar, const unsigned int version)
+   {
+      ar & nx1;
+      ar & nx2;
+      ar & nx3;
+      ar & nx4;
+      ar & data;
+   }
+#endif //CAB_RCF
+
+protected:
+   /*=======================================================================*/
+   //success -> true
+   //else    -> false
+   inline bool indicesInRange(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) const
+   {
+      if(   x1 < 0 || x1 >= this->nx1
+         || x2 < 0 || x2 >= this->nx2
+         || x3 < 0 || x3 >= this->nx3
+         || x4 < 0 || x4 >= this->nx4 )
+      {
+         return false;
+      }
+      return true;
+   }
+   /*=======================================================================*/
+   std::string getExceptionErrorString(const size_type& x1, const size_type& x2, const size_type& x3, const size_type& x4) const
+   {
+      std::stringstream out("index out of range - ");
+      out<<"("<<x1<<","<<x2<<","<<x3<<","<<x4<<") not in ("<<nx1<<","<<nx2<<","<<nx3<<","<<nx4<<")";
+      return out.str();
+   }
+   /*=======================================================================*/
+
+protected:
+   size_type    nx1;
+   size_type    nx2;
+   size_type    nx3;
+   size_type    nx4;
+   indexer_type indexer;
+   std::vector< value_type > data;
+
+};
+
+#endif //CBARRAY4D_H
diff --git a/source/ThirdParty/Library/basics/container/CbVector.h b/source/VirtualFluidsBasic/basics/container/CbVector.h
similarity index 97%
rename from source/ThirdParty/Library/basics/container/CbVector.h
rename to source/VirtualFluidsBasic/basics/container/CbVector.h
index ef2a772cb5c1ff87192e8c381f0d9754b08f8117..e0db945d3e50f56752f47426d5f4a11c225197e6 100644
--- a/source/ThirdParty/Library/basics/container/CbVector.h
+++ b/source/VirtualFluidsBasic/basics/container/CbVector.h
@@ -1,365 +1,365 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef CBVECTOR_H
-#define CBVECTOR_H
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-   #include <RCF/ByteBuffer.hpp>
-#endif
-
-#include <vector>
-#include <algorithm> //for std::swap
-#include <typeinfo>  //for typeid
-#include <PointerDefinitions.h>    //for memcopy
-
-#include <basics/utilities/UbSystem.h>
-#include <basics/utilities/UbEqual.h>
-
-/*=========================================================================*/
-/*  CbVector                                                               */
-/*                                                                         */
-/**
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 08.11.07
-@version 1.1 - 09.02.08
-@version 1.2 - 23.04.08 - swap added
-@version 1.3 - 08.05.08 - boosting up serialization performance!
-*/
-
-/*
-usage: ...
-Da es Voraussetzun bei doeser Klasse war, dass lediglich der Typ als
-template-parameter miteingeht, muss der allcocator eine abstrakte klasse sein
-ansonsten hätte sich hier der allokator als zweites argument
-wie beim STL vector angeboten, womit man auch keinen pointer speichern muesste.
-Im letzteren Fall würde aber jeweils ein bestimmeter Klassentyp in Abhaengigkeit
-des allokators zur compilezeit erzeugt. Problem wir wollen ein und denselben
-typ benutzen und nur der allokator innerhalb der klasse soll sich unterscheiden
-//
-// Rangecheck aktiv, wenn:
-// -debug  : not defined "NO_CB_RANGECHECK"
-// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK"
-*/
-
-template< typename T > class CbVectorAllocator;
-template< typename T > class CbVectorAllocatorStd;
-
-//////////////////////////////////////////////////////////////////////////
-template< typename T >
-class CbVector
-{
-public:
-   typedef T           value_type;
-   typedef value_type* pointer;
-   typedef std::size_t size_type;
-
-   friend class CbVectorAllocator<value_type>; //um auf ptrData und dataSize zugreifen zu koennen!
-
-public:
-   /*==========================================================*/
-   CbVector( CbVectorAllocator<value_type>* const& allocator = new CbVectorAllocatorStd<value_type> )
-      :  ptrData(NULL)
-       , dataSize(0)
-       , allocator(allocator)
-   {
-      this->allocator->alloc(*this,0,value_type());
-   }
-   /*==========================================================*/
-   CbVector( const size_type size, CbVectorAllocator<value_type>* const& allocator = new CbVectorAllocatorStd<value_type>, const value_type& value=value_type() )
-      :  ptrData(NULL)
-       , dataSize(0)
-       , allocator(allocator)
-   {
-      this->allocator->alloc(*this,size,value);
-   }
-   /*==========================================================*/
-   virtual ~CbVector()
-   {
-      if(allocator)
-      {
-         this->allocator->dealloc(*this);
-         delete allocator;
-         allocator=NULL;
-      }
-   }
-   /*=======================================================================*/
-   CbVector& operator= (const CbVector& src)
-   {
-      if(this == &src) return *this;
-
-      //gespeicherte Datenelemente loeschen
-      //Laenge anpassen
-      this->allocator->resize(*this, src.size());
-
-      //gespeicherte Datenelemente kopieren
-      if( !src.empty() ) 
-      {
-         memcpy( (char*)ptrData, (char*)&src[0], src.size()*sizeof(value_type) ); 
-         //for(size_type i=0; i<src.size(); i++)
-         //   (*this)[i] = src[i];
-      }
-
-      return *this;
-   }
-   /*=======================================================================*/
-   CbVector& operator= (const std::vector< value_type >& src)
-   {
-      //gespeicherte Datenelemente loeschen
-      //Laenge anpassen
-      this->allocator->resize(*this, src.size());
-
-      //gespeicherte Datenelemente kopieren
-      if( !src.empty() ) 
-      {
-         memcpy( (char*)ptrData, (char*)&src[0], src.size()*sizeof(value_type) ); 
-         //for(size_type i=0; i<src.size(); i++)
-         //   (*this)[i] = src[i];
-      }
-      
-      return *this;
-   }
-   /*=======================================================================*/
-   bool operator== (const CbVector& rhs) const
-   {
-      if( this           == &rhs         ) return true;
-      if( this->dataSize != rhs.dataSize ) return false;
-
-      for(size_type i=0; i<rhs.size(); i++)
-         if( !isUbEqual( this->operator[](i), rhs.operator[](i) ) )
-            return false;
-
-      return true;
-   }
-   /*==========================================================*/
-   void setAllocator( CbVectorAllocator<value_type>* const& allocator )
-   {
-      if(this->allocator)
-      {
-         if(this->allocator==allocator) return;
-         this->allocator->dealloc(*this);
-         delete this->allocator;
-      }
-      this->allocator = allocator;
-      this->allocator->alloc(*this,0);
-   }
-   /*==========================================================*/
-   size_type size() const { return dataSize; }
-   /*==========================================================*/
-   bool empty() const { return dataSize==0; }
-   /*==========================================================*/
-   bool resize(const size_type& dataSize)
-   {
-      return allocator->resize(*this, dataSize);
-   }
-   /*==========================================================*/
-   bool resize(const size_type& dataSize, const value_type& value)
-   {
-      return allocator->resize(*this, dataSize, value);
-   }
-   /*==========================================================*/
-   void swap(CbVector& rhs)
-   {
-      if( this == &rhs ) return;
-
-      std::swap( this->ptrData  , rhs.ptrData   );
-      std::swap( this->dataSize , rhs.dataSize  );
-      std::swap( this->allocator, rhs.allocator );
-   }
-   /*==========================================================*/
-   value_type& operator[](const size_type& i)
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if(i>=dataSize) 
-            UB_THROW( UbException(UB_EXARGS,"T="+(std::string)typeid(*this).name()+UbSystem::toString(i)+" out of range (size="+UbSystem::toString(dataSize)+")") );
-      #endif // _DEBUG
-
-      return ptrData[i];
-   }
-   /*==========================================================*/
-   const value_type& operator[](const size_type& i) const
-   {
-      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
-         if(i>=dataSize) 
-            UB_THROW( UbException(UB_EXARGS,"T="+(std::string)typeid(*this).name()+UbSystem::toString(i)+" out of range (size="+UbSystem::toString(dataSize)+")") );
-      #endif // _DEBUG
-
-      return ptrData[i];
-   }
-   /*==========================================================*/
-   CbVectorAllocator<value_type>* getAllocator() const { return allocator; }
-   /*==========================================================*/
-   #ifdef CAB_RCF
-      template<typename Archive>
-      void serialize(Archive & ar, const unsigned int version)
-      {
-         if( ArchiveTools::isWriting(ar) )
-         {
-            ar & allocator;
-            ar & dataSize; //!!!erst hier
-
-            //old:
-            //for(size_type i=0; i<dataSize; i++)
-            // ar & ptrData[i];
-
-            //new and boosting to the sky:
-            RCF::ByteBuffer byteBuffer( (char*) &ptrData[0], dataSize*sizeof(value_type) );
-            ar & byteBuffer;
-         }
-         else
-         {
-            CbVectorAllocator<value_type>* tmpCbVectorAllocator(NULL);
-            size_type tmpInteger;
-            ar & tmpCbVectorAllocator;
-            ar & tmpInteger;
-            this->setAllocator(tmpCbVectorAllocator);
-            allocator->resize(*this,tmpInteger);
-
-            //old:
-            //for(size_type i=0; i<dataSize; i++)
-            // ar & ptrData[i];
-
-            //new and boosting to the sky:
-            RCF::ByteBuffer byteBuffer;
-            ar & byteBuffer;
-            memcpy( (char*)ptrData, byteBuffer.getPtr(), byteBuffer.getLength() ); 
-         }
-      }
-   #endif //CAB_RCF
-
-private:
-   value_type* ptrData;
-   size_type   dataSize;
-   CbVectorAllocator<value_type>* allocator;
-   CbVector<value_type>(const CbVector<value_type>& src);
-   //CbVector<value_type>& operator=(const CbVector<value_type>& src);
-};
-
-//////////////////////////////////////////////////////////////////////////
-// CbVectorAllocator-Interface
-//////////////////////////////////////////////////////////////////////////
-template< typename T >
-class CbVectorAllocator
-{
-public:
-   typedef typename CbVector<T>::value_type          value_type;
-   typedef typename CbVector<value_type>::size_type  size_type;
-
-public:
-   CbVectorAllocator() {}
-   virtual ~CbVectorAllocator() {}
-
-   virtual bool alloc(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type()) = 0;
-   virtual bool resize(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type()) = 0;
-   virtual bool dealloc(CbVector< value_type >& vec) = 0;
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void serialize(Archive & ar, const unsigned int version)
-   {
-   }
-#endif //CAB_RCF
-
-protected:
-   //folgende Methoden ersparen eine friend Deklaierung aller moeglichen Allocatoren
-   //denn durch diese beiden Methoden haben sie exklusive Zugriffsrechte!
-   //**********************************************************************************//
-   inline value_type*& ptrDataOf( CbVector< value_type >& vec )
-   {
-      if( vec.getAllocator()!=this ) UB_THROW( UbException(UB_EXARGS,"allocator is not member of vec!") );
-      return vec.ptrData;
-   }
-   //**********************************************************************************//
-   inline size_type& dataSizeOf( CbVector< value_type >& vec )
-   {
-      if( vec.getAllocator()!=this ) UB_THROW( UbException(UB_EXARGS,"allocator is not member of vec!") );
-      return vec.dataSize;
-   }
-};
-
-#ifdef RCF_USE_SF_SERIALIZATION
-SF_NO_CTOR(CbVectorAllocator<double>);
-SF_NO_CTOR(CbVectorAllocator<float>);
-#endif //RCF_USE_SF_SERIALIZATION
-
-
-//////////////////////////////////////////////////////////////////////////
-// CbVectorAllocatorStd
-//////////////////////////////////////////////////////////////////////////
-template< typename T >
-class CbVectorAllocatorStd : public CbVectorAllocator<T>
-{
-public:
-   //typedefs wiederholen, da Basisklasse = template -> "Dependent-Base"-Problem
-   typedef typename CbVector<T>::value_type          value_type;
-   typedef typename CbVector<value_type>::size_type  size_type;
-
-public:
-   CbVectorAllocatorStd() : CbVectorAllocator<value_type>()
-   {
-
-   }
-   /*==========================================================*/
-   bool alloc(CbVector< value_type >& src, const size_type& dataSize, const value_type& value=value_type())
-   {
-      return this->resize(src,dataSize,value);
-   }
-   /*==========================================================*/
-   bool resize(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type())
-   {
-      if( CbVectorAllocatorStd< value_type >::dataSizeOf(vec) == dataSize) return false;
-
-      //new array
-      value_type* new_data = new value_type[dataSize];
-      //copy existing data to array
-      if( this->ptrDataOf(vec) )
-      {
-         for(size_type i=0; (i<vec.size() && i<dataSize); ++i) new_data[i] = CbVectorAllocatorStd< value_type >::ptrDataOf(vec)[i];
-         delete[] this->ptrDataOf(vec);
-      }
-      this->ptrDataOf(vec) = new_data;
-      //new value for new items
-      for(size_type i=this->dataSizeOf(vec); i<dataSize; ++i) this->ptrDataOf(vec)[i] = value;
-      //assign new dataSize
-      this->dataSizeOf(vec) = dataSize;
-
-      return true;
-   }
-   /*==========================================================*/
-   bool dealloc(CbVector< value_type >& vec)
-   {
-      if( this->ptrDataOf(vec) )
-      {
-         delete[] this->ptrDataOf(vec);
-         this->ptrDataOf(vec) = NULL;
-      }
-      this->dataSizeOf(vec) = 0;
-      return true;
-   }
-   /*==========================================================*/
-   #ifdef CAB_RCF
-      template<class Archive>
-      void serialize(Archive & ar, const unsigned int version)
-      {
-         serializeParent< CbVectorAllocator<value_type> >(ar, *this);
-      }
-   #endif //CAB_RCF
-
-private:
-};
-
-
-#ifdef RCF_USE_SF_SERIALIZATION
-   UB_AUTO_RUN_NAMED(   SF::registerType< CbVectorAllocatorStd<double> >(" CbVectorAllocatorStd<double> ")       , SF_CbVectorAllocatorStd_double );
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< CbVectorAllocator<double>, CbVectorAllocatorStd<double> >() ), SF_CbVectorAllocatorStd_double_BD1 );
-
-   UB_AUTO_RUN_NAMED(   SF::registerType< CbVectorAllocatorStd<float> >(" CbVectorAllocatorStd<float> "  )       , SF_CbVectorAllocatorStd_float  );
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< CbVectorAllocator<float> , CbVectorAllocatorStd<float> >()  ), SF_CbVectorAllocatorStd_float_BD2 );
-#endif //RCF_USE_SF_SERIALIZATION
-
-#endif //CBVECTOR_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef CBVECTOR_H
+#define CBVECTOR_H
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+   #include <RCF/ByteBuffer.hpp>
+#endif
+
+#include <vector>
+#include <algorithm> //for std::swap
+#include <typeinfo>  //for typeid
+#include <PointerDefinitions.h>    //for memcopy
+
+#include <basics/utilities/UbSystem.h>
+#include <basics/utilities/UbEqual.h>
+
+/*=========================================================================*/
+/*  CbVector                                                               */
+/*                                                                         */
+/**
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 08.11.07
+@version 1.1 - 09.02.08
+@version 1.2 - 23.04.08 - swap added
+@version 1.3 - 08.05.08 - boosting up serialization performance!
+*/
+
+/*
+usage: ...
+Da es Voraussetzun bei doeser Klasse war, dass lediglich der Typ als
+template-parameter miteingeht, muss der allcocator eine abstrakte klasse sein
+ansonsten hätte sich hier der allokator als zweites argument
+wie beim STL vector angeboten, womit man auch keinen pointer speichern muesste.
+Im letzteren Fall würde aber jeweils ein bestimmeter Klassentyp in Abhaengigkeit
+des allokators zur compilezeit erzeugt. Problem wir wollen ein und denselben
+typ benutzen und nur der allokator innerhalb der klasse soll sich unterscheiden
+//
+// Rangecheck aktiv, wenn:
+// -debug  : not defined "NO_CB_RANGECHECK"
+// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK"
+*/
+
+template< typename T > class CbVectorAllocator;
+template< typename T > class CbVectorAllocatorStd;
+
+//////////////////////////////////////////////////////////////////////////
+template< typename T >
+class CbVector
+{
+public:
+   typedef T           value_type;
+   typedef value_type* pointer;
+   typedef std::size_t size_type;
+
+   friend class CbVectorAllocator<value_type>; //um auf ptrData und dataSize zugreifen zu koennen!
+
+public:
+   /*==========================================================*/
+   CbVector( CbVectorAllocator<value_type>* const& allocator = new CbVectorAllocatorStd<value_type> )
+      :  ptrData(NULL)
+       , dataSize(0)
+       , allocator(allocator)
+   {
+      this->allocator->alloc(*this,0,value_type());
+   }
+   /*==========================================================*/
+   CbVector( const size_type size, CbVectorAllocator<value_type>* const& allocator = new CbVectorAllocatorStd<value_type>, const value_type& value=value_type() )
+      :  ptrData(NULL)
+       , dataSize(0)
+       , allocator(allocator)
+   {
+      this->allocator->alloc(*this,size,value);
+   }
+   /*==========================================================*/
+   virtual ~CbVector()
+   {
+      if(allocator)
+      {
+         this->allocator->dealloc(*this);
+         delete allocator;
+         allocator=NULL;
+      }
+   }
+   /*=======================================================================*/
+   CbVector& operator= (const CbVector& src)
+   {
+      if(this == &src) return *this;
+
+      //gespeicherte Datenelemente loeschen
+      //Laenge anpassen
+      this->allocator->resize(*this, src.size());
+
+      //gespeicherte Datenelemente kopieren
+      if( !src.empty() ) 
+      {
+         memcpy( (char*)ptrData, (char*)&src[0], src.size()*sizeof(value_type) ); 
+         //for(size_type i=0; i<src.size(); i++)
+         //   (*this)[i] = src[i];
+      }
+
+      return *this;
+   }
+   /*=======================================================================*/
+   CbVector& operator= (const std::vector< value_type >& src)
+   {
+      //gespeicherte Datenelemente loeschen
+      //Laenge anpassen
+      this->allocator->resize(*this, src.size());
+
+      //gespeicherte Datenelemente kopieren
+      if( !src.empty() ) 
+      {
+         memcpy( (char*)ptrData, (char*)&src[0], src.size()*sizeof(value_type) ); 
+         //for(size_type i=0; i<src.size(); i++)
+         //   (*this)[i] = src[i];
+      }
+      
+      return *this;
+   }
+   /*=======================================================================*/
+   bool operator== (const CbVector& rhs) const
+   {
+      if( this           == &rhs         ) return true;
+      if( this->dataSize != rhs.dataSize ) return false;
+
+      for(size_type i=0; i<rhs.size(); i++)
+         if( !isUbEqual( this->operator[](i), rhs.operator[](i) ) )
+            return false;
+
+      return true;
+   }
+   /*==========================================================*/
+   void setAllocator( CbVectorAllocator<value_type>* const& allocator )
+   {
+      if(this->allocator)
+      {
+         if(this->allocator==allocator) return;
+         this->allocator->dealloc(*this);
+         delete this->allocator;
+      }
+      this->allocator = allocator;
+      this->allocator->alloc(*this,0);
+   }
+   /*==========================================================*/
+   size_type size() const { return dataSize; }
+   /*==========================================================*/
+   bool empty() const { return dataSize==0; }
+   /*==========================================================*/
+   bool resize(const size_type& dataSize)
+   {
+      return allocator->resize(*this, dataSize);
+   }
+   /*==========================================================*/
+   bool resize(const size_type& dataSize, const value_type& value)
+   {
+      return allocator->resize(*this, dataSize, value);
+   }
+   /*==========================================================*/
+   void swap(CbVector& rhs)
+   {
+      if( this == &rhs ) return;
+
+      std::swap( this->ptrData  , rhs.ptrData   );
+      std::swap( this->dataSize , rhs.dataSize  );
+      std::swap( this->allocator, rhs.allocator );
+   }
+   /*==========================================================*/
+   value_type& operator[](const size_type& i)
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if(i>=dataSize) 
+            UB_THROW( UbException(UB_EXARGS,"T="+(std::string)typeid(*this).name()+UbSystem::toString(i)+" out of range (size="+UbSystem::toString(dataSize)+")") );
+      #endif // _DEBUG
+
+      return ptrData[i];
+   }
+   /*==========================================================*/
+   const value_type& operator[](const size_type& i) const
+   {
+      #if !defined(NO_CB_RANGECHECK) && ( defined(_DEBUG) || defined(CB_RANGECHECK) )
+         if(i>=dataSize) 
+            UB_THROW( UbException(UB_EXARGS,"T="+(std::string)typeid(*this).name()+UbSystem::toString(i)+" out of range (size="+UbSystem::toString(dataSize)+")") );
+      #endif // _DEBUG
+
+      return ptrData[i];
+   }
+   /*==========================================================*/
+   CbVectorAllocator<value_type>* getAllocator() const { return allocator; }
+   /*==========================================================*/
+   #ifdef CAB_RCF
+      template<typename Archive>
+      void serialize(Archive & ar, const unsigned int version)
+      {
+         if( ArchiveTools::isWriting(ar) )
+         {
+            ar & allocator;
+            ar & dataSize; //!!!erst hier
+
+            //old:
+            //for(size_type i=0; i<dataSize; i++)
+            // ar & ptrData[i];
+
+            //new and boosting to the sky:
+            RCF::ByteBuffer byteBuffer( (char*) &ptrData[0], dataSize*sizeof(value_type) );
+            ar & byteBuffer;
+         }
+         else
+         {
+            CbVectorAllocator<value_type>* tmpCbVectorAllocator(NULL);
+            size_type tmpInteger;
+            ar & tmpCbVectorAllocator;
+            ar & tmpInteger;
+            this->setAllocator(tmpCbVectorAllocator);
+            allocator->resize(*this,tmpInteger);
+
+            //old:
+            //for(size_type i=0; i<dataSize; i++)
+            // ar & ptrData[i];
+
+            //new and boosting to the sky:
+            RCF::ByteBuffer byteBuffer;
+            ar & byteBuffer;
+            memcpy( (char*)ptrData, byteBuffer.getPtr(), byteBuffer.getLength() ); 
+         }
+      }
+   #endif //CAB_RCF
+
+private:
+   value_type* ptrData;
+   size_type   dataSize;
+   CbVectorAllocator<value_type>* allocator;
+   CbVector<value_type>(const CbVector<value_type>& src);
+   //CbVector<value_type>& operator=(const CbVector<value_type>& src);
+};
+
+//////////////////////////////////////////////////////////////////////////
+// CbVectorAllocator-Interface
+//////////////////////////////////////////////////////////////////////////
+template< typename T >
+class CbVectorAllocator
+{
+public:
+   typedef typename CbVector<T>::value_type          value_type;
+   typedef typename CbVector<value_type>::size_type  size_type;
+
+public:
+   CbVectorAllocator() {}
+   virtual ~CbVectorAllocator() {}
+
+   virtual bool alloc(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type()) = 0;
+   virtual bool resize(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type()) = 0;
+   virtual bool dealloc(CbVector< value_type >& vec) = 0;
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void serialize(Archive & ar, const unsigned int version)
+   {
+   }
+#endif //CAB_RCF
+
+protected:
+   //folgende Methoden ersparen eine friend Deklaierung aller moeglichen Allocatoren
+   //denn durch diese beiden Methoden haben sie exklusive Zugriffsrechte!
+   //**********************************************************************************//
+   inline value_type*& ptrDataOf( CbVector< value_type >& vec )
+   {
+      if( vec.getAllocator()!=this ) UB_THROW( UbException(UB_EXARGS,"allocator is not member of vec!") );
+      return vec.ptrData;
+   }
+   //**********************************************************************************//
+   inline size_type& dataSizeOf( CbVector< value_type >& vec )
+   {
+      if( vec.getAllocator()!=this ) UB_THROW( UbException(UB_EXARGS,"allocator is not member of vec!") );
+      return vec.dataSize;
+   }
+};
+
+#ifdef RCF_USE_SF_SERIALIZATION
+SF_NO_CTOR(CbVectorAllocator<double>);
+SF_NO_CTOR(CbVectorAllocator<float>);
+#endif //RCF_USE_SF_SERIALIZATION
+
+
+//////////////////////////////////////////////////////////////////////////
+// CbVectorAllocatorStd
+//////////////////////////////////////////////////////////////////////////
+template< typename T >
+class CbVectorAllocatorStd : public CbVectorAllocator<T>
+{
+public:
+   //typedefs wiederholen, da Basisklasse = template -> "Dependent-Base"-Problem
+   typedef typename CbVector<T>::value_type          value_type;
+   typedef typename CbVector<value_type>::size_type  size_type;
+
+public:
+   CbVectorAllocatorStd() : CbVectorAllocator<value_type>()
+   {
+
+   }
+   /*==========================================================*/
+   bool alloc(CbVector< value_type >& src, const size_type& dataSize, const value_type& value=value_type())
+   {
+      return this->resize(src,dataSize,value);
+   }
+   /*==========================================================*/
+   bool resize(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type())
+   {
+      if( CbVectorAllocatorStd< value_type >::dataSizeOf(vec) == dataSize) return false;
+
+      //new array
+      value_type* new_data = new value_type[dataSize];
+      //copy existing data to array
+      if( this->ptrDataOf(vec) )
+      {
+         for(size_type i=0; (i<vec.size() && i<dataSize); ++i) new_data[i] = CbVectorAllocatorStd< value_type >::ptrDataOf(vec)[i];
+         delete[] this->ptrDataOf(vec);
+      }
+      this->ptrDataOf(vec) = new_data;
+      //new value for new items
+      for(size_type i=this->dataSizeOf(vec); i<dataSize; ++i) this->ptrDataOf(vec)[i] = value;
+      //assign new dataSize
+      this->dataSizeOf(vec) = dataSize;
+
+      return true;
+   }
+   /*==========================================================*/
+   bool dealloc(CbVector< value_type >& vec)
+   {
+      if( this->ptrDataOf(vec) )
+      {
+         delete[] this->ptrDataOf(vec);
+         this->ptrDataOf(vec) = NULL;
+      }
+      this->dataSizeOf(vec) = 0;
+      return true;
+   }
+   /*==========================================================*/
+   #ifdef CAB_RCF
+      template<class Archive>
+      void serialize(Archive & ar, const unsigned int version)
+      {
+         serializeParent< CbVectorAllocator<value_type> >(ar, *this);
+      }
+   #endif //CAB_RCF
+
+private:
+};
+
+
+#ifdef RCF_USE_SF_SERIALIZATION
+   UB_AUTO_RUN_NAMED(   SF::registerType< CbVectorAllocatorStd<double> >(" CbVectorAllocatorStd<double> ")       , SF_CbVectorAllocatorStd_double );
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< CbVectorAllocator<double>, CbVectorAllocatorStd<double> >() ), SF_CbVectorAllocatorStd_double_BD1 );
+
+   UB_AUTO_RUN_NAMED(   SF::registerType< CbVectorAllocatorStd<float> >(" CbVectorAllocatorStd<float> "  )       , SF_CbVectorAllocatorStd_float  );
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< CbVectorAllocator<float> , CbVectorAllocatorStd<float> >()  ), SF_CbVectorAllocatorStd_float_BD2 );
+#endif //RCF_USE_SF_SERIALIZATION
+
+#endif //CBVECTOR_H
diff --git a/source/ThirdParty/Library/basics/container/CbVectorPool.h b/source/VirtualFluidsBasic/basics/container/CbVectorPool.h
similarity index 97%
rename from source/ThirdParty/Library/basics/container/CbVectorPool.h
rename to source/VirtualFluidsBasic/basics/container/CbVectorPool.h
index 71019277acc882a364caa636d03781ed812e74bc..92fbde9c16b2bd53ed6238d40872719d168dd156 100644
--- a/source/ThirdParty/Library/basics/container/CbVectorPool.h
+++ b/source/VirtualFluidsBasic/basics/container/CbVectorPool.h
@@ -1,465 +1,465 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef CBVECTORPOOL_H
-#define CBVECTORPOOL_H
-
-#include <iostream>
-#include <sstream>
-#include <vector>
-#include <map>
-#include <limits>
-#include <typeinfo>
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbTuple.h>
-#include <basics/utilities/UbLogger.h>
-#include <basics/container/CbVector.h>
-
-//#include "MPICommunicator.h"
-//
-//#include <execinfo.h>
-//#include <stdio.h>
-//#include <stdlib.h>
-//#include <unistd.h>
-
-/*=========================================================================*/
-/*  CbVectorPool                                                               */
-/*                                                                         */
-/**
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 08.11.07
-@version 1.1 - 09.02.08
-*/
-
-/*
-Durch Verwendung eines CbVectors in Verbindung mit einem CbVectorAllocatorPool
-wird der Datenvector nicht direkt im CbVector gehalten, sondern ist ein Teil
-des Datenvectors des Ãœbergabe-CbVectorPools.
-Die Methoden der von CbVectors funktionieren fehlerfrei
-Es mss einem jedoch bewußt sein, dass die "resize"-Methoden länger benötigen, da
-u.U. viele Elemente im Speicher verschoeben werden muessen.
-Der Poolvector enthaelt KEINE gaps, so dass er z.B. gut zur Ãœbertragung via MPI
-geeignet ist...
-
-Verhaltensweise bei Zerstören des Pools:
-wird der Pool zerstört bevor man die CbVectoren zerstört, so wird beim nächsten
-Datenzugriffsversuch eine entsprechende Exception geworfen, denn alle DatenElemente
-des CbVEctors werden restet und der Pool dort zu NULL gesetzt.
-
-Verhaltensweise bei Zerstören eines CbVectors:
-hier ganz normal der Datenspeicher wieder freigegen und der Poolvektor verkürzt
-*/
-
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-
-
-template<typename T> class CbVectorAllocatorPool;
-
-/*==================================================================*/
-template<typename T>
-class CbVectorPool
-{
-public:
-   typedef typename CbVector<T>::value_type value_type;
-   typedef typename CbVector<T>::size_type  size_type;
-   typedef std::vector< value_type >        Pool;
-
-   typedef std::string CbVectorKey;
-   typedef std::map< CbVectorKey, CbVector< value_type >* /*ptrVector*/  > CbVectorMap;
-   typedef typename CbVectorMap::iterator CbVectorMapIter;
-
-public:
-   //////////////////////////////////////////////////////////////////////////
-   CbVectorPool( const size_type& startPoolSize = 20000) //startPoolSize*sizeof(T)/1024/1024 [MB]
-      :  poolStartAdress(NULL)
-       , nextCbVectorStartIndexInPool(0)
-       , nextCbVectorKey()
-   {
-      pool.reserve(startPoolSize);
-   }
-   /*==================================================================*/
-   virtual ~CbVectorPool()
-   {
-      //hier werden lediglich ihre datenvektoren "resetet"
-      for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it)
-      {
-         CbVector< value_type >& vec = *it->second;
-         CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() );
-         //if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") );
-
-         //allocator daten reseten
-         allocator.ptrVectorPool    = NULL;
-         allocator.key              = CbVectorKey();
-         allocator.startIndexInPool = 0;
-
-         //Datenzeiger/-groessen reseten
-         allocator.ptrDataOf(vec)  = NULL;
-         allocator.dataSizeOf(vec) = 0;
-      }
-   }
-   /*==========================================================*/
-   CbVectorKey getNextCbVectorKey() const
-   {
-      return this->nextCbVectorKey;
-   }
-   /*==================================================================*/
-   bool allocVectorData(CbVector<value_type>& vec, const size_type& dataSize, const value_type& value=value_type() )
-   {
-      //pool-allocator holen
-      CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() );
-      if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") );
-
-      //alloc nur wenn cbVector noch kein Element von Pool!
-      if( cbVectorMap.find(allocator.key)==cbVectorMap.end()   )
-      {
-         return this->allocData(allocator, vec, dataSize, value );
-      }
-
-      UB_THROW( UbException(UB_EXARGS,"vector-key="+UbSystem::toString(allocator.key)+" bereits vergeben!") );
-   }
-   /*==================================================================*/
-   bool resizeVectorData(CbVector<value_type>& vec, const size_type& dataSize, const value_type& value=value_type() )
-   {
-      CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() );
-      if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") );
-
-      //cbVector noch nicht in map?
-      CbVectorMapIter pos = cbVectorMap.find(allocator.key);
-
-      if( pos!=cbVectorMap.end()  ) //cbVector vorhanden
-      {
-         //wenn bei alloc keine Laenge zugewiesen wurde, so erfolgt das nun
-         if( allocator.startIndexInPool==0 && allocator.ptrDataOf(vec)==NULL )
-            return this->allocData(allocator, vec, dataSize, value ) ;
-         else
-            return this->resizeData(allocator, vec, dataSize, value );
-      }
-
-      UB_THROW( UbException(UB_EXARGS,"vector gehoert laut allocator zum pool aber den key gibt s nicht... wie kann das sein?") );
-   }
-   /*==================================================================*/
-   bool deallocVectorData(CbVector<value_type>& vec)
-   {
-      CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() );
-      if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") );
-
-      //nur wenn vector auch teil des
-      if( cbVectorMap.erase(allocator.key) > 0 )
-      {
-         if( this->resizeData(allocator,vec,0,0) )
-         {
-            allocator.ptrVectorPool    = NULL;
-            allocator.key              = CbVectorKey();
-            allocator.startIndexInPool = 0;
-
-            //das Datenzeiger/-groessen reseten wird bereits in resize durchgefuehrt
-            return true;
-         }
-         else UB_THROW( UbException(UB_EXARGS,"unknown error") );
-      }
-
-      
-      //SPtr<Communicator> comm = MPICommunicator::getInstance();
-      //int myid = comm->getProcessID();
-
-//      // Get the name of the processor
-//      char machinename[MPI_MAX_PROCESSOR_NAME];
-//      int name_len;
-//      MPI_Get_processor_name(machinename, &name_len);
-//      UBLOG(logINFO, "PID = " << myid << " host name: " << machinename);
-//
-//      int j, nptrs;
-//#define SIZE 100
-//      void *buffer[100];
-//      char **strings;
-//
-//      nptrs = backtrace(buffer, SIZE);
-//      printf("backtrace() returned %d addresses\n", nptrs);
-//
-//      /* The call backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO)
-//      would produce similar output to the following: */
-//
-//      strings = backtrace_symbols(buffer, nptrs);
-//      if (strings == NULL)
-//      {
-//         perror("backtrace_symbols");
-//         exit(EXIT_FAILURE);
-//      }
-//
-//      for (j = 0; j < nptrs; j++)
-//         printf("%s\n", strings[j]);
-//
-//      free(strings);
-
-      UB_THROW(UbException(UB_EXARGS, "vector gehoert laut allocator zum pool aber den key gibt s nicht... wie kann das sein?"));
-   }
-   /*==================================================================*/
-   friend std::ostream& operator<<(std::ostream& os, const CbVectorPool& cbPool)
-   {
-      os<<"map"<<std::endl;
-      for(CbVectorMapIter pos=cbPool.cbVectorMap.begin(); pos!=cbPool.cbVectorMap.end(); ++pos)
-      {
-         CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*pos->second->getAllocator());
-         os<<"vector-size="<<pos->second->size()<<"vector-Adress="<<tmpAllocator->ptrDataOf(*pos->second)<<", allocator(key="<<tmpAllocator.key<<", startIndex="<<tmpAllocator.startIndexInPool<<")"<<std::endl;
-         for(size_type i=0; i<pos->second->size(); i++) os<<(*pos->second)[i]<<","; 
-         os<<std::endl;
-      }
-      os<<"pool"<<std::endl;
-      for(size_type i=0; i<cbPool.pool.size(); i++)
-            os<<cbPool.pool[i]<<","; os<<std::endl;
-
-      return os;
-   }
-   /*==================================================================*/
-   typename CbVectorMap::size_type getNofStoredVectors() const
-   {
-      return this->cbVectorMap.size();
-   }
-   /*==================================================================*/
-   typename Pool::size_type getPoolSize() const
-   {
-      return this->pool.size();
-   }
-   /*==================================================================*/
-   // checks if all vectors have one to one pool-entries
-   bool consistencyCheck()
-   {
-      std::vector<int> pool2(pool.size(),0);
-      for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it)
-      {
-         CbVector< value_type >& tmpVec = *it->second;
-         CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*tmpVec.getAllocator());
-         for(size_type i=tmpAllocator.startIndexInPool; i<tmpAllocator.startIndexInPool+tmpVec.size(); ++i)
-         {
-            pool2.at(i)++;
-         }
-      }
-      for( size_type i=0; i<pool2.size(); ++i )
-      {
-         if(pool2.at(i) > 1 ) { UBLOG(logERROR,UB_FUNCTION<<" - test failed typo 1"); return false; }
-         if(pool2.at(i) < 1 ) { UBLOG(logERROR,UB_FUNCTION<<" - test failed typo 2"); return false; }
-      }
-      return true;
-   }
-protected:
-   /*==================================================================*/
-   inline bool allocData(CbVectorAllocatorPool< value_type >& allocator, CbVector< value_type >& vec, const size_type& dataSize, const value_type& value )
-   {
-      //safety checks
-      if(    allocator.startIndexInPool!=0
-          || allocator.ptrDataOf(vec)!=NULL
-          || allocator.dataSizeOf(vec)!=0   )
-      {
-         UB_THROW( UbException(UB_EXARGS,"zu allokierender vector ist nicht ganz sauber!!") );
-      }
-
-      //poolVector vergroessern
-      if( dataSize>0 )
-      {
-         pool.resize( pool.size() + dataSize, value );
-
-         //Zeiger der vorhandenen CbVectoren neu setzen, wenn Pool im Speicher verschoben wurde
-         if( poolStartAdress != &pool.front() )
-         {
-            poolStartAdress = &pool.front();
-            for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it)
-            {
-               CbVector< value_type >& tmpVec = *it->second;
-               CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*tmpVec.getAllocator());
-
-               if( !tmpAllocator.ptrDataOf(tmpVec) ) continue; //Fall: CbVector hat noch keinen Datenbereich (data zeigt auf NULL)
-               tmpAllocator.ptrDataOf(tmpVec) = &pool[ tmpAllocator.startIndexInPool];
-            }
-            //std::cout<<"CbVectorPoolMpi::allocVectorData vector wurde im speicher verschoben - adressen angepasst!!!"<<std::endl;
-         }
-
-         //aktuellem element adresse zuweisen (wurde evtl schon inder schleife zuvor gemacht)
-         allocator.ptrDataOf(vec) = &pool.at(nextCbVectorStartIndexInPool);
-         allocator.startIndexInPool = nextCbVectorStartIndexInPool;
-
-         //neuen StartIndex fuer naechstes Element berechnen
-         nextCbVectorStartIndexInPool += dataSize;
-         if(nextCbVectorStartIndexInPool!=pool.size())
-            UB_THROW( UbException(UB_EXARGS,"index Problem... Annahme falsch?") );
-      }
-
-      //vector zu map hinzufügen (speicher wird dann anschliessend zugwiesen)
-      cbVectorMap.insert( std::make_pair( allocator.key, &vec ) ); // ist angeblich performanter als  cbVectorMap[ allocator.key ] = cbVector; //aus Effective STL von Scott Meyer
-      allocator.dataSizeOf(vec) = dataSize;
-
-      //dummDoof nextKey-Generung...
-      if( allocator.key >= this->nextCbVectorKey ) this->nextCbVectorKey = allocator.key + "1";
-
-      return true;
-   }
-   /*==========================================================*/
-   bool resizeData(CbVectorAllocatorPool< value_type >& allocator, CbVector<value_type>& vec, const size_type& dataSize, const value_type& value )
-   {
-      //datenvector verlaengern/-kuerzen
-      typename Pool::iterator startPos = pool.begin()+allocator.startIndexInPool; //startPosition der cbVector-Daten im Pool
-      if( vec.size() > dataSize ) pool.erase( startPos+dataSize, startPos+vec.size());
-      else                        pool.insert( startPos+vec.size(), dataSize-vec.size(), value );
-
-      //////////////////////////////////////////////////////////////////////////
-      //adressen und laengen der einzelnen vectoren anpassen
-      if( !pool.empty() )
-      {
-         bool poolMoved   = ( poolStartAdress != &pool.front() );
-         poolStartAdress  = &pool.front();
-
-         for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it)
-         {
-            CbVector< value_type >& tmpVec = *it->second;
-
-            if( tmpVec.size()>0 )
-            {
-               CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*tmpVec.getAllocator());
-               //liegt CbVector VOR verändertem CbVector?
-               if( tmpAllocator.startIndexInPool <= allocator.startIndexInPool ) //ja: anpassung NUR wenn pool verschoben wurde!
-               {
-                  if(poolMoved && tmpVec.size()>0 ) tmpAllocator.ptrDataOf(tmpVec) = &pool[ tmpAllocator.startIndexInPool];
-               }
-               else //nein: -> Adresse + Index MUSS immer angepasst werden
-               {
-                  tmpAllocator.startIndexInPool += dataSize-vec.size();
-                  tmpAllocator.ptrDataOf(tmpVec) = &pool[ tmpAllocator.startIndexInPool ];
-               }
-            }
-         }
-      }
-      else //Sonderfall: alle Elemente haben Laenge 0 -> kein pool -> alle Feld-Adressen auf NULL setzen!
-      {
-         poolStartAdress = NULL;
-         for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it)
-         {
-            CbVector< value_type >& tmpVec = *it->second;
-            CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*tmpVec.getAllocator());
-            tmpAllocator.startIndexInPool = 0;
-         }
-
-      }
-
-      //restliche Daten von cbVector + allocator aktualisieren
-      allocator.dataSizeOf(vec) = dataSize;
-      if(dataSize==0)
-      {
-         allocator.ptrDataOf(vec)   = NULL;
-         allocator.startIndexInPool = 0;
-      }
-
-      nextCbVectorStartIndexInPool = pool.size();
-
-      return true;
-   }
-
-protected:
-   /*==================================================================*/
-   void getCbVectorData(const CbVector< value_type >& vec, CbVectorKey& vectorKey, size_type& startIndexInPool, size_type& dataSize )
-   {
-      CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() );
-
-      startIndexInPool  = allocator.startIndexInPool;
-      vectorKey         = allocator.key;
-      dataSize          = vec.size();
-   }
-   /*==================================================================*/
-   void setCbVectorData(CbVector< value_type >& vec, const CbVectorKey& vectorKey, const size_type& startIndexInPool, const size_type& dataSize )
-   {
-      CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() );
-
-      allocator.startIndexInPool = startIndexInPool;
-      allocator.key              = vectorKey;
-      allocator.dataSizeOf(vec)  = dataSize;
-      allocator.ptrDataOf(vec)   = &this->pool[ startIndexInPool ];
-   }
-   /*==================================================================*/
-
-   CbVectorMap                cbVectorMap;                      //informationsmap fuer MPIData und zugewiesener vector
-
-   Pool                       pool;                             //globaler Datenvector
-   typename Pool::pointer     poolStartAdress;                  //StartAdresse des aktuellen Datenvektors
-   typename Pool::size_type   nextCbVectorStartIndexInPool;     //StartIndex fuer den naechsten CbVector
-
-   //key - erstmal dummdoof
-   CbVectorKey nextCbVectorKey;
-};
-
-
-//////////////////////////////////////////////////////////////////////////
-//  CbVectorAllocatorPool
-//////////////////////////////////////////////////////////////////////////
-template< typename T >
-class CbVectorAllocatorPool : public CbVectorAllocator<T>
-{
-public:
-   //typedefs wiederholen, da Basisklasse = template -> "Dependent-Base"-Problem
-   typedef typename CbVector<T>::value_type          value_type;
-   typedef typename CbVector<value_type>::size_type  size_type;
-
-   friend class CbVectorPool< value_type >;
-
-public:
-   /*==========================================================*/
-   CbVectorAllocatorPool(const typename CbVectorPool< value_type >::CbVectorKey& key, CbVectorPool<value_type>* const& ptrVectorPool)
-      :  CbVectorAllocator<value_type>()
-       , key(key)
-       , startIndexInPool(0)
-       , ptrVectorPool(ptrVectorPool)
-   {
-      if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"ptrVectorPool==NULL") );
-   }
-   /*==========================================================*/
-   //hier wird der key automatisch erzeugt!
-   CbVectorAllocatorPool(CbVectorPool<value_type>* const& ptrVectorPool)
-      :  CbVectorAllocator<value_type>()
-       , startIndexInPool(0)
-       , ptrVectorPool(ptrVectorPool)
-   {
-      if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"ptrVectorPool==NULL") );
-      key = ptrVectorPool->getNextCbVectorKey();
-   }
-   /*==========================================================*/
-   bool alloc(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type())
-   {
-      if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"vectorPool seems to be destroyed, ptrVectorPool==NULL") );
-      return ptrVectorPool->allocVectorData(vec, dataSize, value);
-   }
-   /*==========================================================*/
-   bool resize(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type())
-   {
-      if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"vectorPool seems to be destroyed, ptrVectorPool==NULL") );
-      return ptrVectorPool->resizeVectorData(vec, dataSize, value);
-   }
-   /*==========================================================*/
-   bool dealloc(CbVector< value_type >& vec)
-   {
-      if(ptrVectorPool) return this->ptrVectorPool->deallocVectorData(vec);
-      //wenn kein ptrVectorPool -> wurde bereits deallokiert
-      return true;
-   }
-   /*==========================================================*/
-   const CbVectorPool< value_type >& getCbVectorPool()
-   {
-      if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"vectorPool seems to be destroyed, ptrVectorPool==NULL") );
-      return *ptrVectorPool;
-   }
-   /*==========================================================*/
-
-private:
-   typename CbVectorPool< value_type >::CbVectorKey     key;
-   typename CbVectorPool< value_type >::Pool::size_type startIndexInPool;
-
-   CbVectorPool< value_type >* ptrVectorPool;
-
-   CbVectorAllocatorPool( const CbVectorAllocatorPool& );                 //no copy allowed
-   const CbVectorAllocatorPool& operator=( const CbVectorAllocatorPool& );//no copy allowed
-};
-
-
-#endif //CBVECTORPOOL_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef CBVECTORPOOL_H
+#define CBVECTORPOOL_H
+
+#include <iostream>
+#include <sstream>
+#include <vector>
+#include <map>
+#include <limits>
+#include <typeinfo>
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbTuple.h>
+#include <basics/utilities/UbLogger.h>
+#include <basics/container/CbVector.h>
+
+//#include "MPICommunicator.h"
+//
+//#include <execinfo.h>
+//#include <stdio.h>
+//#include <stdlib.h>
+//#include <unistd.h>
+
+/*=========================================================================*/
+/*  CbVectorPool                                                               */
+/*                                                                         */
+/**
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 08.11.07
+@version 1.1 - 09.02.08
+*/
+
+/*
+Durch Verwendung eines CbVectors in Verbindung mit einem CbVectorAllocatorPool
+wird der Datenvector nicht direkt im CbVector gehalten, sondern ist ein Teil
+des Datenvectors des Ãœbergabe-CbVectorPools.
+Die Methoden der von CbVectors funktionieren fehlerfrei
+Es mss einem jedoch bewußt sein, dass die "resize"-Methoden länger benötigen, da
+u.U. viele Elemente im Speicher verschoeben werden muessen.
+Der Poolvector enthaelt KEINE gaps, so dass er z.B. gut zur Ãœbertragung via MPI
+geeignet ist...
+
+Verhaltensweise bei Zerstören des Pools:
+wird der Pool zerstört bevor man die CbVectoren zerstört, so wird beim nächsten
+Datenzugriffsversuch eine entsprechende Exception geworfen, denn alle DatenElemente
+des CbVEctors werden restet und der Pool dort zu NULL gesetzt.
+
+Verhaltensweise bei Zerstören eines CbVectors:
+hier ganz normal der Datenspeicher wieder freigegen und der Poolvektor verkürzt
+*/
+
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+
+
+template<typename T> class CbVectorAllocatorPool;
+
+/*==================================================================*/
+template<typename T>
+class CbVectorPool
+{
+public:
+   typedef typename CbVector<T>::value_type value_type;
+   typedef typename CbVector<T>::size_type  size_type;
+   typedef std::vector< value_type >        Pool;
+
+   typedef std::string CbVectorKey;
+   typedef std::map< CbVectorKey, CbVector< value_type >* /*ptrVector*/  > CbVectorMap;
+   typedef typename CbVectorMap::iterator CbVectorMapIter;
+
+public:
+   //////////////////////////////////////////////////////////////////////////
+   CbVectorPool( const size_type& startPoolSize = 20000) //startPoolSize*sizeof(T)/1024/1024 [MB]
+      :  poolStartAdress(NULL)
+       , nextCbVectorStartIndexInPool(0)
+       , nextCbVectorKey()
+   {
+      pool.reserve(startPoolSize);
+   }
+   /*==================================================================*/
+   virtual ~CbVectorPool()
+   {
+      //hier werden lediglich ihre datenvektoren "resetet"
+      for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it)
+      {
+         CbVector< value_type >& vec = *it->second;
+         CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() );
+         //if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") );
+
+         //allocator daten reseten
+         allocator.ptrVectorPool    = NULL;
+         allocator.key              = CbVectorKey();
+         allocator.startIndexInPool = 0;
+
+         //Datenzeiger/-groessen reseten
+         allocator.ptrDataOf(vec)  = NULL;
+         allocator.dataSizeOf(vec) = 0;
+      }
+   }
+   /*==========================================================*/
+   CbVectorKey getNextCbVectorKey() const
+   {
+      return this->nextCbVectorKey;
+   }
+   /*==================================================================*/
+   bool allocVectorData(CbVector<value_type>& vec, const size_type& dataSize, const value_type& value=value_type() )
+   {
+      //pool-allocator holen
+      CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() );
+      if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") );
+
+      //alloc nur wenn cbVector noch kein Element von Pool!
+      if( cbVectorMap.find(allocator.key)==cbVectorMap.end()   )
+      {
+         return this->allocData(allocator, vec, dataSize, value );
+      }
+
+      UB_THROW( UbException(UB_EXARGS,"vector-key="+UbSystem::toString(allocator.key)+" bereits vergeben!") );
+   }
+   /*==================================================================*/
+   bool resizeVectorData(CbVector<value_type>& vec, const size_type& dataSize, const value_type& value=value_type() )
+   {
+      CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() );
+      if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") );
+
+      //cbVector noch nicht in map?
+      CbVectorMapIter pos = cbVectorMap.find(allocator.key);
+
+      if( pos!=cbVectorMap.end()  ) //cbVector vorhanden
+      {
+         //wenn bei alloc keine Laenge zugewiesen wurde, so erfolgt das nun
+         if( allocator.startIndexInPool==0 && allocator.ptrDataOf(vec)==NULL )
+            return this->allocData(allocator, vec, dataSize, value ) ;
+         else
+            return this->resizeData(allocator, vec, dataSize, value );
+      }
+
+      UB_THROW( UbException(UB_EXARGS,"vector gehoert laut allocator zum pool aber den key gibt s nicht... wie kann das sein?") );
+   }
+   /*==================================================================*/
+   bool deallocVectorData(CbVector<value_type>& vec)
+   {
+      CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() );
+      if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") );
+
+      //nur wenn vector auch teil des
+      if( cbVectorMap.erase(allocator.key) > 0 )
+      {
+         if( this->resizeData(allocator,vec,0,0) )
+         {
+            allocator.ptrVectorPool    = NULL;
+            allocator.key              = CbVectorKey();
+            allocator.startIndexInPool = 0;
+
+            //das Datenzeiger/-groessen reseten wird bereits in resize durchgefuehrt
+            return true;
+         }
+         else UB_THROW( UbException(UB_EXARGS,"unknown error") );
+      }
+
+      
+      //SPtr<Communicator> comm = MPICommunicator::getInstance();
+      //int myid = comm->getProcessID();
+
+//      // Get the name of the processor
+//      char machinename[MPI_MAX_PROCESSOR_NAME];
+//      int name_len;
+//      MPI_Get_processor_name(machinename, &name_len);
+//      UBLOG(logINFO, "PID = " << myid << " host name: " << machinename);
+//
+//      int j, nptrs;
+//#define SIZE 100
+//      void *buffer[100];
+//      char **strings;
+//
+//      nptrs = backtrace(buffer, SIZE);
+//      printf("backtrace() returned %d addresses\n", nptrs);
+//
+//      /* The call backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO)
+//      would produce similar output to the following: */
+//
+//      strings = backtrace_symbols(buffer, nptrs);
+//      if (strings == NULL)
+//      {
+//         perror("backtrace_symbols");
+//         exit(EXIT_FAILURE);
+//      }
+//
+//      for (j = 0; j < nptrs; j++)
+//         printf("%s\n", strings[j]);
+//
+//      free(strings);
+
+      UB_THROW(UbException(UB_EXARGS, "vector gehoert laut allocator zum pool aber den key gibt s nicht... wie kann das sein?"));
+   }
+   /*==================================================================*/
+   friend std::ostream& operator<<(std::ostream& os, const CbVectorPool& cbPool)
+   {
+      os<<"map"<<std::endl;
+      for(CbVectorMapIter pos=cbPool.cbVectorMap.begin(); pos!=cbPool.cbVectorMap.end(); ++pos)
+      {
+         CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*pos->second->getAllocator());
+         os<<"vector-size="<<pos->second->size()<<"vector-Adress="<<tmpAllocator->ptrDataOf(*pos->second)<<", allocator(key="<<tmpAllocator.key<<", startIndex="<<tmpAllocator.startIndexInPool<<")"<<std::endl;
+         for(size_type i=0; i<pos->second->size(); i++) os<<(*pos->second)[i]<<","; 
+         os<<std::endl;
+      }
+      os<<"pool"<<std::endl;
+      for(size_type i=0; i<cbPool.pool.size(); i++)
+            os<<cbPool.pool[i]<<","; os<<std::endl;
+
+      return os;
+   }
+   /*==================================================================*/
+   typename CbVectorMap::size_type getNofStoredVectors() const
+   {
+      return this->cbVectorMap.size();
+   }
+   /*==================================================================*/
+   typename Pool::size_type getPoolSize() const
+   {
+      return this->pool.size();
+   }
+   /*==================================================================*/
+   // checks if all vectors have one to one pool-entries
+   bool consistencyCheck()
+   {
+      std::vector<int> pool2(pool.size(),0);
+      for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it)
+      {
+         CbVector< value_type >& tmpVec = *it->second;
+         CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*tmpVec.getAllocator());
+         for(size_type i=tmpAllocator.startIndexInPool; i<tmpAllocator.startIndexInPool+tmpVec.size(); ++i)
+         {
+            pool2.at(i)++;
+         }
+      }
+      for( size_type i=0; i<pool2.size(); ++i )
+      {
+         if(pool2.at(i) > 1 ) { UBLOG(logERROR,UB_FUNCTION<<" - test failed typo 1"); return false; }
+         if(pool2.at(i) < 1 ) { UBLOG(logERROR,UB_FUNCTION<<" - test failed typo 2"); return false; }
+      }
+      return true;
+   }
+protected:
+   /*==================================================================*/
+   inline bool allocData(CbVectorAllocatorPool< value_type >& allocator, CbVector< value_type >& vec, const size_type& dataSize, const value_type& value )
+   {
+      //safety checks
+      if(    allocator.startIndexInPool!=0
+          || allocator.ptrDataOf(vec)!=NULL
+          || allocator.dataSizeOf(vec)!=0   )
+      {
+         UB_THROW( UbException(UB_EXARGS,"zu allokierender vector ist nicht ganz sauber!!") );
+      }
+
+      //poolVector vergroessern
+      if( dataSize>0 )
+      {
+         pool.resize( pool.size() + dataSize, value );
+
+         //Zeiger der vorhandenen CbVectoren neu setzen, wenn Pool im Speicher verschoben wurde
+         if( poolStartAdress != &pool.front() )
+         {
+            poolStartAdress = &pool.front();
+            for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it)
+            {
+               CbVector< value_type >& tmpVec = *it->second;
+               CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*tmpVec.getAllocator());
+
+               if( !tmpAllocator.ptrDataOf(tmpVec) ) continue; //Fall: CbVector hat noch keinen Datenbereich (data zeigt auf NULL)
+               tmpAllocator.ptrDataOf(tmpVec) = &pool[ tmpAllocator.startIndexInPool];
+            }
+            //std::cout<<"CbVectorPoolMpi::allocVectorData vector wurde im speicher verschoben - adressen angepasst!!!"<<std::endl;
+         }
+
+         //aktuellem element adresse zuweisen (wurde evtl schon inder schleife zuvor gemacht)
+         allocator.ptrDataOf(vec) = &pool.at(nextCbVectorStartIndexInPool);
+         allocator.startIndexInPool = nextCbVectorStartIndexInPool;
+
+         //neuen StartIndex fuer naechstes Element berechnen
+         nextCbVectorStartIndexInPool += dataSize;
+         if(nextCbVectorStartIndexInPool!=pool.size())
+            UB_THROW( UbException(UB_EXARGS,"index Problem... Annahme falsch?") );
+      }
+
+      //vector zu map hinzufügen (speicher wird dann anschliessend zugwiesen)
+      cbVectorMap.insert( std::make_pair( allocator.key, &vec ) ); // ist angeblich performanter als  cbVectorMap[ allocator.key ] = cbVector; //aus Effective STL von Scott Meyer
+      allocator.dataSizeOf(vec) = dataSize;
+
+      //dummDoof nextKey-Generung...
+      if( allocator.key >= this->nextCbVectorKey ) this->nextCbVectorKey = allocator.key + "1";
+
+      return true;
+   }
+   /*==========================================================*/
+   bool resizeData(CbVectorAllocatorPool< value_type >& allocator, CbVector<value_type>& vec, const size_type& dataSize, const value_type& value )
+   {
+      //datenvector verlaengern/-kuerzen
+      typename Pool::iterator startPos = pool.begin()+allocator.startIndexInPool; //startPosition der cbVector-Daten im Pool
+      if( vec.size() > dataSize ) pool.erase( startPos+dataSize, startPos+vec.size());
+      else                        pool.insert( startPos+vec.size(), dataSize-vec.size(), value );
+
+      //////////////////////////////////////////////////////////////////////////
+      //adressen und laengen der einzelnen vectoren anpassen
+      if( !pool.empty() )
+      {
+         bool poolMoved   = ( poolStartAdress != &pool.front() );
+         poolStartAdress  = &pool.front();
+
+         for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it)
+         {
+            CbVector< value_type >& tmpVec = *it->second;
+
+            if( tmpVec.size()>0 )
+            {
+               CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*tmpVec.getAllocator());
+               //liegt CbVector VOR verändertem CbVector?
+               if( tmpAllocator.startIndexInPool <= allocator.startIndexInPool ) //ja: anpassung NUR wenn pool verschoben wurde!
+               {
+                  if(poolMoved && tmpVec.size()>0 ) tmpAllocator.ptrDataOf(tmpVec) = &pool[ tmpAllocator.startIndexInPool];
+               }
+               else //nein: -> Adresse + Index MUSS immer angepasst werden
+               {
+                  tmpAllocator.startIndexInPool += dataSize-vec.size();
+                  tmpAllocator.ptrDataOf(tmpVec) = &pool[ tmpAllocator.startIndexInPool ];
+               }
+            }
+         }
+      }
+      else //Sonderfall: alle Elemente haben Laenge 0 -> kein pool -> alle Feld-Adressen auf NULL setzen!
+      {
+         poolStartAdress = NULL;
+         for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it)
+         {
+            CbVector< value_type >& tmpVec = *it->second;
+            CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*tmpVec.getAllocator());
+            tmpAllocator.startIndexInPool = 0;
+         }
+
+      }
+
+      //restliche Daten von cbVector + allocator aktualisieren
+      allocator.dataSizeOf(vec) = dataSize;
+      if(dataSize==0)
+      {
+         allocator.ptrDataOf(vec)   = NULL;
+         allocator.startIndexInPool = 0;
+      }
+
+      nextCbVectorStartIndexInPool = pool.size();
+
+      return true;
+   }
+
+protected:
+   /*==================================================================*/
+   void getCbVectorData(const CbVector< value_type >& vec, CbVectorKey& vectorKey, size_type& startIndexInPool, size_type& dataSize )
+   {
+      CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() );
+
+      startIndexInPool  = allocator.startIndexInPool;
+      vectorKey         = allocator.key;
+      dataSize          = vec.size();
+   }
+   /*==================================================================*/
+   void setCbVectorData(CbVector< value_type >& vec, const CbVectorKey& vectorKey, const size_type& startIndexInPool, const size_type& dataSize )
+   {
+      CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() );
+
+      allocator.startIndexInPool = startIndexInPool;
+      allocator.key              = vectorKey;
+      allocator.dataSizeOf(vec)  = dataSize;
+      allocator.ptrDataOf(vec)   = &this->pool[ startIndexInPool ];
+   }
+   /*==================================================================*/
+
+   CbVectorMap                cbVectorMap;                      //informationsmap fuer MPIData und zugewiesener vector
+
+   Pool                       pool;                             //globaler Datenvector
+   typename Pool::pointer     poolStartAdress;                  //StartAdresse des aktuellen Datenvektors
+   typename Pool::size_type   nextCbVectorStartIndexInPool;     //StartIndex fuer den naechsten CbVector
+
+   //key - erstmal dummdoof
+   CbVectorKey nextCbVectorKey;
+};
+
+
+//////////////////////////////////////////////////////////////////////////
+//  CbVectorAllocatorPool
+//////////////////////////////////////////////////////////////////////////
+template< typename T >
+class CbVectorAllocatorPool : public CbVectorAllocator<T>
+{
+public:
+   //typedefs wiederholen, da Basisklasse = template -> "Dependent-Base"-Problem
+   typedef typename CbVector<T>::value_type          value_type;
+   typedef typename CbVector<value_type>::size_type  size_type;
+
+   friend class CbVectorPool< value_type >;
+
+public:
+   /*==========================================================*/
+   CbVectorAllocatorPool(const typename CbVectorPool< value_type >::CbVectorKey& key, CbVectorPool<value_type>* const& ptrVectorPool)
+      :  CbVectorAllocator<value_type>()
+       , key(key)
+       , startIndexInPool(0)
+       , ptrVectorPool(ptrVectorPool)
+   {
+      if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"ptrVectorPool==NULL") );
+   }
+   /*==========================================================*/
+   //hier wird der key automatisch erzeugt!
+   CbVectorAllocatorPool(CbVectorPool<value_type>* const& ptrVectorPool)
+      :  CbVectorAllocator<value_type>()
+       , startIndexInPool(0)
+       , ptrVectorPool(ptrVectorPool)
+   {
+      if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"ptrVectorPool==NULL") );
+      key = ptrVectorPool->getNextCbVectorKey();
+   }
+   /*==========================================================*/
+   bool alloc(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type())
+   {
+      if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"vectorPool seems to be destroyed, ptrVectorPool==NULL") );
+      return ptrVectorPool->allocVectorData(vec, dataSize, value);
+   }
+   /*==========================================================*/
+   bool resize(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type())
+   {
+      if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"vectorPool seems to be destroyed, ptrVectorPool==NULL") );
+      return ptrVectorPool->resizeVectorData(vec, dataSize, value);
+   }
+   /*==========================================================*/
+   bool dealloc(CbVector< value_type >& vec)
+   {
+      if(ptrVectorPool) return this->ptrVectorPool->deallocVectorData(vec);
+      //wenn kein ptrVectorPool -> wurde bereits deallokiert
+      return true;
+   }
+   /*==========================================================*/
+   const CbVectorPool< value_type >& getCbVectorPool()
+   {
+      if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"vectorPool seems to be destroyed, ptrVectorPool==NULL") );
+      return *ptrVectorPool;
+   }
+   /*==========================================================*/
+
+private:
+   typename CbVectorPool< value_type >::CbVectorKey     key;
+   typename CbVectorPool< value_type >::Pool::size_type startIndexInPool;
+
+   CbVectorPool< value_type >* ptrVectorPool;
+
+   CbVectorAllocatorPool( const CbVectorAllocatorPool& );                 //no copy allowed
+   const CbVectorAllocatorPool& operator=( const CbVectorAllocatorPool& );//no copy allowed
+};
+
+
+#endif //CBVECTORPOOL_H
diff --git a/source/ThirdParty/Library/basics/container/examples/CbVectorPool/CMakeLists.txt b/source/VirtualFluidsBasic/basics/container/examples/CbVectorPool/CMakeLists.txt
similarity index 97%
rename from source/ThirdParty/Library/basics/container/examples/CbVectorPool/CMakeLists.txt
rename to source/VirtualFluidsBasic/basics/container/examples/CbVectorPool/CMakeLists.txt
index 6cf6d2526048573fa4bbf1426f28279b0dc46bb4..a5113c6e77b669fb9a1eb824915569841927f806 100644
--- a/source/ThirdParty/Library/basics/container/examples/CbVectorPool/CMakeLists.txt
+++ b/source/VirtualFluidsBasic/basics/container/examples/CbVectorPool/CMakeLists.txt
@@ -1,30 +1,30 @@
-cmake_minimum_required(VERSION 2.6)
-
-PROJECT(CbVectorPoolTests)
-
-#################################################################
-# MACHINE_SPECIFIC CMAKE_CONFIG_FILE
-#################################################################
-INCLUDE("../../../../../../../CMake/CMakeCABMacros.txt")
-
-#################################################################
-###   PACKAGES                                               ###
-#################################################################
-INCLUDE(${SOURCE_ROOT}/basics/container/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt)
-
-#################################################################
-###   OWN DEFINES 						###
-#################################################################
-FILE(GLOB SPECIFIC_FILES ${SOURCE_ROOT}/basics/container/examples/CbVectorPool/*.h
-                         ${SOURCE_ROOT}/basics/container/examples/CbVectorPool/*.cpp ) 
-
-SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES})
-SOURCE_GROUP(z_specific FILES ${SPECIFIC_FILES})
-
-#################################################################
-###  PROJECT ERSTELLEN                                        ###
-#################################################################
-CREATE_CAB_PROJECT()
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(CbVectorPoolTests)
+
+#################################################################
+# MACHINE_SPECIFIC CMAKE_CONFIG_FILE
+#################################################################
+INCLUDE("../../../../../../../CMake/CMakeCABMacros.txt")
+
+#################################################################
+###   PACKAGES                                               ###
+#################################################################
+INCLUDE(${SOURCE_ROOT}/basics/container/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt)
+
+#################################################################
+###   OWN DEFINES 						###
+#################################################################
+FILE(GLOB SPECIFIC_FILES ${SOURCE_ROOT}/basics/container/examples/CbVectorPool/*.h
+                         ${SOURCE_ROOT}/basics/container/examples/CbVectorPool/*.cpp ) 
+
+SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES})
+SOURCE_GROUP(z_specific FILES ${SPECIFIC_FILES})
+
+#################################################################
+###  PROJECT ERSTELLEN                                        ###
+#################################################################
+CREATE_CAB_PROJECT()
diff --git a/source/ThirdParty/Library/basics/container/examples/CbVectorPool/functions.h b/source/VirtualFluidsBasic/basics/container/examples/CbVectorPool/functions.h
similarity index 97%
rename from source/ThirdParty/Library/basics/container/examples/CbVectorPool/functions.h
rename to source/VirtualFluidsBasic/basics/container/examples/CbVectorPool/functions.h
index b9e376731e5581c75efbfa093122afc42f2405ad..c9a49cdf53b8c0bb8c5885e5004968ed9e031e14 100644
--- a/source/ThirdParty/Library/basics/container/examples/CbVectorPool/functions.h
+++ b/source/VirtualFluidsBasic/basics/container/examples/CbVectorPool/functions.h
@@ -1,190 +1,190 @@
-#include <iostream>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string>
-#include <fstream>
-
-#include <basics/utilities/UbTuple.h>
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbSystem.h>
-#include <basics/utilities/UbFileOutputASCII.h>
-#include <basics/utilities/UbTiming.h>
-
-#include <basics/memory/MbSmartPtr.h>
-
-#include <basics/container/CbVector.h>
-#include <basics/container/CbVectorPool.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::vector;
-
-typedef long double value_type;
-typedef MbSmartPtr<CbVector< value_type > > CbVectorPtr;
-typedef MbSmartPtr<vector< value_type > >   StlVectorPtr;
-
-/*==========================================================*/
-template<typename T>
-inline void setValues(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec)
-{
-   if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() )
-   {
-      cerr<<"sizes:"<<endl;
-      cerr<<"stlvec... = "<<(int)stlvec.size()<<endl;
-      cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl;
-      cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl;
-      throw UB_THROW( UbException("setValues - sizeCheck failed") );
-   }
-   static value_type stlVal    = 1;
-   static value_type cbVal     = 1;
-   static value_type cbPoolVal = 1;
-
-   for(size_t i=0; i<cbvec.size(); i++) stlvec[i]    = stlVal   ++;
-   for(size_t i=0; i<cbvec.size(); i++) cbvec[i]     = cbVal    ++;
-   for(size_t i=0; i<cbvec.size(); i++) cbpoolvec[i] = cbPoolVal++;
-}
-/*==========================================================*/
-template<typename T>
-inline void setValues(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs)
-{
-   if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() )
-   {
-      cerr<<"sizes:"<<endl;
-      cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl;
-      cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl;
-      cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl;
-      throw UB_THROW( UbException("setValues glob - sizeCheck failed") );
-   }
-
-   for(size_t i=0; i<cbvecs.size(); i++)
-      setValues(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]);
-}
-/*==========================================================*/
-template<typename T>
-inline void resize(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec, std::size_t size, const T& val)
-{
-   stlvec.resize(size,val);
-   cbvec.resize(size,val);
-   cbpoolvec.resize(size,val);
-}
-/*==========================================================*/
-template<typename T>
-inline void resize(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, std::size_t size, const value_type& val, bool timed=false)
-{
-   if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() )
-   {
-      cerr<<"sizes:"<<endl;
-      cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl;
-      cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl;
-      cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl;
-      throw UB_THROW( UbException("resize glob - sizeCheck failed") );
-   }
-
-   if(timed)
-   {
-      UbTimer timer;
-      timer.start(); for(size_t i=0; i<cbvecs.size(); i++) stlvecs[i]->resize(size,val);    if(timed) cout<<"stl-resize    in "<<timer.stop()<<"s"<<endl;
-      timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbvecs[i]->resize(size,val);     if(timed) cout<<"cbStd-resize  in "<<timer.stop()<<"s"<<endl;
-      timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbpoolvecs[i]->resize(size,val); if(timed) cout<<"cbPool-resize in "<<timer.stop()<<"s"<<endl;
-   }
-   else
-   {
-      for(size_t i=0; i<cbvecs.size(); i++)
-         resize(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i],size,val);
-   }
-}
-/*==========================================================*/
-inline void createVecs(size_t number, int size,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false)
-{
-   UbTimer timer;
-   timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size)));                                                  if(timed) cout<<"stl-createVecs    in "<<timer.stop()<<"s"<<endl;
-   timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size)));                                                  if(timed) cout<<"cbStd-createVecs  in "<<timer.stop()<<"s"<<endl;
-   timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool))));  if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl;
-
-   for(size_t i=0; i<cbvecs.size(); i++) setValues(*stlvecs.back(),*cbvecs.back(),*cbpoolvecs.back());
-}
-/*==========================================================*/
-inline void createVecs(size_t number, size_t size, const value_type& val,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false)
-{
-   UbTimer timer;
-   timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size,val)));                                                  if(timed) cout<<"stl-createVecs    in "<<timer.stop()<<"s"<<endl;
-   timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorStd<value_type>(),val)));           if(timed) cout<<"cbStd-createVecs  in "<<timer.stop()<<"s"<<endl;
-   timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool),val)));  if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl;
-}
-/*==========================================================*/
-template<typename T>
-inline void equalCheck(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec)
-{
-   if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() )
-   {
-      cerr<<"sizes:"<<endl;
-      cerr<<"stlvec... = "<<(int)stlvec.size()<<endl;
-      cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl;
-      cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl;
-      throw UB_THROW( UbException("equalCheck - sizeCheck failed") );
-   }
-
-   bool check=true;
-   for(size_t i=0; i<cbvec.size(); i++)
-      if(stlvec[i] != cbvec[i] || stlvec[i] != cbpoolvec[i]  )
-         check=false;
-
-   if(!check)
-   {
-      cerr<<"\nstl - "; for(size_t i=0; i<cbvec.size(); i++) cout<<stlvec[i]<<" ";    cout<<endl;
-      cerr<<  "cbv - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbvec[i]<<" ";     cout<<endl;
-      cerr<<  "cbp - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbpoolvec[i]<<" "; cout<<endl;
-      throw UB_THROW( UbException("equalCheck - equalCheck failed") );
-   }
-}
-/*==========================================================*/
-template<typename T>
-void equalCheck(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs)
-{
-   if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() )
-   {
-      cerr<<"sizes:"<<endl;
-      cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl;
-      cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl;
-      cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl;
-      throw UB_THROW( UbException("equalCheck - sizeCheck failed") );
-   }
-
-   for(size_t i=0; i<cbvecs.size(); i++)
-   {
-      //cout<<"equalCheck i="<<i<<"/"<<cbvecs.size()-1;
-      equalCheck(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]);
-      //cout<<" passed"<<endl;
-   }
-}
-/*==========================================================*/
-void accessCheck(int times,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs)
-{
-   UbTimer timer;
-   timer.start();
-   for(size_t i=0; i<stlvecs.size(); i++)
-   {
-      vector<value_type>& vec = *stlvecs[i];
-      for(int m=0; m<times; m++)
-         for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k;
-   }
-   cout<<"stl-accessCheck       in "<<timer.stop()<<"s"<<endl;
-   timer.start();
-   for(size_t i=0; i<cbvecs.size(); i++)
-   {
-      CbVector<value_type>& vec = *cbvecs[i];
-      for(int m=0; m<times; m++)
-         for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k;
-   }
-   cout<<"cbStd-accessCheck     in "<<timer.stop()<<"s"<<endl;
-   timer.start();
-   for(size_t i=0; i<cbpoolvecs.size(); i++)
-   {
-      CbVector<value_type>& vec = *cbpoolvecs[i];
-      for(int m=0; m<times; m++)
-         for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k;
-   }
-   cout<<"cbPool-accessCheck    in "<<timer.stop()<<"s"<<endl;
-}
+#include <iostream>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string>
+#include <fstream>
+
+#include <basics/utilities/UbTuple.h>
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbSystem.h>
+#include <basics/utilities/UbFileOutputASCII.h>
+#include <basics/utilities/UbTiming.h>
+
+#include <basics/memory/MbSmartPtr.h>
+
+#include <basics/container/CbVector.h>
+#include <basics/container/CbVectorPool.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::vector;
+
+typedef long double value_type;
+typedef MbSmartPtr<CbVector< value_type > > CbVectorPtr;
+typedef MbSmartPtr<vector< value_type > >   StlVectorPtr;
+
+/*==========================================================*/
+template<typename T>
+inline void setValues(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec)
+{
+   if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() )
+   {
+      cerr<<"sizes:"<<endl;
+      cerr<<"stlvec... = "<<(int)stlvec.size()<<endl;
+      cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl;
+      cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl;
+      throw UB_THROW( UbException("setValues - sizeCheck failed") );
+   }
+   static value_type stlVal    = 1;
+   static value_type cbVal     = 1;
+   static value_type cbPoolVal = 1;
+
+   for(size_t i=0; i<cbvec.size(); i++) stlvec[i]    = stlVal   ++;
+   for(size_t i=0; i<cbvec.size(); i++) cbvec[i]     = cbVal    ++;
+   for(size_t i=0; i<cbvec.size(); i++) cbpoolvec[i] = cbPoolVal++;
+}
+/*==========================================================*/
+template<typename T>
+inline void setValues(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs)
+{
+   if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() )
+   {
+      cerr<<"sizes:"<<endl;
+      cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl;
+      cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl;
+      cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl;
+      throw UB_THROW( UbException("setValues glob - sizeCheck failed") );
+   }
+
+   for(size_t i=0; i<cbvecs.size(); i++)
+      setValues(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]);
+}
+/*==========================================================*/
+template<typename T>
+inline void resize(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec, std::size_t size, const T& val)
+{
+   stlvec.resize(size,val);
+   cbvec.resize(size,val);
+   cbpoolvec.resize(size,val);
+}
+/*==========================================================*/
+template<typename T>
+inline void resize(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, std::size_t size, const value_type& val, bool timed=false)
+{
+   if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() )
+   {
+      cerr<<"sizes:"<<endl;
+      cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl;
+      cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl;
+      cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl;
+      throw UB_THROW( UbException("resize glob - sizeCheck failed") );
+   }
+
+   if(timed)
+   {
+      UbTimer timer;
+      timer.start(); for(size_t i=0; i<cbvecs.size(); i++) stlvecs[i]->resize(size,val);    if(timed) cout<<"stl-resize    in "<<timer.stop()<<"s"<<endl;
+      timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbvecs[i]->resize(size,val);     if(timed) cout<<"cbStd-resize  in "<<timer.stop()<<"s"<<endl;
+      timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbpoolvecs[i]->resize(size,val); if(timed) cout<<"cbPool-resize in "<<timer.stop()<<"s"<<endl;
+   }
+   else
+   {
+      for(size_t i=0; i<cbvecs.size(); i++)
+         resize(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i],size,val);
+   }
+}
+/*==========================================================*/
+inline void createVecs(size_t number, int size,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false)
+{
+   UbTimer timer;
+   timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size)));                                                  if(timed) cout<<"stl-createVecs    in "<<timer.stop()<<"s"<<endl;
+   timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size)));                                                  if(timed) cout<<"cbStd-createVecs  in "<<timer.stop()<<"s"<<endl;
+   timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool))));  if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl;
+
+   for(size_t i=0; i<cbvecs.size(); i++) setValues(*stlvecs.back(),*cbvecs.back(),*cbpoolvecs.back());
+}
+/*==========================================================*/
+inline void createVecs(size_t number, size_t size, const value_type& val,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false)
+{
+   UbTimer timer;
+   timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size,val)));                                                  if(timed) cout<<"stl-createVecs    in "<<timer.stop()<<"s"<<endl;
+   timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorStd<value_type>(),val)));           if(timed) cout<<"cbStd-createVecs  in "<<timer.stop()<<"s"<<endl;
+   timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool),val)));  if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl;
+}
+/*==========================================================*/
+template<typename T>
+inline void equalCheck(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec)
+{
+   if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() )
+   {
+      cerr<<"sizes:"<<endl;
+      cerr<<"stlvec... = "<<(int)stlvec.size()<<endl;
+      cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl;
+      cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl;
+      throw UB_THROW( UbException("equalCheck - sizeCheck failed") );
+   }
+
+   bool check=true;
+   for(size_t i=0; i<cbvec.size(); i++)
+      if(stlvec[i] != cbvec[i] || stlvec[i] != cbpoolvec[i]  )
+         check=false;
+
+   if(!check)
+   {
+      cerr<<"\nstl - "; for(size_t i=0; i<cbvec.size(); i++) cout<<stlvec[i]<<" ";    cout<<endl;
+      cerr<<  "cbv - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbvec[i]<<" ";     cout<<endl;
+      cerr<<  "cbp - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbpoolvec[i]<<" "; cout<<endl;
+      throw UB_THROW( UbException("equalCheck - equalCheck failed") );
+   }
+}
+/*==========================================================*/
+template<typename T>
+void equalCheck(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs)
+{
+   if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() )
+   {
+      cerr<<"sizes:"<<endl;
+      cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl;
+      cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl;
+      cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl;
+      throw UB_THROW( UbException("equalCheck - sizeCheck failed") );
+   }
+
+   for(size_t i=0; i<cbvecs.size(); i++)
+   {
+      //cout<<"equalCheck i="<<i<<"/"<<cbvecs.size()-1;
+      equalCheck(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]);
+      //cout<<" passed"<<endl;
+   }
+}
+/*==========================================================*/
+void accessCheck(int times,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs)
+{
+   UbTimer timer;
+   timer.start();
+   for(size_t i=0; i<stlvecs.size(); i++)
+   {
+      vector<value_type>& vec = *stlvecs[i];
+      for(int m=0; m<times; m++)
+         for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k;
+   }
+   cout<<"stl-accessCheck       in "<<timer.stop()<<"s"<<endl;
+   timer.start();
+   for(size_t i=0; i<cbvecs.size(); i++)
+   {
+      CbVector<value_type>& vec = *cbvecs[i];
+      for(int m=0; m<times; m++)
+         for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k;
+   }
+   cout<<"cbStd-accessCheck     in "<<timer.stop()<<"s"<<endl;
+   timer.start();
+   for(size_t i=0; i<cbpoolvecs.size(); i++)
+   {
+      CbVector<value_type>& vec = *cbpoolvecs[i];
+      for(int m=0; m<times; m++)
+         for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k;
+   }
+   cout<<"cbPool-accessCheck    in "<<timer.stop()<<"s"<<endl;
+}
diff --git a/source/ThirdParty/Library/basics/container/examples/CbVectorPool/main.cpp b/source/VirtualFluidsBasic/basics/container/examples/CbVectorPool/main.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/container/examples/CbVectorPool/main.cpp
rename to source/VirtualFluidsBasic/basics/container/examples/CbVectorPool/main.cpp
index b3fe50b252cacff1c0484a54a77ee4427316d748..ede778c94479a4c8f4aead8a1db707793333aa72 100644
--- a/source/ThirdParty/Library/basics/container/examples/CbVectorPool/main.cpp
+++ b/source/VirtualFluidsBasic/basics/container/examples/CbVectorPool/main.cpp
@@ -1,277 +1,277 @@
-#include "./functions.h"
-
-using namespace std;
-
-//////////////////////////////////////////////////////////////////////////
-int main(int argc, char** argv)
-{
-   try
-   {
-       {
-         CbVectorPool<float>* floatPool = new CbVectorPool<float>(0);
-         CbVector<float> v1,v2,v3;
-         CbVector<float> v0(new CbVectorAllocatorPool<float>(104,floatPool) );
-         v0.resize(20);
-         v0[3] = 60000;
-         v0.resize(40);
-         v0[3] = 90000;
-         v1.setAllocator( new CbVectorAllocatorPool<float>(100,floatPool) );
-         v2.setAllocator( new CbVectorAllocatorPool<float>(101,floatPool) );
-         v3.setAllocator( new CbVectorAllocatorPool<float>(102,floatPool) );
-         v1.resize(20, 0.0);
-         v1.resize(30, 0.0);
-         v2.resize(0);
-         v2.resize(40, 0.0);
-         v3.resize(30, 0.0);
-         v3.resize(50, 0.0);
-
-         for(CbVector<float>::size_type i=v1.size()-1; i>=15; i--)
-            v1[i] = (CbVector<float>::value_type)i;
-         for(CbVector<float>::size_type i=v2.size()-1; i>=35; i--)
-            v2[i] = (CbVector<float>::value_type)i;
-         for(CbVector<float>::size_type i=v3.size()-1; i>=10; i--)
-            v3[i] = (CbVector<float>::value_type)i;
-         v1.size(); 
-         v2.size();
-         v3.size();
-         for(CbVector<float>::size_type i=0; i<v1.size(); i++)  v1[i];
-         v1.size();
-         v2.size();
-         v3.size();
-         for(CbVector<float>::size_type i=0; i<v2.size(); i++) v2[i];
-         v1.size();
-         v2.size();
-         v3.size();
-         for(CbVector<float>::size_type i=0; i<v3.size(); i++) v3[i];
-      }
-      
-     CbVectorPool<value_type>* vectorPool = new CbVectorPool<value_type>(0);
-
-     vector< StlVectorPtr > stlVecs;
-     vector< CbVectorPtr >  cbVecs;
-     vector< CbVectorPtr >  cbPoolVecs;
-
-     cout<<"check"<<__LINE__<<endl;
-     createVecs(10,12,0,stlVecs,cbVecs,cbPoolVecs,vectorPool);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     resize(stlVecs,cbVecs,cbPoolVecs,0,2);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     resize(stlVecs,cbVecs,cbPoolVecs,3,3);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     setValues(stlVecs,cbVecs,cbPoolVecs);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     createVecs(8,5,stlVecs,cbVecs,cbPoolVecs,vectorPool);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     resize(stlVecs,cbVecs,cbPoolVecs,20,7);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     setValues(stlVecs,cbVecs,cbPoolVecs);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     resize(stlVecs,cbVecs,cbPoolVecs,20,3);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     setValues(stlVecs,cbVecs,cbPoolVecs);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     resize(stlVecs,cbVecs,cbPoolVecs,0,7);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     setValues(stlVecs,cbVecs,cbPoolVecs);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     resize(stlVecs,cbVecs,cbPoolVecs,20,3);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     setValues(stlVecs,cbVecs,cbPoolVecs);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     createVecs(4,3,stlVecs,cbVecs,cbPoolVecs,vectorPool);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     resize(stlVecs,cbVecs,cbPoolVecs,20,3);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     setValues(stlVecs,cbVecs,cbPoolVecs);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     resize(stlVecs,cbVecs,cbPoolVecs,0,7);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     setValues(stlVecs,cbVecs,cbPoolVecs);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     resize(stlVecs,cbVecs,cbPoolVecs,20,3);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     //dealloc check
-     stlVecs.resize(5);
-     cbVecs.resize(5);
-     cbPoolVecs.resize(5);
-
-     cout<<"check"<<__LINE__<<endl;
-     createVecs(4,3,stlVecs,cbVecs,cbPoolVecs,vectorPool);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     setValues(stlVecs,cbVecs,cbPoolVecs);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     createVecs(4,3,stlVecs,cbVecs,cbPoolVecs,vectorPool);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-
-     //operator= check
-     CbVector<value_type> testPool1(10, new CbVectorAllocatorPool<value_type>(vectorPool));
-     CbVector<value_type> testPool2(1 , new CbVectorAllocatorPool<value_type>(vectorPool));
-     CbVector<value_type> testPool3(8 , new CbVectorAllocatorPool<value_type>(vectorPool));
-     CbVector<value_type> testPool4(8 , new CbVectorAllocatorPool<value_type>(vectorPool));
-     CbVector<value_type> testStd1(10);
-
-     for(CbVector<value_type>::size_type i=0; i<testStd1.size(); i++ )
-        testStd1[i] = (value_type)i*10;
-
-     testPool1 = testStd1;
-     testPool4 = testStd1;
-     testPool3 = testPool4;
-     testPool2 = testPool3;
-
-     for(CbVector<value_type>::size_type i=0; i<testStd1.size(); i++ )
-        cout<<testStd1[i]<<" "; cout<<endl;
-     for(CbVector<value_type>::size_type i=0; i<testPool1.size(); i++ )
-        cout<<testPool1[i]<<" "; cout<<endl;
-     for(CbVector<value_type>::size_type i=0; i<testPool2.size(); i++ )
-        cout<<testPool2[i]<<" "; cout<<endl;
-     for(CbVector<value_type>::size_type i=0; i<testPool3.size(); i++ )
-        cout<<testPool3[i]<<" "; cout<<endl;
-     for(CbVector<value_type>::size_type i=0; i<testPool4.size(); i++ )
-        cout<<testPool4[i]<<" "; cout<<endl;
-    ///end
-
-
-     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
-     cout<<"// access test - start"<<endl;
-     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
-     cout<<"check"<<__LINE__<<endl;
-     createVecs(1000,1000,stlVecs,cbVecs,cbPoolVecs,vectorPool,true);
-
-     CbVectorPool<value_type>* pool2 = new CbVectorPool<value_type>(1);
-     vector< StlVectorPtr > stlVecs2;
-     vector< CbVectorPtr >  cbVecs2;
-     vector< CbVectorPtr >  cbPoolVecs2;
-     createVecs(1000,1000,stlVecs2,cbVecs2,cbPoolVecs2,pool2,true);
-
-     cout<<"access check\n";
-     //accessCheck(1000,stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     setValues(stlVecs,cbVecs,cbPoolVecs);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"check"<<__LINE__<<endl;
-     resize(stlVecs,cbVecs,cbPoolVecs,120,3,true);
-     equalCheck(stlVecs,cbVecs,cbPoolVecs);
-
-     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
-     cout<<"// access test - end"<<endl;
-     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
-
-     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
-     cout<<"// EXCEPTION TEST - start"<<endl;
-     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
-     delete vectorPool;
-     vectorPool = NULL;
-     try
-     {
-        resize(stlVecs,cbVecs,cbPoolVecs,20,3);
-     }
-     catch(UbException& e)
-     {
-        cout<<"if exception tells something about \"vectorPool==NULL\" -> test successfully passed:"<<endl;
-        cout<<e<<endl;
-     }
-     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
-     cout<<"// EXCEPTION TEST - end"<<endl;
-     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
-
-     cout<<"\n\n\nALL TESTS PASSED\n";
-   }
-   catch(UbException& e)
-   {
-      std::cerr<<e<<std::endl;
-   }
-   catch(const std::exception &e)
-   {
-      std::cerr << "Caught exception:\n";
-      std::cerr << "Type: " << typeid(e).name() << "\n";
-      std::cerr << "What: " << e.what() << "\n";
-   }
-   catch(...)
-   {
-      std::cerr<<" **            Verdammte Scheisse - mal wieder Mist gebaut!                **"<<endl;
-   }
-    return 0;
-}
-
-// #include <functional>
-// #include <iostream>
-// #include <vector>
-// #include <algorithm>
-// #include <typeinfo>
-//
-// struct bar
-// {
-//    bar()
-//       : data(0)
-//    {}
-//
-//    void foo(const std::size_t value) { std::cout << "data = " << value << " (old: " << data << ");" << std::endl; data = value; }
-//
-// private:
-//    std::size_t data;
-// };
-//
-// int main()
-// {
-//    std::vector<bar> data(10);
-//
-//    /* operator[] => Indexoperator */
-//    for (std::size_t i(0); i < data.size(); ++i)
-//       data[i].foo(2);
-//
-//    /* begin(), end() => Iterator */
-//    const std::vector<bar>::iterator it_end(data.end());
-//    for (std::vector<bar>::iterator it(data.begin()); it != it_end; ++it)
-//       it->foo(3);
-//
-//    /* for_each => Algorithm | Iterator */
-//    std::for_each(data.begin(), data.end(), std::bind2nd(std::mem_fun_ref(&bar::foo), 2));
-// }
+#include "./functions.h"
+
+using namespace std;
+
+//////////////////////////////////////////////////////////////////////////
+int main(int argc, char** argv)
+{
+   try
+   {
+       {
+         CbVectorPool<float>* floatPool = new CbVectorPool<float>(0);
+         CbVector<float> v1,v2,v3;
+         CbVector<float> v0(new CbVectorAllocatorPool<float>(104,floatPool) );
+         v0.resize(20);
+         v0[3] = 60000;
+         v0.resize(40);
+         v0[3] = 90000;
+         v1.setAllocator( new CbVectorAllocatorPool<float>(100,floatPool) );
+         v2.setAllocator( new CbVectorAllocatorPool<float>(101,floatPool) );
+         v3.setAllocator( new CbVectorAllocatorPool<float>(102,floatPool) );
+         v1.resize(20, 0.0);
+         v1.resize(30, 0.0);
+         v2.resize(0);
+         v2.resize(40, 0.0);
+         v3.resize(30, 0.0);
+         v3.resize(50, 0.0);
+
+         for(CbVector<float>::size_type i=v1.size()-1; i>=15; i--)
+            v1[i] = (CbVector<float>::value_type)i;
+         for(CbVector<float>::size_type i=v2.size()-1; i>=35; i--)
+            v2[i] = (CbVector<float>::value_type)i;
+         for(CbVector<float>::size_type i=v3.size()-1; i>=10; i--)
+            v3[i] = (CbVector<float>::value_type)i;
+         v1.size(); 
+         v2.size();
+         v3.size();
+         for(CbVector<float>::size_type i=0; i<v1.size(); i++)  v1[i];
+         v1.size();
+         v2.size();
+         v3.size();
+         for(CbVector<float>::size_type i=0; i<v2.size(); i++) v2[i];
+         v1.size();
+         v2.size();
+         v3.size();
+         for(CbVector<float>::size_type i=0; i<v3.size(); i++) v3[i];
+      }
+      
+     CbVectorPool<value_type>* vectorPool = new CbVectorPool<value_type>(0);
+
+     vector< StlVectorPtr > stlVecs;
+     vector< CbVectorPtr >  cbVecs;
+     vector< CbVectorPtr >  cbPoolVecs;
+
+     cout<<"check"<<__LINE__<<endl;
+     createVecs(10,12,0,stlVecs,cbVecs,cbPoolVecs,vectorPool);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     resize(stlVecs,cbVecs,cbPoolVecs,0,2);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     resize(stlVecs,cbVecs,cbPoolVecs,3,3);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     setValues(stlVecs,cbVecs,cbPoolVecs);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     createVecs(8,5,stlVecs,cbVecs,cbPoolVecs,vectorPool);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     resize(stlVecs,cbVecs,cbPoolVecs,20,7);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     setValues(stlVecs,cbVecs,cbPoolVecs);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     resize(stlVecs,cbVecs,cbPoolVecs,20,3);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     setValues(stlVecs,cbVecs,cbPoolVecs);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     resize(stlVecs,cbVecs,cbPoolVecs,0,7);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     setValues(stlVecs,cbVecs,cbPoolVecs);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     resize(stlVecs,cbVecs,cbPoolVecs,20,3);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     setValues(stlVecs,cbVecs,cbPoolVecs);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     createVecs(4,3,stlVecs,cbVecs,cbPoolVecs,vectorPool);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     resize(stlVecs,cbVecs,cbPoolVecs,20,3);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     setValues(stlVecs,cbVecs,cbPoolVecs);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     resize(stlVecs,cbVecs,cbPoolVecs,0,7);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     setValues(stlVecs,cbVecs,cbPoolVecs);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     resize(stlVecs,cbVecs,cbPoolVecs,20,3);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     //dealloc check
+     stlVecs.resize(5);
+     cbVecs.resize(5);
+     cbPoolVecs.resize(5);
+
+     cout<<"check"<<__LINE__<<endl;
+     createVecs(4,3,stlVecs,cbVecs,cbPoolVecs,vectorPool);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     setValues(stlVecs,cbVecs,cbPoolVecs);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     createVecs(4,3,stlVecs,cbVecs,cbPoolVecs,vectorPool);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+
+     //operator= check
+     CbVector<value_type> testPool1(10, new CbVectorAllocatorPool<value_type>(vectorPool));
+     CbVector<value_type> testPool2(1 , new CbVectorAllocatorPool<value_type>(vectorPool));
+     CbVector<value_type> testPool3(8 , new CbVectorAllocatorPool<value_type>(vectorPool));
+     CbVector<value_type> testPool4(8 , new CbVectorAllocatorPool<value_type>(vectorPool));
+     CbVector<value_type> testStd1(10);
+
+     for(CbVector<value_type>::size_type i=0; i<testStd1.size(); i++ )
+        testStd1[i] = (value_type)i*10;
+
+     testPool1 = testStd1;
+     testPool4 = testStd1;
+     testPool3 = testPool4;
+     testPool2 = testPool3;
+
+     for(CbVector<value_type>::size_type i=0; i<testStd1.size(); i++ )
+        cout<<testStd1[i]<<" "; cout<<endl;
+     for(CbVector<value_type>::size_type i=0; i<testPool1.size(); i++ )
+        cout<<testPool1[i]<<" "; cout<<endl;
+     for(CbVector<value_type>::size_type i=0; i<testPool2.size(); i++ )
+        cout<<testPool2[i]<<" "; cout<<endl;
+     for(CbVector<value_type>::size_type i=0; i<testPool3.size(); i++ )
+        cout<<testPool3[i]<<" "; cout<<endl;
+     for(CbVector<value_type>::size_type i=0; i<testPool4.size(); i++ )
+        cout<<testPool4[i]<<" "; cout<<endl;
+    ///end
+
+
+     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
+     cout<<"// access test - start"<<endl;
+     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
+     cout<<"check"<<__LINE__<<endl;
+     createVecs(1000,1000,stlVecs,cbVecs,cbPoolVecs,vectorPool,true);
+
+     CbVectorPool<value_type>* pool2 = new CbVectorPool<value_type>(1);
+     vector< StlVectorPtr > stlVecs2;
+     vector< CbVectorPtr >  cbVecs2;
+     vector< CbVectorPtr >  cbPoolVecs2;
+     createVecs(1000,1000,stlVecs2,cbVecs2,cbPoolVecs2,pool2,true);
+
+     cout<<"access check\n";
+     //accessCheck(1000,stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     setValues(stlVecs,cbVecs,cbPoolVecs);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"check"<<__LINE__<<endl;
+     resize(stlVecs,cbVecs,cbPoolVecs,120,3,true);
+     equalCheck(stlVecs,cbVecs,cbPoolVecs);
+
+     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
+     cout<<"// access test - end"<<endl;
+     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
+
+     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
+     cout<<"// EXCEPTION TEST - start"<<endl;
+     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
+     delete vectorPool;
+     vectorPool = NULL;
+     try
+     {
+        resize(stlVecs,cbVecs,cbPoolVecs,20,3);
+     }
+     catch(UbException& e)
+     {
+        cout<<"if exception tells something about \"vectorPool==NULL\" -> test successfully passed:"<<endl;
+        cout<<e<<endl;
+     }
+     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
+     cout<<"// EXCEPTION TEST - end"<<endl;
+     cout<<"//////////////////////////////////////////////////////////////////////////"<<endl;
+
+     cout<<"\n\n\nALL TESTS PASSED\n";
+   }
+   catch(UbException& e)
+   {
+      std::cerr<<e<<std::endl;
+   }
+   catch(const std::exception &e)
+   {
+      std::cerr << "Caught exception:\n";
+      std::cerr << "Type: " << typeid(e).name() << "\n";
+      std::cerr << "What: " << e.what() << "\n";
+   }
+   catch(...)
+   {
+      std::cerr<<" **            Verdammte Scheisse - mal wieder Mist gebaut!                **"<<endl;
+   }
+    return 0;
+}
+
+// #include <functional>
+// #include <iostream>
+// #include <vector>
+// #include <algorithm>
+// #include <typeinfo>
+//
+// struct bar
+// {
+//    bar()
+//       : data(0)
+//    {}
+//
+//    void foo(const std::size_t value) { std::cout << "data = " << value << " (old: " << data << ");" << std::endl; data = value; }
+//
+// private:
+//    std::size_t data;
+// };
+//
+// int main()
+// {
+//    std::vector<bar> data(10);
+//
+//    /* operator[] => Indexoperator */
+//    for (std::size_t i(0); i < data.size(); ++i)
+//       data[i].foo(2);
+//
+//    /* begin(), end() => Iterator */
+//    const std::vector<bar>::iterator it_end(data.end());
+//    for (std::vector<bar>::iterator it(data.begin()); it != it_end; ++it)
+//       it->foo(3);
+//
+//    /* for_each => Algorithm | Iterator */
+//    std::for_each(data.begin(), data.end(), std::bind2nd(std::mem_fun_ref(&bar::foo), 2));
+// }
diff --git a/source/VirtualFluidsBasic/basics/memory/CMakePackage.txt b/source/VirtualFluidsBasic/basics/memory/CMakePackage.txt
new file mode 100644
index 0000000000000000000000000000000000000000..1b8416f010d2a7de30b8f70c9abf19a96dd8cf8f
--- /dev/null
+++ b/source/VirtualFluidsBasic/basics/memory/CMakePackage.txt
@@ -0,0 +1,2 @@
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
diff --git a/source/ThirdParty/Library/basics/memory/MbChessMemPool2D.h b/source/VirtualFluidsBasic/basics/memory/MbChessMemPool2D.h
similarity index 97%
rename from source/ThirdParty/Library/basics/memory/MbChessMemPool2D.h
rename to source/VirtualFluidsBasic/basics/memory/MbChessMemPool2D.h
index c665f7798f096fd9bc95d70e6d45e7b4f2716b30..3ae46d2a52a8271bda3534fa26eaf477d05967a9 100644
--- a/source/ThirdParty/Library/basics/memory/MbChessMemPool2D.h
+++ b/source/VirtualFluidsBasic/basics/memory/MbChessMemPool2D.h
@@ -1,519 +1,519 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef MBCHESSMEMPOOL2D_H
-#define MBCHESSMEMPOOL2D_H
-
-#include <map>
-#include <vector>
-#include <iostream>
-#include <iomanip>
-#include <string>
-#include <sstream>
-#include <fstream>
-#include <cmath>
-#include <typeinfo>
-
-#include <basics/utilities/UbException.h>
-
-
-template <class TData, std::size_t cachSize>
-class MbChessMemPool2D;
-
-//////////////////////////////////////////////////////////////////////////
-//class MbChessMap2DKey
-//key zum Auffinden der ChessMem2DBlocks
-class MbChessMap2DKey
-{
-public:
-   //////////////////////////////////////////////////////////////////////////
-   //Konstruktoren
-   MbChessMap2DKey(): mVectorPos(0),mFirstCriteria(0),mSecondCriteria(0)
-   {
-
-   }
-   /*==========================================================*/
-   MbChessMap2DKey(std::size_t vectorPos, std::size_t firstCriteria, std::size_t secondCriteria)
-      : mVectorPos(vectorPos), mFirstCriteria(firstCriteria), mSecondCriteria(secondCriteria)
-   {
-   }
-   /*==========================================================*/
-   MbChessMap2DKey& operator=(const MbChessMap2DKey& srcKey)
-   {
-      if(this == &srcKey ) return *this;
-
-      mVectorPos      = srcKey.mVectorPos;
-      mFirstCriteria  = srcKey.mFirstCriteria;
-      mSecondCriteria = srcKey.mSecondCriteria;
-
-      return *this;
-   }
-
-   //////////////////////////////////////////////////////////////////////////
-   //global ueberladene Operatoren
-   friend inline bool operator<(const MbChessMap2DKey& lhsKey,const MbChessMap2DKey& rhsKey)
-   {
-      if(lhsKey.mFirstCriteria  < rhsKey.mFirstCriteria ) return true;
-      if(lhsKey.mFirstCriteria  > rhsKey.mFirstCriteria ) return false;
-      if(lhsKey.mSecondCriteria < rhsKey.mSecondCriteria) return true;
-
-      return false;
-   }
-   /*==========================================================*/
-   friend inline bool operator==(const MbChessMap2DKey& lhsKey,const MbChessMap2DKey& rhsKey)
-   {
-      if(lhsKey.mVectorPos      != rhsKey.mVectorPos      ) return false;
-      if(lhsKey.mFirstCriteria  != rhsKey.mFirstCriteria  ) return false;
-      if(lhsKey.mSecondCriteria != rhsKey.mSecondCriteria ) return false;
-
-      return true;
-   }
-   //ueberladene Operatoren
-   friend inline bool operator!=(const MbChessMap2DKey& lhsKey,const MbChessMap2DKey& rhsKey)
-   {
-      return !(lhsKey==rhsKey);
-   }
-   //ueberladene Operatoren
-   /*==========================================================*/
-   friend inline std::ostream& operator << (std::ostream& os, const MbChessMap2DKey& key)
-   {
-      os<<"VectorPos,first-,second-,third Criteria) (";
-      os<<key.mVectorPos<<","<<key.mFirstCriteria<<","<<key.mSecondCriteria<<")";
-      return os;
-   }
-
-   //////////////////////////////////////////////////////////////////////////
-   //public Methoden
-   std::size_t getVectorPos() {return mVectorPos;}
-private:
-   //////////////////////////////////////////////////////////////////////////
-   //private Member
-   std::size_t mVectorPos;
-   std::size_t mFirstCriteria;
-   std::size_t mSecondCriteria;
-};
-
-
-
-template<class T,std::size_t cachSize>
-class MbChessMem2DBlock
-{
-   friend class MbChessMemPool2D<T,cachSize>;
-public:
-   //////////////////////////////////////////////////////////////////////////
-   //Konstruktoren
-   MbChessMem2DBlock()
-   {
-      mUsedElements = 0;
-      std::size_t arrayLength = mBlockWidth*mBlockWidth;
-      //mDataElements = new T[arrayLength];
-      mDataElements = operator new(arrayLength*sizeof(T));
-      mFlagVector   = new bool[arrayLength];
-      for(std::size_t i=0;i<arrayLength;i++) mFlagVector[i] = false;
-   }
-   //////////////////////////////////////////////////////////////////////////
-   //Destruktor
-   ~MbChessMem2DBlock()
-   {
-      //if(mDataElements) delete[] mDataElements;
-      if(mDataElements) operator delete(mDataElements);
-      if(mFlagVector)   delete[] mFlagVector;
-   }
-
-private:
-   //////////////////////////////////////////////////////////////////////////
-   //private Methoden
-   void* getReference(std::size_t chessX1, std::size_t chessX2)
-   {
-      std::size_t arrayIndex = chessX2*mBlockWidth + chessX1;
-      #ifdef _DEBUG
-         if(arrayIndex>=mBlockWidth*mBlockWidth) UB_THROW( UbException(UB_EXARGS,"index out of range") );
-      #endif
-
-      if(mFlagVector[arrayIndex]==true) UB_THROW( UbException(UB_EXARGS,"memory already allocated!") );
-
-      mUsedElements++;
-      mFlagVector[arrayIndex]=true;
-
-      return (void*)((T*)(mDataElements)+arrayIndex);//&(mDataElements[arrayIndex]);
-   }
-   /*==========================================================*/
-   std::size_t freeReference(void* p)
-   {
-      //std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - mDataElements); //mDataElements = &mDataElements[0]
-      std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - static_cast<T*>(mDataElements));
-
-      #ifdef _DEBUG
-         if(arrayIndex>=mBlockWidth*mBlockWidth) UB_THROW( UbException(UB_EXARGS,"index out of range") );
-      #endif
-
-      if(mFlagVector[arrayIndex]==false) UB_THROW( UbException(UB_EXARGS,"memory not allocated!") );
-
-      mFlagVector[arrayIndex]=false;
-
-      return --mUsedElements;
-   }
-   /*==========================================================*/
-   std::size_t getNofUsedElements()   { return mUsedElements; }
-   /*==========================================================*/
-   void addPointerToTElementsToVector(std::vector<T*>& tdataVector)
-   {
-      std::size_t arrayLength = mBlockWidth*mBlockWidth;
-      for(std::size_t arrayIndex=0;arrayIndex<arrayLength;arrayIndex++)
-      {
-         //if(mFlagVector[arrayIndex]) tdataVector.push_back(&mDataElements[arrayIndex]);
-         if(mFlagVector[arrayIndex]) tdataVector.push_back(static_cast<T*>(mDataElements)+arrayIndex);
-      }
-   }
-   /*==========================================================*/
-   template<typename Pred>
-   void addPointerToTElementsToVector(std::vector<T*>& tdataVector, Pred& pred)
-   {
-      std::size_t arrayLength = mBlockWidth*mBlockWidth;
-      T* tmp;
-      for(std::size_t arrayIndex=0;arrayIndex<arrayLength;arrayIndex++)
-      {
-         if(mFlagVector[arrayIndex])
-         {
-            //tmp = &mDataElements[arrayIndex];
-            tmp = (static_cast<T*>(mDataElements))+arrayIndex;
-            if( pred(*tmp) ) tdataVector.push_back(tmp);
-         }
-      }
-   }
-private:
-   //////////////////////////////////////////////////////////////////////////
-   //static Member
-   static const std::size_t   mBlockWidth;
-
-   //////////////////////////////////////////////////////////////////////////
-   //private Member
-   std::size_t   mUsedElements;
-   //T*    mDataElements;
-   void* mDataElements;
-   bool* mFlagVector;
-
-};
-
-//////////////////////////////////////////////////////////////////////////
-//class MbChessMemPool2D
-//zum Verwalten von TData Elementen in einer Schabrett-artigen Struktur
-//die ChessMemBloecke haben hier eine Groesse von ~cachSize
-template <class TData, std::size_t cachSize>
-class MbChessMemPool2D
-{
-private:
-   //////////////////////////////////////////////////////////////////////////
-   //protected static const Member
-   const static std::size_t mCacheSize;
-
-   //////////////////////////////////////////////////////////////////////////
-   //protected Member
-   static std::vector< std::map< MbChessMap2DKey , MbChessMem2DBlock< TData,cachSize >* > > mMapVector;
-   static std::map< void*, MbChessMap2DKey > mPointerKeyMap;
-
-   //////////////////////////////////////////////////////////////////////////
-   //protected Konstrukoren
-   MbChessMemPool2D() //protected, um max einmal vererbt werden zu koennen!!!
-   {              //zudem kann man so keine elmente von TreeBasedMemPool erstellen
-
-   }
-   //////////////////////////////////////////////////////////////////////////
-   //Destruktor
-    ~MbChessMemPool2D()
-   {
-   }
-
-public:
-
-   //////////////////////////////////////////////////////////////////////////
-   //static public Methoden
-   static void* getReference(std::size_t level, std::size_t ix1, std::size_t ix2)
-   {
-      if(!MbChessMem2DBlock< TData,cachSize >::mBlockWidth)
-      {
-         std::stringstream ss;
-         ss<<"TreeBasedMemPool() - InitialisationError\n";
-         ss<<"\t size of StorageData ("<<typeid(TData).name()<<", "<<sizeof(TData)<<" byte)\n";
-         ss<<"\t exceeds user-specifyed cache-zize ("<<mCacheSize<<" byte)\n";
-         ss<<"\t cache-size has to be larger than data-size";
-         UB_THROW( UbException(ss.str()) );
-      }
-
-      if( mMapVector.size()<=level ) mMapVector.resize(level+1);
-
-      std::size_t chessX1 = ix1/(MbChessMem2DBlock<TData,cachSize>::mBlockWidth);
-      std::size_t chessX2 = ix2/(MbChessMem2DBlock<TData,cachSize>::mBlockWidth);
-
-      MbChessMap2DKey mapKey(level,chessX1,chessX2);
-
-      typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos = mMapVector[level].find(mapKey);
-
-      MbChessMem2DBlock<TData,cachSize>* memBlock = NULL;
-
-      if(pos==mMapVector[level].end())
-      {
-         memBlock = new MbChessMem2DBlock<TData,cachSize>;
-         (mMapVector[level])[mapKey] = memBlock;
-      }
-      else memBlock = pos->second;
-
-      std::size_t internalChessX1 = ix1%(MbChessMem2DBlock<TData,cachSize>::mBlockWidth);
-      std::size_t internalChessX2 = ix2%(MbChessMem2DBlock<TData,cachSize>::mBlockWidth);
-
-      void* p = memBlock->getReference(internalChessX1,internalChessX2);
-
-      mPointerKeyMap[p]=mapKey;
-
-      return p;
-   }
-   /*==========================================================*/
-   static void freeReference(void *p)
-   {
-      typename std::map<void*,MbChessMap2DKey>::iterator posPointerKeyMap = mPointerKeyMap.find(p);
-
-      if(posPointerKeyMap==mPointerKeyMap.end()) UB_THROW( UbException(UB_EXARGS,"pointer not in map") );
-
-      MbChessMap2DKey mapKey = posPointerKeyMap->second;
-      mPointerKeyMap.erase(posPointerKeyMap);
-
-      typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator posMemBlockMap;
-      posMemBlockMap = mMapVector[mapKey.getVectorPos()].find(mapKey);
-
-      if(posMemBlockMap == mMapVector[mapKey.getVectorPos()].end())
-         UB_THROW( UbException(UB_EXARGS,"mapKey not in ChessMem2DBlockMap") );
-
-      std::size_t leftElements = posMemBlockMap->second->freeReference(p);
-      if(!leftElements)
-      {
-         MbChessMem2DBlock<TData,cachSize>* tmp = posMemBlockMap->second;
-         mMapVector[mapKey.getVectorPos()].erase(posMemBlockMap);
-         delete tmp;
-      }
-   }
-   /*==========================================================*/
-   static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector)
-   {
-      tdataVector.clear();
-
-      if(level>=mMapVector.size()) return;
-      typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos;
-      for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos)
-      {
-         pos->second->addPointerToTElementsToVector(tdataVector);
-      }
-   }
-   /*==========================================================*/
-   static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector)
-   {
-      tdataVector.clear();
-
-      typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos;
-
-      for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ )
-      {
-         for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos)
-         {
-            pos->second->addPointerToTElementsToVector(tdataVector);
-         }
-      }
-   }
-   /*==========================================================*/
-   template<typename Pred>
-   static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector, Pred pred)
-   {
-      tdataVector.clear();
-
-      if(level>=mMapVector.size()) return;
-      typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos;
-      for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos)
-      {
-         pos->second->addPointerToTElementsToVector(tdataVector,pred);
-      }
-   }
-   /*==========================================================*/
-   template<typename Pred>
-   static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector, Pred pred)
-   {
-      tdataVector.clear();
-
-      typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos;
-
-      for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ )
-      {
-         for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos)
-         {
-            pos->second->addPointerToTElementsToVector(tdataVector,pred);
-         }
-      }
-   }
-   /*==========================================================*/
-   static std::size_t getNumberOfChessMemoryBlocks()
-   {
-      std::size_t nofElements = 0;
-      for(std::size_t i=0; i<mMapVector.size(); i++)
-      {
-         nofElements+=mMapVector[i].size();
-      }
-      return nofElements;
-   }
-   /*==========================================================*/
-   static std::size_t getNumberOfChessMemoryBlocks(std::size_t level)
-   {
-      if(level<mMapVector.size() )return mMapVector[level].size();
-      return 0;
-   }
-   /*==========================================================*/
-   static std::size_t getNumberOfStoredDataElements()
-   {
-      return mPointerKeyMap.size();
-   }
-   /*==========================================================*/
-   static std::size_t getNumberOfStoredDataElements(std::size_t level)
-   {
-      if(level<mMapVector.size() )
-      {
-         std::size_t nofElements = 0;
-         typename std::map< MbChessMap2DKey , MbChessMem2DBlock< TData,cachSize >* >::iterator pos;
-
-         for(pos=mMapVector[level].begin(); pos!=mMapVector[level].end(); ++pos)
-         {
-            nofElements += pos->second->getNofUsedElements();
-         }
-         return nofElements;
-      }
-      return 0;
-
-   }
-   /*==========================================================*/
-   static std::string toString()
-   {
-      long double capaticityPerBlock   = (std::size_t)pow((double)MbChessMem2DBlock<TData,cachSize>::mBlockWidth,2.0);
-      std::size_t storedElements       = MbChessMemPool2D<TData,cachSize>::getNumberOfStoredDataElements();
-      std::size_t initialisedMemBlocks = MbChessMemPool2D<TData,cachSize>::getNumberOfChessMemoryBlocks();
-
-      std::stringstream ss;
-      ss<<std::endl;
-      ss<<"****************** MbChessMemPool2D-Info (BEGIN) ******************"<<std::endl;
-      ss<<"type of Storage-Data.................. : "<<typeid(TData).name()<<std::endl;
-      ss<<"size of Storage-Data........... [bytes]: "<<sizeof(TData)<<std::endl;
-      ss<<"specified cache-size........... [bytes]: "<<mCacheSize<<std::endl;
-      ss<<"#elements per MbChessMem2DBlock [bytes]: "<<capaticityPerBlock<<std::endl;
-      ss<<"mem per MbChessMem2DBlock...... [bytes]: "<<capaticityPerBlock*sizeof(TData)<<std::endl;
-      ss<<"used cache-size[%]............. [bytes]: "<<capaticityPerBlock*sizeof(TData)/(double)mCacheSize*100<<std::endl;
-      ss<<"\n";
-      ss<<"#stored Elements  = "<<storedElements<<std::endl;
-      ss<<"#ChessMem2DBlocks = "<<initialisedMemBlocks<<std::endl;
-      ss<<std::endl;
-      ss<<"level | #ChessMem2DBlocks | #stored Elements | used capaticity [%] \n";
-      ss<<"----------------------------------------------------------------\n";
-      for(std::size_t level=0;level<mMapVector.size();level++)
-      {
-         std::size_t nofStoredElements = MbChessMemPool2D<TData,cachSize>::getNumberOfStoredDataElements(level);
-         std::size_t nofChessMem2DBlocks = MbChessMemPool2D<TData,cachSize>::getNumberOfChessMemoryBlocks(level);
-
-         ss<<std::left<<" "<<std::setw(5)<<level<<"| "
-            <<std::setw(16)<<nofChessMem2DBlocks<<"| "
-            <<std::setw(17)<<nofStoredElements<<"| ";
-         if(nofStoredElements)
-            ss<<setw(15)<<nofStoredElements/(double)(capaticityPerBlock*nofChessMem2DBlocks)*100<<std::endl;
-         else ss<<"-"<<std::endl;
-      }
-      ss<<std::endl;
-      ss<<"called memory..... [bytes]: "<<storedElements*sizeof(TData)<<std::endl;
-      ss<<"initialised memory [bytes]: "<<initialisedMemBlocks*capaticityPerBlock*sizeof(TData)<<std::endl;
-      double denominator = (double)(initialisedMemBlocks*capaticityPerBlock*sizeof(TData));
-      if(fabs(denominator)>1.E-13) ss<<"used.............. [%]    : "<<100.*storedElements*sizeof(TData)/denominator<<std::endl;
-      else                         ss<<"used.............. [%]    : 0.0"<<std::endl;
-      ss<<"****************** MbChessMemPool2D-Info (END)  *******************"<<std::endl;
-      return ss.str();
-   }
-   /*==========================================================*/
-   static void writeStatisticFiles(const std::string& filename)
-   {
-      //liefert Statistik ueber aufuellung der einzelnen bloecke (gesamt und pro level)
-      //x-Achse: 0... max moegliche Anzahl von moeglichen Elementen pro MemBlock
-      //y-Achse: Anzahl an Bloecken, die die Anzahl an Elementen beinhalten
-      std::ofstream spreadingFile(((std::string)(filename+"_spreading.txt")).c_str());
-      if(!spreadingFile) UB_THROW( UbException(UB_EXARGS,"couldn't open file") );
-
-      std::size_t initialisedMemBlocks       =   MbChessMemPool2D<TData,cachSize>::getNumberOfChessMemoryBlocks();
-      std::size_t maxNofDataElementsPerBlock =   MbChessMem2DBlock<TData,cachSize>::mBlockWidth
-                                               * MbChessMem2DBlock<TData,cachSize>::mBlockWidth
-                                               * MbChessMem2DBlock<TData,cachSize>::mBlockWidth;
-      std::vector<std::size_t> spreading;
-      spreading.resize(maxNofDataElementsPerBlock+1,0);
-      std::vector< std::vector<std::size_t> > spreadingPerLevel;
-      spreadingPerLevel.resize(mMapVector.size());
-
-      typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos;
-
-      for(std::size_t level=0; level<mMapVector.size(); level++ )
-      {
-         spreadingPerLevel[level].resize(maxNofDataElementsPerBlock+1,0);
-         for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos)
-         {
-            std::size_t number = pos->second->getNofUsedElements();
-            spreading[number]++;
-            spreadingPerLevel[level][number]++;
-         }
-      }
-      spreadingFile<<"#BlockUsage nofBlocks(all Level) ";
-      for(std::size_t level=0; level<mMapVector.size(); level++ )
-         spreadingFile<<"nofBlockLevel"<<level<<" ";
-      spreadingFile<<std::endl;
-
-      for(std::size_t i=0; i<spreading.size(); i++)
-      {
-         spreadingFile<<i<<" "<<spreading[i];
-         for(std::size_t level=0; level<mMapVector.size(); level++ )
-            spreadingFile<<" "<<spreadingPerLevel[level][i];
-         spreadingFile<<std::endl;
-      }
-      spreadingFile.flush();
-      spreadingFile.close();
-   }
-   //////////////////////////////////////////////////////////////////////////
-   //ueberladene operatoren
-   void* operator new(size_t size, std::size_t level, std::size_t ix1, std::size_t ix2)
-   {
-      if(level<0) UB_THROW( UbException(UB_EXARGS,"level ist negativ!") );
-      void *p = getReference(level,ix1,ix2);
-      return p;
-   }
-   /*==========================================================*/
-   void operator delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2)
-   {
-      //ACHTUNG: wenn man hier ne Exception schmeisst, dann gibts einen BoeSEN compilerFehler!!!
-      //UB_THROW( UbException(UB_EXARGS,"Scheisse noch nicht gerafft, wie das geht!") );
-      std::cerr<<"MbChessMemPool2D::delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2) - Scheisse noch nicht gerafft, wie das geht!\n";
-   }
-
-   /*==========================================================*/
-   void operator delete(void* p)
-   {
-      freeReference(p);
-   }
-
-private:
-   //////////////////////////////////////////////////////////////////////////
-   //private statische Methoden
-};
-
-//statische Variablen initialisieren
-template <class TData, std::size_t cachSize>
-std::vector< std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* > > MbChessMemPool2D<TData,cachSize>::mMapVector;
-
-template <class TData, std::size_t cachSize>
-std::map<void*,MbChessMap2DKey >  MbChessMemPool2D< TData, cachSize>::mPointerKeyMap;
-
-template <class TData, std::size_t cachSize>
-const std::size_t  MbChessMemPool2D<TData,cachSize>::mCacheSize=cachSize;
-
-template <class TData,std::size_t cachSize>
-const std::size_t  MbChessMem2DBlock<TData,cachSize>::mBlockWidth=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.));
-
-#endif
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef MBCHESSMEMPOOL2D_H
+#define MBCHESSMEMPOOL2D_H
+
+#include <map>
+#include <vector>
+#include <iostream>
+#include <iomanip>
+#include <string>
+#include <sstream>
+#include <fstream>
+#include <cmath>
+#include <typeinfo>
+
+#include <basics/utilities/UbException.h>
+
+
+template <class TData, std::size_t cachSize>
+class MbChessMemPool2D;
+
+//////////////////////////////////////////////////////////////////////////
+//class MbChessMap2DKey
+//key zum Auffinden der ChessMem2DBlocks
+class MbChessMap2DKey
+{
+public:
+   //////////////////////////////////////////////////////////////////////////
+   //Konstruktoren
+   MbChessMap2DKey(): mVectorPos(0),mFirstCriteria(0),mSecondCriteria(0)
+   {
+
+   }
+   /*==========================================================*/
+   MbChessMap2DKey(std::size_t vectorPos, std::size_t firstCriteria, std::size_t secondCriteria)
+      : mVectorPos(vectorPos), mFirstCriteria(firstCriteria), mSecondCriteria(secondCriteria)
+   {
+   }
+   /*==========================================================*/
+   MbChessMap2DKey& operator=(const MbChessMap2DKey& srcKey)
+   {
+      if(this == &srcKey ) return *this;
+
+      mVectorPos      = srcKey.mVectorPos;
+      mFirstCriteria  = srcKey.mFirstCriteria;
+      mSecondCriteria = srcKey.mSecondCriteria;
+
+      return *this;
+   }
+
+   //////////////////////////////////////////////////////////////////////////
+   //global ueberladene Operatoren
+   friend inline bool operator<(const MbChessMap2DKey& lhsKey,const MbChessMap2DKey& rhsKey)
+   {
+      if(lhsKey.mFirstCriteria  < rhsKey.mFirstCriteria ) return true;
+      if(lhsKey.mFirstCriteria  > rhsKey.mFirstCriteria ) return false;
+      if(lhsKey.mSecondCriteria < rhsKey.mSecondCriteria) return true;
+
+      return false;
+   }
+   /*==========================================================*/
+   friend inline bool operator==(const MbChessMap2DKey& lhsKey,const MbChessMap2DKey& rhsKey)
+   {
+      if(lhsKey.mVectorPos      != rhsKey.mVectorPos      ) return false;
+      if(lhsKey.mFirstCriteria  != rhsKey.mFirstCriteria  ) return false;
+      if(lhsKey.mSecondCriteria != rhsKey.mSecondCriteria ) return false;
+
+      return true;
+   }
+   //ueberladene Operatoren
+   friend inline bool operator!=(const MbChessMap2DKey& lhsKey,const MbChessMap2DKey& rhsKey)
+   {
+      return !(lhsKey==rhsKey);
+   }
+   //ueberladene Operatoren
+   /*==========================================================*/
+   friend inline std::ostream& operator << (std::ostream& os, const MbChessMap2DKey& key)
+   {
+      os<<"VectorPos,first-,second-,third Criteria) (";
+      os<<key.mVectorPos<<","<<key.mFirstCriteria<<","<<key.mSecondCriteria<<")";
+      return os;
+   }
+
+   //////////////////////////////////////////////////////////////////////////
+   //public Methoden
+   std::size_t getVectorPos() {return mVectorPos;}
+private:
+   //////////////////////////////////////////////////////////////////////////
+   //private Member
+   std::size_t mVectorPos;
+   std::size_t mFirstCriteria;
+   std::size_t mSecondCriteria;
+};
+
+
+
+template<class T,std::size_t cachSize>
+class MbChessMem2DBlock
+{
+   friend class MbChessMemPool2D<T,cachSize>;
+public:
+   //////////////////////////////////////////////////////////////////////////
+   //Konstruktoren
+   MbChessMem2DBlock()
+   {
+      mUsedElements = 0;
+      std::size_t arrayLength = mBlockWidth*mBlockWidth;
+      //mDataElements = new T[arrayLength];
+      mDataElements = operator new(arrayLength*sizeof(T));
+      mFlagVector   = new bool[arrayLength];
+      for(std::size_t i=0;i<arrayLength;i++) mFlagVector[i] = false;
+   }
+   //////////////////////////////////////////////////////////////////////////
+   //Destruktor
+   ~MbChessMem2DBlock()
+   {
+      //if(mDataElements) delete[] mDataElements;
+      if(mDataElements) operator delete(mDataElements);
+      if(mFlagVector)   delete[] mFlagVector;
+   }
+
+private:
+   //////////////////////////////////////////////////////////////////////////
+   //private Methoden
+   void* getReference(std::size_t chessX1, std::size_t chessX2)
+   {
+      std::size_t arrayIndex = chessX2*mBlockWidth + chessX1;
+      #ifdef _DEBUG
+         if(arrayIndex>=mBlockWidth*mBlockWidth) UB_THROW( UbException(UB_EXARGS,"index out of range") );
+      #endif
+
+      if(mFlagVector[arrayIndex]==true) UB_THROW( UbException(UB_EXARGS,"memory already allocated!") );
+
+      mUsedElements++;
+      mFlagVector[arrayIndex]=true;
+
+      return (void*)((T*)(mDataElements)+arrayIndex);//&(mDataElements[arrayIndex]);
+   }
+   /*==========================================================*/
+   std::size_t freeReference(void* p)
+   {
+      //std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - mDataElements); //mDataElements = &mDataElements[0]
+      std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - static_cast<T*>(mDataElements));
+
+      #ifdef _DEBUG
+         if(arrayIndex>=mBlockWidth*mBlockWidth) UB_THROW( UbException(UB_EXARGS,"index out of range") );
+      #endif
+
+      if(mFlagVector[arrayIndex]==false) UB_THROW( UbException(UB_EXARGS,"memory not allocated!") );
+
+      mFlagVector[arrayIndex]=false;
+
+      return --mUsedElements;
+   }
+   /*==========================================================*/
+   std::size_t getNofUsedElements()   { return mUsedElements; }
+   /*==========================================================*/
+   void addPointerToTElementsToVector(std::vector<T*>& tdataVector)
+   {
+      std::size_t arrayLength = mBlockWidth*mBlockWidth;
+      for(std::size_t arrayIndex=0;arrayIndex<arrayLength;arrayIndex++)
+      {
+         //if(mFlagVector[arrayIndex]) tdataVector.push_back(&mDataElements[arrayIndex]);
+         if(mFlagVector[arrayIndex]) tdataVector.push_back(static_cast<T*>(mDataElements)+arrayIndex);
+      }
+   }
+   /*==========================================================*/
+   template<typename Pred>
+   void addPointerToTElementsToVector(std::vector<T*>& tdataVector, Pred& pred)
+   {
+      std::size_t arrayLength = mBlockWidth*mBlockWidth;
+      T* tmp;
+      for(std::size_t arrayIndex=0;arrayIndex<arrayLength;arrayIndex++)
+      {
+         if(mFlagVector[arrayIndex])
+         {
+            //tmp = &mDataElements[arrayIndex];
+            tmp = (static_cast<T*>(mDataElements))+arrayIndex;
+            if( pred(*tmp) ) tdataVector.push_back(tmp);
+         }
+      }
+   }
+private:
+   //////////////////////////////////////////////////////////////////////////
+   //static Member
+   static const std::size_t   mBlockWidth;
+
+   //////////////////////////////////////////////////////////////////////////
+   //private Member
+   std::size_t   mUsedElements;
+   //T*    mDataElements;
+   void* mDataElements;
+   bool* mFlagVector;
+
+};
+
+//////////////////////////////////////////////////////////////////////////
+//class MbChessMemPool2D
+//zum Verwalten von TData Elementen in einer Schabrett-artigen Struktur
+//die ChessMemBloecke haben hier eine Groesse von ~cachSize
+template <class TData, std::size_t cachSize>
+class MbChessMemPool2D
+{
+private:
+   //////////////////////////////////////////////////////////////////////////
+   //protected static const Member
+   const static std::size_t mCacheSize;
+
+   //////////////////////////////////////////////////////////////////////////
+   //protected Member
+   static std::vector< std::map< MbChessMap2DKey , MbChessMem2DBlock< TData,cachSize >* > > mMapVector;
+   static std::map< void*, MbChessMap2DKey > mPointerKeyMap;
+
+   //////////////////////////////////////////////////////////////////////////
+   //protected Konstrukoren
+   MbChessMemPool2D() //protected, um max einmal vererbt werden zu koennen!!!
+   {              //zudem kann man so keine elmente von TreeBasedMemPool erstellen
+
+   }
+   //////////////////////////////////////////////////////////////////////////
+   //Destruktor
+    ~MbChessMemPool2D()
+   {
+   }
+
+public:
+
+   //////////////////////////////////////////////////////////////////////////
+   //static public Methoden
+   static void* getReference(std::size_t level, std::size_t ix1, std::size_t ix2)
+   {
+      if(!MbChessMem2DBlock< TData,cachSize >::mBlockWidth)
+      {
+         std::stringstream ss;
+         ss<<"TreeBasedMemPool() - InitialisationError\n";
+         ss<<"\t size of StorageData ("<<typeid(TData).name()<<", "<<sizeof(TData)<<" byte)\n";
+         ss<<"\t exceeds user-specifyed cache-zize ("<<mCacheSize<<" byte)\n";
+         ss<<"\t cache-size has to be larger than data-size";
+         UB_THROW( UbException(ss.str()) );
+      }
+
+      if( mMapVector.size()<=level ) mMapVector.resize(level+1);
+
+      std::size_t chessX1 = ix1/(MbChessMem2DBlock<TData,cachSize>::mBlockWidth);
+      std::size_t chessX2 = ix2/(MbChessMem2DBlock<TData,cachSize>::mBlockWidth);
+
+      MbChessMap2DKey mapKey(level,chessX1,chessX2);
+
+      typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos = mMapVector[level].find(mapKey);
+
+      MbChessMem2DBlock<TData,cachSize>* memBlock = NULL;
+
+      if(pos==mMapVector[level].end())
+      {
+         memBlock = new MbChessMem2DBlock<TData,cachSize>;
+         (mMapVector[level])[mapKey] = memBlock;
+      }
+      else memBlock = pos->second;
+
+      std::size_t internalChessX1 = ix1%(MbChessMem2DBlock<TData,cachSize>::mBlockWidth);
+      std::size_t internalChessX2 = ix2%(MbChessMem2DBlock<TData,cachSize>::mBlockWidth);
+
+      void* p = memBlock->getReference(internalChessX1,internalChessX2);
+
+      mPointerKeyMap[p]=mapKey;
+
+      return p;
+   }
+   /*==========================================================*/
+   static void freeReference(void *p)
+   {
+      typename std::map<void*,MbChessMap2DKey>::iterator posPointerKeyMap = mPointerKeyMap.find(p);
+
+      if(posPointerKeyMap==mPointerKeyMap.end()) UB_THROW( UbException(UB_EXARGS,"pointer not in map") );
+
+      MbChessMap2DKey mapKey = posPointerKeyMap->second;
+      mPointerKeyMap.erase(posPointerKeyMap);
+
+      typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator posMemBlockMap;
+      posMemBlockMap = mMapVector[mapKey.getVectorPos()].find(mapKey);
+
+      if(posMemBlockMap == mMapVector[mapKey.getVectorPos()].end())
+         UB_THROW( UbException(UB_EXARGS,"mapKey not in ChessMem2DBlockMap") );
+
+      std::size_t leftElements = posMemBlockMap->second->freeReference(p);
+      if(!leftElements)
+      {
+         MbChessMem2DBlock<TData,cachSize>* tmp = posMemBlockMap->second;
+         mMapVector[mapKey.getVectorPos()].erase(posMemBlockMap);
+         delete tmp;
+      }
+   }
+   /*==========================================================*/
+   static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector)
+   {
+      tdataVector.clear();
+
+      if(level>=mMapVector.size()) return;
+      typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos;
+      for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos)
+      {
+         pos->second->addPointerToTElementsToVector(tdataVector);
+      }
+   }
+   /*==========================================================*/
+   static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector)
+   {
+      tdataVector.clear();
+
+      typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos;
+
+      for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ )
+      {
+         for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos)
+         {
+            pos->second->addPointerToTElementsToVector(tdataVector);
+         }
+      }
+   }
+   /*==========================================================*/
+   template<typename Pred>
+   static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector, Pred pred)
+   {
+      tdataVector.clear();
+
+      if(level>=mMapVector.size()) return;
+      typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos;
+      for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos)
+      {
+         pos->second->addPointerToTElementsToVector(tdataVector,pred);
+      }
+   }
+   /*==========================================================*/
+   template<typename Pred>
+   static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector, Pred pred)
+   {
+      tdataVector.clear();
+
+      typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos;
+
+      for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ )
+      {
+         for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos)
+         {
+            pos->second->addPointerToTElementsToVector(tdataVector,pred);
+         }
+      }
+   }
+   /*==========================================================*/
+   static std::size_t getNumberOfChessMemoryBlocks()
+   {
+      std::size_t nofElements = 0;
+      for(std::size_t i=0; i<mMapVector.size(); i++)
+      {
+         nofElements+=mMapVector[i].size();
+      }
+      return nofElements;
+   }
+   /*==========================================================*/
+   static std::size_t getNumberOfChessMemoryBlocks(std::size_t level)
+   {
+      if(level<mMapVector.size() )return mMapVector[level].size();
+      return 0;
+   }
+   /*==========================================================*/
+   static std::size_t getNumberOfStoredDataElements()
+   {
+      return mPointerKeyMap.size();
+   }
+   /*==========================================================*/
+   static std::size_t getNumberOfStoredDataElements(std::size_t level)
+   {
+      if(level<mMapVector.size() )
+      {
+         std::size_t nofElements = 0;
+         typename std::map< MbChessMap2DKey , MbChessMem2DBlock< TData,cachSize >* >::iterator pos;
+
+         for(pos=mMapVector[level].begin(); pos!=mMapVector[level].end(); ++pos)
+         {
+            nofElements += pos->second->getNofUsedElements();
+         }
+         return nofElements;
+      }
+      return 0;
+
+   }
+   /*==========================================================*/
+   static std::string toString()
+   {
+      long double capaticityPerBlock   = (std::size_t)pow((double)MbChessMem2DBlock<TData,cachSize>::mBlockWidth,2.0);
+      std::size_t storedElements       = MbChessMemPool2D<TData,cachSize>::getNumberOfStoredDataElements();
+      std::size_t initialisedMemBlocks = MbChessMemPool2D<TData,cachSize>::getNumberOfChessMemoryBlocks();
+
+      std::stringstream ss;
+      ss<<std::endl;
+      ss<<"****************** MbChessMemPool2D-Info (BEGIN) ******************"<<std::endl;
+      ss<<"type of Storage-Data.................. : "<<typeid(TData).name()<<std::endl;
+      ss<<"size of Storage-Data........... [bytes]: "<<sizeof(TData)<<std::endl;
+      ss<<"specified cache-size........... [bytes]: "<<mCacheSize<<std::endl;
+      ss<<"#elements per MbChessMem2DBlock [bytes]: "<<capaticityPerBlock<<std::endl;
+      ss<<"mem per MbChessMem2DBlock...... [bytes]: "<<capaticityPerBlock*sizeof(TData)<<std::endl;
+      ss<<"used cache-size[%]............. [bytes]: "<<capaticityPerBlock*sizeof(TData)/(double)mCacheSize*100<<std::endl;
+      ss<<"\n";
+      ss<<"#stored Elements  = "<<storedElements<<std::endl;
+      ss<<"#ChessMem2DBlocks = "<<initialisedMemBlocks<<std::endl;
+      ss<<std::endl;
+      ss<<"level | #ChessMem2DBlocks | #stored Elements | used capaticity [%] \n";
+      ss<<"----------------------------------------------------------------\n";
+      for(std::size_t level=0;level<mMapVector.size();level++)
+      {
+         std::size_t nofStoredElements = MbChessMemPool2D<TData,cachSize>::getNumberOfStoredDataElements(level);
+         std::size_t nofChessMem2DBlocks = MbChessMemPool2D<TData,cachSize>::getNumberOfChessMemoryBlocks(level);
+
+         ss<<std::left<<" "<<std::setw(5)<<level<<"| "
+            <<std::setw(16)<<nofChessMem2DBlocks<<"| "
+            <<std::setw(17)<<nofStoredElements<<"| ";
+         if(nofStoredElements)
+            ss<<setw(15)<<nofStoredElements/(double)(capaticityPerBlock*nofChessMem2DBlocks)*100<<std::endl;
+         else ss<<"-"<<std::endl;
+      }
+      ss<<std::endl;
+      ss<<"called memory..... [bytes]: "<<storedElements*sizeof(TData)<<std::endl;
+      ss<<"initialised memory [bytes]: "<<initialisedMemBlocks*capaticityPerBlock*sizeof(TData)<<std::endl;
+      double denominator = (double)(initialisedMemBlocks*capaticityPerBlock*sizeof(TData));
+      if(fabs(denominator)>1.E-13) ss<<"used.............. [%]    : "<<100.*storedElements*sizeof(TData)/denominator<<std::endl;
+      else                         ss<<"used.............. [%]    : 0.0"<<std::endl;
+      ss<<"****************** MbChessMemPool2D-Info (END)  *******************"<<std::endl;
+      return ss.str();
+   }
+   /*==========================================================*/
+   static void writeStatisticFiles(const std::string& filename)
+   {
+      //liefert Statistik ueber aufuellung der einzelnen bloecke (gesamt und pro level)
+      //x-Achse: 0... max moegliche Anzahl von moeglichen Elementen pro MemBlock
+      //y-Achse: Anzahl an Bloecken, die die Anzahl an Elementen beinhalten
+      std::ofstream spreadingFile(((std::string)(filename+"_spreading.txt")).c_str());
+      if(!spreadingFile) UB_THROW( UbException(UB_EXARGS,"couldn't open file") );
+
+      std::size_t initialisedMemBlocks       =   MbChessMemPool2D<TData,cachSize>::getNumberOfChessMemoryBlocks();
+      std::size_t maxNofDataElementsPerBlock =   MbChessMem2DBlock<TData,cachSize>::mBlockWidth
+                                               * MbChessMem2DBlock<TData,cachSize>::mBlockWidth
+                                               * MbChessMem2DBlock<TData,cachSize>::mBlockWidth;
+      std::vector<std::size_t> spreading;
+      spreading.resize(maxNofDataElementsPerBlock+1,0);
+      std::vector< std::vector<std::size_t> > spreadingPerLevel;
+      spreadingPerLevel.resize(mMapVector.size());
+
+      typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos;
+
+      for(std::size_t level=0; level<mMapVector.size(); level++ )
+      {
+         spreadingPerLevel[level].resize(maxNofDataElementsPerBlock+1,0);
+         for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos)
+         {
+            std::size_t number = pos->second->getNofUsedElements();
+            spreading[number]++;
+            spreadingPerLevel[level][number]++;
+         }
+      }
+      spreadingFile<<"#BlockUsage nofBlocks(all Level) ";
+      for(std::size_t level=0; level<mMapVector.size(); level++ )
+         spreadingFile<<"nofBlockLevel"<<level<<" ";
+      spreadingFile<<std::endl;
+
+      for(std::size_t i=0; i<spreading.size(); i++)
+      {
+         spreadingFile<<i<<" "<<spreading[i];
+         for(std::size_t level=0; level<mMapVector.size(); level++ )
+            spreadingFile<<" "<<spreadingPerLevel[level][i];
+         spreadingFile<<std::endl;
+      }
+      spreadingFile.flush();
+      spreadingFile.close();
+   }
+   //////////////////////////////////////////////////////////////////////////
+   //ueberladene operatoren
+   void* operator new(size_t size, std::size_t level, std::size_t ix1, std::size_t ix2)
+   {
+      if(level<0) UB_THROW( UbException(UB_EXARGS,"level ist negativ!") );
+      void *p = getReference(level,ix1,ix2);
+      return p;
+   }
+   /*==========================================================*/
+   void operator delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2)
+   {
+      //ACHTUNG: wenn man hier ne Exception schmeisst, dann gibts einen BoeSEN compilerFehler!!!
+      //UB_THROW( UbException(UB_EXARGS,"Scheisse noch nicht gerafft, wie das geht!") );
+      std::cerr<<"MbChessMemPool2D::delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2) - Scheisse noch nicht gerafft, wie das geht!\n";
+   }
+
+   /*==========================================================*/
+   void operator delete(void* p)
+   {
+      freeReference(p);
+   }
+
+private:
+   //////////////////////////////////////////////////////////////////////////
+   //private statische Methoden
+};
+
+//statische Variablen initialisieren
+template <class TData, std::size_t cachSize>
+std::vector< std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* > > MbChessMemPool2D<TData,cachSize>::mMapVector;
+
+template <class TData, std::size_t cachSize>
+std::map<void*,MbChessMap2DKey >  MbChessMemPool2D< TData, cachSize>::mPointerKeyMap;
+
+template <class TData, std::size_t cachSize>
+const std::size_t  MbChessMemPool2D<TData,cachSize>::mCacheSize=cachSize;
+
+template <class TData,std::size_t cachSize>
+const std::size_t  MbChessMem2DBlock<TData,cachSize>::mBlockWidth=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.));
+
+#endif
diff --git a/source/ThirdParty/Library/basics/memory/MbChessMemPool3D.h b/source/VirtualFluidsBasic/basics/memory/MbChessMemPool3D.h
similarity index 97%
rename from source/ThirdParty/Library/basics/memory/MbChessMemPool3D.h
rename to source/VirtualFluidsBasic/basics/memory/MbChessMemPool3D.h
index 99fef93f6c79612e298e08dc3f504df7b0cd695d..ffc74a8d6d39cffa4b7c23c73dafda1597d9fffe 100644
--- a/source/ThirdParty/Library/basics/memory/MbChessMemPool3D.h
+++ b/source/VirtualFluidsBasic/basics/memory/MbChessMemPool3D.h
@@ -1,537 +1,537 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef MBCHESSMEMPOOL3D_H
-#define MBCHESSMEMPOOL3D_H
-
-#include <map>
-#include <vector>
-#include <iostream>
-#include <iomanip>
-#include <string>
-#include <sstream>
-#include <fstream>
-#include <cmath>
-
-#include <basics/utilities/UbException.h>
-
-template <class TData, std::size_t cachSize>
-class MbChessMemPool3D;
-
-//////////////////////////////////////////////////////////////////////////
-//class MbChessMap3DKey
-//key zum Auffinden der ChessMem3DBlocks
-class MbChessMap3DKey
-{
-public:
-   //////////////////////////////////////////////////////////////////////////
-   //Konstruktoren
-   MbChessMap3DKey(): mVectorPos(0),mFirstCriteria(0),mSecondCriteria(0),mThirdCriteria(0)
-   {
-   }
-   /*==========================================================*/
-   MbChessMap3DKey(std::size_t vectorPos,std::size_t firstCriteria,std::size_t secondCriteria,std::size_t thirdCriteria)
-      : mVectorPos(vectorPos), mFirstCriteria(firstCriteria), mSecondCriteria(secondCriteria), mThirdCriteria(thirdCriteria)
-   {
-   }
-   /*==========================================================*/
-   MbChessMap3DKey& operator=(const MbChessMap3DKey& srcKey)
-   {
-      if(this == &srcKey ) return *this;
-
-      mVectorPos      = srcKey.mVectorPos;
-      mFirstCriteria  = srcKey.mFirstCriteria;
-      mSecondCriteria = srcKey.mSecondCriteria;
-      mThirdCriteria  = srcKey.mThirdCriteria;
-
-      return *this;
-   }
-
-   //////////////////////////////////////////////////////////////////////////
-   //global ueberladene Operatoren
-   friend inline bool operator<(const MbChessMap3DKey& lhsKey,const MbChessMap3DKey& rhsKey)
-   {
-      if(lhsKey.mFirstCriteria  < rhsKey.mFirstCriteria ) return true;
-      if(lhsKey.mFirstCriteria  > rhsKey.mFirstCriteria ) return false;
-      if(lhsKey.mSecondCriteria < rhsKey.mSecondCriteria) return true;
-      if(lhsKey.mSecondCriteria > rhsKey.mSecondCriteria) return false;
-      if(lhsKey.mThirdCriteria  < rhsKey.mThirdCriteria ) return true;
-
-      return false;
-   }
-   /*==========================================================*/
-   friend inline bool operator==(const MbChessMap3DKey& lhsKey,const MbChessMap3DKey& rhsKey)
-   {
-      if(lhsKey.mVectorPos      != rhsKey.mVectorPos      ) return false;
-      if(lhsKey.mFirstCriteria  != rhsKey.mFirstCriteria  ) return false;
-      if(lhsKey.mSecondCriteria != rhsKey.mSecondCriteria ) return false;
-      if(lhsKey.mThirdCriteria  != rhsKey.mThirdCriteria  ) return false;
-
-      return true;
-   }
-   //ueberladene Operatoren
-   friend inline bool operator!=(const MbChessMap3DKey& lhsKey,const MbChessMap3DKey& rhsKey)
-   {
-      return !(lhsKey==rhsKey);
-   }
-   //ueberladene Operatoren
-   /*==========================================================*/
-   friend inline std::ostream& operator << (std::ostream& os, const MbChessMap3DKey& key)
-   {
-      os<<"VectorPos,first-,second-,third Criteria) (";
-      os<<key.mVectorPos<<","<<key.mFirstCriteria<<","<<key.mSecondCriteria<<","<<key.mThirdCriteria<<")";
-      return os;
-   }
-
-   //////////////////////////////////////////////////////////////////////////
-   //public Methoden
-   std::size_t getVectorPos() {return mVectorPos;}
-private:
-   //////////////////////////////////////////////////////////////////////////
-   //private Member
-   std::size_t mVectorPos;
-   std::size_t mFirstCriteria;
-   std::size_t mSecondCriteria;
-   std::size_t mThirdCriteria;
-};
-
-
-
-template<class T,std::size_t cachSize>
-class MbChessMem3DBlock
-{
-   friend class MbChessMemPool3D<T,cachSize>;
-public:
-   //////////////////////////////////////////////////////////////////////////
-   //Konstruktoren
-   MbChessMem3DBlock()
-   {
-      mUsedElements = 0;
-      std::size_t arrayLength = mBlockWidth*mBlockWidth*mBlockWidth;
-      //mDataElements = new T[arrayLength];
-      mDataElements = operator new(arrayLength*sizeof(T));
-      if(!mDataElements) UB_THROW( UbException(UB_EXARGS,"out of memeory!") );
-      mFlagVector   = new bool[arrayLength];
-      if(!mFlagVector) UB_THROW( UbException(UB_EXARGS,"out of memeory!") );
-      for(std::size_t i=0;i<arrayLength;i++) mFlagVector[i] = false;
-   }
-   //////////////////////////////////////////////////////////////////////////
-   //Destruktor
-   ~MbChessMem3DBlock()
-   {
-      //if(mDataElements) delete[] mDataElements;
-      if(mDataElements) operator delete(mDataElements);
-      if(mFlagVector)   delete[] mFlagVector;
-   }
-
-private:
-   //////////////////////////////////////////////////////////////////////////
-   //private Methoden
-   void* getReference(std::size_t chessX1, std::size_t chessX2, std::size_t chessX3)
-   {
-      //std::size_t arrayIndex = (chessX1*mBlockWidth+chessX2)*mBlockWidth + chessX3;
-      std::size_t arrayIndex = (chessX3*mBlockWidth+chessX2)*mBlockWidth + chessX1;
-      #ifdef _DEBUG
-         if(arrayIndex>=mBlockWidth*mBlockWidth*mBlockWidth) UB_THROW( UbException(UB_EXARGS,"index out of range") );
-      #endif
-
-      if(mFlagVector[arrayIndex]==true) UB_THROW( UbException(UB_EXARGS,"memory already allocated!") );
-
-      mUsedElements++;
-      mFlagVector[arrayIndex]=true;
-
-      return (void*)((T*)(mDataElements)+arrayIndex);//&(mDataElements[arrayIndex]);
-   }
-   /*==========================================================*/
-   std::size_t freeReference(void* p)
-   {
-      //std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - mDataElements); //mDataElements = &mDataElements[0]
-      std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - static_cast<T*>(mDataElements));
-
-      #ifdef _DEBUG
-        if(arrayIndex>=mBlockWidth*mBlockWidth*mBlockWidth) UB_THROW( UbException(UB_EXARGS,"index out of range") );
-      #endif
-
-      if(mFlagVector[arrayIndex]==false) UB_THROW( UbException(UB_EXARGS,"memory not allocated!") );
-
-      mFlagVector[arrayIndex]=false;
-
-      return --mUsedElements;
-   }
-   /*==========================================================*/
-   std::size_t  getNofUsedElements()   { return mUsedElements; }
-   /*==========================================================*/
-   void addPointerToTElementsToVector(std::vector<T*>& tdataVector)
-   {
-      std::size_t arrayLength = mBlockWidth*mBlockWidth*mBlockWidth;
-      for(std::size_t arrayIndex=0; arrayIndex<arrayLength; arrayIndex++)
-      {
-         //if(mFlagVector[arrayIndex]) tdataVector.push_back(&mDataElements[arrayIndex]);
-         if(mFlagVector[arrayIndex]) tdataVector.push_back(static_cast<T*>(mDataElements)+arrayIndex);
-      }
-   }
-   /*==========================================================*/
-   template<typename Pred>
-   void addPointerToTElementsToVector(std::vector<T*>& tdataVector,Pred& pred )
-   {
-      std::size_t arrayLength = mBlockWidth*mBlockWidth*mBlockWidth;
-      T* tmp;
-      for(std::size_t arrayIndex=0;arrayIndex<arrayLength;arrayIndex++)
-      {
-         if(mFlagVector[arrayIndex])
-         {
-            //tmp = &mDataElements[arrayIndex];
-            tmp = static_cast<T*>(mDataElements)+arrayIndex;
-            if( pred(*tmp) ) tdataVector.push_back(tmp);
-         }
-      }
-   }
-private:
-   //////////////////////////////////////////////////////////////////////////
-   //static Member
-   static const std::size_t  mBlockWidth;
-
-   //////////////////////////////////////////////////////////////////////////
-   //private Member
-   std::size_t mUsedElements;
-   //T*    mDataElements;
-   void* mDataElements;
-   bool* mFlagVector;
-
-};
-
-//////////////////////////////////////////////////////////////////////////
-//class MbChessMemPool3D
-//zum Verwalten von TData Elementen in einer Schabrett-artigen Struktur
-//die ChessMemBloecke haben hier eine Groesse von ~cachSize
-template <class TData, std::size_t cachSize>
-class MbChessMemPool3D
-{
-private:
-   //////////////////////////////////////////////////////////////////////////
-   //protected static const Member
-   const static std::size_t mCacheSize;
-
-   //////////////////////////////////////////////////////////////////////////
-   //protected Member
-   static std::vector< std::map< MbChessMap3DKey , MbChessMem3DBlock< TData,cachSize >* > > mMapVector;
-   static std::map< void*, MbChessMap3DKey > mPointerKeyMap;
-
-   //////////////////////////////////////////////////////////////////////////
-   //protected Konstrukoren
-   MbChessMemPool3D() //private, da NUR static erlaubt!!!
-   {
-
-   }
-   //////////////////////////////////////////////////////////////////////////
-   //Destruktor
-   ~MbChessMemPool3D()
-   {
-   }
-
-public:
-   //////////////////////////////////////////////////////////////////////////
-   //static public Methoden
-   static void* getReference(std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3)
-   {
-      if(!MbChessMem3DBlock< TData,cachSize >::mBlockWidth)
-      {
-         std::stringstream ss;
-         ss<<"TreeBasedMemPool() - InitialisationError\n";
-         ss<<"\t size of StorageData ("<<typeid(TData).name()<<", "<<sizeof(TData)<<" byte)\n";
-         ss<<"\t exceeds user-specifyed cache-zize ("<<mCacheSize<<" byte)\n";
-         ss<<"\t cache-size has to be larger than data-size";
-         UB_THROW( UbException(UB_EXARGS,ss.str()) );
-      }
-
-      if( mMapVector.size()<=level ) mMapVector.resize(level+1);
-
-      std::size_t chessX1 = ix1/(MbChessMem3DBlock<TData,cachSize>::mBlockWidth);
-      std::size_t chessX2 = ix2/(MbChessMem3DBlock<TData,cachSize>::mBlockWidth);
-      std::size_t chessX3 = ix3/(MbChessMem3DBlock<TData,cachSize>::mBlockWidth);
-
-      MbChessMap3DKey mapKey(level,chessX1,chessX2,chessX3);
-
-      typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos = mMapVector[level].find(mapKey);
-
-      MbChessMem3DBlock<TData,cachSize>* memBlock = NULL;
-
-      if(pos==mMapVector[level].end())
-      {
-         memBlock = new MbChessMem3DBlock<TData,cachSize>;
-         (mMapVector[level])[mapKey] = memBlock;
-      }
-      else memBlock = pos->second;
-
-      std::size_t internalChessX1 = ix1%(MbChessMem3DBlock<TData,cachSize>::mBlockWidth);
-      std::size_t internalChessX2 = ix2%(MbChessMem3DBlock<TData,cachSize>::mBlockWidth);
-      std::size_t internalChessX3 = ix3%(MbChessMem3DBlock<TData,cachSize>::mBlockWidth);
-
-      void* p = memBlock->getReference(internalChessX1,internalChessX2,internalChessX3);
-
-      mPointerKeyMap[p]=mapKey;
-
-      return p;
-   }
-   static void freeReference(void *p)
-   {
-      typename std::map<void*,MbChessMap3DKey>::iterator posPointerKeyMap = mPointerKeyMap.find(p);
-
-      if(posPointerKeyMap==mPointerKeyMap.end()) UB_THROW( UbException(UB_EXARGS,"pointer not in map") );
-
-      MbChessMap3DKey mapKey = posPointerKeyMap->second;
-      mPointerKeyMap.erase(posPointerKeyMap);
-
-
-      typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator posMemBlockMap;
-      posMemBlockMap = mMapVector[mapKey.getVectorPos()].find(mapKey);
-
-
-      if(posMemBlockMap == mMapVector[mapKey.getVectorPos()].end())
-         UB_THROW( UbException(UB_EXARGS,"mapKey not in ChessMem3DBlockMap") );
-
-      std::size_t leftElements = posMemBlockMap->second->freeReference(p);
-      if(!leftElements)
-      {
-         MbChessMem3DBlock<TData,cachSize>* tmp = posMemBlockMap->second;
-         mMapVector[mapKey.getVectorPos()].erase(posMemBlockMap);
-         try{ delete tmp; }
-         catch(...){UB_THROW( UbException(UB_EXARGS,"could not delete MbChessMem3DBlock") );}
-      }
-   }
-   /*==========================================================*/
-   static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector)
-   {
-      tdataVector.clear();
-
-      if(level>=mMapVector.size()) return;
-      typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos;
-      for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos)
-      {
-         pos->second->addPointerToTElementsToVector(tdataVector);
-      }
-   }
-   /*==========================================================*/
-   static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector)
-   {
-      tdataVector.clear();
-
-      typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos;
-
-      for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ )
-      {
-         for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos)
-         {
-            pos->second->addPointerToTElementsToVector(tdataVector);
-         }
-      }
-   }
-   /*==========================================================*/
-   template<class Pred>
-   static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector, Pred pred)
-   {
-      tdataVector.clear();
-
-      if(level>=mMapVector.size()) return;
-      typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos;
-      for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos)
-      {
-         pos->second->addPointerToTElementsToVector(tdataVector,pred);
-      }
-   }
-   /*==========================================================*/
-   template<typename Pred>
-   static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector, Pred pred)
-   {
-      tdataVector.clear();
-
-      typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos;
-
-      for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ )
-      {
-         for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos)
-         {
-            pos->second->addPointerToTElementsToVector(tdataVector,pred);
-         }
-      }
-   }
-   /*==========================================================*/
-   static std::size_t getNumberOfChessMemoryBlocks()
-   {
-      std::size_t nofElements = 0;
-      for(std::size_t i=0;i<mMapVector.size();i++)
-      {
-         nofElements+=mMapVector[i].size();
-      }
-      return nofElements;
-   }
-   /*==========================================================*/
-   static std::size_t getNumberOfChessMemoryBlocks(std::size_t level)
-   {
-      if(level<mMapVector.size() ) return mMapVector[level].size();
-      return 0;
-   }
-   /*==========================================================*/
-   static std::size_t getNumberOfStoredDataElements()
-   {
-      return mPointerKeyMap.size();
-   }
-   /*==========================================================*/
-   static std::size_t getNumberOfStoredDataElements(std::size_t level)
-   {
-      if(level<mMapVector.size() )
-      {
-         std::size_t nofElements = 0;
-         typename std::map< MbChessMap3DKey , MbChessMem3DBlock< TData,cachSize >* >::iterator pos;
-
-         for(pos=mMapVector[level].begin(); pos!=mMapVector[level].end(); ++pos)
-         {
-            nofElements+= pos->second->getNofUsedElements();
-         }
-         return nofElements;
-      }
-      return 0;
-   }
-   /*==========================================================*/
-   static std::string toString()
-   {
-      long double capaticityPerBlock   = pow((double)MbChessMem3DBlock<TData,cachSize>::mBlockWidth,3.0);
-      std::size_t storedElements       = MbChessMemPool3D<TData,cachSize>::getNumberOfStoredDataElements();
-      std::size_t initialisedMemBlocks = MbChessMemPool3D<TData,cachSize>::getNumberOfChessMemoryBlocks();
-
-      std::stringstream ss;
-      ss<<std::endl;
-      ss<<"****************** MbChessMemPool3D-Info (BEGIN) ******************"<<std::endl;
-      ss<<"type of Storage-Data.................. : "<<typeid(TData).name()<<std::endl;
-      ss<<"size of Storage-Data........... [bytes]: "<<sizeof(TData)<<std::endl;
-      ss<<"specified cache-size........... [bytes]: "<<mCacheSize<<std::endl;
-      ss<<"#elements per MbChessMem3DBlock [bytes]: "<<capaticityPerBlock<<std::endl;
-      ss<<"mem per MbChessMem3DBlock...... [bytes]: "<<capaticityPerBlock*sizeof(TData)<<std::endl;
-      ss<<"used cache-size[%]............. [bytes]: "<<capaticityPerBlock*sizeof(TData)/(double)mCacheSize*100<<std::endl;
-      ss<<"\n";
-      ss<<"#stored Elements   = "<<storedElements<<std::endl;
-      ss<<"#ChessMem3DBlocks  = "<<initialisedMemBlocks<<std::endl;
-      ss<<std::endl;
-      ss<<"level | #ChessMem3DBlocks | #stored Elements | used capaticity [%] \n";
-      ss<<"----------------------------------------------------------------\n";
-      for(std::size_t level=0;level<mMapVector.size();level++)
-      {
-         std::size_t nofStoredElements   = MbChessMemPool3D<TData,cachSize>::getNumberOfStoredDataElements(level);
-         std::size_t nofChessMem3DBlocks = MbChessMemPool3D<TData,cachSize>::getNumberOfChessMemoryBlocks(level);
-
-         ss<<std::left<<" "<<std::setw(5)<<level<<"| "
-            <<std::setw(16)<<nofChessMem3DBlocks<<"| "
-            <<std::setw(17)<<nofStoredElements<<"| ";
-         if(nofStoredElements)
-            ss<<std::setw(15)<<nofStoredElements/(double)(capaticityPerBlock*nofChessMem3DBlocks)*100<<std::endl;
-         else ss<<"-"<<std::endl;
-      }
-      ss<<std::endl;
-      ss<<"called memory..... [bytes]: "<<storedElements*sizeof(TData)<<std::endl;
-      ss<<"initialised memory [bytes]: "<<initialisedMemBlocks*capaticityPerBlock*sizeof(TData)<<std::endl;
-      double denominator = (double)(initialisedMemBlocks*capaticityPerBlock*sizeof(TData));
-      if(fabs(denominator)>1.E-13) ss<<"used.............. [%]    : "<<100.*storedElements*sizeof(TData)/denominator<<std::endl;
-      else                         ss<<"used.............. [%]    : 0.0"<<std::endl;
-      ss<<"****************** MbChessMemPool3D-Info (END)  *******************"<<std::endl;
-      return ss.str();
-   }
-   /*==========================================================*/
-   static void writeStatisticFiles(const std::string& filename)
-   {
-      //liefert Statistik ueber aufuellung der einzelnen bloecke (gesamt und pro level)
-      //x-Achse: 0... max moegliche Anzahl von moeglichen Elementen pro MemBlock
-      //y-Achse: Anzahl an Bloecken, die die Anzahl an Elementen beinhalten
-      std::ofstream spreadingFile(((std::string)(filename+"_spreading.txt")).c_str());
-      if(!spreadingFile) UB_THROW( UbException(UB_EXARGS,"couldn't open file") );
-
-      //std::size_t initialisedMemBlocks       =  MbChessMemPool3D<TData,cachSize>::getNumberOfChessMemoryBlocks();
-      std::size_t maxNofDataElementsPerBlock =  MbChessMem3DBlock<TData,cachSize>::mBlockWidth
-                                               *MbChessMem3DBlock<TData,cachSize>::mBlockWidth
-                                               *MbChessMem3DBlock<TData,cachSize>::mBlockWidth;
-      std::vector<std::size_t> spreading;
-      spreading.resize(maxNofDataElementsPerBlock+1,0);
-      std::vector< std::vector<std::size_t> > spreadingPerLevel;
-      spreadingPerLevel.resize(mMapVector.size());
-
-      typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos;
-
-      for(std::size_t level=0; level<mMapVector.size(); level++ )
-      {
-         spreadingPerLevel[level].resize(maxNofDataElementsPerBlock+1,0);
-         for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos)
-         {
-            std::size_t number = pos->second->getNofUsedElements();
-            spreading[number]++;
-            spreadingPerLevel[level][number]++;
-         }
-      }
-      spreadingFile<<"#BlockUsage nofBlocks(all Level) ";
-      for(std::size_t level=0; level<mMapVector.size(); level++ )
-         spreadingFile<<"nofBlockLevel"<<level<<" ";
-      spreadingFile<<std::endl;
-
-      for(std::size_t i=0;i<spreading.size();i++)
-      {
-         spreadingFile<<i<<" "<<spreading[i];
-         for(std::size_t level=0; level<mMapVector.size(); level++ )
-            spreadingFile<<" "<<spreadingPerLevel[level][i];
-         spreadingFile<<std::endl;
-      }
-      spreadingFile.flush();
-      spreadingFile.close();
-   }
-
-   ////////////////////////////////////////////////////////////////////////////
-   ////ueberladene operatoren
-   //void* operator new(size_t size, std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3)
-   //{
-   //   if(level<0) UB_THROW( UbException(UB_EXARGS,"level ist negativ!") );
-   //   void *p = getReference(level,ix1,ix2,ix3);
-   //   return p;
-   //}
-   ///*==========================================================*/
-   //void operator delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3)
-   //{
-   //   //ACHTUNG: wenn man hier ne Exception schmeisst, dann gibts einen BoeSEN compilerFehler!!!
-   //   //UB_THROW( UbException(__FILE__, __LINE__, "MbChessMemPool3D::delete - Scheisse noch nicht gerafft, wie das geht!") );
-   //   cout<<"MbChessMemPool3D::delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3) - Scheisse noch nicht gerafft, wie das geht!\n";
-   //}
-
-   ///*==========================================================*/
-   //void operator delete(void* p)
-   //{
-   //   freeReference(p);
-   //}
-
-private:
-   //////////////////////////////////////////////////////////////////////////
-   //private statische Methoden
-};
-
-
-//statische Variablen initialisieren
-template <class TData, std::size_t cachSize>
-std::vector< std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* > > MbChessMemPool3D<TData,cachSize>::mMapVector;
-
-template <class TData, std::size_t cachSize>
-std::map<void*,MbChessMap3DKey >  MbChessMemPool3D< TData, cachSize>::mPointerKeyMap;
-
-template <class TData, std::size_t cachSize>
-const std::size_t  MbChessMemPool3D<TData,cachSize>::mCacheSize=cachSize;
-
-//template <class TData, std::size_t cachSize>
-//const std::size_t  MbChessMemPool3D<TData,cachSize>::mNofElementsWidthMemBlock=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.));
-
-//template <class TData, std::size_t cachSize>
-//const std::size_t  MbChessMemPool3D<TData,cachSize>::mNofElementsInMemBlock=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.))),3.0));
-
-template <class TData,std::size_t cachSize>
-const std::size_t  MbChessMem3DBlock<TData,cachSize>::mBlockWidth=static_cast<std::size_t>(std::pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.));
-
-//template <class TData,std::size_t cachSize>
-//const std::size_t  MbChessMem3DBlock<TData,cachSize>::mMaxElements=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1.0/3.0))),3.0))),3.0));
-
-#endif
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef MBCHESSMEMPOOL3D_H
+#define MBCHESSMEMPOOL3D_H
+
+#include <map>
+#include <vector>
+#include <iostream>
+#include <iomanip>
+#include <string>
+#include <sstream>
+#include <fstream>
+#include <cmath>
+
+#include <basics/utilities/UbException.h>
+
+template <class TData, std::size_t cachSize>
+class MbChessMemPool3D;
+
+//////////////////////////////////////////////////////////////////////////
+//class MbChessMap3DKey
+//key zum Auffinden der ChessMem3DBlocks
+class MbChessMap3DKey
+{
+public:
+   //////////////////////////////////////////////////////////////////////////
+   //Konstruktoren
+   MbChessMap3DKey(): mVectorPos(0),mFirstCriteria(0),mSecondCriteria(0),mThirdCriteria(0)
+   {
+   }
+   /*==========================================================*/
+   MbChessMap3DKey(std::size_t vectorPos,std::size_t firstCriteria,std::size_t secondCriteria,std::size_t thirdCriteria)
+      : mVectorPos(vectorPos), mFirstCriteria(firstCriteria), mSecondCriteria(secondCriteria), mThirdCriteria(thirdCriteria)
+   {
+   }
+   /*==========================================================*/
+   MbChessMap3DKey& operator=(const MbChessMap3DKey& srcKey)
+   {
+      if(this == &srcKey ) return *this;
+
+      mVectorPos      = srcKey.mVectorPos;
+      mFirstCriteria  = srcKey.mFirstCriteria;
+      mSecondCriteria = srcKey.mSecondCriteria;
+      mThirdCriteria  = srcKey.mThirdCriteria;
+
+      return *this;
+   }
+
+   //////////////////////////////////////////////////////////////////////////
+   //global ueberladene Operatoren
+   friend inline bool operator<(const MbChessMap3DKey& lhsKey,const MbChessMap3DKey& rhsKey)
+   {
+      if(lhsKey.mFirstCriteria  < rhsKey.mFirstCriteria ) return true;
+      if(lhsKey.mFirstCriteria  > rhsKey.mFirstCriteria ) return false;
+      if(lhsKey.mSecondCriteria < rhsKey.mSecondCriteria) return true;
+      if(lhsKey.mSecondCriteria > rhsKey.mSecondCriteria) return false;
+      if(lhsKey.mThirdCriteria  < rhsKey.mThirdCriteria ) return true;
+
+      return false;
+   }
+   /*==========================================================*/
+   friend inline bool operator==(const MbChessMap3DKey& lhsKey,const MbChessMap3DKey& rhsKey)
+   {
+      if(lhsKey.mVectorPos      != rhsKey.mVectorPos      ) return false;
+      if(lhsKey.mFirstCriteria  != rhsKey.mFirstCriteria  ) return false;
+      if(lhsKey.mSecondCriteria != rhsKey.mSecondCriteria ) return false;
+      if(lhsKey.mThirdCriteria  != rhsKey.mThirdCriteria  ) return false;
+
+      return true;
+   }
+   //ueberladene Operatoren
+   friend inline bool operator!=(const MbChessMap3DKey& lhsKey,const MbChessMap3DKey& rhsKey)
+   {
+      return !(lhsKey==rhsKey);
+   }
+   //ueberladene Operatoren
+   /*==========================================================*/
+   friend inline std::ostream& operator << (std::ostream& os, const MbChessMap3DKey& key)
+   {
+      os<<"VectorPos,first-,second-,third Criteria) (";
+      os<<key.mVectorPos<<","<<key.mFirstCriteria<<","<<key.mSecondCriteria<<","<<key.mThirdCriteria<<")";
+      return os;
+   }
+
+   //////////////////////////////////////////////////////////////////////////
+   //public Methoden
+   std::size_t getVectorPos() {return mVectorPos;}
+private:
+   //////////////////////////////////////////////////////////////////////////
+   //private Member
+   std::size_t mVectorPos;
+   std::size_t mFirstCriteria;
+   std::size_t mSecondCriteria;
+   std::size_t mThirdCriteria;
+};
+
+
+
+template<class T,std::size_t cachSize>
+class MbChessMem3DBlock
+{
+   friend class MbChessMemPool3D<T,cachSize>;
+public:
+   //////////////////////////////////////////////////////////////////////////
+   //Konstruktoren
+   MbChessMem3DBlock()
+   {
+      mUsedElements = 0;
+      std::size_t arrayLength = mBlockWidth*mBlockWidth*mBlockWidth;
+      //mDataElements = new T[arrayLength];
+      mDataElements = operator new(arrayLength*sizeof(T));
+      if(!mDataElements) UB_THROW( UbException(UB_EXARGS,"out of memeory!") );
+      mFlagVector   = new bool[arrayLength];
+      if(!mFlagVector) UB_THROW( UbException(UB_EXARGS,"out of memeory!") );
+      for(std::size_t i=0;i<arrayLength;i++) mFlagVector[i] = false;
+   }
+   //////////////////////////////////////////////////////////////////////////
+   //Destruktor
+   ~MbChessMem3DBlock()
+   {
+      //if(mDataElements) delete[] mDataElements;
+      if(mDataElements) operator delete(mDataElements);
+      if(mFlagVector)   delete[] mFlagVector;
+   }
+
+private:
+   //////////////////////////////////////////////////////////////////////////
+   //private Methoden
+   void* getReference(std::size_t chessX1, std::size_t chessX2, std::size_t chessX3)
+   {
+      //std::size_t arrayIndex = (chessX1*mBlockWidth+chessX2)*mBlockWidth + chessX3;
+      std::size_t arrayIndex = (chessX3*mBlockWidth+chessX2)*mBlockWidth + chessX1;
+      #ifdef _DEBUG
+         if(arrayIndex>=mBlockWidth*mBlockWidth*mBlockWidth) UB_THROW( UbException(UB_EXARGS,"index out of range") );
+      #endif
+
+      if(mFlagVector[arrayIndex]==true) UB_THROW( UbException(UB_EXARGS,"memory already allocated!") );
+
+      mUsedElements++;
+      mFlagVector[arrayIndex]=true;
+
+      return (void*)((T*)(mDataElements)+arrayIndex);//&(mDataElements[arrayIndex]);
+   }
+   /*==========================================================*/
+   std::size_t freeReference(void* p)
+   {
+      //std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - mDataElements); //mDataElements = &mDataElements[0]
+      std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - static_cast<T*>(mDataElements));
+
+      #ifdef _DEBUG
+        if(arrayIndex>=mBlockWidth*mBlockWidth*mBlockWidth) UB_THROW( UbException(UB_EXARGS,"index out of range") );
+      #endif
+
+      if(mFlagVector[arrayIndex]==false) UB_THROW( UbException(UB_EXARGS,"memory not allocated!") );
+
+      mFlagVector[arrayIndex]=false;
+
+      return --mUsedElements;
+   }
+   /*==========================================================*/
+   std::size_t  getNofUsedElements()   { return mUsedElements; }
+   /*==========================================================*/
+   void addPointerToTElementsToVector(std::vector<T*>& tdataVector)
+   {
+      std::size_t arrayLength = mBlockWidth*mBlockWidth*mBlockWidth;
+      for(std::size_t arrayIndex=0; arrayIndex<arrayLength; arrayIndex++)
+      {
+         //if(mFlagVector[arrayIndex]) tdataVector.push_back(&mDataElements[arrayIndex]);
+         if(mFlagVector[arrayIndex]) tdataVector.push_back(static_cast<T*>(mDataElements)+arrayIndex);
+      }
+   }
+   /*==========================================================*/
+   template<typename Pred>
+   void addPointerToTElementsToVector(std::vector<T*>& tdataVector,Pred& pred )
+   {
+      std::size_t arrayLength = mBlockWidth*mBlockWidth*mBlockWidth;
+      T* tmp;
+      for(std::size_t arrayIndex=0;arrayIndex<arrayLength;arrayIndex++)
+      {
+         if(mFlagVector[arrayIndex])
+         {
+            //tmp = &mDataElements[arrayIndex];
+            tmp = static_cast<T*>(mDataElements)+arrayIndex;
+            if( pred(*tmp) ) tdataVector.push_back(tmp);
+         }
+      }
+   }
+private:
+   //////////////////////////////////////////////////////////////////////////
+   //static Member
+   static const std::size_t  mBlockWidth;
+
+   //////////////////////////////////////////////////////////////////////////
+   //private Member
+   std::size_t mUsedElements;
+   //T*    mDataElements;
+   void* mDataElements;
+   bool* mFlagVector;
+
+};
+
+//////////////////////////////////////////////////////////////////////////
+//class MbChessMemPool3D
+//zum Verwalten von TData Elementen in einer Schabrett-artigen Struktur
+//die ChessMemBloecke haben hier eine Groesse von ~cachSize
+template <class TData, std::size_t cachSize>
+class MbChessMemPool3D
+{
+private:
+   //////////////////////////////////////////////////////////////////////////
+   //protected static const Member
+   const static std::size_t mCacheSize;
+
+   //////////////////////////////////////////////////////////////////////////
+   //protected Member
+   static std::vector< std::map< MbChessMap3DKey , MbChessMem3DBlock< TData,cachSize >* > > mMapVector;
+   static std::map< void*, MbChessMap3DKey > mPointerKeyMap;
+
+   //////////////////////////////////////////////////////////////////////////
+   //protected Konstrukoren
+   MbChessMemPool3D() //private, da NUR static erlaubt!!!
+   {
+
+   }
+   //////////////////////////////////////////////////////////////////////////
+   //Destruktor
+   ~MbChessMemPool3D()
+   {
+   }
+
+public:
+   //////////////////////////////////////////////////////////////////////////
+   //static public Methoden
+   static void* getReference(std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3)
+   {
+      if(!MbChessMem3DBlock< TData,cachSize >::mBlockWidth)
+      {
+         std::stringstream ss;
+         ss<<"TreeBasedMemPool() - InitialisationError\n";
+         ss<<"\t size of StorageData ("<<typeid(TData).name()<<", "<<sizeof(TData)<<" byte)\n";
+         ss<<"\t exceeds user-specifyed cache-zize ("<<mCacheSize<<" byte)\n";
+         ss<<"\t cache-size has to be larger than data-size";
+         UB_THROW( UbException(UB_EXARGS,ss.str()) );
+      }
+
+      if( mMapVector.size()<=level ) mMapVector.resize(level+1);
+
+      std::size_t chessX1 = ix1/(MbChessMem3DBlock<TData,cachSize>::mBlockWidth);
+      std::size_t chessX2 = ix2/(MbChessMem3DBlock<TData,cachSize>::mBlockWidth);
+      std::size_t chessX3 = ix3/(MbChessMem3DBlock<TData,cachSize>::mBlockWidth);
+
+      MbChessMap3DKey mapKey(level,chessX1,chessX2,chessX3);
+
+      typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos = mMapVector[level].find(mapKey);
+
+      MbChessMem3DBlock<TData,cachSize>* memBlock = NULL;
+
+      if(pos==mMapVector[level].end())
+      {
+         memBlock = new MbChessMem3DBlock<TData,cachSize>;
+         (mMapVector[level])[mapKey] = memBlock;
+      }
+      else memBlock = pos->second;
+
+      std::size_t internalChessX1 = ix1%(MbChessMem3DBlock<TData,cachSize>::mBlockWidth);
+      std::size_t internalChessX2 = ix2%(MbChessMem3DBlock<TData,cachSize>::mBlockWidth);
+      std::size_t internalChessX3 = ix3%(MbChessMem3DBlock<TData,cachSize>::mBlockWidth);
+
+      void* p = memBlock->getReference(internalChessX1,internalChessX2,internalChessX3);
+
+      mPointerKeyMap[p]=mapKey;
+
+      return p;
+   }
+   static void freeReference(void *p)
+   {
+      typename std::map<void*,MbChessMap3DKey>::iterator posPointerKeyMap = mPointerKeyMap.find(p);
+
+      if(posPointerKeyMap==mPointerKeyMap.end()) UB_THROW( UbException(UB_EXARGS,"pointer not in map") );
+
+      MbChessMap3DKey mapKey = posPointerKeyMap->second;
+      mPointerKeyMap.erase(posPointerKeyMap);
+
+
+      typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator posMemBlockMap;
+      posMemBlockMap = mMapVector[mapKey.getVectorPos()].find(mapKey);
+
+
+      if(posMemBlockMap == mMapVector[mapKey.getVectorPos()].end())
+         UB_THROW( UbException(UB_EXARGS,"mapKey not in ChessMem3DBlockMap") );
+
+      std::size_t leftElements = posMemBlockMap->second->freeReference(p);
+      if(!leftElements)
+      {
+         MbChessMem3DBlock<TData,cachSize>* tmp = posMemBlockMap->second;
+         mMapVector[mapKey.getVectorPos()].erase(posMemBlockMap);
+         try{ delete tmp; }
+         catch(...){UB_THROW( UbException(UB_EXARGS,"could not delete MbChessMem3DBlock") );}
+      }
+   }
+   /*==========================================================*/
+   static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector)
+   {
+      tdataVector.clear();
+
+      if(level>=mMapVector.size()) return;
+      typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos;
+      for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos)
+      {
+         pos->second->addPointerToTElementsToVector(tdataVector);
+      }
+   }
+   /*==========================================================*/
+   static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector)
+   {
+      tdataVector.clear();
+
+      typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos;
+
+      for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ )
+      {
+         for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos)
+         {
+            pos->second->addPointerToTElementsToVector(tdataVector);
+         }
+      }
+   }
+   /*==========================================================*/
+   template<class Pred>
+   static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector, Pred pred)
+   {
+      tdataVector.clear();
+
+      if(level>=mMapVector.size()) return;
+      typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos;
+      for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos)
+      {
+         pos->second->addPointerToTElementsToVector(tdataVector,pred);
+      }
+   }
+   /*==========================================================*/
+   template<typename Pred>
+   static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector, Pred pred)
+   {
+      tdataVector.clear();
+
+      typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos;
+
+      for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ )
+      {
+         for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos)
+         {
+            pos->second->addPointerToTElementsToVector(tdataVector,pred);
+         }
+      }
+   }
+   /*==========================================================*/
+   static std::size_t getNumberOfChessMemoryBlocks()
+   {
+      std::size_t nofElements = 0;
+      for(std::size_t i=0;i<mMapVector.size();i++)
+      {
+         nofElements+=mMapVector[i].size();
+      }
+      return nofElements;
+   }
+   /*==========================================================*/
+   static std::size_t getNumberOfChessMemoryBlocks(std::size_t level)
+   {
+      if(level<mMapVector.size() ) return mMapVector[level].size();
+      return 0;
+   }
+   /*==========================================================*/
+   static std::size_t getNumberOfStoredDataElements()
+   {
+      return mPointerKeyMap.size();
+   }
+   /*==========================================================*/
+   static std::size_t getNumberOfStoredDataElements(std::size_t level)
+   {
+      if(level<mMapVector.size() )
+      {
+         std::size_t nofElements = 0;
+         typename std::map< MbChessMap3DKey , MbChessMem3DBlock< TData,cachSize >* >::iterator pos;
+
+         for(pos=mMapVector[level].begin(); pos!=mMapVector[level].end(); ++pos)
+         {
+            nofElements+= pos->second->getNofUsedElements();
+         }
+         return nofElements;
+      }
+      return 0;
+   }
+   /*==========================================================*/
+   static std::string toString()
+   {
+      long double capaticityPerBlock   = pow((double)MbChessMem3DBlock<TData,cachSize>::mBlockWidth,3.0);
+      std::size_t storedElements       = MbChessMemPool3D<TData,cachSize>::getNumberOfStoredDataElements();
+      std::size_t initialisedMemBlocks = MbChessMemPool3D<TData,cachSize>::getNumberOfChessMemoryBlocks();
+
+      std::stringstream ss;
+      ss<<std::endl;
+      ss<<"****************** MbChessMemPool3D-Info (BEGIN) ******************"<<std::endl;
+      ss<<"type of Storage-Data.................. : "<<typeid(TData).name()<<std::endl;
+      ss<<"size of Storage-Data........... [bytes]: "<<sizeof(TData)<<std::endl;
+      ss<<"specified cache-size........... [bytes]: "<<mCacheSize<<std::endl;
+      ss<<"#elements per MbChessMem3DBlock [bytes]: "<<capaticityPerBlock<<std::endl;
+      ss<<"mem per MbChessMem3DBlock...... [bytes]: "<<capaticityPerBlock*sizeof(TData)<<std::endl;
+      ss<<"used cache-size[%]............. [bytes]: "<<capaticityPerBlock*sizeof(TData)/(double)mCacheSize*100<<std::endl;
+      ss<<"\n";
+      ss<<"#stored Elements   = "<<storedElements<<std::endl;
+      ss<<"#ChessMem3DBlocks  = "<<initialisedMemBlocks<<std::endl;
+      ss<<std::endl;
+      ss<<"level | #ChessMem3DBlocks | #stored Elements | used capaticity [%] \n";
+      ss<<"----------------------------------------------------------------\n";
+      for(std::size_t level=0;level<mMapVector.size();level++)
+      {
+         std::size_t nofStoredElements   = MbChessMemPool3D<TData,cachSize>::getNumberOfStoredDataElements(level);
+         std::size_t nofChessMem3DBlocks = MbChessMemPool3D<TData,cachSize>::getNumberOfChessMemoryBlocks(level);
+
+         ss<<std::left<<" "<<std::setw(5)<<level<<"| "
+            <<std::setw(16)<<nofChessMem3DBlocks<<"| "
+            <<std::setw(17)<<nofStoredElements<<"| ";
+         if(nofStoredElements)
+            ss<<std::setw(15)<<nofStoredElements/(double)(capaticityPerBlock*nofChessMem3DBlocks)*100<<std::endl;
+         else ss<<"-"<<std::endl;
+      }
+      ss<<std::endl;
+      ss<<"called memory..... [bytes]: "<<storedElements*sizeof(TData)<<std::endl;
+      ss<<"initialised memory [bytes]: "<<initialisedMemBlocks*capaticityPerBlock*sizeof(TData)<<std::endl;
+      double denominator = (double)(initialisedMemBlocks*capaticityPerBlock*sizeof(TData));
+      if(fabs(denominator)>1.E-13) ss<<"used.............. [%]    : "<<100.*storedElements*sizeof(TData)/denominator<<std::endl;
+      else                         ss<<"used.............. [%]    : 0.0"<<std::endl;
+      ss<<"****************** MbChessMemPool3D-Info (END)  *******************"<<std::endl;
+      return ss.str();
+   }
+   /*==========================================================*/
+   static void writeStatisticFiles(const std::string& filename)
+   {
+      //liefert Statistik ueber aufuellung der einzelnen bloecke (gesamt und pro level)
+      //x-Achse: 0... max moegliche Anzahl von moeglichen Elementen pro MemBlock
+      //y-Achse: Anzahl an Bloecken, die die Anzahl an Elementen beinhalten
+      std::ofstream spreadingFile(((std::string)(filename+"_spreading.txt")).c_str());
+      if(!spreadingFile) UB_THROW( UbException(UB_EXARGS,"couldn't open file") );
+
+      //std::size_t initialisedMemBlocks       =  MbChessMemPool3D<TData,cachSize>::getNumberOfChessMemoryBlocks();
+      std::size_t maxNofDataElementsPerBlock =  MbChessMem3DBlock<TData,cachSize>::mBlockWidth
+                                               *MbChessMem3DBlock<TData,cachSize>::mBlockWidth
+                                               *MbChessMem3DBlock<TData,cachSize>::mBlockWidth;
+      std::vector<std::size_t> spreading;
+      spreading.resize(maxNofDataElementsPerBlock+1,0);
+      std::vector< std::vector<std::size_t> > spreadingPerLevel;
+      spreadingPerLevel.resize(mMapVector.size());
+
+      typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos;
+
+      for(std::size_t level=0; level<mMapVector.size(); level++ )
+      {
+         spreadingPerLevel[level].resize(maxNofDataElementsPerBlock+1,0);
+         for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos)
+         {
+            std::size_t number = pos->second->getNofUsedElements();
+            spreading[number]++;
+            spreadingPerLevel[level][number]++;
+         }
+      }
+      spreadingFile<<"#BlockUsage nofBlocks(all Level) ";
+      for(std::size_t level=0; level<mMapVector.size(); level++ )
+         spreadingFile<<"nofBlockLevel"<<level<<" ";
+      spreadingFile<<std::endl;
+
+      for(std::size_t i=0;i<spreading.size();i++)
+      {
+         spreadingFile<<i<<" "<<spreading[i];
+         for(std::size_t level=0; level<mMapVector.size(); level++ )
+            spreadingFile<<" "<<spreadingPerLevel[level][i];
+         spreadingFile<<std::endl;
+      }
+      spreadingFile.flush();
+      spreadingFile.close();
+   }
+
+   ////////////////////////////////////////////////////////////////////////////
+   ////ueberladene operatoren
+   //void* operator new(size_t size, std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3)
+   //{
+   //   if(level<0) UB_THROW( UbException(UB_EXARGS,"level ist negativ!") );
+   //   void *p = getReference(level,ix1,ix2,ix3);
+   //   return p;
+   //}
+   ///*==========================================================*/
+   //void operator delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3)
+   //{
+   //   //ACHTUNG: wenn man hier ne Exception schmeisst, dann gibts einen BoeSEN compilerFehler!!!
+   //   //UB_THROW( UbException(__FILE__, __LINE__, "MbChessMemPool3D::delete - Scheisse noch nicht gerafft, wie das geht!") );
+   //   cout<<"MbChessMemPool3D::delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3) - Scheisse noch nicht gerafft, wie das geht!\n";
+   //}
+
+   ///*==========================================================*/
+   //void operator delete(void* p)
+   //{
+   //   freeReference(p);
+   //}
+
+private:
+   //////////////////////////////////////////////////////////////////////////
+   //private statische Methoden
+};
+
+
+//statische Variablen initialisieren
+template <class TData, std::size_t cachSize>
+std::vector< std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* > > MbChessMemPool3D<TData,cachSize>::mMapVector;
+
+template <class TData, std::size_t cachSize>
+std::map<void*,MbChessMap3DKey >  MbChessMemPool3D< TData, cachSize>::mPointerKeyMap;
+
+template <class TData, std::size_t cachSize>
+const std::size_t  MbChessMemPool3D<TData,cachSize>::mCacheSize=cachSize;
+
+//template <class TData, std::size_t cachSize>
+//const std::size_t  MbChessMemPool3D<TData,cachSize>::mNofElementsWidthMemBlock=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.));
+
+//template <class TData, std::size_t cachSize>
+//const std::size_t  MbChessMemPool3D<TData,cachSize>::mNofElementsInMemBlock=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.))),3.0));
+
+template <class TData,std::size_t cachSize>
+const std::size_t  MbChessMem3DBlock<TData,cachSize>::mBlockWidth=static_cast<std::size_t>(std::pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.));
+
+//template <class TData,std::size_t cachSize>
+//const std::size_t  MbChessMem3DBlock<TData,cachSize>::mMaxElements=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1.0/3.0))),3.0))),3.0));
+
+#endif
diff --git a/source/ThirdParty/Library/basics/memory/MbMemPool.h b/source/VirtualFluidsBasic/basics/memory/MbMemPool.h
similarity index 96%
rename from source/ThirdParty/Library/basics/memory/MbMemPool.h
rename to source/VirtualFluidsBasic/basics/memory/MbMemPool.h
index 3a835596a9c717e4e31bf3f6570b7615759a754b..e2482caa702661ab838e0ce94d2ad9b2195c7ecc 100644
--- a/source/ThirdParty/Library/basics/memory/MbMemPool.h
+++ b/source/VirtualFluidsBasic/basics/memory/MbMemPool.h
@@ -1,87 +1,87 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef MBMEMPOOL_H
-#define MBMEMPOOL_H
-
-#include <queue>
-#include <list>
-
-
-template <typename TData, int asize>
-class MbMemPool
-{
-
-protected:
-   MbMemPool(){}
-   // Alle 3 Attribute sind Singleton-Objekte !
-   // Allokiere Blocke der Groesse m_asize
-   static int m_asize;       
-   // Halte alle freien Pointer (jedes einzelne Element)  in eine FIFO Liste
-   static std::queue<void*> m_queue;
-   // Pointer auf Bloecke zum Loeschen !
-   static std::list<TData*> m_list;
-
-public:
-
-   
-   ~MbMemPool(){}
-
-   // Daten-Bloecke Loeschen, damit wird der gesamte Speicher freigegeben,
-   // erst aufrufen, wenn die objekte nicht mehr gebraucht werden!
-   static void	deallocatePool();
-
-   void* operator new(std::size_t size)
-   {
-      void*  pNew;
-      TData* feld;	
-      int i;
-
-      //i=m_queue.size();
-      //pNew = m_queue.front();
-      if(m_queue.size()==0) 
-      {
-         //Wenn kein freier Speicher mehr vorhanden, Block anlegen
-         feld = new TData[m_asize];
-         m_list.push_back(feld);
-         for(i=0 ; i<m_asize ; i++)
-         {
-            pNew = (void*) &(feld[i]);
-            m_queue.push( pNew );
-         }
-      }
-      pNew = m_queue.front();
-      m_queue.pop();
-      return pNew;
-
-   }
-
-   void  operator delete(void* p)
-   {
-      m_queue.push(p);
-   }
-};
-
-
-template <typename TData, int asize> 
-std::queue<void*>  MbMemPool<TData,asize>::m_queue;
-
-template <typename TData, int asize> 
-std::list<TData*>  MbMemPool<TData,asize>::m_list;
-
-template <typename TData, int asize> 
-int  MbMemPool<TData,asize>::m_asize=asize;
-
-template <typename TData, int asize> 
-void MbMemPool<TData,asize>::deallocatePool()
-{	
-   for(typename std::list<TData*>::iterator pos=m_list.begin() ; pos!=m_list.end(); ++pos)
-   {
-      delete[] pos;
-   }
-}
-
-#endif //MBMEMPOOL_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef MBMEMPOOL_H
+#define MBMEMPOOL_H
+
+#include <queue>
+#include <list>
+
+
+template <typename TData, int asize>
+class MbMemPool
+{
+
+protected:
+   MbMemPool(){}
+   // Alle 3 Attribute sind Singleton-Objekte !
+   // Allokiere Blocke der Groesse m_asize
+   static int m_asize;       
+   // Halte alle freien Pointer (jedes einzelne Element)  in eine FIFO Liste
+   static std::queue<void*> m_queue;
+   // Pointer auf Bloecke zum Loeschen !
+   static std::list<TData*> m_list;
+
+public:
+
+   
+   ~MbMemPool(){}
+
+   // Daten-Bloecke Loeschen, damit wird der gesamte Speicher freigegeben,
+   // erst aufrufen, wenn die objekte nicht mehr gebraucht werden!
+   static void	deallocatePool();
+
+   void* operator new(std::size_t size)
+   {
+      void*  pNew;
+      TData* feld;	
+      int i;
+
+      //i=m_queue.size();
+      //pNew = m_queue.front();
+      if(m_queue.size()==0) 
+      {
+         //Wenn kein freier Speicher mehr vorhanden, Block anlegen
+         feld = new TData[m_asize];
+         m_list.push_back(feld);
+         for(i=0 ; i<m_asize ; i++)
+         {
+            pNew = (void*) &(feld[i]);
+            m_queue.push( pNew );
+         }
+      }
+      pNew = m_queue.front();
+      m_queue.pop();
+      return pNew;
+
+   }
+
+   void  operator delete(void* p)
+   {
+      m_queue.push(p);
+   }
+};
+
+
+template <typename TData, int asize> 
+std::queue<void*>  MbMemPool<TData,asize>::m_queue;
+
+template <typename TData, int asize> 
+std::list<TData*>  MbMemPool<TData,asize>::m_list;
+
+template <typename TData, int asize> 
+int  MbMemPool<TData,asize>::m_asize=asize;
+
+template <typename TData, int asize> 
+void MbMemPool<TData,asize>::deallocatePool()
+{	
+   for(typename std::list<TData*>::iterator pos=m_list.begin() ; pos!=m_list.end(); ++pos)
+   {
+      delete[] pos;
+   }
+}
+
+#endif //MBMEMPOOL_H
diff --git a/source/ThirdParty/Library/basics/memory/MbSharedPointerDefines.h b/source/VirtualFluidsBasic/basics/memory/MbSharedPointerDefines.h
similarity index 94%
rename from source/ThirdParty/Library/basics/memory/MbSharedPointerDefines.h
rename to source/VirtualFluidsBasic/basics/memory/MbSharedPointerDefines.h
index 9d366ae57bfb46620ca67bb335794c4fec4c0f7e..7832c1282b9f729f4ef7f75d67b21dc45989d3e2 100644
--- a/source/ThirdParty/Library/basics/memory/MbSharedPointerDefines.h
+++ b/source/VirtualFluidsBasic/basics/memory/MbSharedPointerDefines.h
@@ -1,22 +1,22 @@
-
-#ifndef MBSHAREDPOINTERDEFINES_H
-#define MBSHAREDPOINTERDEFINES_H
-
-
-#include <PointerDefinitions.h>
-
-//#define VFSharedFromThis enableSharedFromThis
-//#define SPtr SPtr
-//#define VFWeakPtr   WPtr
-//#define VFDynamicPtrCast dynamicPointerCast
-//
-//template<typename T>
-//class VFPtrDeleter
-//{
-//public:
-//   void operator()(T* p) { delete p; }
-//};
-
-
-
-#endif
+
+#ifndef MBSHAREDPOINTERDEFINES_H
+#define MBSHAREDPOINTERDEFINES_H
+
+
+#include <PointerDefinitions.h>
+
+//#define VFSharedFromThis enableSharedFromThis
+//#define SPtr SPtr
+//#define VFWeakPtr   WPtr
+//#define VFDynamicPtrCast dynamicPointerCast
+//
+//template<typename T>
+//class VFPtrDeleter
+//{
+//public:
+//   void operator()(T* p) { delete p; }
+//};
+
+
+
+#endif
diff --git a/source/ThirdParty/Library/basics/memory/MbSmartPtr.h b/source/VirtualFluidsBasic/basics/memory/MbSmartPtr.h
similarity index 96%
rename from source/ThirdParty/Library/basics/memory/MbSmartPtr.h
rename to source/VirtualFluidsBasic/basics/memory/MbSmartPtr.h
index 6f2bf7631745b9940817d41014205f0a5b6e1077..4321a8e1aa5a0949899a77767499d68266e49049 100644
--- a/source/ThirdParty/Library/basics/memory/MbSmartPtr.h
+++ b/source/VirtualFluidsBasic/basics/memory/MbSmartPtr.h
@@ -1,147 +1,147 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef MBSMARTPTR_H
-#define MBSMARTPTR_H
-
-#include <basics/memory/MbSmartPtrBase.h>
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif
-
-//=====================================================
-// Globale Funktion, um das Loeschen des referenzierten
-// Objektes flexibler zu gestalten.
-//
-template<class ObjType>
-void deleteRefPtr(ObjType* ptr)
-{
-   delete ptr;
-}
-
-//======================================================
-// Die Reference-Pointer Klasse:
-//
-// Beim Referenzieren eines Objektes ueber einen SmartPointer wird ein Zaehler fuer die referezierte Objekt-
-// adresse inkrementiert. Wird der Pointer wieder einem anderen Objekt zugewiesen, so wird der Zaehler fuer das
-// urspruenglich referenzierte Objekt wieder dekremtiert, ebenfalls beim Destruktor des Reference-Pointers.
-// Tatsaechlich geloescht wird das referenzierte Objekt erst, wenn der zugehoerige Zaehler auf 0 ist. Dies geschieht
-// ueber die globale Template-Funktion deleteRefPtr(), die bei Bedarf ueberschrieben werden kann.
-// Der Reference-Pointer verfuegt also sozusagen ueber eine automatische Garbage Collection
-
-template<class ObjType>
-class MbSmartPtr  : public MbSmartPtrBase
-{
-public:
-   // Konstruktoren //bei explicit geht der implizite cast nicht mehr, aber um keinen stress zu verursachen
-   /*explicit*/ MbSmartPtr<ObjType>(const ObjType* pPtr=NULL)
-      : MbSmartPtrBase(), mpPtr(NULL)
-	{
-		init(pPtr);
-	}
-	template<class ParamType>
-	MbSmartPtr<ObjType>(const MbSmartPtr<ParamType>& ptr)
-      : MbSmartPtrBase(), mpPtr(NULL)
-	{
-		init(ptr.get());
-	}
-	// Destruktor
-   ~MbSmartPtr<ObjType>()
-	{
-      init(NULL);
-	}
-   //---------------------------------------------------
-   // Kopierkonstruktor
-   MbSmartPtr<ObjType>(const MbSmartPtr<ObjType>& ptr)
-     : MbSmartPtrBase(), mpPtr(NULL)
-	{
-		init(ptr.get());
-	}
-   //---------------------------------------------------
-   // Zuweisungsoperatoren
-	template<class ParamType>
-	const MbSmartPtr<ObjType>& operator =(const MbSmartPtr<ParamType>& ptr)
-	{
-   	init(ptr.get());
-		return *this;
-	}
-	const MbSmartPtr<ObjType>& operator =(const MbSmartPtr<ObjType>& ptr)
-	{
-		init(ptr.get());
-		return *this;
-	}
-
-	const MbSmartPtr<ObjType>& operator =(const ObjType *pPtr)
-	{
-		init(pPtr);
-		return *this;
-	}
-   //---------------------------------------------------
-   // Dereferenzierung-Operatoren
-	ObjType& operator *() const  { return *mpPtr; }
-   ObjType* operator ->() const { return mpPtr;  }
-   bool operator !() const      { return !mpPtr; }
-   operator ObjType *() const   { return mpPtr;  }
-   //---------------------------------------------------
-	// Methoden
-	ObjType* get() const
-   {
-      return mpPtr;
-   }
-   //---------------------------------------------------
-   int ref_count() const
-   {
-      return MbSmartPtrBase::ref_count(mpPtr);
-   }
-   //---------------------------------------------------
-   bool release() const
-   {
-      return MbSmartPtrBase::removeFromGC(mpPtr);
-   }
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void serialize(Archive & ar, const unsigned int version)
-   {
-      if(ArchiveTools::isWriting(ar))
-      {
-         ar & mpPtr;
-      }
-      else
-      {
-         ObjType* ptr;
-         ar & ptr;
-
-         mpPtr=NULL;
-         init(ptr);
-      }
-   }
-#endif //CAB_RCF
-
-private:
-   void init(const ObjType* pPtr)
-	{
-      // Nur was tun, wenn wirklich noetig
-		if(pPtr==mpPtr) return;
-
-      // Aktuell referenziertes Objekt freigeben, dabei ueberpruefen, ob letztes Release
-		if(mpPtr && releaseRef(mpPtr))
-		{
-         // referenziertes Objekt loeschen
-			deleteRefPtr(mpPtr);
-		}
-
-      // Wenn pPtr ein neues Objekt ist, Zugriffszaehler auf neues Objekt erhoehen
-		mpPtr=const_cast<ObjType*>(pPtr);
-	   if(mpPtr) addRef(mpPtr);
-	}
-
-private:
-   ObjType* mpPtr;
-};
-
-#endif //MBSMARTPTR_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef MBSMARTPTR_H
+#define MBSMARTPTR_H
+
+#include <basics/memory/MbSmartPtrBase.h>
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif
+
+//=====================================================
+// Globale Funktion, um das Loeschen des referenzierten
+// Objektes flexibler zu gestalten.
+//
+template<class ObjType>
+void deleteRefPtr(ObjType* ptr)
+{
+   delete ptr;
+}
+
+//======================================================
+// Die Reference-Pointer Klasse:
+//
+// Beim Referenzieren eines Objektes ueber einen SmartPointer wird ein Zaehler fuer die referezierte Objekt-
+// adresse inkrementiert. Wird der Pointer wieder einem anderen Objekt zugewiesen, so wird der Zaehler fuer das
+// urspruenglich referenzierte Objekt wieder dekremtiert, ebenfalls beim Destruktor des Reference-Pointers.
+// Tatsaechlich geloescht wird das referenzierte Objekt erst, wenn der zugehoerige Zaehler auf 0 ist. Dies geschieht
+// ueber die globale Template-Funktion deleteRefPtr(), die bei Bedarf ueberschrieben werden kann.
+// Der Reference-Pointer verfuegt also sozusagen ueber eine automatische Garbage Collection
+
+template<class ObjType>
+class MbSmartPtr  : public MbSmartPtrBase
+{
+public:
+   // Konstruktoren //bei explicit geht der implizite cast nicht mehr, aber um keinen stress zu verursachen
+   /*explicit*/ MbSmartPtr<ObjType>(const ObjType* pPtr=NULL)
+      : MbSmartPtrBase(), mpPtr(NULL)
+	{
+		init(pPtr);
+	}
+	template<class ParamType>
+	MbSmartPtr<ObjType>(const MbSmartPtr<ParamType>& ptr)
+      : MbSmartPtrBase(), mpPtr(NULL)
+	{
+		init(ptr.get());
+	}
+	// Destruktor
+   ~MbSmartPtr<ObjType>()
+	{
+      init(NULL);
+	}
+   //---------------------------------------------------
+   // Kopierkonstruktor
+   MbSmartPtr<ObjType>(const MbSmartPtr<ObjType>& ptr)
+     : MbSmartPtrBase(), mpPtr(NULL)
+	{
+		init(ptr.get());
+	}
+   //---------------------------------------------------
+   // Zuweisungsoperatoren
+	template<class ParamType>
+	const MbSmartPtr<ObjType>& operator =(const MbSmartPtr<ParamType>& ptr)
+	{
+   	init(ptr.get());
+		return *this;
+	}
+	const MbSmartPtr<ObjType>& operator =(const MbSmartPtr<ObjType>& ptr)
+	{
+		init(ptr.get());
+		return *this;
+	}
+
+	const MbSmartPtr<ObjType>& operator =(const ObjType *pPtr)
+	{
+		init(pPtr);
+		return *this;
+	}
+   //---------------------------------------------------
+   // Dereferenzierung-Operatoren
+	ObjType& operator *() const  { return *mpPtr; }
+   ObjType* operator ->() const { return mpPtr;  }
+   bool operator !() const      { return !mpPtr; }
+   operator ObjType *() const   { return mpPtr;  }
+   //---------------------------------------------------
+	// Methoden
+	ObjType* get() const
+   {
+      return mpPtr;
+   }
+   //---------------------------------------------------
+   int ref_count() const
+   {
+      return MbSmartPtrBase::ref_count(mpPtr);
+   }
+   //---------------------------------------------------
+   bool release() const
+   {
+      return MbSmartPtrBase::removeFromGC(mpPtr);
+   }
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void serialize(Archive & ar, const unsigned int version)
+   {
+      if(ArchiveTools::isWriting(ar))
+      {
+         ar & mpPtr;
+      }
+      else
+      {
+         ObjType* ptr;
+         ar & ptr;
+
+         mpPtr=NULL;
+         init(ptr);
+      }
+   }
+#endif //CAB_RCF
+
+private:
+   void init(const ObjType* pPtr)
+	{
+      // Nur was tun, wenn wirklich noetig
+		if(pPtr==mpPtr) return;
+
+      // Aktuell referenziertes Objekt freigeben, dabei ueberpruefen, ob letztes Release
+		if(mpPtr && releaseRef(mpPtr))
+		{
+         // referenziertes Objekt loeschen
+			deleteRefPtr(mpPtr);
+		}
+
+      // Wenn pPtr ein neues Objekt ist, Zugriffszaehler auf neues Objekt erhoehen
+		mpPtr=const_cast<ObjType*>(pPtr);
+	   if(mpPtr) addRef(mpPtr);
+	}
+
+private:
+   ObjType* mpPtr;
+};
+
+#endif //MBSMARTPTR_H
diff --git a/source/ThirdParty/Library/basics/memory/MbSmartPtrBase.cpp b/source/VirtualFluidsBasic/basics/memory/MbSmartPtrBase.cpp
similarity index 100%
rename from source/ThirdParty/Library/basics/memory/MbSmartPtrBase.cpp
rename to source/VirtualFluidsBasic/basics/memory/MbSmartPtrBase.cpp
diff --git a/source/ThirdParty/Library/basics/memory/MbSmartPtrBase.h b/source/VirtualFluidsBasic/basics/memory/MbSmartPtrBase.h
similarity index 97%
rename from source/ThirdParty/Library/basics/memory/MbSmartPtrBase.h
rename to source/VirtualFluidsBasic/basics/memory/MbSmartPtrBase.h
index d1bf281ce1f7fe8b41c19cd0d6deac9dd43f9574..bd8af59096a5edecd81b1ad8df7e876e2c28f9b9 100644
--- a/source/ThirdParty/Library/basics/memory/MbSmartPtrBase.h
+++ b/source/VirtualFluidsBasic/basics/memory/MbSmartPtrBase.h
@@ -1,50 +1,50 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef MBSMARTPTRBASE_H
-#define MBSMARTPTRBASE_H
-
-#include <iostream>
-#include <map>
-
-//============================================================
-// Klasse MbSmartPtrBase
-//
-// Basisklasse, speziell fuer MbSmartPtr, die das eigentliche
-// Reference-Counting uebernimmt.
-//
-class MbSmartPtrBase
-{
-   //Ursprung:
-   // mpCntrMap ist ein Pointer, weil sichergestellt sein muss, dass die
-   // Map existiert, wenn das erste mal darauf zugegriffen wird.
-   // Ein Zugriff zwischen zwei statischen Objekten kann zum Fehler fuehren, da
-   // die Reihenfolge der Konstruktorenaufrufe dann vom Linker bestimmt wird.
-
-   //Anpassung a la UbWriter mit SingletonMap
-   class MbSmartPtrBaseMap
-   {
-   private:
-      MbSmartPtrBaseMap() { }
-      MbSmartPtrBaseMap( const MbSmartPtrBaseMap& );                  //no copy allowed
-      const MbSmartPtrBaseMap& operator=( const MbSmartPtrBaseMap& ); //no copy allowed
-
-      std::map<void*,int> mpCntrMap;
-   public:
-      static MbSmartPtrBaseMap* getInstance() { static MbSmartPtrBaseMap instance; return &instance; }
-      std::map<void*,int>& getMap()           { return mpCntrMap;                                    }
-   };
-
-protected:
-   MbSmartPtrBase() {}
-   virtual ~MbSmartPtrBase() {}
-   bool addRef(void* p);
-	bool releaseRef(void* p);
-   bool removeFromGC(void* ptr) const;
-   int  ref_count(void* ptr) const;
-};
-
-#endif //MBSMARTPTRBASE_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef MBSMARTPTRBASE_H
+#define MBSMARTPTRBASE_H
+
+#include <iostream>
+#include <map>
+
+//============================================================
+// Klasse MbSmartPtrBase
+//
+// Basisklasse, speziell fuer MbSmartPtr, die das eigentliche
+// Reference-Counting uebernimmt.
+//
+class MbSmartPtrBase
+{
+   //Ursprung:
+   // mpCntrMap ist ein Pointer, weil sichergestellt sein muss, dass die
+   // Map existiert, wenn das erste mal darauf zugegriffen wird.
+   // Ein Zugriff zwischen zwei statischen Objekten kann zum Fehler fuehren, da
+   // die Reihenfolge der Konstruktorenaufrufe dann vom Linker bestimmt wird.
+
+   //Anpassung a la UbWriter mit SingletonMap
+   class MbSmartPtrBaseMap
+   {
+   private:
+      MbSmartPtrBaseMap() { }
+      MbSmartPtrBaseMap( const MbSmartPtrBaseMap& );                  //no copy allowed
+      const MbSmartPtrBaseMap& operator=( const MbSmartPtrBaseMap& ); //no copy allowed
+
+      std::map<void*,int> mpCntrMap;
+   public:
+      static MbSmartPtrBaseMap* getInstance() { static MbSmartPtrBaseMap instance; return &instance; }
+      std::map<void*,int>& getMap()           { return mpCntrMap;                                    }
+   };
+
+protected:
+   MbSmartPtrBase() {}
+   virtual ~MbSmartPtrBase() {}
+   bool addRef(void* p);
+	bool releaseRef(void* p);
+   bool removeFromGC(void* ptr) const;
+   int  ref_count(void* ptr) const;
+};
+
+#endif //MBSMARTPTRBASE_H
diff --git a/source/VirtualFluidsBasic/basics/objects/CMakePackage.txt b/source/VirtualFluidsBasic/basics/objects/CMakePackage.txt
new file mode 100644
index 0000000000000000000000000000000000000000..1b8416f010d2a7de30b8f70c9abf19a96dd8cf8f
--- /dev/null
+++ b/source/VirtualFluidsBasic/basics/objects/CMakePackage.txt
@@ -0,0 +1,2 @@
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
diff --git a/source/ThirdParty/Library/basics/objects/ObCreator.h b/source/VirtualFluidsBasic/basics/objects/ObCreator.h
similarity index 97%
rename from source/ThirdParty/Library/basics/objects/ObCreator.h
rename to source/VirtualFluidsBasic/basics/objects/ObCreator.h
index 253fc616e2f1d9c2b279423ce93462095e698774..8b9ef047c8d4653225def53978fdefccef59ee2f 100644
--- a/source/ThirdParty/Library/basics/objects/ObCreator.h
+++ b/source/VirtualFluidsBasic/basics/objects/ObCreator.h
@@ -1,112 +1,112 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef OBCREATOR_H
-#define OBCREATOR_H
-
-#include <string>
-
-/*=========================================================================*/
-/*  ObCreator / ObCreatorImpl                                              */
-/*                                                                         */
-/**
-generic factory
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 14.06.07
-@version 1.1 - 12.04.08
-*/ 
-
-/*
-usage: see bottom of file "./ObFactory.h"
-*/
-
-//////////////////////////////////////////////////////////////////////////
-// ObCreator
-// Um in der Factory verschiedene Typen von Creaors in einer 
-// std::map<std::string,ObCreator<BaseT>*> halten zu koennen
-// muss eine gemeinsame Basisklasse existieren
-//////////////////////////////////////////////////////////////////////////
-template< class BaseT >
-class ObCreator
-{
-public:
-   virtual std::string  getObjectTypeID()=0;
-   virtual BaseT*       createObject() = 0;
-
-   virtual ~ObCreator() {  }
-
-protected:
-   ObCreator() {}
-private:
-   ObCreator( const ObCreator< BaseT >& );         //no copy allowed 
-   const ObCreator& operator=( const ObCreator& ); //no copy allowed
-};
-
-//////////////////////////////////////////////////////////////////////////
-// ObCreatorImpl
-// Implementierung des speziellen Creators 
-//////////////////////////////////////////////////////////////////////////
-template< class T, class BaseT=T >
-class ObCreatorImpl : public ObCreator< BaseT >
-{
-public:
-   static ObCreator<BaseT >* getInstance()
-   {
-      static ObCreatorImpl< T, BaseT > instance;
-      return &instance;
-   }
-
-public:
-   ~ObCreatorImpl() {}
-
-   //aus portabilitaetsgruenden kann man nicht typeinfo nehmen, da diese compilerabhaengig ist
-   std::string getObjectTypeID()  { return T::getStaticClassObjectTypeID();  } 
-   
-   virtual T*  createObject() { return new T(); }
-
-protected:
-	ObCreatorImpl() {}
-private:
-	ObCreatorImpl( const ObCreatorImpl< T, BaseT >& );      //no copy allowed 
-   const ObCreatorImpl& operator=( const ObCreatorImpl& ); //no copy allowed
-};
-
-//////////////////////////////////////////////////////////////////////////
-// ObCreatorImpl
-// Implementierung des speziellen Creators fuer Singletons
-//////////////////////////////////////////////////////////////////////////
-template< class T, class BaseT=T >
-class ObSingletonCreatorImpl : public ObCreator< BaseT >
-{
-public:
-   static ObCreator<BaseT >* getInstance()
-   {
-      static ObSingletonCreatorImpl< T, BaseT > instance;
-      return &instance;
-   }
-public:
-   ~ObSingletonCreatorImpl() {}
-
-   //aus portabilitaetsgruenden kann man nicht typeinfo nehmen, da diese compilerabhaengig ist
-   std::string getObjectTypeID()  { return T::getStaticClassObjectTypeID();  } 
-
-   virtual T* createObject() { return T::getInstance(); }
-
-protected:
-   ObSingletonCreatorImpl() {}
-private:
-   ObSingletonCreatorImpl( const ObSingletonCreatorImpl< T, BaseT >& );      //no copy allowed 
-   const ObSingletonCreatorImpl& operator=( const ObSingletonCreatorImpl& ); //no copy allowed
-};
-
-//workaround for the not perfect C++ world. typeinfo::name is not usable for this purpose!
-//see Andrei Alexandrescu, "Modern C++ Design: Generic Programming and Design Patterns Applied", Chapter 8.5
-#define OBCREATOR_EXT( ClassObject ) \
-   static  std::string  getStaticClassObjectTypeID() { return #ClassObject;                 } \
-   virtual std::string  getClassObjectTypeID()       { return getStaticClassObjectTypeID(); } 
-
-#endif //OBCREATOR_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef OBCREATOR_H
+#define OBCREATOR_H
+
+#include <string>
+
+/*=========================================================================*/
+/*  ObCreator / ObCreatorImpl                                              */
+/*                                                                         */
+/**
+generic factory
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 14.06.07
+@version 1.1 - 12.04.08
+*/ 
+
+/*
+usage: see bottom of file "./ObFactory.h"
+*/
+
+//////////////////////////////////////////////////////////////////////////
+// ObCreator
+// Um in der Factory verschiedene Typen von Creaors in einer 
+// std::map<std::string,ObCreator<BaseT>*> halten zu koennen
+// muss eine gemeinsame Basisklasse existieren
+//////////////////////////////////////////////////////////////////////////
+template< class BaseT >
+class ObCreator
+{
+public:
+   virtual std::string  getObjectTypeID()=0;
+   virtual BaseT*       createObject() = 0;
+
+   virtual ~ObCreator() {  }
+
+protected:
+   ObCreator() {}
+private:
+   ObCreator( const ObCreator< BaseT >& );         //no copy allowed 
+   const ObCreator& operator=( const ObCreator& ); //no copy allowed
+};
+
+//////////////////////////////////////////////////////////////////////////
+// ObCreatorImpl
+// Implementierung des speziellen Creators 
+//////////////////////////////////////////////////////////////////////////
+template< class T, class BaseT=T >
+class ObCreatorImpl : public ObCreator< BaseT >
+{
+public:
+   static ObCreator<BaseT >* getInstance()
+   {
+      static ObCreatorImpl< T, BaseT > instance;
+      return &instance;
+   }
+
+public:
+   ~ObCreatorImpl() {}
+
+   //aus portabilitaetsgruenden kann man nicht typeinfo nehmen, da diese compilerabhaengig ist
+   std::string getObjectTypeID()  { return T::getStaticClassObjectTypeID();  } 
+   
+   virtual T*  createObject() { return new T(); }
+
+protected:
+	ObCreatorImpl() {}
+private:
+	ObCreatorImpl( const ObCreatorImpl< T, BaseT >& );      //no copy allowed 
+   const ObCreatorImpl& operator=( const ObCreatorImpl& ); //no copy allowed
+};
+
+//////////////////////////////////////////////////////////////////////////
+// ObCreatorImpl
+// Implementierung des speziellen Creators fuer Singletons
+//////////////////////////////////////////////////////////////////////////
+template< class T, class BaseT=T >
+class ObSingletonCreatorImpl : public ObCreator< BaseT >
+{
+public:
+   static ObCreator<BaseT >* getInstance()
+   {
+      static ObSingletonCreatorImpl< T, BaseT > instance;
+      return &instance;
+   }
+public:
+   ~ObSingletonCreatorImpl() {}
+
+   //aus portabilitaetsgruenden kann man nicht typeinfo nehmen, da diese compilerabhaengig ist
+   std::string getObjectTypeID()  { return T::getStaticClassObjectTypeID();  } 
+
+   virtual T* createObject() { return T::getInstance(); }
+
+protected:
+   ObSingletonCreatorImpl() {}
+private:
+   ObSingletonCreatorImpl( const ObSingletonCreatorImpl< T, BaseT >& );      //no copy allowed 
+   const ObSingletonCreatorImpl& operator=( const ObSingletonCreatorImpl& ); //no copy allowed
+};
+
+//workaround for the not perfect C++ world. typeinfo::name is not usable for this purpose!
+//see Andrei Alexandrescu, "Modern C++ Design: Generic Programming and Design Patterns Applied", Chapter 8.5
+#define OBCREATOR_EXT( ClassObject ) \
+   static  std::string  getStaticClassObjectTypeID() { return #ClassObject;                 } \
+   virtual std::string  getClassObjectTypeID()       { return getStaticClassObjectTypeID(); } 
+
+#endif //OBCREATOR_H
diff --git a/source/ThirdParty/Library/basics/objects/ObFactory.h b/source/VirtualFluidsBasic/basics/objects/ObFactory.h
similarity index 97%
rename from source/ThirdParty/Library/basics/objects/ObFactory.h
rename to source/VirtualFluidsBasic/basics/objects/ObFactory.h
index 6b51787819b0548efc89960be450d129753aa0b3..aa522ec5c3bbbc7aa2558ce694068887db06a1ff 100644
--- a/source/ThirdParty/Library/basics/objects/ObFactory.h
+++ b/source/VirtualFluidsBasic/basics/objects/ObFactory.h
@@ -1,174 +1,174 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef OBFACTORY_H
-#define OBFACTORY_H
-
-
-#include <string>
-#include <map>
-#include <sstream>
-#include <iomanip>
-#include <typeinfo>
-
-#include <basics/objects/ObCreator.h>
-
-/*=========================================================================*/
-/*  ObFactory                                                            */
-/*                                                                         */
-/**
-generic factory
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 14.06.07
-@version 1.1 - 12.04.08
-*/ 
-
-/*
-usage:  T       = zu erzeugende Klasse
-        Creator = Erzeugerklasse
-//////////////////////////////////////////////////////////////////////////
-//example
-//////////////////////////////////////////////////////////////////////////
-//  class Base{ 
-//  public:
-//        OBCREATOR_EXT(Base)
-//  };
-//  //automatisches registrieren:
-//  UB_AUTO_RUN_NAMED(ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Base,Base>::getInstance()), CAB_Base);
-//  class Derived : public Base 
-//  {
-//   public:
-//        OBCREATOR_EXT(Derived)
-//};
-//  //automatisches registrieren:
-//  UB_AUTO_RUN_NAMED(ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Base,Derived>::getInstance()), CAB_Derived);
-////////////////////////////////////////////////////////////////////////////
-//  int main()
-//  {
-//       //Alternativ zu UB_AUTO_RUN_NAMED: haendisches registrieren
-//       ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Base>::getInstance());
-//       ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Derived,Base>::getInstance());
-// 
-//       //create objects - method1
-//       Base* test1 = ObFactory<Base>::getInstance()->createObject<Base>();
-//       Base* test2 = ObFactory<Base>::getInstance()->createObject<Derived>();
-// 
-//       //create objects - method2
-//       Base* test1 = ObFactory<Base>::getInstance()->createObject(Base::getStaticClassObjectTypeID()    );
-//       Base* test2 = ObFactory<Base>::getInstance()->createObject(Derived::getStaticClassObjectTypeID() );
-//   //...
-// }
-*/
-
-
-template<class  T, typename Creator = ObCreator< T > >
-class ObFactory
-{
-   typedef std::map<  std::string, Creator* > CreatorMap;
-   typedef typename CreatorMap::iterator      CreatorMapIt;
-   typedef std::pair< std::string, Creator* > CreatorMapElement;
-
-protected:
-   ObFactory() {}  //so ist vererbung gewahrleistet
-
-private:
-   ObFactory( const ObFactory< T, Creator >& );    //no copy allowed 
-   const ObFactory& operator=( const ObFactory& ); //no copy allowed
-
-
-public:
-   virtual ~ObFactory() {}
-
-   static ObFactory< T, Creator >* getInstance() 
-   {
-      static ObFactory< T, Creator > instance;
-      return &instance;
-   }
-
-   bool addObCreator(Creator* creator);
-   bool removeObCreator(Creator* creator);
-
-   T* createObject(const std::string& objectTypeID);
-   
-   template< typename T2 > 
-   T* createObject() { return this->createObject( T2::getStaticClassObjectTypeID() ); }
-   
-   Creator* getCreator(const std::string& objectTypeID);
-
-   virtual std::string toString();
-  
-private:
-   CreatorMap creatorMap;
-};
-
-//////////////////////////////////////////////////////////////////////////
-//Implementation
-template<class  T, typename Creator >
-bool ObFactory< T, Creator >::addObCreator(Creator* creator)
-{
-	if(creatorMap.insert( CreatorMapElement(creator->getObjectTypeID(), creator) ).second )
-   {
-      //insert succeeded
-      return true;
-   }
-   //insert fails
-   return false;
-}
-/*======================================================================*/
-template<class  T, typename Creator >
-bool ObFactory< T, Creator >::removeObCreator(Creator* creator)
-{
-   if(creator && creatorMap->erase( creator->getClassObjectTypeID() ) ) 
-      return true;
-
-   return false;
-}
-/*======================================================================*/
-template<class  T, typename Creator >
-Creator* ObFactory< T, Creator >::getCreator(const std::string& obtypeID)
-{
-   CreatorMapIt it = creatorMap.find(obtypeID);
-   if(it == creatorMap.end()) return NULL;
-
-   Creator* creator = it->second;
-   if(!creator) return NULL;
-
-   return creator;
-}
-/*======================================================================*/
- template<class  T, typename Creator >
- T* ObFactory< T, Creator >::createObject(const std::string& objectTypeID)
- {
-    Creator* creator = this->getCreator(objectTypeID);
-    
-    if(!creator) 
-    {
-       UB_THROW( UbException(UB_EXARGS,"no creator avaivlable for ID="+objectTypeID ) );
-    }
- 
-    return creator->createObject();
- }
-/*======================================================================*/
-template<class  T, typename Creator >
-std::string ObFactory< T, Creator >::toString() 
-{
-   std::size_t maxL = 6;
-   for(CreatorMapIt it=creatorMap.begin(); it!=creatorMap.end(); ++it)
-      if( it->first.size() > maxL ) 
-         maxL = it->first.size();
-   
-   std::stringstream os;
-   os<<(std::string)typeid(*this).name()<<" - info:"<<std::endl;
-   os<<"   "<<std::left<<std::setw(maxL)<<"object"<<" <-> "<<"creator "<<std::endl;
-   for(CreatorMapIt it=creatorMap.begin(); it!=creatorMap.end(); ++it)
-      os<< " - " << std::setw(maxL) << it->first << " <-> " << (std::string)typeid(*it->second).name() << std::endl;
-
-   return os.str();
-}
-/*======================================================================*/
-
-#endif //OBFACTORY_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef OBFACTORY_H
+#define OBFACTORY_H
+
+
+#include <string>
+#include <map>
+#include <sstream>
+#include <iomanip>
+#include <typeinfo>
+
+#include <basics/objects/ObCreator.h>
+
+/*=========================================================================*/
+/*  ObFactory                                                            */
+/*                                                                         */
+/**
+generic factory
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 14.06.07
+@version 1.1 - 12.04.08
+*/ 
+
+/*
+usage:  T       = zu erzeugende Klasse
+        Creator = Erzeugerklasse
+//////////////////////////////////////////////////////////////////////////
+//example
+//////////////////////////////////////////////////////////////////////////
+//  class Base{ 
+//  public:
+//        OBCREATOR_EXT(Base)
+//  };
+//  //automatisches registrieren:
+//  UB_AUTO_RUN_NAMED(ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Base,Base>::getInstance()), CAB_Base);
+//  class Derived : public Base 
+//  {
+//   public:
+//        OBCREATOR_EXT(Derived)
+//};
+//  //automatisches registrieren:
+//  UB_AUTO_RUN_NAMED(ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Base,Derived>::getInstance()), CAB_Derived);
+////////////////////////////////////////////////////////////////////////////
+//  int main()
+//  {
+//       //Alternativ zu UB_AUTO_RUN_NAMED: haendisches registrieren
+//       ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Base>::getInstance());
+//       ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Derived,Base>::getInstance());
+// 
+//       //create objects - method1
+//       Base* test1 = ObFactory<Base>::getInstance()->createObject<Base>();
+//       Base* test2 = ObFactory<Base>::getInstance()->createObject<Derived>();
+// 
+//       //create objects - method2
+//       Base* test1 = ObFactory<Base>::getInstance()->createObject(Base::getStaticClassObjectTypeID()    );
+//       Base* test2 = ObFactory<Base>::getInstance()->createObject(Derived::getStaticClassObjectTypeID() );
+//   //...
+// }
+*/
+
+
+template<class  T, typename Creator = ObCreator< T > >
+class ObFactory
+{
+   typedef std::map<  std::string, Creator* > CreatorMap;
+   typedef typename CreatorMap::iterator      CreatorMapIt;
+   typedef std::pair< std::string, Creator* > CreatorMapElement;
+
+protected:
+   ObFactory() {}  //so ist vererbung gewahrleistet
+
+private:
+   ObFactory( const ObFactory< T, Creator >& );    //no copy allowed 
+   const ObFactory& operator=( const ObFactory& ); //no copy allowed
+
+
+public:
+   virtual ~ObFactory() {}
+
+   static ObFactory< T, Creator >* getInstance() 
+   {
+      static ObFactory< T, Creator > instance;
+      return &instance;
+   }
+
+   bool addObCreator(Creator* creator);
+   bool removeObCreator(Creator* creator);
+
+   T* createObject(const std::string& objectTypeID);
+   
+   template< typename T2 > 
+   T* createObject() { return this->createObject( T2::getStaticClassObjectTypeID() ); }
+   
+   Creator* getCreator(const std::string& objectTypeID);
+
+   virtual std::string toString();
+  
+private:
+   CreatorMap creatorMap;
+};
+
+//////////////////////////////////////////////////////////////////////////
+//Implementation
+template<class  T, typename Creator >
+bool ObFactory< T, Creator >::addObCreator(Creator* creator)
+{
+	if(creatorMap.insert( CreatorMapElement(creator->getObjectTypeID(), creator) ).second )
+   {
+      //insert succeeded
+      return true;
+   }
+   //insert fails
+   return false;
+}
+/*======================================================================*/
+template<class  T, typename Creator >
+bool ObFactory< T, Creator >::removeObCreator(Creator* creator)
+{
+   if(creator && creatorMap->erase( creator->getClassObjectTypeID() ) ) 
+      return true;
+
+   return false;
+}
+/*======================================================================*/
+template<class  T, typename Creator >
+Creator* ObFactory< T, Creator >::getCreator(const std::string& obtypeID)
+{
+   CreatorMapIt it = creatorMap.find(obtypeID);
+   if(it == creatorMap.end()) return NULL;
+
+   Creator* creator = it->second;
+   if(!creator) return NULL;
+
+   return creator;
+}
+/*======================================================================*/
+ template<class  T, typename Creator >
+ T* ObFactory< T, Creator >::createObject(const std::string& objectTypeID)
+ {
+    Creator* creator = this->getCreator(objectTypeID);
+    
+    if(!creator) 
+    {
+       UB_THROW( UbException(UB_EXARGS,"no creator avaivlable for ID="+objectTypeID ) );
+    }
+ 
+    return creator->createObject();
+ }
+/*======================================================================*/
+template<class  T, typename Creator >
+std::string ObFactory< T, Creator >::toString() 
+{
+   std::size_t maxL = 6;
+   for(CreatorMapIt it=creatorMap.begin(); it!=creatorMap.end(); ++it)
+      if( it->first.size() > maxL ) 
+         maxL = it->first.size();
+   
+   std::stringstream os;
+   os<<(std::string)typeid(*this).name()<<" - info:"<<std::endl;
+   os<<"   "<<std::left<<std::setw(maxL)<<"object"<<" <-> "<<"creator "<<std::endl;
+   for(CreatorMapIt it=creatorMap.begin(); it!=creatorMap.end(); ++it)
+      os<< " - " << std::setw(maxL) << it->first << " <-> " << (std::string)typeid(*it->second).name() << std::endl;
+
+   return os.str();
+}
+/*======================================================================*/
+
+#endif //OBFACTORY_H
diff --git a/source/ThirdParty/Library/basics/objects/ObObject.cpp b/source/VirtualFluidsBasic/basics/objects/ObObject.cpp
similarity index 94%
rename from source/ThirdParty/Library/basics/objects/ObObject.cpp
rename to source/VirtualFluidsBasic/basics/objects/ObObject.cpp
index 452791ad8f43507c069ea9e90e59193fd39334f6..e7774e9163d6173e456afeb9d3e91608a431a2f7 100644
--- a/source/ThirdParty/Library/basics/objects/ObObject.cpp
+++ b/source/VirtualFluidsBasic/basics/objects/ObObject.cpp
@@ -1,10 +1,10 @@
-//#include <basics/objects/ObObject.h>
-
-// ObObject::ObObject()
-// { 
-// }
-// /*=======================================*/
-// std::string ObObject::getName()
-// {
-//    return name;
-// }
+//#include <basics/objects/ObObject.h>
+
+// ObObject::ObObject()
+// { 
+// }
+// /*=======================================*/
+// std::string ObObject::getName()
+// {
+//    return name;
+// }
diff --git a/source/ThirdParty/Library/basics/objects/ObObject.h b/source/VirtualFluidsBasic/basics/objects/ObObject.h
similarity index 96%
rename from source/ThirdParty/Library/basics/objects/ObObject.h
rename to source/VirtualFluidsBasic/basics/objects/ObObject.h
index aeb3ed9c48bb7bbe0b58fc534c6c2313d17ce35b..addf7e134ef0de98fc4a4d7d1dc65f82caf7e571 100644
--- a/source/ThirdParty/Library/basics/objects/ObObject.h
+++ b/source/VirtualFluidsBasic/basics/objects/ObObject.h
@@ -1,60 +1,60 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef OBOBJECT_H
-#define OBOBJECT_H
-
-#include <string>
-
-#include <basics/objects/ObObjectCreator.h>
-#include <basics/utilities/UbObservable.h>
-
-#ifdef CAB_RCF
-#include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif
-
-
-class ObObjectCreator;
-
-class ObObject : public UbObservable
-{
-public:
-   ObObject() : name("") { }
-   ObObject(const std::string& name) : name(name) { }
-
-   virtual ~ObObject() { }
-
-   virtual ObObject*   clone()=0;
-   virtual std::string getTypeID()=0;
-
-   virtual std::string getName()  { return name; }
-   void setName(std::string name) { this->name=name; }
-
-   virtual std::string toString()=0;
-
-   virtual ObObjectCreator* getCreator()=0;
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void SF_SERIALIZE(Archive & ar) 
-   {
-      //SF::SF_SERIALIZE_PARENT<UbObservable>(ar, *this);
-      SF_SERIALIZE_PARENT<UbObservable>(ar, *this);
-      ar & name;
-   }
-#endif //CAB_RCF
-
-private:
-   std::string name;
-};
-
-#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
-SF_NO_CTOR(ObObject);
-UB_AUTO_RUN_NAMED( ( SF::registerType<ObObject>("ObObject") ),                SF_ObObject     );
-UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived<UbObservable, ObObject >() ), SF_ObObject_BD1 );
-#endif //RCF_USE_SF_SERIALIZATION
-
-#endif
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef OBOBJECT_H
+#define OBOBJECT_H
+
+#include <string>
+
+#include <basics/objects/ObObjectCreator.h>
+#include <basics/utilities/UbObservable.h>
+
+#ifdef CAB_RCF
+#include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif
+
+
+class ObObjectCreator;
+
+class ObObject : public UbObservable
+{
+public:
+   ObObject() : name("") { }
+   ObObject(const std::string& name) : name(name) { }
+
+   virtual ~ObObject() { }
+
+   virtual ObObject*   clone()=0;
+   virtual std::string getTypeID()=0;
+
+   virtual std::string getName()  { return name; }
+   void setName(std::string name) { this->name=name; }
+
+   virtual std::string toString()=0;
+
+   virtual ObObjectCreator* getCreator()=0;
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void SF_SERIALIZE(Archive & ar) 
+   {
+      //SF::SF_SERIALIZE_PARENT<UbObservable>(ar, *this);
+      SF_SERIALIZE_PARENT<UbObservable>(ar, *this);
+      ar & name;
+   }
+#endif //CAB_RCF
+
+private:
+   std::string name;
+};
+
+#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
+SF_NO_CTOR(ObObject);
+UB_AUTO_RUN_NAMED( ( SF::registerType<ObObject>("ObObject") ),                SF_ObObject     );
+UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived<UbObservable, ObObject >() ), SF_ObObject_BD1 );
+#endif //RCF_USE_SF_SERIALIZATION
+
+#endif
diff --git a/source/ThirdParty/Library/basics/objects/ObObjectCreator.h b/source/VirtualFluidsBasic/basics/objects/ObObjectCreator.h
similarity index 96%
rename from source/ThirdParty/Library/basics/objects/ObObjectCreator.h
rename to source/VirtualFluidsBasic/basics/objects/ObObjectCreator.h
index 540f422d5ddc6ef9320743bfbee4432a85225796..3224466dc34d500e67d381cba2e68e04fe5f474b 100644
--- a/source/ThirdParty/Library/basics/objects/ObObjectCreator.h
+++ b/source/VirtualFluidsBasic/basics/objects/ObObjectCreator.h
@@ -1,58 +1,58 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef OBOBJECTCREATOR_H
-#define OBOBJECTCREATOR_H
-
-#include <string>
-
-class ObObject;
-class ObObjectManager;
-
-class Presentator;
-class QViewer;
-
-#ifdef CAB_QT 
-class QObObjectSpecificInstrument;
-class QWidget;
-class QActionGroup;
-#endif
-
-class ObObjectCreator
-{
-public:
-   virtual ~ObObjectCreator() {}
-
-	virtual ObObject* createObObject()=0;
-
-	virtual std::string getTypeID()	{ return "ObObject"; }
-	virtual std::string toString()	{ return "ObObjectCreator"; }
-   
-#ifdef CAB_QT 
-   //virtual Presentator* createObjectPresentator(ObObject *object)=0;
-   virtual Presentator* createObjectPresentator(ObObject *object) { return NULL; }
-   virtual QActionGroup* getSpecificPresentatorGroup(ObObject* object, QViewer *viewer, QWidget* parent) { return NULL; }
-   virtual QActionGroup* getSpecificActionGroup(ObObjectManager* manager, ObObject* object, QWidget* parent) 
-   { 
-      return NULL; 
-   }
-
-   virtual ObObject* createObObjectWithQt() { return NULL; }
-   virtual void showSpecificInstrument(ObObject* object, QWidget* parent=0) {}
-   virtual QObObjectSpecificInstrument* getSpecificInstrument() { return NULL; }
-   
-   //virtual QActionGroup *getSpecificContextMenuActionGroup() { return NULL; }
-#endif
-
-protected:
-	ObObjectCreator() {}
-
-private:
-   ObObjectCreator( const ObObjectCreator& );                  //no copy allowed 
-   const ObObjectCreator& operator=( const ObObjectCreator& ); //no copy allowed
-
-};
-#endif
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef OBOBJECTCREATOR_H
+#define OBOBJECTCREATOR_H
+
+#include <string>
+
+class ObObject;
+class ObObjectManager;
+
+class Presentator;
+class QViewer;
+
+#ifdef CAB_QT 
+class QObObjectSpecificInstrument;
+class QWidget;
+class QActionGroup;
+#endif
+
+class ObObjectCreator
+{
+public:
+   virtual ~ObObjectCreator() {}
+
+	virtual ObObject* createObObject()=0;
+
+	virtual std::string getTypeID()	{ return "ObObject"; }
+	virtual std::string toString()	{ return "ObObjectCreator"; }
+   
+#ifdef CAB_QT 
+   //virtual Presentator* createObjectPresentator(ObObject *object)=0;
+   virtual Presentator* createObjectPresentator(ObObject *object) { return NULL; }
+   virtual QActionGroup* getSpecificPresentatorGroup(ObObject* object, QViewer *viewer, QWidget* parent) { return NULL; }
+   virtual QActionGroup* getSpecificActionGroup(ObObjectManager* manager, ObObject* object, QWidget* parent) 
+   { 
+      return NULL; 
+   }
+
+   virtual ObObject* createObObjectWithQt() { return NULL; }
+   virtual void showSpecificInstrument(ObObject* object, QWidget* parent=0) {}
+   virtual QObObjectSpecificInstrument* getSpecificInstrument() { return NULL; }
+   
+   //virtual QActionGroup *getSpecificContextMenuActionGroup() { return NULL; }
+#endif
+
+protected:
+	ObObjectCreator() {}
+
+private:
+   ObObjectCreator( const ObObjectCreator& );                  //no copy allowed 
+   const ObObjectCreator& operator=( const ObObjectCreator& ); //no copy allowed
+
+};
+#endif
diff --git a/source/ThirdParty/Library/basics/objects/ObObjectFactory.cpp b/source/VirtualFluidsBasic/basics/objects/ObObjectFactory.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/objects/ObObjectFactory.cpp
rename to source/VirtualFluidsBasic/basics/objects/ObObjectFactory.cpp
index 5cc03a78f2b2d550406e14a95cdbcffe22157e9c..49bf03fe3ab159a91a17b9fd4f7b65f6c2dcda9c 100644
--- a/source/ThirdParty/Library/basics/objects/ObObjectFactory.cpp
+++ b/source/VirtualFluidsBasic/basics/objects/ObObjectFactory.cpp
@@ -1,54 +1,54 @@
-#include <basics/objects/ObObjectFactory.h>
-
-/**** Eigene ****/
-#include <basics/objects/ObObjectCreator.h>
-#include <basics/utilities/UbException.h>
-
-using namespace std;
-
-//ObObjectFactory::ObObjectFactory()
-//{
-//}
-//
-//ObObjectFactory::~ObObjectFactory()
-//{
-//}
-/*======================================================================*/  
-//ObObjectFactory* ObObjectFactory::getInstance()
-//{
-//	static ObObjectFactory instance;
-//	return &instance;
-//}
-/*======================================================================*/
-void ObObjectFactory::addObObjectCreator(ObObjectCreator *creator)
-{
-	//cout<<"Meth:"<<creator->toString()<<" Meth-ID:"<<creator->getTypeID()<<endl;
-	creatorSet.insert(std::pair<string, ObObjectCreator*>(creator->getTypeID(), creator));
-}
-/*======================================================================*/
-void ObObjectFactory::removeObObjectCreator(ObObjectCreator *creator)
-{
-	UB_THROW( UbException(UB_EXARGS,"not implemented") );
-}
-/*======================================================================*/
-ObObjectCreator* ObObjectFactory::getCreator(string objectType) 
-{
-	std::map<string, ObObjectCreator*>::iterator creatorIterator = creatorSet.find(objectType);
-	if(creatorIterator == creatorSet.end()) UB_THROW( UbException(UB_EXARGS,"factory has no creator for "+objectType) );
-	ObObjectCreator *creator = creatorIterator->second;
-	if(!creator) UB_THROW( UbException(UB_EXARGS,"no time series creator for type available") );
-	return creator;
-}
-/*======================================================================*/
-string ObObjectFactory::toString() 
-{
-   stringstream text;
-
-   std::map<string, ObObjectCreator*>::iterator creatorIterator;
-   std::map<string, ObObjectCreator*>* creatorSet = this->getCreatorSet();
-
-   for(creatorIterator = creatorSet->begin(); creatorIterator!=creatorSet->end(); ++creatorIterator)
-      text<<"   - "<<(creatorIterator->second)->toString()<<" for "<<(creatorIterator->first)<<endl;
-
-   return text.str();
-}
+#include <basics/objects/ObObjectFactory.h>
+
+/**** Eigene ****/
+#include <basics/objects/ObObjectCreator.h>
+#include <basics/utilities/UbException.h>
+
+using namespace std;
+
+//ObObjectFactory::ObObjectFactory()
+//{
+//}
+//
+//ObObjectFactory::~ObObjectFactory()
+//{
+//}
+/*======================================================================*/  
+//ObObjectFactory* ObObjectFactory::getInstance()
+//{
+//	static ObObjectFactory instance;
+//	return &instance;
+//}
+/*======================================================================*/
+void ObObjectFactory::addObObjectCreator(ObObjectCreator *creator)
+{
+	//cout<<"Meth:"<<creator->toString()<<" Meth-ID:"<<creator->getTypeID()<<endl;
+	creatorSet.insert(std::pair<string, ObObjectCreator*>(creator->getTypeID(), creator));
+}
+/*======================================================================*/
+void ObObjectFactory::removeObObjectCreator(ObObjectCreator *creator)
+{
+	UB_THROW( UbException(UB_EXARGS,"not implemented") );
+}
+/*======================================================================*/
+ObObjectCreator* ObObjectFactory::getCreator(string objectType) 
+{
+	std::map<string, ObObjectCreator*>::iterator creatorIterator = creatorSet.find(objectType);
+	if(creatorIterator == creatorSet.end()) UB_THROW( UbException(UB_EXARGS,"factory has no creator for "+objectType) );
+	ObObjectCreator *creator = creatorIterator->second;
+	if(!creator) UB_THROW( UbException(UB_EXARGS,"no time series creator for type available") );
+	return creator;
+}
+/*======================================================================*/
+string ObObjectFactory::toString() 
+{
+   stringstream text;
+
+   std::map<string, ObObjectCreator*>::iterator creatorIterator;
+   std::map<string, ObObjectCreator*>* creatorSet = this->getCreatorSet();
+
+   for(creatorIterator = creatorSet->begin(); creatorIterator!=creatorSet->end(); ++creatorIterator)
+      text<<"   - "<<(creatorIterator->second)->toString()<<" for "<<(creatorIterator->first)<<endl;
+
+   return text.str();
+}
diff --git a/source/ThirdParty/Library/basics/objects/ObObjectFactory.h b/source/VirtualFluidsBasic/basics/objects/ObObjectFactory.h
similarity index 96%
rename from source/ThirdParty/Library/basics/objects/ObObjectFactory.h
rename to source/VirtualFluidsBasic/basics/objects/ObObjectFactory.h
index da8ef389c6ef433d96be6663eefaf34c9c99bd1c..2af7458cdf9fa742b19710a3ab4cc4ca665c6860 100644
--- a/source/ThirdParty/Library/basics/objects/ObObjectFactory.h
+++ b/source/VirtualFluidsBasic/basics/objects/ObObjectFactory.h
@@ -1,42 +1,42 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef OBOBJECTFACTORY_H
-#define OBOBJECTFACTORY_H
-
-#include <string>
-#include <map>
-
-class ObObjectCreator; 
-
-class ObObjectFactory
-{
-public:
-   ObObjectFactory() {}
-   virtual ~ObObjectFactory() {}
-
-   //static geht nicht, da abgeleitete Factories existieren ...
-   //static ObObjectFactory* getInstance();
-   //virtual ObObjectFactory* getInstance()=0;
-
-   ObObjectCreator* getCreator(std::string objectType);
-
-	void addObObjectCreator(ObObjectCreator* creator);
-	void removeObObjectCreator(ObObjectCreator* creator);
-
-   std::map<std::string, ObObjectCreator*>* getCreatorSet() { return &creatorSet;  }
-
-   virtual std::string toString();
-	
-private:
-   ObObjectFactory( const ObObjectFactory& );                  //no copy allowed 
-   const ObObjectFactory& operator=( const ObObjectFactory& ); //no copy allowed
-
-   std::map<std::string, ObObjectCreator*> creatorSet;
-};
-
-
-#endif //OBOBJECTFACTORY_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef OBOBJECTFACTORY_H
+#define OBOBJECTFACTORY_H
+
+#include <string>
+#include <map>
+
+class ObObjectCreator; 
+
+class ObObjectFactory
+{
+public:
+   ObObjectFactory() {}
+   virtual ~ObObjectFactory() {}
+
+   //static geht nicht, da abgeleitete Factories existieren ...
+   //static ObObjectFactory* getInstance();
+   //virtual ObObjectFactory* getInstance()=0;
+
+   ObObjectCreator* getCreator(std::string objectType);
+
+	void addObObjectCreator(ObObjectCreator* creator);
+	void removeObObjectCreator(ObObjectCreator* creator);
+
+   std::map<std::string, ObObjectCreator*>* getCreatorSet() { return &creatorSet;  }
+
+   virtual std::string toString();
+	
+private:
+   ObObjectFactory( const ObObjectFactory& );                  //no copy allowed 
+   const ObObjectFactory& operator=( const ObObjectFactory& ); //no copy allowed
+
+   std::map<std::string, ObObjectCreator*> creatorSet;
+};
+
+
+#endif //OBOBJECTFACTORY_H
diff --git a/source/ThirdParty/Library/basics/objects/ObObjectManager.cpp b/source/VirtualFluidsBasic/basics/objects/ObObjectManager.cpp
similarity index 96%
rename from source/ThirdParty/Library/basics/objects/ObObjectManager.cpp
rename to source/VirtualFluidsBasic/basics/objects/ObObjectManager.cpp
index 44bba546bf9e157bc21baff5d6e24aa8f3700786..d84f49fc158850203f6ddc2467a1e3fb7c5c6d32 100644
--- a/source/ThirdParty/Library/basics/objects/ObObjectManager.cpp
+++ b/source/VirtualFluidsBasic/basics/objects/ObObjectManager.cpp
@@ -1,216 +1,216 @@
-#include <basics/objects/ObObjectManager.h>
-#include <basics/objects/ObObject.h>
-#include <basics/objects/ObObjectCreator.h>
-#include <basics/utilities/UbTableModel.h>
-#include <basics/utilities/UbException.h>
-
-using namespace std;
-
-ObObjectEntry::ObObjectEntry(ObObjectManager *parent, ObObject *object)
-{
-   this->parent = parent;
-   this->object = object;
-}
-/*======================================================*/
-ObObjectManager::ObObjectManager()
-{
-	this->selectedObject = NULL;
-	this->tableModel = NULL;
-}
-
-/*======================================================*/
-ObObjectManager::~ObObjectManager()
-{
-	//cerr<<"NEIN, notifyObserversObjectWillBeDeleted wird AUSSCHLIESSLICH von BasisKlasse aufgerufen!!!"<<endl;
- //  cerr<<"das muss so sein, denn ansonsten duerfte diese funktion nur in der speziellen klasse stehen, da\n";
- //  cerr<<"virtuelle destruktoren sich rekursiv vom speziellen ins allg. aufrufen --> notify.. wuerde\n";
- //  cerr<<"oefters aufgerufen werden...\n";
-
-	this->objectList.clear();
-	if(this->tableModel) delete this->tableModel;
-}
-/*======================================================*/
-UbTableModel* ObObjectManager::getTableModel()
-{ 
-	return tableModel; 
-}
-/*======================================================*/
-//bool ObObjectManager::addObObject(ObObject *object)
-//{
-//   cout<<"ObObjectManager::addObObject "<<object->toString()<<endl;
-//	for(int pos=0; pos<(int)this->objectList.size(); pos++)
-//		if(this->objectList[pos]->object==object) 
-//			return false;
-//
-//	this->objectList.push_back(new ObObjectEntry(this,object));
-//	//object->addObserver(this);
-//	this->selectObObject(object);
-//	return true;
-//}
-/*======================================================*/
-bool ObObjectManager::addObObjectEntry(ObObjectEntry* objectEntry)
-{
-   for(int pos=0; pos<(int)this->objectList.size(); pos++)
-      if(this->objectList[pos]->object==objectEntry->object) 
-         return false;
-
-   this->objectList.push_back(objectEntry);
-//   objectEntry->getObject()->addObserver(this);
-   this->selectObObject(objectEntry->object);
-   return true;
-}
-/*======================================================*/
-bool ObObjectManager::removeObObject(ObObject* object)
-{
-	if (this->selectedObject == object) this->selectedObject=NULL;
-	for(int pos=0; pos<(int)this->objectList.size(); pos++)
-	{
-
-		if(this->objectList[pos]->object==object) 
-		{
-         return this->removeObObject(pos);
-//			this->objectList.erase(objectList.begin()+pos);
-//			//this->removeObserver(this);
-//			return true;
-		}
-	}
-	return false;
-}
-/*======================================================*/
-bool ObObjectManager::removeObObject(int index)
-{
-	try
-	{
-		if ( objectList[index]->object == this->selectedObject ) this->selectedObject=NULL;
-      //den entry loeschen ... das object im Entry ??? erstmal ausserhalb ...
-      delete objectList[index]; 
-		objectList.erase(objectList.begin()+index);
-   	this->notifyObserversObjectChanged();
-   	return true;
-	}
-	catch(const std::exception& e)  {  cerr<<e.what()<<endl;    }
-   catch(...)                      {  cerr<<"Fehler in ObObjectManager::removeObObject"<<endl; }
-   return false;
-}
-/*======================================================*/
-void ObObjectManager::removeAllObObjects() 
-{  
-	//TODO: implementieren!!
-	//foreach grid:
-	//grid->removeObserver(this);
-	//vector<ObObject*>::iterator it;
-	//for(it=objectList.begin();  it!=objectList.end(); it++)
-	//{
-	//	it->removeObserver(this);
-	//}
-// 	for(int i=0; i<(int)objectList.size(); i++)
-// 	{
-// 		delete objectList[i]->object->removeObserver(this);
-// 	} 
-	this->objectList.clear();
-	this->selectedObject = NULL;
-	this->notifyObserversObjectChanged();
-}
-/*======================================================*/
-int ObObjectManager::getNumberOfObObjects()
-{ 
-	return (int)this->objectList.size();
-}
-/*======================================================*/
-vector<ObObject*>* ObObjectManager::getAllObObjects()  
-{ 
-   UB_THROW( UbException(UB_EXARGS,"hier muss noch was getan werden") );
-//	return this->objectList;  
-}
-vector<ObObjectEntry*>* ObObjectManager::getAllObObjectEntries()
-{
-   return &this->objectList;  
-}
-/*======================================================*/
-ObObject* ObObjectManager::getObObject(int index)
-{
-	if(index <  0)                            return NULL;
-	if(index >= (int)this->objectList.size()) return NULL;
-
-	return(this->objectList[index]->object);
-}
-/*======================================================*/
-ObObjectEntry* ObObjectManager::getObObjectEntry(int index)
-{
-   if(index <  0)                            return NULL;
-   if(index >= (int)this->objectList.size()) return NULL;
-
-   return(this->objectList[index]);
-}
-/*====================================================*/
-string ObObjectManager::toString()
-{
-	stringstream ss; ss<<endl;
-
-	for(int pos=0; pos<(int)this->objectList.size(); pos++)          
-	{
-		ObObject* object = this->objectList[pos]->object;
-		ss<<(pos+1)<<". "<<object->toString()<<endl;
-	}
-	return ss.str();
-}
-/*======================================================*/
-void ObObjectManager::objectChanged(UbObservable* observable)
-{
-   //cout<<"ObObjectManager::objectChanged ??";
-	this->notifyObserversObjectChanged();
-}
-/*======================================================*/
-void ObObjectManager::objectWillBeDeleted(UbObservable* observable)
-{
-   cout<<"ObObjectManager::objectWillBeDeleted ??";
-	//observable->removeObserver(this);
-}
-/*======================================================*/
-bool ObObjectManager::selectObObject(int index)
-{
-   if((int)this->objectList.size()==0) 
-   {
-      this->selectedObject = NULL; return false; 
-   }
-	if (index > (int)this->objectList.size()-1 || index < 0) return false; 
-	if ( this->selectedObject == this->getObObject(index) ) return true;
-   
-	this->selectedObject = this->getObObject(index);
-   //cout<<this->getObserverList()->size()<<endl;
-
-	this->notifyObserversObjectChanged();
-	return true;
-}
-/*======================================================*/
-bool ObObjectManager::selectObObject(ObObject* object)
-{
-   if((int)this->objectList.size()==0) { this->selectedObject = NULL; return false; }
-	for(int pos=0; pos<(int)this->objectList.size(); pos++)
-	{
-		if(this->objectList[pos]->object==object) 
-		{
-			return this->selectObObject(pos);
-		}
-	}
-	return false;
-}
-/*======================================================*/
-ObObject* ObObjectManager::getSelectedObObject()
-{
-	return this->selectedObject;
-}
-/*======================================================*/
-int ObObjectManager::getSelectedIndex()
-{
-	for(int pos=0; pos<(int)this->objectList.size(); pos++)
-	{
-		if(this->objectList[pos]->object==this->selectedObject) 
-		{
-			return pos;
-		}
-	}
-	return -1;
-}
-/*======================================================*/
-
+#include <basics/objects/ObObjectManager.h>
+#include <basics/objects/ObObject.h>
+#include <basics/objects/ObObjectCreator.h>
+#include <basics/utilities/UbTableModel.h>
+#include <basics/utilities/UbException.h>
+
+using namespace std;
+
+ObObjectEntry::ObObjectEntry(ObObjectManager *parent, ObObject *object)
+{
+   this->parent = parent;
+   this->object = object;
+}
+/*======================================================*/
+ObObjectManager::ObObjectManager()
+{
+	this->selectedObject = NULL;
+	this->tableModel = NULL;
+}
+
+/*======================================================*/
+ObObjectManager::~ObObjectManager()
+{
+	//cerr<<"NEIN, notifyObserversObjectWillBeDeleted wird AUSSCHLIESSLICH von BasisKlasse aufgerufen!!!"<<endl;
+ //  cerr<<"das muss so sein, denn ansonsten duerfte diese funktion nur in der speziellen klasse stehen, da\n";
+ //  cerr<<"virtuelle destruktoren sich rekursiv vom speziellen ins allg. aufrufen --> notify.. wuerde\n";
+ //  cerr<<"oefters aufgerufen werden...\n";
+
+	this->objectList.clear();
+	if(this->tableModel) delete this->tableModel;
+}
+/*======================================================*/
+UbTableModel* ObObjectManager::getTableModel()
+{ 
+	return tableModel; 
+}
+/*======================================================*/
+//bool ObObjectManager::addObObject(ObObject *object)
+//{
+//   cout<<"ObObjectManager::addObObject "<<object->toString()<<endl;
+//	for(int pos=0; pos<(int)this->objectList.size(); pos++)
+//		if(this->objectList[pos]->object==object) 
+//			return false;
+//
+//	this->objectList.push_back(new ObObjectEntry(this,object));
+//	//object->addObserver(this);
+//	this->selectObObject(object);
+//	return true;
+//}
+/*======================================================*/
+bool ObObjectManager::addObObjectEntry(ObObjectEntry* objectEntry)
+{
+   for(int pos=0; pos<(int)this->objectList.size(); pos++)
+      if(this->objectList[pos]->object==objectEntry->object) 
+         return false;
+
+   this->objectList.push_back(objectEntry);
+//   objectEntry->getObject()->addObserver(this);
+   this->selectObObject(objectEntry->object);
+   return true;
+}
+/*======================================================*/
+bool ObObjectManager::removeObObject(ObObject* object)
+{
+	if (this->selectedObject == object) this->selectedObject=NULL;
+	for(int pos=0; pos<(int)this->objectList.size(); pos++)
+	{
+
+		if(this->objectList[pos]->object==object) 
+		{
+         return this->removeObObject(pos);
+//			this->objectList.erase(objectList.begin()+pos);
+//			//this->removeObserver(this);
+//			return true;
+		}
+	}
+	return false;
+}
+/*======================================================*/
+bool ObObjectManager::removeObObject(int index)
+{
+	try
+	{
+		if ( objectList[index]->object == this->selectedObject ) this->selectedObject=NULL;
+      //den entry loeschen ... das object im Entry ??? erstmal ausserhalb ...
+      delete objectList[index]; 
+		objectList.erase(objectList.begin()+index);
+   	this->notifyObserversObjectChanged();
+   	return true;
+	}
+	catch(const std::exception& e)  {  cerr<<e.what()<<endl;    }
+   catch(...)                      {  cerr<<"Fehler in ObObjectManager::removeObObject"<<endl; }
+   return false;
+}
+/*======================================================*/
+void ObObjectManager::removeAllObObjects() 
+{  
+	//TODO: implementieren!!
+	//foreach grid:
+	//grid->removeObserver(this);
+	//vector<ObObject*>::iterator it;
+	//for(it=objectList.begin();  it!=objectList.end(); it++)
+	//{
+	//	it->removeObserver(this);
+	//}
+// 	for(int i=0; i<(int)objectList.size(); i++)
+// 	{
+// 		delete objectList[i]->object->removeObserver(this);
+// 	} 
+	this->objectList.clear();
+	this->selectedObject = NULL;
+	this->notifyObserversObjectChanged();
+}
+/*======================================================*/
+int ObObjectManager::getNumberOfObObjects()
+{ 
+	return (int)this->objectList.size();
+}
+/*======================================================*/
+vector<ObObject*>* ObObjectManager::getAllObObjects()  
+{ 
+   UB_THROW( UbException(UB_EXARGS,"hier muss noch was getan werden") );
+//	return this->objectList;  
+}
+vector<ObObjectEntry*>* ObObjectManager::getAllObObjectEntries()
+{
+   return &this->objectList;  
+}
+/*======================================================*/
+ObObject* ObObjectManager::getObObject(int index)
+{
+	if(index <  0)                            return NULL;
+	if(index >= (int)this->objectList.size()) return NULL;
+
+	return(this->objectList[index]->object);
+}
+/*======================================================*/
+ObObjectEntry* ObObjectManager::getObObjectEntry(int index)
+{
+   if(index <  0)                            return NULL;
+   if(index >= (int)this->objectList.size()) return NULL;
+
+   return(this->objectList[index]);
+}
+/*====================================================*/
+string ObObjectManager::toString()
+{
+	stringstream ss; ss<<endl;
+
+	for(int pos=0; pos<(int)this->objectList.size(); pos++)          
+	{
+		ObObject* object = this->objectList[pos]->object;
+		ss<<(pos+1)<<". "<<object->toString()<<endl;
+	}
+	return ss.str();
+}
+/*======================================================*/
+void ObObjectManager::objectChanged(UbObservable* observable)
+{
+   //cout<<"ObObjectManager::objectChanged ??";
+	this->notifyObserversObjectChanged();
+}
+/*======================================================*/
+void ObObjectManager::objectWillBeDeleted(UbObservable* observable)
+{
+   cout<<"ObObjectManager::objectWillBeDeleted ??";
+	//observable->removeObserver(this);
+}
+/*======================================================*/
+bool ObObjectManager::selectObObject(int index)
+{
+   if((int)this->objectList.size()==0) 
+   {
+      this->selectedObject = NULL; return false; 
+   }
+	if (index > (int)this->objectList.size()-1 || index < 0) return false; 
+	if ( this->selectedObject == this->getObObject(index) ) return true;
+   
+	this->selectedObject = this->getObObject(index);
+   //cout<<this->getObserverList()->size()<<endl;
+
+	this->notifyObserversObjectChanged();
+	return true;
+}
+/*======================================================*/
+bool ObObjectManager::selectObObject(ObObject* object)
+{
+   if((int)this->objectList.size()==0) { this->selectedObject = NULL; return false; }
+	for(int pos=0; pos<(int)this->objectList.size(); pos++)
+	{
+		if(this->objectList[pos]->object==object) 
+		{
+			return this->selectObObject(pos);
+		}
+	}
+	return false;
+}
+/*======================================================*/
+ObObject* ObObjectManager::getSelectedObObject()
+{
+	return this->selectedObject;
+}
+/*======================================================*/
+int ObObjectManager::getSelectedIndex()
+{
+	for(int pos=0; pos<(int)this->objectList.size(); pos++)
+	{
+		if(this->objectList[pos]->object==this->selectedObject) 
+		{
+			return pos;
+		}
+	}
+	return -1;
+}
+/*======================================================*/
+
diff --git a/source/ThirdParty/Library/basics/objects/ObObjectManager.h b/source/VirtualFluidsBasic/basics/objects/ObObjectManager.h
similarity index 96%
rename from source/ThirdParty/Library/basics/objects/ObObjectManager.h
rename to source/VirtualFluidsBasic/basics/objects/ObObjectManager.h
index 632e124bf72f3a259f638f12116eeac2b661e61f..9d5b42df99209527228127eb195122054d550bfd 100644
--- a/source/ThirdParty/Library/basics/objects/ObObjectManager.h
+++ b/source/VirtualFluidsBasic/basics/objects/ObObjectManager.h
@@ -1,79 +1,79 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef OBOBJECTMANAGER_H
-#define OBOBJECTMANAGER_H
-
-#include <string>
-#include <sstream>
-#include <vector>
-
-#include <basics/utilities/UbObservable.h>
-#include <basics/utilities/UbObserver.h>
-
-class UbException;
-class UbTableModel;
-class ObObjectManager;
-class ObObjectFactory;
-class ObObject;
-
-
-class ObObjectEntry
-{
-   friend class ObObjectManager;
-public:
-   ObObjectManager* getParent() { return parent; }
-   ObObject*        getObject() { return object; }
-   
-   ObObjectEntry(ObObjectManager* parent, ObObject* object);
-   virtual ~ObObjectEntry() {  }
-
-protected:
-   ObObjectManager* parent;
-   ObObject* object;
-};
-
-
-class ObObjectManager : public UbObservable, public UbObserver
-{
-public:
-	ObObjectManager();
-	~ObObjectManager();
-	
-   //virtual bool addObObject(ObObject* object);   
-   virtual bool addObObjectEntry(ObObjectEntry* objectEntry);
-
-   virtual ObObjectEntry* createNewObObjectEntry(ObObject* obj) { return new ObObjectEntry(this, obj); }
-
-	bool removeObObject(ObObject* object);
-	bool removeObObject(int index);
-	void removeAllObObjects();
-	bool selectObObject(int index);
-	bool selectObObject(ObObject* object);
-	ObObject* getSelectedObObject();
-	int getSelectedIndex();
-
-	int getNumberOfObObjects();                 
-   std::vector<ObObject*>* getAllObObjects();
-   std::vector<ObObjectEntry*>* getAllObObjectEntries();
-	ObObject* getObObject(int index);
-   ObObjectEntry* getObObjectEntry(int index);
-
-	std::string toString();
-
-	virtual void objectChanged(UbObservable* observable);
-	virtual void objectWillBeDeleted(UbObservable* observable);
-
-	UbTableModel* getTableModel();
-   virtual ObObjectFactory* getObObjectFactory()=0;
-
-protected:
-	 std::vector<ObObjectEntry*> objectList;
-	 ObObject* selectedObject;
-	 UbTableModel* tableModel;
-};
-
-#endif //OBOBJECTMANAGER_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef OBOBJECTMANAGER_H
+#define OBOBJECTMANAGER_H
+
+#include <string>
+#include <sstream>
+#include <vector>
+
+#include <basics/utilities/UbObservable.h>
+#include <basics/utilities/UbObserver.h>
+
+class UbException;
+class UbTableModel;
+class ObObjectManager;
+class ObObjectFactory;
+class ObObject;
+
+
+class ObObjectEntry
+{
+   friend class ObObjectManager;
+public:
+   ObObjectManager* getParent() { return parent; }
+   ObObject*        getObject() { return object; }
+   
+   ObObjectEntry(ObObjectManager* parent, ObObject* object);
+   virtual ~ObObjectEntry() {  }
+
+protected:
+   ObObjectManager* parent;
+   ObObject* object;
+};
+
+
+class ObObjectManager : public UbObservable, public UbObserver
+{
+public:
+	ObObjectManager();
+	~ObObjectManager();
+	
+   //virtual bool addObObject(ObObject* object);   
+   virtual bool addObObjectEntry(ObObjectEntry* objectEntry);
+
+   virtual ObObjectEntry* createNewObObjectEntry(ObObject* obj) { return new ObObjectEntry(this, obj); }
+
+	bool removeObObject(ObObject* object);
+	bool removeObObject(int index);
+	void removeAllObObjects();
+	bool selectObObject(int index);
+	bool selectObObject(ObObject* object);
+	ObObject* getSelectedObObject();
+	int getSelectedIndex();
+
+	int getNumberOfObObjects();                 
+   std::vector<ObObject*>* getAllObObjects();
+   std::vector<ObObjectEntry*>* getAllObObjectEntries();
+	ObObject* getObObject(int index);
+   ObObjectEntry* getObObjectEntry(int index);
+
+	std::string toString();
+
+	virtual void objectChanged(UbObservable* observable);
+	virtual void objectWillBeDeleted(UbObservable* observable);
+
+	UbTableModel* getTableModel();
+   virtual ObObjectFactory* getObObjectFactory()=0;
+
+protected:
+	 std::vector<ObObjectEntry*> objectList;
+	 ObObject* selectedObject;
+	 UbTableModel* tableModel;
+};
+
+#endif //OBOBJECTMANAGER_H
diff --git a/source/VirtualFluidsBasic/basics/parallel/CMakePackage.txt b/source/VirtualFluidsBasic/basics/parallel/CMakePackage.txt
new file mode 100644
index 0000000000000000000000000000000000000000..1b8416f010d2a7de30b8f70c9abf19a96dd8cf8f
--- /dev/null
+++ b/source/VirtualFluidsBasic/basics/parallel/CMakePackage.txt
@@ -0,0 +1,2 @@
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
diff --git a/source/ThirdParty/Library/basics/parallel/PbMpi.h b/source/VirtualFluidsBasic/basics/parallel/PbMpi.h
similarity index 97%
rename from source/ThirdParty/Library/basics/parallel/PbMpi.h
rename to source/VirtualFluidsBasic/basics/parallel/PbMpi.h
index 21dd38f923eed543af9be4262366db5caf2b37f6..76011d61360a4ac89d8c843603ecec9a8f2f868a 100644
--- a/source/ThirdParty/Library/basics/parallel/PbMpi.h
+++ b/source/VirtualFluidsBasic/basics/parallel/PbMpi.h
@@ -1,454 +1,454 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef PbMpi_H
-#define PbMpi_H
-
-#include <vector>
-#include <sstream>
-
-#ifndef VF_MPI
-#  error VF_MPI has to be defined
-#endif
-
-//#undef SEEK_SET
-//#undef SEEK_CUR
-//#undef SEEK_END
-#include <mpi.h>
-
-#include <basics/utilities/UbException.h>
-
-#ifdef USE_MPI_CXX_SYNTAX
-   #define PbMpi_COMM_WORLD MPI::COMM_WORLD
-   #define PbMpi_INT        MPI::INT  
-   #define PbMpi_CHAR       MPI::CHAR 
-   #define PbMpi_SHORT      MPI::SHORT
-   #define PbMpi_FLOAT      MPI::FLOAT
-   #define PbMpi_DOUBLE     MPI::DOUBLE
-   #define PbMpi_COMM_NULL  MPI::COMM_NULL   
-
-
-namespace PbMpi
-{
-   typedef MPI::Intracomm Comm;
-   typedef MPI::Group     Group;
-   typedef MPI::Request   Request;
-   typedef MPI::Status    Status;
-
-   inline void Init( )  
-   {
-      MPI::Init(); 
-      MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS); 
-   }
-   inline void Init(int& argc, char** argv )  
-   {
-      MPI::Init(argc, argv); 
-      MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS); 
-   }
-   inline void Finalize()                      { MPI::Finalize();        }
-
-   inline int  GetCommSize( const Comm& comm ) { return comm.Get_size(); }
-   inline int  GetCommRank( const Comm& comm ) { return comm.Get_rank(); }
-   inline void Barrier( const Comm& comm  )    { comm.Barrier();         }
-
-   inline double Wtime()                       { return MPI::Wtime();    }
-   inline double Wtick()                       { return MPI::Wtick();    }
-
-   inline void Wait( Request& request, Status* outStatus=NULL) 
-   { 
-      if(outStatus) request.Wait(*outStatus); 
-      else request.Wait();   
-   }
-
-   inline Group GetCommGroup(Comm& comm)                               { return comm.Get_group();     }
-   inline Group GetGroupIncl( Group& group, const int& n, int* ranks ) { return group.Incl(n, ranks); }
-   inline Comm  CommCreateComm( Comm& comm, Group& group )             { return comm.Create(group);   }
-
-   inline void Alltoall( Comm& comm, void* sendBuffer, const int& sn, const MPI_Datatype& sdatatype, void* recvBuffer, const int& rn, const MPI_Datatype& rdatatype)
-   {
-      comm.Alltoall(sendBuffer, sn, sdatatype, recvBuffer, rn, rdatatype);
-   }
-   inline void Bcast(Comm& comm, void* data, const int& n, const MPI_Datatype& datatype , const int& srcRank )
-   {
-      comm.Bcast(data, n, datatype, srcRank);
-   }
-   inline void Send(Comm& comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag)
-   {
-      try
-      { 
-         comm.Send(data, length, dataType, destRank, tag);
-      }
-      catch(MPI::Exception& e)
-      {
-         std::stringstream ss; 
-         ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-         throw UbException(UB_EXARGS,"MPI:Exception catched\n"+ss.str());
-      }
-      catch(...)  
-      {
-         throw UbException(UB_EXARGS,"unknown exception"); 
-      }
-   }
-   inline void Recv(Comm& comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag)
-   {
-      try
-      { 
-         comm.Recv(const_cast<void*>(data), length, dataType, srcRank, tag);
-      }
-      catch(MPI::Exception& e)
-      {
-         std::stringstream ss; 
-         ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-         throw UbException(UB_EXARGS,"MPI:Exception catched \n"+ss.str());
-      }
-      catch(...)  
-      {
-         throw UbException(UB_EXARGS,"unknown exception"); 
-      }
-   }
-
-   inline void Irecv(Comm comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag, Request& outRequest)
-   {
-      outRequest = comm.Irecv(const_cast<void*>(data), length, dataType, srcRank, tag);
-   }
-   inline void Ssend(Comm& comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag)
-   {
-      try
-      { 
-         comm.Ssend(data, length, dataType, destRank, tag);
-      }
-      catch(MPI::Exception& e)
-      {
-         std::stringstream ss; 
-         ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-         throw UbException(UB_EXARGS,"MPI:Exception catched\n"+ss.str());
-      }
-      catch(...)  
-      {
-         throw UbException(UB_EXARGS,"unknown exception"); 
-      }
-   }
-
-}
-#else //////////////////////////////////////////////////////////////////////////
-   //////////////////////////////////////////////////////////////////////////
-   // C-Syntax 
-   //////////////////////////////////////////////////////////////////////////
-   namespace PbMpi
-   {
-      typedef MPI_Comm    Comm;
-      typedef MPI_Group   Group;
-      typedef MPI_Request Request;
-      typedef MPI_Status  Status;
-   }
-
-   #define PbMpi_COMM_WORLD ((PbMpi::Comm)MPI_COMM_WORLD)
-   #define PbMpi_INT        MPI_INT
-   #define PbMpi_CHAR       MPI_CHAR
-   #define PbMpi_SHORT      MPI_SHORT
-   #define PbMpi_FLOAT      MPI_FLOAT
-   #define PbMpi_DOUBLE     MPI_DOUBLE
-   #define PbMpi_COMM_NULL  MPI_COMM_NULL   
-
-namespace PbMpi
-{
-   inline void Init( )  
-   {
-      int    argc = 1;
-      char** argv = new char*[1];
-      argv[0]     = new char[1];
-      argv[0][0]  = 'n';
-      MPI_Init(&argc, &argv); 
-   }
-   inline void Init(int& argc, char** argv ) { MPI_Init(&argc, &argv);                         }
-   inline void Finalize( )                   { MPI_Finalize();                                 }
-   inline int  GetCommSize( Comm comm )      { int tmp; MPI_Comm_size(comm, &tmp); return tmp; }
-   inline int  GetCommRank( Comm comm )      { int tmp; MPI_Comm_rank(comm, &tmp); return tmp; }
-   inline void Barrier(  Comm comm )         { MPI_Barrier( comm );                            }
-   inline double Wtime()                     { return MPI_Wtime();                             }
-   inline double Wtick()                     { return MPI_Wtick();                             }
-   inline void   Wait( Request& request, Status* outStatus=NULL) { MPI_Wait( &request, outStatus);   }
-
-   inline Group GetCommGroup(Comm comm)                               { Group out; MPI_Comm_group(comm, &out);            return out; }
-   inline Group GetGroupIncl( Group group, const int& n, int* ranks ) { Group out; MPI_Group_incl(group, n, ranks, &out); return out; }
-   inline Comm  CommCreateComm( Comm comm, Group& group )             { Comm out;  MPI_Comm_create(comm, group, &out);    return out; }
-
-   inline void Alltoall( Comm comm, void* sendBuffer, const int& sn, const MPI_Datatype& sdatatype, void* recvBuffer, const int& rn, const MPI_Datatype& rdatatype)
-   {
-      MPI_Alltoall(sendBuffer, sn, sdatatype, recvBuffer, rn, rdatatype, comm);
-   }
-   inline void Bcast(Comm comm, void* data, const int& n, const MPI_Datatype& datatype , const int& srcRank )
-   {
-      MPI_Bcast(data, n, datatype, srcRank, comm);
-   }
-   inline void Send(Comm comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag)
-   {
-      MPI_Send(const_cast<void*>(data), length, dataType, destRank, tag, comm);
-   }
-   inline void Recv(Comm comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag)
-   {
-      MPI_Recv(const_cast<void*>(data), length, dataType, srcRank, tag, comm, MPI_STATUS_IGNORE);
-   }
-   inline void Ssend(Comm comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag)
-   {
-      MPI_Ssend(const_cast<void*>(data), length, dataType, destRank, tag, comm);
-   }
-   inline void Irecv(Comm comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag, Request& outRequest)
-   {
-      MPI_Irecv(const_cast<void*>(data), length, dataType, srcRank, tag, comm, &outRequest);
-   }
-
-}
-#endif
-
-namespace PbMpi
-{
-   /*======================================================================*/  
-   // send a single value "value" of MPI_Datatype
-   template <class T>
-   inline void sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm);
-   
-   /*======================================================================*/  
-   // receives a single value "value" of MPI_Datatype
-   template <class T>
-   inline void receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm);
-   
-   /*======================================================================*/  
-   // receives and returns a single value of MPI_Datatype
-   // expample: int value = PbMpi::receiveSingleValue<int>(MPI::INT,0,10,comm);
-   template <class T>
-   inline T receiveSingleValue(MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm);
-   
-   /*======================================================================*/  
-   // sends bool value (doesn't work with template, why ever... stupid MPI)
-   inline void sendBoolValue(const bool& value,int dest, int tag, PbMpi::Comm comm);
-
-   /*======================================================================*/  
-   // receives bool value (doesn't work with template, why ever... stupid MPI)
-   inline bool receiveBoolValue(int source, int tag, PbMpi::Comm comm);
-
-   /*======================================================================*/  
-   // sends bool value (doesn't work with template, why ever... stupid MPI)
-   inline void sendStringValue(const std::string& value,int dest, int tag, PbMpi::Comm comm);
-
-   /*======================================================================*/  
-   // receives bool value (doesn't work with template, why ever... stupid MPI)
-   inline std::string receiveStringValue(int source, int tag, PbMpi::Comm comm);
-
-   /*======================================================================*/  
-   // send a vector of MPI_Datatype
-   template <class T>
-	inline void sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm);
-	
-   /*======================================================================*/  
-   // receive a std::vector of MPI_Datatype
-   template <class T>
-   inline void receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm);
-
-   /*======================================================================*/  
-   // receive a vector of MPI_Datatype and adds this vector to existing vector
-   // ans returns number of received elements
-   template <class T>
-   inline int receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm);
-
-   /*======================================================================*/  
-   // send a std::vector of strings
-   inline void sendStringVector(const std::vector<std::string>& v, int dest, int tag, PbMpi::Comm comm);
-
-   /*======================================================================*/  
-   // send a vector of strings
-   inline void receiveStringVector(std::vector<std::string>& v, int dest, int tag, PbMpi::Comm comm);
-};
-
-/*======================================================================*/  
-// send a single value of MPI_Datatype
-template <class T>
-void PbMpi::sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm)
-{
-   PbMpi::Send(comm, &value, 1, datatype, dest, tag); 
-   //comm.Send(&value, 1, datatype, dest, tag); 
-}
-/*======================================================================*/  
-template <class T>
-void PbMpi::receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) 
-{
-   PbMpi::Recv(comm, &value, 1, datatype, source, tag); 
-   //comm.Recv(&value, 1, datatype, source, tag); 
-}
-/*======================================================================*/  
-template <class T>
-T PbMpi::receiveSingleValue(MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) 
-{
-   T value;
-   PbMpi::Recv(comm, &value, 1, datatype, source, tag); 
-   //comm.Recv(&value, 1, datatype, source, tag); 
-
-   return value;
-}
-/*======================================================================*/  
-// send a bool value (bool doesn't work with template, why ever)
-void PbMpi::sendBoolValue(const bool& value,int dest, int tag, PbMpi::Comm comm)
-{
-   short dummy;
-   if(value) dummy=1;                  
-   else      dummy=0;
-
-   PbMpi::Send(comm, &dummy, 1, PbMpi_SHORT, dest, tag); 
-   //comm.Send(&dummy, 1, MPI::SHORT, dest, tag); 
-}
-/*======================================================================*/  
-bool PbMpi::receiveBoolValue(int source, int tag, PbMpi::Comm comm) 
-{
-   short dummy;
-   PbMpi::Recv(comm, &dummy, 1, PbMpi_SHORT, source, tag); 
-   //comm.Recv(&dummy, 1, MPI::SHORT, source, tag);
- 
-   return (dummy==1);
-}
-/*======================================================================*/  
-// sends bool value (doesn't work with template, why ever... stupid MPI)
-void PbMpi::sendStringValue(const std::string& value,int dest, int tag, PbMpi::Comm comm)
-{
-   std::vector<char> vec;
-   for(std::size_t i=0; i<value.size(); i++)
-      vec.push_back(value[i]);
- 
-   PbMpi::sendVector(vec,PbMpi_CHAR,dest,tag,comm);
-}
-
-/*======================================================================*/  
-// receives bool value (doesn't work with template, why ever... stupid MPI)
-std::string PbMpi::receiveStringValue(int source, int tag, PbMpi::Comm comm)
-{
-   std::vector<char> vec;
-   PbMpi::receiveVector(vec,PbMpi_CHAR,source,tag,comm);
-   
-   std::string str;
-   for(std::size_t i=0; i<vec.size(); i++)
-      str+=vec[i];
-
-   return str;
-}
-/*======================================================================*/  
-// send a vector of MPI_Datatype
-template <class T>
-void PbMpi::sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm)
-{
-   // send size
-   int size = (int)v.size();
-   
-   PbMpi::Send(comm, &size, 1, PbMpi_INT, dest, tag);
-   //comm.Send(&size, 1, MPI::INT, dest, tag); 
-   
-   if(size>0)
-	{
-      PbMpi::Send(comm, &v[0], size, datatype, dest, tag);
-      //comm.Send(&v[0], size, datatype, dest, tag);
-   }
-}
-/*======================================================================*/  
-// receive a vector of MPI_Datatype
-template <class T>
-void PbMpi::receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) 
-{
-   int size;
-
-   PbMpi::Recv(comm, &size, 1, PbMpi_INT, source, tag);
-   //comm.Recv(&size, 1, MPI::INT, source, tag); 
-
-   v.resize(size);
-
-   if( size>0 )
-   {
-      PbMpi::Recv(comm, &v[0], size, datatype, source, tag);
-      //comm.Recv(&v[0], size, datatype, source, tag); 
-   }
-}
-/*======================================================================*/  
-// receive a vector of MPI_Datatype and adds this vector to existing vector
-// return value is size of received elements
-template <class T>
-int PbMpi::receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) 
-{
-   int incommingSize;
-
-   PbMpi::Recv(comm, &incommingSize, 1, PbMpi_INT, source, tag);
-   //comm.Recv(&incommingSize, 1, MPI::INT, source, tag);
-
-   int oldSize = (int)v.size();
-   v.resize(oldSize+incommingSize);
-
-   if( incommingSize>0 )
-   {
-      PbMpi::Recv(comm, &v[oldSize], incommingSize, datatype, source, tag);
-      //comm.Recv(&v[oldSize], incommingSize, datatype, source, tag);
-   }
-
-   return incommingSize;
-}
-/*======================================================================*/  
-// send a vector of strings
-void PbMpi::sendStringVector(const std::vector<std::string>& v, int dest, int tag, PbMpi::Comm comm)
-{
-   // send size
-   int stringVectorSize = (int)v.size();
-
-   PbMpi::Send(comm, &stringVectorSize, 1, PbMpi_INT, dest, tag); 
-   //comm.Send(&stringVectorSize, 1, MPI::INT, dest, tag); 
-
-   if(stringVectorSize>0)
-   {
-      std::vector<int> singleStringSizes(stringVectorSize+1);
-      int nofChars = 0;
-      for(int i=0; i<stringVectorSize; i++)
-         nofChars += singleStringSizes[i] = (int)v[i].length();
-      singleStringSizes[stringVectorSize] = nofChars;
-
-      PbMpi::Send(comm, &singleStringSizes[0], stringVectorSize+1, PbMpi_INT, dest, tag); 
-
-      std::vector<char> charVector(nofChars);
-      int pos = 0;
-      for(int i=0; i<stringVectorSize; i++)
-         for(int j=0; j<singleStringSizes[i]; j++)
-            charVector[pos++] = v[i][j];      
-
-      PbMpi::Send(comm, &charVector[0], nofChars, PbMpi_CHAR, dest, tag); 
-      //comm.Send(&charVector[0], nofChars, MPI::CHAR, dest, tag); 
-   }
-}
-/*======================================================================*/  
-// send a vector of strings
-void PbMpi::receiveStringVector(std::vector<std::string>& v, int source, int tag, PbMpi::Comm comm)
-{
-   // send size
-   int stringVectorSize;
-   PbMpi::Recv(comm, &stringVectorSize, 1, PbMpi_INT, source, tag);
-   //comm.Recv(&stringVectorSize, 1, MPI::INT, source, tag); 
-
-   v.clear();
-   v.resize(stringVectorSize);
-
-   if(stringVectorSize>0)
-   {
-      std::vector<int> singleStringSizes(stringVectorSize+1);
-
-      PbMpi::Recv(comm, &singleStringSizes[0], stringVectorSize+1, PbMpi_INT, source, tag); 
-      //comm.Recv(&singleStringSizes[0], stringVectorSize+1, MPI::INT, source, tag); 
-
-      int nofChars = singleStringSizes[stringVectorSize];
-      std::vector<char> charVector(nofChars);
-
-      PbMpi::Recv(comm, &charVector[0], nofChars, PbMpi_CHAR, source, tag); 
-      //comm.Recv(&charVector[0], nofChars, MPI::CHAR, source, tag); 
-
-      int pos=0;
-      for(int i=0; i<stringVectorSize; i++)
-         for(int j=0; j<singleStringSizes[i]; j++)
-            v[i].push_back(charVector[pos++]);      
-   }
-}
-
-#endif //PbMpi_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef PbMpi_H
+#define PbMpi_H
+
+#include <vector>
+#include <sstream>
+
+#ifndef VF_MPI
+#  error VF_MPI has to be defined
+#endif
+
+//#undef SEEK_SET
+//#undef SEEK_CUR
+//#undef SEEK_END
+#include <mpi.h>
+
+#include <basics/utilities/UbException.h>
+
+#ifdef USE_MPI_CXX_SYNTAX
+   #define PbMpi_COMM_WORLD MPI::COMM_WORLD
+   #define PbMpi_INT        MPI::INT  
+   #define PbMpi_CHAR       MPI::CHAR 
+   #define PbMpi_SHORT      MPI::SHORT
+   #define PbMpi_FLOAT      MPI::FLOAT
+   #define PbMpi_DOUBLE     MPI::DOUBLE
+   #define PbMpi_COMM_NULL  MPI::COMM_NULL   
+
+
+namespace PbMpi
+{
+   typedef MPI::Intracomm Comm;
+   typedef MPI::Group     Group;
+   typedef MPI::Request   Request;
+   typedef MPI::Status    Status;
+
+   inline void Init( )  
+   {
+      MPI::Init(); 
+      MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS); 
+   }
+   inline void Init(int& argc, char** argv )  
+   {
+      MPI::Init(argc, argv); 
+      MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS); 
+   }
+   inline void Finalize()                      { MPI::Finalize();        }
+
+   inline int  GetCommSize( const Comm& comm ) { return comm.Get_size(); }
+   inline int  GetCommRank( const Comm& comm ) { return comm.Get_rank(); }
+   inline void Barrier( const Comm& comm  )    { comm.Barrier();         }
+
+   inline double Wtime()                       { return MPI::Wtime();    }
+   inline double Wtick()                       { return MPI::Wtick();    }
+
+   inline void Wait( Request& request, Status* outStatus=NULL) 
+   { 
+      if(outStatus) request.Wait(*outStatus); 
+      else request.Wait();   
+   }
+
+   inline Group GetCommGroup(Comm& comm)                               { return comm.Get_group();     }
+   inline Group GetGroupIncl( Group& group, const int& n, int* ranks ) { return group.Incl(n, ranks); }
+   inline Comm  CommCreateComm( Comm& comm, Group& group )             { return comm.Create(group);   }
+
+   inline void Alltoall( Comm& comm, void* sendBuffer, const int& sn, const MPI_Datatype& sdatatype, void* recvBuffer, const int& rn, const MPI_Datatype& rdatatype)
+   {
+      comm.Alltoall(sendBuffer, sn, sdatatype, recvBuffer, rn, rdatatype);
+   }
+   inline void Bcast(Comm& comm, void* data, const int& n, const MPI_Datatype& datatype , const int& srcRank )
+   {
+      comm.Bcast(data, n, datatype, srcRank);
+   }
+   inline void Send(Comm& comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag)
+   {
+      try
+      { 
+         comm.Send(data, length, dataType, destRank, tag);
+      }
+      catch(MPI::Exception& e)
+      {
+         std::stringstream ss; 
+         ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+         throw UbException(UB_EXARGS,"MPI:Exception catched\n"+ss.str());
+      }
+      catch(...)  
+      {
+         throw UbException(UB_EXARGS,"unknown exception"); 
+      }
+   }
+   inline void Recv(Comm& comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag)
+   {
+      try
+      { 
+         comm.Recv(const_cast<void*>(data), length, dataType, srcRank, tag);
+      }
+      catch(MPI::Exception& e)
+      {
+         std::stringstream ss; 
+         ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+         throw UbException(UB_EXARGS,"MPI:Exception catched \n"+ss.str());
+      }
+      catch(...)  
+      {
+         throw UbException(UB_EXARGS,"unknown exception"); 
+      }
+   }
+
+   inline void Irecv(Comm comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag, Request& outRequest)
+   {
+      outRequest = comm.Irecv(const_cast<void*>(data), length, dataType, srcRank, tag);
+   }
+   inline void Ssend(Comm& comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag)
+   {
+      try
+      { 
+         comm.Ssend(data, length, dataType, destRank, tag);
+      }
+      catch(MPI::Exception& e)
+      {
+         std::stringstream ss; 
+         ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+         throw UbException(UB_EXARGS,"MPI:Exception catched\n"+ss.str());
+      }
+      catch(...)  
+      {
+         throw UbException(UB_EXARGS,"unknown exception"); 
+      }
+   }
+
+}
+#else //////////////////////////////////////////////////////////////////////////
+   //////////////////////////////////////////////////////////////////////////
+   // C-Syntax 
+   //////////////////////////////////////////////////////////////////////////
+   namespace PbMpi
+   {
+      typedef MPI_Comm    Comm;
+      typedef MPI_Group   Group;
+      typedef MPI_Request Request;
+      typedef MPI_Status  Status;
+   }
+
+   #define PbMpi_COMM_WORLD ((PbMpi::Comm)MPI_COMM_WORLD)
+   #define PbMpi_INT        MPI_INT
+   #define PbMpi_CHAR       MPI_CHAR
+   #define PbMpi_SHORT      MPI_SHORT
+   #define PbMpi_FLOAT      MPI_FLOAT
+   #define PbMpi_DOUBLE     MPI_DOUBLE
+   #define PbMpi_COMM_NULL  MPI_COMM_NULL   
+
+namespace PbMpi
+{
+   inline void Init( )  
+   {
+      int    argc = 1;
+      char** argv = new char*[1];
+      argv[0]     = new char[1];
+      argv[0][0]  = 'n';
+      MPI_Init(&argc, &argv); 
+   }
+   inline void Init(int& argc, char** argv ) { MPI_Init(&argc, &argv);                         }
+   inline void Finalize( )                   { MPI_Finalize();                                 }
+   inline int  GetCommSize( Comm comm )      { int tmp; MPI_Comm_size(comm, &tmp); return tmp; }
+   inline int  GetCommRank( Comm comm )      { int tmp; MPI_Comm_rank(comm, &tmp); return tmp; }
+   inline void Barrier(  Comm comm )         { MPI_Barrier( comm );                            }
+   inline double Wtime()                     { return MPI_Wtime();                             }
+   inline double Wtick()                     { return MPI_Wtick();                             }
+   inline void   Wait( Request& request, Status* outStatus=NULL) { MPI_Wait( &request, outStatus);   }
+
+   inline Group GetCommGroup(Comm comm)                               { Group out; MPI_Comm_group(comm, &out);            return out; }
+   inline Group GetGroupIncl( Group group, const int& n, int* ranks ) { Group out; MPI_Group_incl(group, n, ranks, &out); return out; }
+   inline Comm  CommCreateComm( Comm comm, Group& group )             { Comm out;  MPI_Comm_create(comm, group, &out);    return out; }
+
+   inline void Alltoall( Comm comm, void* sendBuffer, const int& sn, const MPI_Datatype& sdatatype, void* recvBuffer, const int& rn, const MPI_Datatype& rdatatype)
+   {
+      MPI_Alltoall(sendBuffer, sn, sdatatype, recvBuffer, rn, rdatatype, comm);
+   }
+   inline void Bcast(Comm comm, void* data, const int& n, const MPI_Datatype& datatype , const int& srcRank )
+   {
+      MPI_Bcast(data, n, datatype, srcRank, comm);
+   }
+   inline void Send(Comm comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag)
+   {
+      MPI_Send(const_cast<void*>(data), length, dataType, destRank, tag, comm);
+   }
+   inline void Recv(Comm comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag)
+   {
+      MPI_Recv(const_cast<void*>(data), length, dataType, srcRank, tag, comm, MPI_STATUS_IGNORE);
+   }
+   inline void Ssend(Comm comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag)
+   {
+      MPI_Ssend(const_cast<void*>(data), length, dataType, destRank, tag, comm);
+   }
+   inline void Irecv(Comm comm,  const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag, Request& outRequest)
+   {
+      MPI_Irecv(const_cast<void*>(data), length, dataType, srcRank, tag, comm, &outRequest);
+   }
+
+}
+#endif
+
+namespace PbMpi
+{
+   /*======================================================================*/  
+   // send a single value "value" of MPI_Datatype
+   template <class T>
+   inline void sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm);
+   
+   /*======================================================================*/  
+   // receives a single value "value" of MPI_Datatype
+   template <class T>
+   inline void receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm);
+   
+   /*======================================================================*/  
+   // receives and returns a single value of MPI_Datatype
+   // expample: int value = PbMpi::receiveSingleValue<int>(MPI::INT,0,10,comm);
+   template <class T>
+   inline T receiveSingleValue(MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm);
+   
+   /*======================================================================*/  
+   // sends bool value (doesn't work with template, why ever... stupid MPI)
+   inline void sendBoolValue(const bool& value,int dest, int tag, PbMpi::Comm comm);
+
+   /*======================================================================*/  
+   // receives bool value (doesn't work with template, why ever... stupid MPI)
+   inline bool receiveBoolValue(int source, int tag, PbMpi::Comm comm);
+
+   /*======================================================================*/  
+   // sends bool value (doesn't work with template, why ever... stupid MPI)
+   inline void sendStringValue(const std::string& value,int dest, int tag, PbMpi::Comm comm);
+
+   /*======================================================================*/  
+   // receives bool value (doesn't work with template, why ever... stupid MPI)
+   inline std::string receiveStringValue(int source, int tag, PbMpi::Comm comm);
+
+   /*======================================================================*/  
+   // send a vector of MPI_Datatype
+   template <class T>
+	inline void sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm);
+	
+   /*======================================================================*/  
+   // receive a std::vector of MPI_Datatype
+   template <class T>
+   inline void receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm);
+
+   /*======================================================================*/  
+   // receive a vector of MPI_Datatype and adds this vector to existing vector
+   // ans returns number of received elements
+   template <class T>
+   inline int receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm);
+
+   /*======================================================================*/  
+   // send a std::vector of strings
+   inline void sendStringVector(const std::vector<std::string>& v, int dest, int tag, PbMpi::Comm comm);
+
+   /*======================================================================*/  
+   // send a vector of strings
+   inline void receiveStringVector(std::vector<std::string>& v, int dest, int tag, PbMpi::Comm comm);
+};
+
+/*======================================================================*/  
+// send a single value of MPI_Datatype
+template <class T>
+void PbMpi::sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm)
+{
+   PbMpi::Send(comm, &value, 1, datatype, dest, tag); 
+   //comm.Send(&value, 1, datatype, dest, tag); 
+}
+/*======================================================================*/  
+template <class T>
+void PbMpi::receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) 
+{
+   PbMpi::Recv(comm, &value, 1, datatype, source, tag); 
+   //comm.Recv(&value, 1, datatype, source, tag); 
+}
+/*======================================================================*/  
+template <class T>
+T PbMpi::receiveSingleValue(MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) 
+{
+   T value;
+   PbMpi::Recv(comm, &value, 1, datatype, source, tag); 
+   //comm.Recv(&value, 1, datatype, source, tag); 
+
+   return value;
+}
+/*======================================================================*/  
+// send a bool value (bool doesn't work with template, why ever)
+void PbMpi::sendBoolValue(const bool& value,int dest, int tag, PbMpi::Comm comm)
+{
+   short dummy;
+   if(value) dummy=1;                  
+   else      dummy=0;
+
+   PbMpi::Send(comm, &dummy, 1, PbMpi_SHORT, dest, tag); 
+   //comm.Send(&dummy, 1, MPI::SHORT, dest, tag); 
+}
+/*======================================================================*/  
+bool PbMpi::receiveBoolValue(int source, int tag, PbMpi::Comm comm) 
+{
+   short dummy;
+   PbMpi::Recv(comm, &dummy, 1, PbMpi_SHORT, source, tag); 
+   //comm.Recv(&dummy, 1, MPI::SHORT, source, tag);
+ 
+   return (dummy==1);
+}
+/*======================================================================*/  
+// sends bool value (doesn't work with template, why ever... stupid MPI)
+void PbMpi::sendStringValue(const std::string& value,int dest, int tag, PbMpi::Comm comm)
+{
+   std::vector<char> vec;
+   for(std::size_t i=0; i<value.size(); i++)
+      vec.push_back(value[i]);
+ 
+   PbMpi::sendVector(vec,PbMpi_CHAR,dest,tag,comm);
+}
+
+/*======================================================================*/  
+// receives bool value (doesn't work with template, why ever... stupid MPI)
+std::string PbMpi::receiveStringValue(int source, int tag, PbMpi::Comm comm)
+{
+   std::vector<char> vec;
+   PbMpi::receiveVector(vec,PbMpi_CHAR,source,tag,comm);
+   
+   std::string str;
+   for(std::size_t i=0; i<vec.size(); i++)
+      str+=vec[i];
+
+   return str;
+}
+/*======================================================================*/  
+// send a vector of MPI_Datatype
+template <class T>
+void PbMpi::sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm)
+{
+   // send size
+   int size = (int)v.size();
+   
+   PbMpi::Send(comm, &size, 1, PbMpi_INT, dest, tag);
+   //comm.Send(&size, 1, MPI::INT, dest, tag); 
+   
+   if(size>0)
+	{
+      PbMpi::Send(comm, &v[0], size, datatype, dest, tag);
+      //comm.Send(&v[0], size, datatype, dest, tag);
+   }
+}
+/*======================================================================*/  
+// receive a vector of MPI_Datatype
+template <class T>
+void PbMpi::receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) 
+{
+   int size;
+
+   PbMpi::Recv(comm, &size, 1, PbMpi_INT, source, tag);
+   //comm.Recv(&size, 1, MPI::INT, source, tag); 
+
+   v.resize(size);
+
+   if( size>0 )
+   {
+      PbMpi::Recv(comm, &v[0], size, datatype, source, tag);
+      //comm.Recv(&v[0], size, datatype, source, tag); 
+   }
+}
+/*======================================================================*/  
+// receive a vector of MPI_Datatype and adds this vector to existing vector
+// return value is size of received elements
+template <class T>
+int PbMpi::receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) 
+{
+   int incommingSize;
+
+   PbMpi::Recv(comm, &incommingSize, 1, PbMpi_INT, source, tag);
+   //comm.Recv(&incommingSize, 1, MPI::INT, source, tag);
+
+   int oldSize = (int)v.size();
+   v.resize(oldSize+incommingSize);
+
+   if( incommingSize>0 )
+   {
+      PbMpi::Recv(comm, &v[oldSize], incommingSize, datatype, source, tag);
+      //comm.Recv(&v[oldSize], incommingSize, datatype, source, tag);
+   }
+
+   return incommingSize;
+}
+/*======================================================================*/  
+// send a vector of strings
+void PbMpi::sendStringVector(const std::vector<std::string>& v, int dest, int tag, PbMpi::Comm comm)
+{
+   // send size
+   int stringVectorSize = (int)v.size();
+
+   PbMpi::Send(comm, &stringVectorSize, 1, PbMpi_INT, dest, tag); 
+   //comm.Send(&stringVectorSize, 1, MPI::INT, dest, tag); 
+
+   if(stringVectorSize>0)
+   {
+      std::vector<int> singleStringSizes(stringVectorSize+1);
+      int nofChars = 0;
+      for(int i=0; i<stringVectorSize; i++)
+         nofChars += singleStringSizes[i] = (int)v[i].length();
+      singleStringSizes[stringVectorSize] = nofChars;
+
+      PbMpi::Send(comm, &singleStringSizes[0], stringVectorSize+1, PbMpi_INT, dest, tag); 
+
+      std::vector<char> charVector(nofChars);
+      int pos = 0;
+      for(int i=0; i<stringVectorSize; i++)
+         for(int j=0; j<singleStringSizes[i]; j++)
+            charVector[pos++] = v[i][j];      
+
+      PbMpi::Send(comm, &charVector[0], nofChars, PbMpi_CHAR, dest, tag); 
+      //comm.Send(&charVector[0], nofChars, MPI::CHAR, dest, tag); 
+   }
+}
+/*======================================================================*/  
+// send a vector of strings
+void PbMpi::receiveStringVector(std::vector<std::string>& v, int source, int tag, PbMpi::Comm comm)
+{
+   // send size
+   int stringVectorSize;
+   PbMpi::Recv(comm, &stringVectorSize, 1, PbMpi_INT, source, tag);
+   //comm.Recv(&stringVectorSize, 1, MPI::INT, source, tag); 
+
+   v.clear();
+   v.resize(stringVectorSize);
+
+   if(stringVectorSize>0)
+   {
+      std::vector<int> singleStringSizes(stringVectorSize+1);
+
+      PbMpi::Recv(comm, &singleStringSizes[0], stringVectorSize+1, PbMpi_INT, source, tag); 
+      //comm.Recv(&singleStringSizes[0], stringVectorSize+1, MPI::INT, source, tag); 
+
+      int nofChars = singleStringSizes[stringVectorSize];
+      std::vector<char> charVector(nofChars);
+
+      PbMpi::Recv(comm, &charVector[0], nofChars, PbMpi_CHAR, source, tag); 
+      //comm.Recv(&charVector[0], nofChars, MPI::CHAR, source, tag); 
+
+      int pos=0;
+      for(int i=0; i<stringVectorSize; i++)
+         for(int j=0; j<singleStringSizes[i]; j++)
+            v[i].push_back(charVector[pos++]);      
+   }
+}
+
+#endif //PbMpi_H
diff --git a/source/ThirdParty/Library/basics/parallel/PbMpiTools.h b/source/VirtualFluidsBasic/basics/parallel/PbMpiTools.h
similarity index 98%
rename from source/ThirdParty/Library/basics/parallel/PbMpiTools.h
rename to source/VirtualFluidsBasic/basics/parallel/PbMpiTools.h
index 0842c54b9dad7ca73f7e68613d802bc36c65d378..07ea52881f8e0704c3ca0523727ec10fbcd06c8b 100644
--- a/source/ThirdParty/Library/basics/parallel/PbMpiTools.h
+++ b/source/VirtualFluidsBasic/basics/parallel/PbMpiTools.h
@@ -1,303 +1,303 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef PBMPITOOLS_H
-#define PBMPITOOLS_H
-
-#include <vector>
-#include <sstream>
-
-//#undef SEEK_SET
-//#undef SEEK_CUR
-//#undef SEEK_END
-#include <mpi.h>
-#include <basics/utilities/UbException.h>
-
-#ifdef USE_MPI_CXX_SYNTAX
-
-namespace PbMpiTools
-{
-   /*======================================================================*/  
-   // send a single value "value" of MPI_Datatype
-   template <class T>
-   inline void sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm);
-   
-   /*======================================================================*/  
-   // receives a single value "value" of MPI_Datatype
-   template <class T>
-   inline void receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm);
-   
-   /*======================================================================*/  
-   // receives and returns a single value of MPI_Datatype
-   // expample: int value = PbMpiTools::receiveSingleValue<int>(MPI::INT,0,10,comm);
-   template <class T>
-   inline T receiveSingleValue(MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm);
-   
-   /*======================================================================*/  
-   // sends bool value (doesn't work with template, why ever... stupid MPI)
-   inline void sendBoolValue(const bool& value,int dest, int tag, MPI::Intracomm comm);
-
-   /*======================================================================*/  
-   // receives bool value (doesn't work with template, why ever... stupid MPI)
-   inline bool receiveBoolValue(int source, int tag, MPI::Intracomm comm);
-
-   /*======================================================================*/  
-   // sends bool value (doesn't work with template, why ever... stupid MPI)
-   inline void sendStringValue(const std::string& value,int dest, int tag, MPI::Intracomm comm);
-
-   /*======================================================================*/  
-   // receives bool value (doesn't work with template, why ever... stupid MPI)
-   inline std::string receiveStringValue(int source, int tag, MPI::Intracomm comm);
-
-   /*======================================================================*/  
-   // send a vector of MPI_Datatype
-   template <class T>
-	inline void sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm);
-	
-   /*======================================================================*/  
-   // receive a std::vector of MPI_Datatype
-   template <class T>
-   inline void receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm);
-
-   /*======================================================================*/  
-   // receive a vector of MPI_Datatype and adds this vector to existing vector
-   // ans returns number of received elements
-   template <class T>
-   inline int receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm);
-
-   /*======================================================================*/  
-   // send a std::vector of strings
-   inline void sendStringVector(const std::vector<std::string>& v, int dest, int tag, MPI::Intracomm comm);
-
-   /*======================================================================*/  
-   // send a vector of strings
-   inline void receiveStringVector(std::vector<std::string>& v, int dest, int tag, MPI::Intracomm comm);
-};
-
-/*======================================================================*/  
-// send a single value of MPI_Datatype
-template <class T>
-void PbMpiTools::sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm)
-{
-   try{ comm.Send(&value, 1, datatype, dest, tag); }
-   catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                             UB_THROW( UbException(UB_EXARGS,"catched with info at send size\n"+ss.str()) ); }
-   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); }
-}
-/*======================================================================*/  
-template <class T>
-void PbMpiTools::receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) 
-{
-   try { comm.Recv(&value, 1, datatype, source, tag); }
-   catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );}
-   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); }
-}
-/*======================================================================*/  
-template <class T>
-T PbMpiTools::receiveSingleValue(MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) 
-{
-   T value;
-   try { comm.Recv(&value, 1, datatype, source, tag); }
-   catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );}
-   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); }
-
-   return value;
-}
-/*======================================================================*/  
-// send a bool value (bool doesn't work with template, why ever)
-void PbMpiTools::sendBoolValue(const bool& value,int dest, int tag, MPI::Intracomm comm)
-{
-   short dummy;
-   if(value) dummy=1;                  
-   else      dummy=0;
-
-   try{ comm.Send(&dummy, 1, MPI::SHORT, dest, tag); }
-   catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); }
-   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); }
-}
-/*======================================================================*/  
-bool PbMpiTools::receiveBoolValue(int source, int tag, MPI::Intracomm comm) 
-{
-   short dummy;
-   try { comm.Recv(&dummy, 1, MPI::SHORT, source, tag); }
-   catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );}
-   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); }
-
-   return (dummy==1);
-}
-/*======================================================================*/  
-// sends bool value (doesn't work with template, why ever... stupid MPI)
-void PbMpiTools::sendStringValue(const std::string& value,int dest, int tag, MPI::Intracomm comm)
-{
-   std::vector<char> vec;
-   for(std::size_t i=0; i<value.size(); i++)
-      vec.push_back(value[i]);
-   PbMpiTools::sendVector(vec,MPI::CHAR,dest,tag,comm);
-}
-
-/*======================================================================*/  
-// receives bool value (doesn't work with template, why ever... stupid MPI)
-std::string PbMpiTools::receiveStringValue(int source, int tag, MPI::Intracomm comm)
-{
-   std::vector<char> vec;
-   PbMpiTools::receiveVector(vec,MPI::CHAR,source,tag,comm);
-   std::string str;
-   for(std::size_t i=0; i<vec.size(); i++)
-      str+=vec[i];
-
-   return str;
-}
-/*======================================================================*/  
-// send a vector of MPI_Datatype
-template <class T>
-void PbMpiTools::sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm)
-{
-   // send size
-   int size = (int)v.size();
-   
-   try{ comm.Send(&size, 1, MPI::INT, dest, tag); }
-   catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); }
-   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); }
-   
-   if(size>0)
-	{
-      try{ comm.Send(&v[0], size, datatype, dest, tag); }
-      catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                                UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );}
-      catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); }
-   }
-}
-/*======================================================================*/  
-// receive a vector of MPI_Datatype
-template <class T>
-void PbMpiTools::receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) 
-{
-   int size;
-
-   try { comm.Recv(&size, 1, MPI::INT, source, tag); }
-   catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );}
-   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); }
-
-   v.resize(size);
-
-   if( size>0 )
-   {
-      try{ comm.Recv(&v[0], size, datatype, source, tag); }
-      catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                                UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive vector\n"+ss.str()) ); }
-      catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive vector") ); }
-   }
-}
-/*======================================================================*/  
-// receive a vector of MPI_Datatype and adds this vector to existing vector
-// return value is size of received elements
-template <class T>
-int PbMpiTools::receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) 
-{
-   int incommingSize;
-
-   try { comm.Recv(&incommingSize, 1, MPI::INT, source, tag); }
-   catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );}
-   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); }
-
-   int oldSize = (int)v.size();
-   v.resize(oldSize+incommingSize);
-
-   if( incommingSize>0 )
-   {
-      try{ comm.Recv(&v[oldSize], incommingSize, datatype, source, tag); }
-      catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                                UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive vector\n"+ss.str()) ); }
-      catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive vector") ); }
-   }
-
-   return incommingSize;
-}
-/*======================================================================*/  
-// send a vector of strings
-void PbMpiTools::sendStringVector(const std::vector<std::string>& v, int dest, int tag, MPI::Intracomm comm)
-{
-   // send size
-   int stringVectorSize = (int)v.size();
-
-   try{ comm.Send(&stringVectorSize, 1, MPI::INT, dest, tag); }
-   catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); }
-   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); }
-
-   if(stringVectorSize>0)
-   {
-      std::vector<int> singleStringSizes(stringVectorSize+1);
-      int nofChars = 0;
-      for(int i=0; i<stringVectorSize; i++)
-         nofChars += singleStringSizes[i] = (int)v[i].length();
-      singleStringSizes[stringVectorSize] = nofChars;
-
-      try{ comm.Send(&singleStringSizes[0], stringVectorSize+1, MPI::INT, dest, tag); }
-      catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                                UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );}
-      catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); }
-
-      std::vector<char> charVector(nofChars);
-      int pos = 0;
-      for(int i=0; i<stringVectorSize; i++)
-         for(int j=0; j<singleStringSizes[i]; j++)
-            charVector[pos++] = v[i][j];      
-
-      try{ comm.Send(&charVector[0], nofChars, MPI::CHAR, dest, tag); }
-      catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                                UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );}
-      catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); }
-   }
-}
-/*======================================================================*/  
-// send a vector of strings
-void PbMpiTools::receiveStringVector(std::vector<std::string>& v, int source, int tag, MPI::Intracomm comm)
-{
-   // send size
-   int stringVectorSize;
-   try { comm.Recv(&stringVectorSize, 1, MPI::INT, source, tag); }
-   catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); }
-   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); }
-
-   v.clear();
-   v.resize(stringVectorSize);
-
-   if(stringVectorSize>0)
-   {
-      std::vector<int> singleStringSizes(stringVectorSize+1);
-
-      try{ comm.Recv(&singleStringSizes[0], stringVectorSize+1, MPI::INT, source, tag); }
-      catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                                UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );}
-      catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); }
-
-      int nofChars = singleStringSizes[stringVectorSize];
-      std::vector<char> charVector(nofChars);
-
-       try{ comm.Recv(&charVector[0], nofChars, MPI::CHAR, source, tag); }
-       catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
-                                 UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );}
-       catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); }
-      
-      int pos=0;
-      for(int i=0; i<stringVectorSize; i++)
-         for(int j=0; j<singleStringSizes[i]; j++)
-            v[i].push_back(charVector[pos++]);      
-   }
-}
-
-#endif
-
-#endif //PBMPITOOLS_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef PBMPITOOLS_H
+#define PBMPITOOLS_H
+
+#include <vector>
+#include <sstream>
+
+//#undef SEEK_SET
+//#undef SEEK_CUR
+//#undef SEEK_END
+#include <mpi.h>
+#include <basics/utilities/UbException.h>
+
+#ifdef USE_MPI_CXX_SYNTAX
+
+namespace PbMpiTools
+{
+   /*======================================================================*/  
+   // send a single value "value" of MPI_Datatype
+   template <class T>
+   inline void sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm);
+   
+   /*======================================================================*/  
+   // receives a single value "value" of MPI_Datatype
+   template <class T>
+   inline void receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm);
+   
+   /*======================================================================*/  
+   // receives and returns a single value of MPI_Datatype
+   // expample: int value = PbMpiTools::receiveSingleValue<int>(MPI::INT,0,10,comm);
+   template <class T>
+   inline T receiveSingleValue(MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm);
+   
+   /*======================================================================*/  
+   // sends bool value (doesn't work with template, why ever... stupid MPI)
+   inline void sendBoolValue(const bool& value,int dest, int tag, MPI::Intracomm comm);
+
+   /*======================================================================*/  
+   // receives bool value (doesn't work with template, why ever... stupid MPI)
+   inline bool receiveBoolValue(int source, int tag, MPI::Intracomm comm);
+
+   /*======================================================================*/  
+   // sends bool value (doesn't work with template, why ever... stupid MPI)
+   inline void sendStringValue(const std::string& value,int dest, int tag, MPI::Intracomm comm);
+
+   /*======================================================================*/  
+   // receives bool value (doesn't work with template, why ever... stupid MPI)
+   inline std::string receiveStringValue(int source, int tag, MPI::Intracomm comm);
+
+   /*======================================================================*/  
+   // send a vector of MPI_Datatype
+   template <class T>
+	inline void sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm);
+	
+   /*======================================================================*/  
+   // receive a std::vector of MPI_Datatype
+   template <class T>
+   inline void receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm);
+
+   /*======================================================================*/  
+   // receive a vector of MPI_Datatype and adds this vector to existing vector
+   // ans returns number of received elements
+   template <class T>
+   inline int receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm);
+
+   /*======================================================================*/  
+   // send a std::vector of strings
+   inline void sendStringVector(const std::vector<std::string>& v, int dest, int tag, MPI::Intracomm comm);
+
+   /*======================================================================*/  
+   // send a vector of strings
+   inline void receiveStringVector(std::vector<std::string>& v, int dest, int tag, MPI::Intracomm comm);
+};
+
+/*======================================================================*/  
+// send a single value of MPI_Datatype
+template <class T>
+void PbMpiTools::sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm)
+{
+   try{ comm.Send(&value, 1, datatype, dest, tag); }
+   catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                             UB_THROW( UbException(UB_EXARGS,"catched with info at send size\n"+ss.str()) ); }
+   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); }
+}
+/*======================================================================*/  
+template <class T>
+void PbMpiTools::receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) 
+{
+   try { comm.Recv(&value, 1, datatype, source, tag); }
+   catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );}
+   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); }
+}
+/*======================================================================*/  
+template <class T>
+T PbMpiTools::receiveSingleValue(MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) 
+{
+   T value;
+   try { comm.Recv(&value, 1, datatype, source, tag); }
+   catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );}
+   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); }
+
+   return value;
+}
+/*======================================================================*/  
+// send a bool value (bool doesn't work with template, why ever)
+void PbMpiTools::sendBoolValue(const bool& value,int dest, int tag, MPI::Intracomm comm)
+{
+   short dummy;
+   if(value) dummy=1;                  
+   else      dummy=0;
+
+   try{ comm.Send(&dummy, 1, MPI::SHORT, dest, tag); }
+   catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); }
+   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); }
+}
+/*======================================================================*/  
+bool PbMpiTools::receiveBoolValue(int source, int tag, MPI::Intracomm comm) 
+{
+   short dummy;
+   try { comm.Recv(&dummy, 1, MPI::SHORT, source, tag); }
+   catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );}
+   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); }
+
+   return (dummy==1);
+}
+/*======================================================================*/  
+// sends bool value (doesn't work with template, why ever... stupid MPI)
+void PbMpiTools::sendStringValue(const std::string& value,int dest, int tag, MPI::Intracomm comm)
+{
+   std::vector<char> vec;
+   for(std::size_t i=0; i<value.size(); i++)
+      vec.push_back(value[i]);
+   PbMpiTools::sendVector(vec,MPI::CHAR,dest,tag,comm);
+}
+
+/*======================================================================*/  
+// receives bool value (doesn't work with template, why ever... stupid MPI)
+std::string PbMpiTools::receiveStringValue(int source, int tag, MPI::Intracomm comm)
+{
+   std::vector<char> vec;
+   PbMpiTools::receiveVector(vec,MPI::CHAR,source,tag,comm);
+   std::string str;
+   for(std::size_t i=0; i<vec.size(); i++)
+      str+=vec[i];
+
+   return str;
+}
+/*======================================================================*/  
+// send a vector of MPI_Datatype
+template <class T>
+void PbMpiTools::sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm)
+{
+   // send size
+   int size = (int)v.size();
+   
+   try{ comm.Send(&size, 1, MPI::INT, dest, tag); }
+   catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); }
+   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); }
+   
+   if(size>0)
+	{
+      try{ comm.Send(&v[0], size, datatype, dest, tag); }
+      catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                                UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );}
+      catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); }
+   }
+}
+/*======================================================================*/  
+// receive a vector of MPI_Datatype
+template <class T>
+void PbMpiTools::receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) 
+{
+   int size;
+
+   try { comm.Recv(&size, 1, MPI::INT, source, tag); }
+   catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );}
+   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); }
+
+   v.resize(size);
+
+   if( size>0 )
+   {
+      try{ comm.Recv(&v[0], size, datatype, source, tag); }
+      catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                                UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive vector\n"+ss.str()) ); }
+      catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive vector") ); }
+   }
+}
+/*======================================================================*/  
+// receive a vector of MPI_Datatype and adds this vector to existing vector
+// return value is size of received elements
+template <class T>
+int PbMpiTools::receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) 
+{
+   int incommingSize;
+
+   try { comm.Recv(&incommingSize, 1, MPI::INT, source, tag); }
+   catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );}
+   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); }
+
+   int oldSize = (int)v.size();
+   v.resize(oldSize+incommingSize);
+
+   if( incommingSize>0 )
+   {
+      try{ comm.Recv(&v[oldSize], incommingSize, datatype, source, tag); }
+      catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                                UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive vector\n"+ss.str()) ); }
+      catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive vector") ); }
+   }
+
+   return incommingSize;
+}
+/*======================================================================*/  
+// send a vector of strings
+void PbMpiTools::sendStringVector(const std::vector<std::string>& v, int dest, int tag, MPI::Intracomm comm)
+{
+   // send size
+   int stringVectorSize = (int)v.size();
+
+   try{ comm.Send(&stringVectorSize, 1, MPI::INT, dest, tag); }
+   catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); }
+   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); }
+
+   if(stringVectorSize>0)
+   {
+      std::vector<int> singleStringSizes(stringVectorSize+1);
+      int nofChars = 0;
+      for(int i=0; i<stringVectorSize; i++)
+         nofChars += singleStringSizes[i] = (int)v[i].length();
+      singleStringSizes[stringVectorSize] = nofChars;
+
+      try{ comm.Send(&singleStringSizes[0], stringVectorSize+1, MPI::INT, dest, tag); }
+      catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                                UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );}
+      catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); }
+
+      std::vector<char> charVector(nofChars);
+      int pos = 0;
+      for(int i=0; i<stringVectorSize; i++)
+         for(int j=0; j<singleStringSizes[i]; j++)
+            charVector[pos++] = v[i][j];      
+
+      try{ comm.Send(&charVector[0], nofChars, MPI::CHAR, dest, tag); }
+      catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                                UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );}
+      catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); }
+   }
+}
+/*======================================================================*/  
+// send a vector of strings
+void PbMpiTools::receiveStringVector(std::vector<std::string>& v, int source, int tag, MPI::Intracomm comm)
+{
+   // send size
+   int stringVectorSize;
+   try { comm.Recv(&stringVectorSize, 1, MPI::INT, source, tag); }
+   catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                             UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); }
+   catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); }
+
+   v.clear();
+   v.resize(stringVectorSize);
+
+   if(stringVectorSize>0)
+   {
+      std::vector<int> singleStringSizes(stringVectorSize+1);
+
+      try{ comm.Recv(&singleStringSizes[0], stringVectorSize+1, MPI::INT, source, tag); }
+      catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                                UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );}
+      catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); }
+
+      int nofChars = singleStringSizes[stringVectorSize];
+      std::vector<char> charVector(nofChars);
+
+       try{ comm.Recv(&charVector[0], nofChars, MPI::CHAR, source, tag); }
+       catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl;
+                                 UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );}
+       catch(...)              { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); }
+      
+      int pos=0;
+      for(int i=0; i<stringVectorSize; i++)
+         for(int j=0; j<singleStringSizes[i]; j++)
+            v[i].push_back(charVector[pos++]);      
+   }
+}
+
+#endif
+
+#endif //PBMPITOOLS_H
diff --git a/source/ThirdParty/Library/basics/parallel/examples/simpleMPI/CMakeLists.txt b/source/VirtualFluidsBasic/basics/parallel/examples/simpleMPI/CMakeLists.txt
similarity index 97%
rename from source/ThirdParty/Library/basics/parallel/examples/simpleMPI/CMakeLists.txt
rename to source/VirtualFluidsBasic/basics/parallel/examples/simpleMPI/CMakeLists.txt
index 2c93dee4f1f17b3084223e50c1f1628f2878e4df..a44b5c76e4b9b5e805f501b94d895a6f7026c039 100644
--- a/source/ThirdParty/Library/basics/parallel/examples/simpleMPI/CMakeLists.txt
+++ b/source/VirtualFluidsBasic/basics/parallel/examples/simpleMPI/CMakeLists.txt
@@ -1,64 +1,64 @@
-cmake_minimum_required(VERSION 2.6)
-
-INCLUDE("../../../../CMakeCABMacros.txt")
-INCLUDE("../../../../CMakeSetCompilerFlags.txt")
-  
-CHECK_FOR_VARIABLE(CAB_MACHINE "machine name, e.g. ALTIX, ARWEN")
-SET(CMAKE_CONFIG_FILE "${SOURCE_ROOT}/cmake_config_files/${CAB_MACHINE}.config.cmake")
-
-PROJECT(simpleMPI)
-
-#erst hier das config file einfügen, ansonsten werden manche settings durch (Project) überschrieben)  
-INCLUDE(${CMAKE_CONFIG_FILE})  
-  
-SET(EXECUTABLE_NAME simpleMPI)
-
-################################################################
-##   PACKAGES						###
-################################################################
-INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/basics/parallel/CMakePackage.txt)
-   
-#################################################################
-###   OWN DEFINES 						###
-#################################################################
-SET(ALL_SOURCES ${ALL_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp )
-
-SOURCE_GROUP(main FILES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp )
-   
-ADD_CXX_FLAGS("/wd4996") #deprecated strcpy...
-
-#################################################################
-###   MPI                                                     ###
-#################################################################
-SET_MPI_STUFF(CAB_MACHINE)
-SET(EXECUTABLE_NAME ${EXECUTABLE_NAME}_mpi)
-
-#################################################################
-###   EXCECUTABLE						###
-#################################################################
-ADD_EXECUTABLE(${EXECUTABLE_NAME} ${ALL_SOURCES} )
-
-#################################################################
-###   ADDITIONAL LINK LIBRARIES                               ###
-#################################################################
-IF(ADDITIONAL_LINK_LIBRARIES)
- TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${ADDITIONAL_LINK_LIBRARIES}) 
-ENDIF(ADDITIONAL_LINK_LIBRARIES)
-
-#################################################################
-###   ADDITIONAL LINK PROPERTIES                              ###
-#################################################################
-IF(ADDITIONAL_LINK_PROPS)
- SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS ${ADDITIONAL_LINK_PROPS})
-ENDIF(ADDITIONAL_LINK_PROPS)
-IF(ADDITIONAL_LINK_PROPS_DEBUG)
- SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS_DEBUG ${ADDITIONAL_LINK_PROPS_DEBUG})
-ENDIF(ADDITIONAL_LINK_PROPS_DEBUG)
-IF(ADDITIONAL_LINK_PROPS_RELEASE)
- SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS_RELEASE ${ADDITIONAL_LINK_PROPS_RELEASE})
-ENDIF(ADDITIONAL_LINK_PROPS_RELEASE)
-
-
-
+cmake_minimum_required(VERSION 2.6)
+
+INCLUDE("../../../../CMakeCABMacros.txt")
+INCLUDE("../../../../CMakeSetCompilerFlags.txt")
+  
+CHECK_FOR_VARIABLE(CAB_MACHINE "machine name, e.g. ALTIX, ARWEN")
+SET(CMAKE_CONFIG_FILE "${SOURCE_ROOT}/cmake_config_files/${CAB_MACHINE}.config.cmake")
+
+PROJECT(simpleMPI)
+
+#erst hier das config file einfügen, ansonsten werden manche settings durch (Project) überschrieben)  
+INCLUDE(${CMAKE_CONFIG_FILE})  
+  
+SET(EXECUTABLE_NAME simpleMPI)
+
+################################################################
+##   PACKAGES						###
+################################################################
+INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/basics/parallel/CMakePackage.txt)
+   
+#################################################################
+###   OWN DEFINES 						###
+#################################################################
+SET(ALL_SOURCES ${ALL_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp )
+
+SOURCE_GROUP(main FILES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp )
+   
+ADD_CXX_FLAGS("/wd4996") #deprecated strcpy...
+
+#################################################################
+###   MPI                                                     ###
+#################################################################
+SET_MPI_STUFF(CAB_MACHINE)
+SET(EXECUTABLE_NAME ${EXECUTABLE_NAME}_mpi)
+
+#################################################################
+###   EXCECUTABLE						###
+#################################################################
+ADD_EXECUTABLE(${EXECUTABLE_NAME} ${ALL_SOURCES} )
+
+#################################################################
+###   ADDITIONAL LINK LIBRARIES                               ###
+#################################################################
+IF(ADDITIONAL_LINK_LIBRARIES)
+ TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${ADDITIONAL_LINK_LIBRARIES}) 
+ENDIF(ADDITIONAL_LINK_LIBRARIES)
+
+#################################################################
+###   ADDITIONAL LINK PROPERTIES                              ###
+#################################################################
+IF(ADDITIONAL_LINK_PROPS)
+ SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS ${ADDITIONAL_LINK_PROPS})
+ENDIF(ADDITIONAL_LINK_PROPS)
+IF(ADDITIONAL_LINK_PROPS_DEBUG)
+ SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS_DEBUG ${ADDITIONAL_LINK_PROPS_DEBUG})
+ENDIF(ADDITIONAL_LINK_PROPS_DEBUG)
+IF(ADDITIONAL_LINK_PROPS_RELEASE)
+ SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS_RELEASE ${ADDITIONAL_LINK_PROPS_RELEASE})
+ENDIF(ADDITIONAL_LINK_PROPS_RELEASE)
+
+
+
diff --git a/source/ThirdParty/Library/basics/parallel/examples/simpleMPI/functions.h b/source/VirtualFluidsBasic/basics/parallel/examples/simpleMPI/functions.h
similarity index 97%
rename from source/ThirdParty/Library/basics/parallel/examples/simpleMPI/functions.h
rename to source/VirtualFluidsBasic/basics/parallel/examples/simpleMPI/functions.h
index 3977c69e00299b64773cb0ff16dc4ed536c37ca6..38005eca57b1a61a5a862169716afc49bb3cda5d 100644
--- a/source/ThirdParty/Library/basics/parallel/examples/simpleMPI/functions.h
+++ b/source/VirtualFluidsBasic/basics/parallel/examples/simpleMPI/functions.h
@@ -1,193 +1,193 @@
-#include <iostream>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string>
-#include <fstream>
-
-#include <basics/utilities/UbTuple.h>
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbSystem.h>
-#include <basics/utilities/UbFileOutputASCII.h>
-#include <basics/utilities/UbTiming.h>
-
-#include <basics/memory/MbSmartPtr.h>
-
-#include <basics/container/CbVector.h>
-#include <basics/container/CbVectorPool.h>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::vector;
-
-typedef long double value_type;
-typedef MbSmartPtr<CbVector< value_type > > CbVectorPtr;
-typedef MbSmartPtr<vector< value_type > >   StlVectorPtr;
-
-/*==========================================================*/
-template<typename T>
-inline void setValues(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec)
-{
-   if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() )
-   {
-      cerr<<"sizes:"<<endl;
-      cerr<<"stlvec... = "<<(int)stlvec.size()<<endl;
-      cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl;
-      cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl;
-      throw UB_THROW( UbException("setValues - sizeCheck failed") );
-   }
-   static value_type stlVal    = 1;
-   static value_type cbVal     = 1;
-   static value_type cbPoolVal = 1;
-
-   for(size_t i=0; i<cbvec.size(); i++) stlvec[i]    = stlVal   ++;
-   for(size_t i=0; i<cbvec.size(); i++) cbvec[i]     = cbVal    ++;
-   for(size_t i=0; i<cbvec.size(); i++) cbpoolvec[i] = cbPoolVal++;
-}
-/*==========================================================*/
-template<typename T>
-inline void setValues(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs)
-{
-   if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() )
-   {
-      cerr<<"sizes:"<<endl;
-      cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl;
-      cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl;
-      cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl;
-      UB_THROW( UbException("setValues glob - sizeCheck failed") );
-   }
-
-   for(size_t i=0; i<cbvecs.size(); i++)
-      setValues(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]);
-}
-/*==========================================================*/
-template<typename T>
-inline void resize(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec, std::size_t size, const T& val)
-{
-   stlvec.resize(size,val);
-   cbvec.resize(size,val);
-   cbpoolvec.resize(size,val);
-}
-/*==========================================================*/
-template<typename T>
-inline void resize(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, std::size_t size, const value_type& val, bool timed=false)
-{
-   if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() )
-   {
-      cerr<<"sizes:"<<endl;
-      cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl;
-      cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl;
-      cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl;
-      UB_THROW( UbException("resize glob - sizeCheck failed") );
-   }
-
-   if(timed)
-   {
-      UbTimer timer;
-      timer.start(); for(size_t i=0; i<cbvecs.size(); i++) stlvecs[i]->resize(size,val);    if(timed) cout<<"stl-resize    in "<<timer.stop()<<"s"<<endl;
-      timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbvecs[i]->resize(size,val);     if(timed) cout<<"cbStd-resize  in "<<timer.stop()<<"s"<<endl;
-      timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbpoolvecs[i]->resize(size,val); if(timed) cout<<"cbPool-resize in "<<timer.stop()<<"s"<<endl;
-   }
-   else
-   {
-      for(size_t i=0; i<cbvecs.size(); i++)
-         resize(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i],size,val);
-   }
-}
-/*==========================================================*/
-template<typename T>
-inline void createVecs(size_t number, int size,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false)
-{
-   UbTimer timer;
-   timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size)));                                                  if(timed) cout<<"stl-createVecs    in "<<timer.stop()<<"s"<<endl;
-   timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size)));                                                  if(timed) cout<<"cbStd-createVecs  in "<<timer.stop()<<"s"<<endl;
-   timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool))));  if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl;
-
-   for(size_t i=0; i<cbvecs.size(); i++) setValues(*stlvecs.back(),*cbvecs.back(),*cbpoolvecs.back());
-}
-/*==========================================================*/
-template<typename T>
-inline void createVecs(size_t number, size_t size, const value_type& val,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false)
-{
-   UbTimer timer;
-   timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size,val)));                                                  if(timed) cout<<"stl-createVecs    in "<<timer.stop()<<"s"<<endl;
-   timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorStd<value_type>(),val)));           if(timed) cout<<"cbStd-createVecs  in "<<timer.stop()<<"s"<<endl;
-   timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool),val)));  if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl;
-}
-/*==========================================================*/
-template<typename T>
-inline void equalCheck(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec)
-{
-   if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() )
-   {
-      cerr<<"sizes:"<<endl;
-      cerr<<"stlvec... = "<<(int)stlvec.size()<<endl;
-      cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl;
-      cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl;
-      throw UB_THROW( UbException("equalCheck - sizeCheck failed") );
-   }
-
-   bool check=true;
-   for(size_t i=0; i<cbvec.size(); i++)
-      if(stlvec[i] != cbvec[i] || stlvec[i] != cbpoolvec[i]  )
-         check=false;
-
-   if(!check)
-   {
-      cerr<<"\nstl - "; for(size_t i=0; i<cbvec.size(); i++) cout<<stlvec[i]<<" ";    cout<<endl;
-      cerr<<  "cbv - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbvec[i]<<" ";     cout<<endl;
-      cerr<<  "cbp - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbpoolvec[i]<<" "; cout<<endl;
-      throw UB_THROW( UbException("equalCheck - equalCheck failed") );
-   }
-}
-/*==========================================================*/
-template<typename T>
-void equalCheck(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs)
-{
-   if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() )
-   {
-      cerr<<"sizes:"<<endl;
-      cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl;
-      cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl;
-      cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl;
-      UB_THROW( UbException("equalCheck - sizeCheck failed") );
-   }
-
-   for(size_t i=0; i<cbvecs.size(); i++)
-   {
-      //cout<<"equalCheck i="<<i<<"/"<<cbvecs.size()-1;
-      equalCheck(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]);
-      //cout<<" passed"<<endl;
-   }
-}
-/*==========================================================*/
-template<typename T>
-void accessCheck(int times,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs)
-{
-   UbTimer timer;
-   timer.start();
-   for(size_t i=0; i<stlvecs.size(); i++)
-   {
-      vector<value_type>& vec = *stlvecs[i];
-      for(int m=0; m<times; m++)
-         for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k;
-   }
-   cout<<"stl-accessCheck       in "<<timer.stop()<<"s"<<endl;
-   timer.start();
-   for(size_t i=0; i<cbvecs.size(); i++)
-   {
-      CbVector<value_type>& vec = *cbvecs[i];
-      for(int m=0; m<times; m++)
-         for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k;
-   }
-   cout<<"cbStd-accessCheck     in "<<timer.stop()<<"s"<<endl;
-   timer.start();
-   for(size_t i=0; i<cbpoolvecs.size(); i++)
-   {
-      CbVector<value_type>& vec = *cbpoolvecs[i];
-      for(int m=0; m<times; m++)
-         for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k;
-   }
-   cout<<"cbPool-accessCheck    in "<<timer.stop()<<"s"<<endl;
-}
+#include <iostream>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string>
+#include <fstream>
+
+#include <basics/utilities/UbTuple.h>
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbSystem.h>
+#include <basics/utilities/UbFileOutputASCII.h>
+#include <basics/utilities/UbTiming.h>
+
+#include <basics/memory/MbSmartPtr.h>
+
+#include <basics/container/CbVector.h>
+#include <basics/container/CbVectorPool.h>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::vector;
+
+typedef long double value_type;
+typedef MbSmartPtr<CbVector< value_type > > CbVectorPtr;
+typedef MbSmartPtr<vector< value_type > >   StlVectorPtr;
+
+/*==========================================================*/
+template<typename T>
+inline void setValues(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec)
+{
+   if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() )
+   {
+      cerr<<"sizes:"<<endl;
+      cerr<<"stlvec... = "<<(int)stlvec.size()<<endl;
+      cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl;
+      cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl;
+      throw UB_THROW( UbException("setValues - sizeCheck failed") );
+   }
+   static value_type stlVal    = 1;
+   static value_type cbVal     = 1;
+   static value_type cbPoolVal = 1;
+
+   for(size_t i=0; i<cbvec.size(); i++) stlvec[i]    = stlVal   ++;
+   for(size_t i=0; i<cbvec.size(); i++) cbvec[i]     = cbVal    ++;
+   for(size_t i=0; i<cbvec.size(); i++) cbpoolvec[i] = cbPoolVal++;
+}
+/*==========================================================*/
+template<typename T>
+inline void setValues(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs)
+{
+   if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() )
+   {
+      cerr<<"sizes:"<<endl;
+      cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl;
+      cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl;
+      cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl;
+      UB_THROW( UbException("setValues glob - sizeCheck failed") );
+   }
+
+   for(size_t i=0; i<cbvecs.size(); i++)
+      setValues(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]);
+}
+/*==========================================================*/
+template<typename T>
+inline void resize(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec, std::size_t size, const T& val)
+{
+   stlvec.resize(size,val);
+   cbvec.resize(size,val);
+   cbpoolvec.resize(size,val);
+}
+/*==========================================================*/
+template<typename T>
+inline void resize(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, std::size_t size, const value_type& val, bool timed=false)
+{
+   if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() )
+   {
+      cerr<<"sizes:"<<endl;
+      cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl;
+      cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl;
+      cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl;
+      UB_THROW( UbException("resize glob - sizeCheck failed") );
+   }
+
+   if(timed)
+   {
+      UbTimer timer;
+      timer.start(); for(size_t i=0; i<cbvecs.size(); i++) stlvecs[i]->resize(size,val);    if(timed) cout<<"stl-resize    in "<<timer.stop()<<"s"<<endl;
+      timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbvecs[i]->resize(size,val);     if(timed) cout<<"cbStd-resize  in "<<timer.stop()<<"s"<<endl;
+      timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbpoolvecs[i]->resize(size,val); if(timed) cout<<"cbPool-resize in "<<timer.stop()<<"s"<<endl;
+   }
+   else
+   {
+      for(size_t i=0; i<cbvecs.size(); i++)
+         resize(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i],size,val);
+   }
+}
+/*==========================================================*/
+template<typename T>
+inline void createVecs(size_t number, int size,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false)
+{
+   UbTimer timer;
+   timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size)));                                                  if(timed) cout<<"stl-createVecs    in "<<timer.stop()<<"s"<<endl;
+   timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size)));                                                  if(timed) cout<<"cbStd-createVecs  in "<<timer.stop()<<"s"<<endl;
+   timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool))));  if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl;
+
+   for(size_t i=0; i<cbvecs.size(); i++) setValues(*stlvecs.back(),*cbvecs.back(),*cbpoolvecs.back());
+}
+/*==========================================================*/
+template<typename T>
+inline void createVecs(size_t number, size_t size, const value_type& val,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false)
+{
+   UbTimer timer;
+   timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size,val)));                                                  if(timed) cout<<"stl-createVecs    in "<<timer.stop()<<"s"<<endl;
+   timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorStd<value_type>(),val)));           if(timed) cout<<"cbStd-createVecs  in "<<timer.stop()<<"s"<<endl;
+   timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool),val)));  if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl;
+}
+/*==========================================================*/
+template<typename T>
+inline void equalCheck(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec)
+{
+   if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() )
+   {
+      cerr<<"sizes:"<<endl;
+      cerr<<"stlvec... = "<<(int)stlvec.size()<<endl;
+      cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl;
+      cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl;
+      throw UB_THROW( UbException("equalCheck - sizeCheck failed") );
+   }
+
+   bool check=true;
+   for(size_t i=0; i<cbvec.size(); i++)
+      if(stlvec[i] != cbvec[i] || stlvec[i] != cbpoolvec[i]  )
+         check=false;
+
+   if(!check)
+   {
+      cerr<<"\nstl - "; for(size_t i=0; i<cbvec.size(); i++) cout<<stlvec[i]<<" ";    cout<<endl;
+      cerr<<  "cbv - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbvec[i]<<" ";     cout<<endl;
+      cerr<<  "cbp - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbpoolvec[i]<<" "; cout<<endl;
+      throw UB_THROW( UbException("equalCheck - equalCheck failed") );
+   }
+}
+/*==========================================================*/
+template<typename T>
+void equalCheck(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs)
+{
+   if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() )
+   {
+      cerr<<"sizes:"<<endl;
+      cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl;
+      cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl;
+      cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl;
+      UB_THROW( UbException("equalCheck - sizeCheck failed") );
+   }
+
+   for(size_t i=0; i<cbvecs.size(); i++)
+   {
+      //cout<<"equalCheck i="<<i<<"/"<<cbvecs.size()-1;
+      equalCheck(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]);
+      //cout<<" passed"<<endl;
+   }
+}
+/*==========================================================*/
+template<typename T>
+void accessCheck(int times,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs)
+{
+   UbTimer timer;
+   timer.start();
+   for(size_t i=0; i<stlvecs.size(); i++)
+   {
+      vector<value_type>& vec = *stlvecs[i];
+      for(int m=0; m<times; m++)
+         for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k;
+   }
+   cout<<"stl-accessCheck       in "<<timer.stop()<<"s"<<endl;
+   timer.start();
+   for(size_t i=0; i<cbvecs.size(); i++)
+   {
+      CbVector<value_type>& vec = *cbvecs[i];
+      for(int m=0; m<times; m++)
+         for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k;
+   }
+   cout<<"cbStd-accessCheck     in "<<timer.stop()<<"s"<<endl;
+   timer.start();
+   for(size_t i=0; i<cbpoolvecs.size(); i++)
+   {
+      CbVector<value_type>& vec = *cbpoolvecs[i];
+      for(int m=0; m<times; m++)
+         for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k;
+   }
+   cout<<"cbPool-accessCheck    in "<<timer.stop()<<"s"<<endl;
+}
diff --git a/source/ThirdParty/Library/basics/parallel/examples/simpleMPI/main.cpp b/source/VirtualFluidsBasic/basics/parallel/examples/simpleMPI/main.cpp
similarity index 96%
rename from source/ThirdParty/Library/basics/parallel/examples/simpleMPI/main.cpp
rename to source/VirtualFluidsBasic/basics/parallel/examples/simpleMPI/main.cpp
index 5ff9dfcbfd4d458d1bfac99df9bf7fea0a4f2374..18c2769e02e8ad571eba9a0805996257f4b743f8 100644
--- a/source/ThirdParty/Library/basics/parallel/examples/simpleMPI/main.cpp
+++ b/source/VirtualFluidsBasic/basics/parallel/examples/simpleMPI/main.cpp
@@ -1,101 +1,101 @@
-#include <iostream>
-#include <vector>
-#include <algorithm>
-#include <mpi.h>
-
-#include <basics/utilities/UbSystem.h>
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbLogger.h>
-
-using namespace std;
-
-int randomNumber () { return (rand()%100); }
-
-struct RankSetter{
-   RankSetter(int rank) : rank(rank) {}
-   
-   int operator()() 
-   {
-      return rank;
-   }
-  
-   int rank;
-} /*rankSetter*/;
-
-
-//////////////////////////////////////////////////////////////////////////
-int main(int argc, char** argv)
-{
-   MPI::Init(argc, argv);
-   MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS); 
-
-   try
-   {  
-      MPI::Intracomm comm = MPI::COMM_WORLD;
-      
-      int rank = comm.Get_rank();
-      
-      vector<int> sendData(1000,0);
-      generate(sendData.begin(), sendData.end(), RankSetter(rank+1) );
-
-      vector<int> recvData(1000,0);
-
-      if(rank==0)
-      {
-         UBLOG(logINFO,"rank="<<rank<<" - recv request");
-         MPI::Request request = comm.Irecv(&recvData[0], (int)recvData.size(), MPI::INT, 1, 100);
-         UBLOG(logINFO,"rank="<<rank<<" - sendData");
-         comm.Ssend(&sendData[0],(int)sendData.size(), MPI::INT, 1, 100);
-         sendData.back() = 999;
-
-         UBLOG(logINFO,"rank="<<rank<<" - Wait");
-         request.Wait();
-         UBLOG(logINFO,"rank="<<rank<<" - all data received, last = "<<recvData.back());
-      }
-      else if(rank == 1)
-      {
-         UbSystem::sleepS(5);
-         UBLOG(logINFO,"rank="<<rank<<" - recv request");
-         MPI::Request request = comm.Irecv(&recvData[0],(int)recvData.size(), MPI::INT, 0, 100);
-         
-         request.Wait();
-         UBLOG(logINFO,"rank="<<rank<<" - all data received, last = "<<recvData.back());
-
-         UbSystem::sleepS(5);
-         UBLOG(logINFO,"rank="<<rank<<" - sendData");
-         comm.Ssend(&sendData[0],(int)sendData.size(), MPI::INT, 0, 100);
-         sendData.back() = 999;
-         UBLOG(logINFO,"rank="<<rank<<" - data sent");
-      }
-      else 
-      {
-         throw UB_THROW( UbException(UB_EXARGS,"only two ranks allwoed") );
-      }
-
-      UBLOG(logINFO,"rank="<<rank<<" barrier start");
-      MPI::COMM_WORLD.Barrier();
-      UBLOG(logINFO,"rank="<<rank<<" barrier done ");
-
-   }
-   catch(const std::exception& e)
-   {
-      UBLOG2(  logERROR,std::cerr, "caught exception:" );
-      UBLOG2(  logERROR,std::cerr, "type: " << typeid(e).name() );
-      UBLOG2ML(logERROR,std::cerr, "what: " << e.what() );
-   }
-   catch(MPI::Exception e)
-   { 
-      UBLOG2ML(logERROR,std::cerr, "caught exception:" << e.Get_error_string());
-
-      MPI::COMM_WORLD.Abort(99); 
-   } 
-   catch(...)
-   {
-      UBLOG2(logERROR,std::cerr,"Verdammte Scheisse - mal wieder Mist gebaut!");
-   }
-
-   MPI::Finalize();
-
-   return 0;
-}
-
+#include <iostream>
+#include <vector>
+#include <algorithm>
+#include <mpi.h>
+
+#include <basics/utilities/UbSystem.h>
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbLogger.h>
+
+using namespace std;
+
+int randomNumber () { return (rand()%100); }
+
+struct RankSetter{
+   RankSetter(int rank) : rank(rank) {}
+   
+   int operator()() 
+   {
+      return rank;
+   }
+  
+   int rank;
+} /*rankSetter*/;
+
+
+//////////////////////////////////////////////////////////////////////////
+int main(int argc, char** argv)
+{
+   MPI::Init(argc, argv);
+   MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS); 
+
+   try
+   {  
+      MPI::Intracomm comm = MPI::COMM_WORLD;
+      
+      int rank = comm.Get_rank();
+      
+      vector<int> sendData(1000,0);
+      generate(sendData.begin(), sendData.end(), RankSetter(rank+1) );
+
+      vector<int> recvData(1000,0);
+
+      if(rank==0)
+      {
+         UBLOG(logINFO,"rank="<<rank<<" - recv request");
+         MPI::Request request = comm.Irecv(&recvData[0], (int)recvData.size(), MPI::INT, 1, 100);
+         UBLOG(logINFO,"rank="<<rank<<" - sendData");
+         comm.Ssend(&sendData[0],(int)sendData.size(), MPI::INT, 1, 100);
+         sendData.back() = 999;
+
+         UBLOG(logINFO,"rank="<<rank<<" - Wait");
+         request.Wait();
+         UBLOG(logINFO,"rank="<<rank<<" - all data received, last = "<<recvData.back());
+      }
+      else if(rank == 1)
+      {
+         UbSystem::sleepS(5);
+         UBLOG(logINFO,"rank="<<rank<<" - recv request");
+         MPI::Request request = comm.Irecv(&recvData[0],(int)recvData.size(), MPI::INT, 0, 100);
+         
+         request.Wait();
+         UBLOG(logINFO,"rank="<<rank<<" - all data received, last = "<<recvData.back());
+
+         UbSystem::sleepS(5);
+         UBLOG(logINFO,"rank="<<rank<<" - sendData");
+         comm.Ssend(&sendData[0],(int)sendData.size(), MPI::INT, 0, 100);
+         sendData.back() = 999;
+         UBLOG(logINFO,"rank="<<rank<<" - data sent");
+      }
+      else 
+      {
+         throw UB_THROW( UbException(UB_EXARGS,"only two ranks allwoed") );
+      }
+
+      UBLOG(logINFO,"rank="<<rank<<" barrier start");
+      MPI::COMM_WORLD.Barrier();
+      UBLOG(logINFO,"rank="<<rank<<" barrier done ");
+
+   }
+   catch(const std::exception& e)
+   {
+      UBLOG2(  logERROR,std::cerr, "caught exception:" );
+      UBLOG2(  logERROR,std::cerr, "type: " << typeid(e).name() );
+      UBLOG2ML(logERROR,std::cerr, "what: " << e.what() );
+   }
+   catch(MPI::Exception e)
+   { 
+      UBLOG2ML(logERROR,std::cerr, "caught exception:" << e.Get_error_string());
+
+      MPI::COMM_WORLD.Abort(99); 
+   } 
+   catch(...)
+   {
+      UBLOG2(logERROR,std::cerr,"Verdammte Scheisse - mal wieder Mist gebaut!");
+   }
+
+   MPI::Finalize();
+
+   return 0;
+}
+
diff --git a/source/VirtualFluidsBasic/basics/relation/CMakePackage.txt b/source/VirtualFluidsBasic/basics/relation/CMakePackage.txt
new file mode 100644
index 0000000000000000000000000000000000000000..1b8416f010d2a7de30b8f70c9abf19a96dd8cf8f
--- /dev/null
+++ b/source/VirtualFluidsBasic/basics/relation/CMakePackage.txt
@@ -0,0 +1,2 @@
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
diff --git a/source/ThirdParty/Library/basics/relation/RbAggregation.h b/source/VirtualFluidsBasic/basics/relation/RbAggregation.h
similarity index 96%
rename from source/ThirdParty/Library/basics/relation/RbAggregation.h
rename to source/VirtualFluidsBasic/basics/relation/RbAggregation.h
index 409336c9ec9f2d4ec31e5151c61bf7afe08fabd8..c86c07fdddbbe3207888fc4e287bd7862045d212 100644
--- a/source/ThirdParty/Library/basics/relation/RbAggregation.h
+++ b/source/VirtualFluidsBasic/basics/relation/RbAggregation.h
@@ -1,70 +1,70 @@
-#ifndef RBAGGREGATION_H
-#define RBAGGREGATION_H
-
-#include <sstream>
-#include <iostream>
-#include <map>
-
-using namespace std;
-
-template <class T1, class T2>
-class RbAggregation 
-{
-private:
-   string name;
-   std::multimap<T1,T2> obj1Map;
-   std::multimap<T2,T1> obj2Map;
-                       
-public:
-   RbAggregation(string name)
-   {
-      this->name = name;
-   }
-   /*=========================================================================*/
-   void insertPair(T1& to1, T2& to2)
-   {
-      obj1Map.insert(pair<T1,T2>(to1,to2));
-      obj2Map.insert(pair<T2,T1>(to2,to1));
-   }     
-   /*=========================================================================*/
-   int countObj2forObj1(T1& to1)
-   {                                                                
-      return((int)obj1Map.count(to1));
-   }
-
-   /*=========================================================================*/
-   int countObj1forObj2(T2& to2)
-   {
-      return((int)obj2Map.count(to2));
-   }
-   /*=========================================================================*/
-   vector<T2> getObj2vectorForObj1(T1& to1)
-   {
-      vector<T2> obj2vector;
-      unsigned number = (unsigned)obj1Map.count(to1);
-      typedef std::multimap<T1, T2>::iterator obj1MapIterator = obj1Map.find(to1);
-      for(unsigned u =0; u<number; u++) 
-      {
-         obj2vector.push_back(obj1MapIterator->second);
-         obj1MapIterator++;
-      }
-      return obj2vector;
-   }
-   ///*=========================================================================*/
-   vector<T1>  getObj1vectorForObj2(T2& to2)
-   {
-      vector<T1> obj1vector;
-      unsigned number = (unsigned)obj2Map.count(to2);
-      typedef std::multimap<T2, T1>::iterator obj2MapIterator = obj2Map.find(to2);
-      for(unsigned u =0; u<number; u++) 
-      {
-         obj1vector.push_back(obj2MapIterator->second);
-         obj2MapIterator++;
-      }
-      return obj1vector;
-   }
-};
-/*=========================================================================*/
-#endif
-
-
+#ifndef RBAGGREGATION_H
+#define RBAGGREGATION_H
+
+#include <sstream>
+#include <iostream>
+#include <map>
+
+using namespace std;
+
+template <class T1, class T2>
+class RbAggregation 
+{
+private:
+   string name;
+   std::multimap<T1,T2> obj1Map;
+   std::multimap<T2,T1> obj2Map;
+                       
+public:
+   RbAggregation(string name)
+   {
+      this->name = name;
+   }
+   /*=========================================================================*/
+   void insertPair(T1& to1, T2& to2)
+   {
+      obj1Map.insert(pair<T1,T2>(to1,to2));
+      obj2Map.insert(pair<T2,T1>(to2,to1));
+   }     
+   /*=========================================================================*/
+   int countObj2forObj1(T1& to1)
+   {                                                                
+      return((int)obj1Map.count(to1));
+   }
+
+   /*=========================================================================*/
+   int countObj1forObj2(T2& to2)
+   {
+      return((int)obj2Map.count(to2));
+   }
+   /*=========================================================================*/
+   vector<T2> getObj2vectorForObj1(T1& to1)
+   {
+      vector<T2> obj2vector;
+      unsigned number = (unsigned)obj1Map.count(to1);
+      typedef std::multimap<T1, T2>::iterator obj1MapIterator = obj1Map.find(to1);
+      for(unsigned u =0; u<number; u++) 
+      {
+         obj2vector.push_back(obj1MapIterator->second);
+         obj1MapIterator++;
+      }
+      return obj2vector;
+   }
+   ///*=========================================================================*/
+   vector<T1>  getObj1vectorForObj2(T2& to2)
+   {
+      vector<T1> obj1vector;
+      unsigned number = (unsigned)obj2Map.count(to2);
+      typedef std::multimap<T2, T1>::iterator obj2MapIterator = obj2Map.find(to2);
+      for(unsigned u =0; u<number; u++) 
+      {
+         obj1vector.push_back(obj2MapIterator->second);
+         obj2MapIterator++;
+      }
+      return obj1vector;
+   }
+};
+/*=========================================================================*/
+#endif
+
+
diff --git a/source/ThirdParty/Library/basics/transmitter/CMakePackage.txt b/source/VirtualFluidsBasic/basics/transmitter/CMakePackage.txt
similarity index 99%
rename from source/ThirdParty/Library/basics/transmitter/CMakePackage.txt
rename to source/VirtualFluidsBasic/basics/transmitter/CMakePackage.txt
index de1dc5a88225180b8e40c6cf46f4a6fbb102778f..e3e3f9a387b022a62ecc0d63c3ef0210313e906d 100644
--- a/source/ThirdParty/Library/basics/transmitter/CMakePackage.txt
+++ b/source/VirtualFluidsBasic/basics/transmitter/CMakePackage.txt
@@ -1,2 +1,2 @@
-GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
 COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
\ No newline at end of file
diff --git a/source/ThirdParty/Library/basics/transmitter/TbTransmitter.h b/source/VirtualFluidsBasic/basics/transmitter/TbTransmitter.h
similarity index 96%
rename from source/ThirdParty/Library/basics/transmitter/TbTransmitter.h
rename to source/VirtualFluidsBasic/basics/transmitter/TbTransmitter.h
index 159cb029ace1aa0f768a9f0217cb307a1a869d05..b5bb087df96a9045ff541f83afe7cc058e344289 100644
--- a/source/ThirdParty/Library/basics/transmitter/TbTransmitter.h
+++ b/source/VirtualFluidsBasic/basics/transmitter/TbTransmitter.h
@@ -1,68 +1,68 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef TBTRANSMITTER_H
-#define TBTRANSMITTER_H
-
-#include <string>
-
-/*================================================================================*/
-/*  TbTransmitter                                                                 */
-/*                                                                                */
-/**
-This Class provides the base for sending and receiving of data.
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 08.11.07
-*/ 
-
-/*
-usage: ...
-*/
-
-//////////////////////////////////////////////////////////////////////////
-// Transmitter 
-// macht nichts ausser daten senden und empfangen
-template<typename T>
-class TbTransmitter
-{
-public:
-   typedef T value_type;
-
-public:
-   TbTransmitter() {}
-   virtual ~TbTransmitter()  {  /*std::cout<<typeid(*this).name()<<" dtor"<<std::endl;*/  }
-
-   virtual bool isLocalTransmitter()  const = 0;
-   virtual bool isRemoteTransmitter() const = 0;
-
-   //preprocess (e.g. synchronizing send-/receive-buffer)
-   virtual void sendDataSize()   = 0;
-   virtual void receiveDataSize()= 0; 
-   
-   //calculation
-   virtual void        prepareForSend() {}
-   virtual void        sendData()=0;
-   virtual void        prepareForReceive() {}
-   virtual value_type& receiveData()=0;
-
-   //data-access
-   inline value_type&       getData()       { return this->data; }
-   inline const value_type& getData() const { return this->data; }
-
-   //info-section (usable for remote transmitter)
-   virtual int  getSendToRank()   const { return  -1; }
-   virtual int  getSendToTag()    const { return  -1; }
-   virtual int  getRecvFromRank() const { return  -1; }
-   virtual int  getRecvFromTag()  const { return  -1; }
-
-   virtual std::string toString() const = 0;
-
-protected:
-   value_type data;
-};
-
-#endif //TBTRANSMITTER_H 
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef TBTRANSMITTER_H
+#define TBTRANSMITTER_H
+
+#include <string>
+
+/*================================================================================*/
+/*  TbTransmitter                                                                 */
+/*                                                                                */
+/**
+This Class provides the base for sending and receiving of data.
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 08.11.07
+*/ 
+
+/*
+usage: ...
+*/
+
+//////////////////////////////////////////////////////////////////////////
+// Transmitter 
+// macht nichts ausser daten senden und empfangen
+template<typename T>
+class TbTransmitter
+{
+public:
+   typedef T value_type;
+
+public:
+   TbTransmitter() {}
+   virtual ~TbTransmitter()  {  /*std::cout<<typeid(*this).name()<<" dtor"<<std::endl;*/  }
+
+   virtual bool isLocalTransmitter()  const = 0;
+   virtual bool isRemoteTransmitter() const = 0;
+
+   //preprocess (e.g. synchronizing send-/receive-buffer)
+   virtual void sendDataSize()   = 0;
+   virtual void receiveDataSize()= 0; 
+   
+   //calculation
+   virtual void        prepareForSend() {}
+   virtual void        sendData()=0;
+   virtual void        prepareForReceive() {}
+   virtual value_type& receiveData()=0;
+
+   //data-access
+   inline value_type&       getData()       { return this->data; }
+   inline const value_type& getData() const { return this->data; }
+
+   //info-section (usable for remote transmitter)
+   virtual int  getSendToRank()   const { return  -1; }
+   virtual int  getSendToTag()    const { return  -1; }
+   virtual int  getRecvFromRank() const { return  -1; }
+   virtual int  getRecvFromTag()  const { return  -1; }
+
+   virtual std::string toString() const = 0;
+
+protected:
+   value_type data;
+};
+
+#endif //TBTRANSMITTER_H 
diff --git a/source/ThirdParty/Library/basics/transmitter/TbTransmitterLocal.h b/source/VirtualFluidsBasic/basics/transmitter/TbTransmitterLocal.h
similarity index 97%
rename from source/ThirdParty/Library/basics/transmitter/TbTransmitterLocal.h
rename to source/VirtualFluidsBasic/basics/transmitter/TbTransmitterLocal.h
index 43a72251772300277f35162eff23fa8838a9b3ff..fba8f150c814b82f1042afad3c9f6f68de4bd0bb 100644
--- a/source/ThirdParty/Library/basics/transmitter/TbTransmitterLocal.h
+++ b/source/VirtualFluidsBasic/basics/transmitter/TbTransmitterLocal.h
@@ -1,129 +1,129 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef TOTRANSMITTERLOCAL_H
-#define TOTRANSMITTERLOCAL_H
-
-#include <basics/utilities/UbException.h>
-#include <basics/transmitter/TbTransmitter.h>
-#include <PointerDefinitions.h>
-
-/*================================================================================*/
-/*   TbLocalTransmitter, TbVectorSenderLocal, TbVectorReceiverLocal               */
-/*                                                                                */
-/**
-This Class provides the base for exception handling.
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 08.11.07
-*/ 
-
-/*
-usage: ...
-*/
-
-//////////////////////////////////////////////////////////////////////////
-// LocalTransmitter lokalen Datenaustausch
-// data = send- und zugleich receive-buffer
-template<typename T>
-class TbLocalTransmitter : public TbTransmitter<T>
-{
-public:
-   typedef SPtr< TbLocalTransmitter<T> > TbLocalTransmitterPtr;
-
-   typedef T value_type;
-
-public:
-   TbLocalTransmitter() : TbTransmitter<T>() 
-   {
-
-   }
-   
-   bool isLocalTransmitter()  const { return true;                         }
-   bool isRemoteTransmitter() const { return !this->isLocalTransmitter();  }
-
-   //send buffer wird autom resized
-   void sendDataSize()    { }
-   //reiceive braucht nichts machen, da send==receive buffer ;-)
-   void receiveDataSize() { } 
-
-   void        sendData()    { }
-   value_type& receiveData() { return this->data; }
-
-   std::string toString()  const { return "TbLocalTransmitter"+(std::string)typeid(T).name(); }
-};
-
-//////////////////////////////////////////////////////////////////////////
-// TbVectorSender/ReceiverLocal lokalen Datenaustausch ueber ZWEI vektoren
-template<typename T>
-class TbVectorReceiverLocal : public TbTransmitter<T>
-{
-public:
-   typedef T value_type;
-
-public:
-   TbVectorReceiverLocal() : TbTransmitter<value_type>() 
-   {
-
-   }
-   //virtual ~TbVectorReceiverLocal() { std::cout<<typeid(*this).name()<<" tot"<<std::endl;   }
-
-   bool isLocalTransmitter()  const { return true;                         }
-   bool isRemoteTransmitter() const { return !this->isLocalTransmitter();  }
-
-   //send buffer wird autom resized
-   void sendDataSize()    { UB_THROW( UbException(UB_EXARGS,"empfaengt nur") ); }
-   //reiceive braucht nichts machen, das macht der sender :-)
-   void receiveDataSize() { } 
-
-   void         sendData()    { UB_THROW( UbException(UB_EXARGS,"empfaengt nur") ); }
-   value_type&  receiveData() { return this->data; }
-
-   std::string toString() const { return "TbVectorReceiverLocal<"+(std::string)typeid(T).name()+">"; }
-};
-
-template<typename T>
-class TbVectorSenderLocal : public TbTransmitter<T>
-{
-public:
-   typedef T value_type;
-
-public:
-   TbVectorSenderLocal(SPtr< TbVectorReceiverLocal< value_type > > receiver) 
-      : TbTransmitter< value_type >(), receiver(receiver) 
-   {
-
-   }
-   //virtual ~TbVectorSenderLocal() { std::cout<<typeid(*this).name()<<" tot"<<std::endl;   }
-
-   bool isLocalTransmitter()  const { return true;                         }
-   bool isRemoteTransmitter() const { return !this->isLocalTransmitter();  }
-
-   //send buffer wird autom resized
-   void sendDataSize()  
-   { 
-      assert(receiver!=NULL); 
-      receiver->getData().resize( this->data.size() ); 
-   }
-   //reiceive braucht nichts machen, da send==receive buffer ;-)
-   void receiveDataSize()  { UB_THROW( UbException(UB_EXARGS,"sendet nur") ); } 
-   
-   void sendData()    
-   { 
-      assert( this->data.size() == receiver->getData().size() );
-      receiver->getData() = this->data;
-//       for(int i=(int)this->data.size()-1; i>=0; --i)
-//          receiver->getData()[i]= this->data[i];
-   }
-   value_type& receiveData() { UB_THROW( UbException(UB_EXARGS,"sendet nur") ); }
-
-   std::string toString() const { return "TbVectorSenderLocal<"+(std::string)typeid(T).name()+">"; }
-
-protected:
-   SPtr< TbVectorReceiverLocal< value_type > > receiver; 
-};
-                                        
-#endif //TOTRANSMITTERLOCAL_H 
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef TOTRANSMITTERLOCAL_H
+#define TOTRANSMITTERLOCAL_H
+
+#include <basics/utilities/UbException.h>
+#include <basics/transmitter/TbTransmitter.h>
+#include <PointerDefinitions.h>
+
+/*================================================================================*/
+/*   TbLocalTransmitter, TbVectorSenderLocal, TbVectorReceiverLocal               */
+/*                                                                                */
+/**
+This Class provides the base for exception handling.
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 08.11.07
+*/ 
+
+/*
+usage: ...
+*/
+
+//////////////////////////////////////////////////////////////////////////
+// LocalTransmitter lokalen Datenaustausch
+// data = send- und zugleich receive-buffer
+template<typename T>
+class TbLocalTransmitter : public TbTransmitter<T>
+{
+public:
+   typedef SPtr< TbLocalTransmitter<T> > TbLocalTransmitterPtr;
+
+   typedef T value_type;
+
+public:
+   TbLocalTransmitter() : TbTransmitter<T>() 
+   {
+
+   }
+   
+   bool isLocalTransmitter()  const { return true;                         }
+   bool isRemoteTransmitter() const { return !this->isLocalTransmitter();  }
+
+   //send buffer wird autom resized
+   void sendDataSize()    { }
+   //reiceive braucht nichts machen, da send==receive buffer ;-)
+   void receiveDataSize() { } 
+
+   void        sendData()    { }
+   value_type& receiveData() { return this->data; }
+
+   std::string toString()  const { return "TbLocalTransmitter"+(std::string)typeid(T).name(); }
+};
+
+//////////////////////////////////////////////////////////////////////////
+// TbVectorSender/ReceiverLocal lokalen Datenaustausch ueber ZWEI vektoren
+template<typename T>
+class TbVectorReceiverLocal : public TbTransmitter<T>
+{
+public:
+   typedef T value_type;
+
+public:
+   TbVectorReceiverLocal() : TbTransmitter<value_type>() 
+   {
+
+   }
+   //virtual ~TbVectorReceiverLocal() { std::cout<<typeid(*this).name()<<" tot"<<std::endl;   }
+
+   bool isLocalTransmitter()  const { return true;                         }
+   bool isRemoteTransmitter() const { return !this->isLocalTransmitter();  }
+
+   //send buffer wird autom resized
+   void sendDataSize()    { UB_THROW( UbException(UB_EXARGS,"empfaengt nur") ); }
+   //reiceive braucht nichts machen, das macht der sender :-)
+   void receiveDataSize() { } 
+
+   void         sendData()    { UB_THROW( UbException(UB_EXARGS,"empfaengt nur") ); }
+   value_type&  receiveData() { return this->data; }
+
+   std::string toString() const { return "TbVectorReceiverLocal<"+(std::string)typeid(T).name()+">"; }
+};
+
+template<typename T>
+class TbVectorSenderLocal : public TbTransmitter<T>
+{
+public:
+   typedef T value_type;
+
+public:
+   TbVectorSenderLocal(SPtr< TbVectorReceiverLocal< value_type > > receiver) 
+      : TbTransmitter< value_type >(), receiver(receiver) 
+   {
+
+   }
+   //virtual ~TbVectorSenderLocal() { std::cout<<typeid(*this).name()<<" tot"<<std::endl;   }
+
+   bool isLocalTransmitter()  const { return true;                         }
+   bool isRemoteTransmitter() const { return !this->isLocalTransmitter();  }
+
+   //send buffer wird autom resized
+   void sendDataSize()  
+   { 
+      assert(receiver!=NULL); 
+      receiver->getData().resize( this->data.size() ); 
+   }
+   //reiceive braucht nichts machen, da send==receive buffer ;-)
+   void receiveDataSize()  { UB_THROW( UbException(UB_EXARGS,"sendet nur") ); } 
+   
+   void sendData()    
+   { 
+      assert( this->data.size() == receiver->getData().size() );
+      receiver->getData() = this->data;
+//       for(int i=(int)this->data.size()-1; i>=0; --i)
+//          receiver->getData()[i]= this->data[i];
+   }
+   value_type& receiveData() { UB_THROW( UbException(UB_EXARGS,"sendet nur") ); }
+
+   std::string toString() const { return "TbVectorSenderLocal<"+(std::string)typeid(T).name()+">"; }
+
+protected:
+   SPtr< TbVectorReceiverLocal< value_type > > receiver; 
+};
+                                        
+#endif //TOTRANSMITTERLOCAL_H 
diff --git a/source/ThirdParty/Library/basics/transmitter/TbTransmitterMpiPool.h b/source/VirtualFluidsBasic/basics/transmitter/TbTransmitterMpiPool.h
similarity index 97%
rename from source/ThirdParty/Library/basics/transmitter/TbTransmitterMpiPool.h
rename to source/VirtualFluidsBasic/basics/transmitter/TbTransmitterMpiPool.h
index 4f673f122c09de9f892236e357f5a1b0e4ac88ee..78decb50c1447ccc3c3e84b388a11e37c302e2fc 100644
--- a/source/ThirdParty/Library/basics/transmitter/TbTransmitterMpiPool.h
+++ b/source/VirtualFluidsBasic/basics/transmitter/TbTransmitterMpiPool.h
@@ -1,536 +1,536 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef TBTRANSMITTERMPIPOOL_H
-#define TBTRANSMITTERMPIPOOL_H
-
-#ifdef VF_MPI
-
-#include <iostream>
-#include <sstream>
-#include <iomanip>
-#include <vector>
-#include <map>
-
-#include <mpi.h>
-
-#include <basics/transmitter/TbTransmitter.h>
-#include <basics/container/CbVector.h>
-#include <basics/container/CbVectorPool.h>
-
-#include <PointerDefinitions.h>
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-//TbCbVectorMpiPoolSender/Receiver
-//diese verschicken immer einen VectorPool. Letztlich einen langen vector,
-//der eigentlich aus vielen kleinen besteht
-//jeder MpiPoolVector hat einen pointer auf die startadresse in diesem vector
-//die informationen werden im TbMpiVectorPool verwaltet
-//MpiPoolVector verhaelt sich nach aussen hin mit einschraenkungen wie ein std::vector
-//und kann somit bei den vector connector verwendet werden
-//man kann die klassen theoretisch verallgemeinern.
-
-template<typename T> class TbCbVectorSenderMpiPool;
-template<typename T> class TbCbVectorReceiverMpiPool;
-
-/*==================================================================*/
-template<typename T>
-class TbCbVectorMpiPool : public CbVectorPool<T>
-{
-public:
-   typedef SPtr< TbCbVectorMpiPool< T > > MpiPoolPtr;
-
-   //////////////////////////////////////////////////////////////////////////
-   typedef std::map<std::string, MpiPoolPtr >      MpiPoolPtrMap;
-   typedef typename MpiPoolPtrMap::iterator MpiPoolPtrMapIter;
-
-   //da BasisKlasse templateKlasse ist MUSS man hier die typedefs nochmal wiederholen!
-   typedef typename CbVector<T>::value_type value_type;
-   typedef typename CbVector<T>::size_type  size_type;
-   typedef std::vector< value_type >        Pool;
-
-   typedef std::string CbVectorKey;
-   typedef std::map< CbVectorKey, CbVector< value_type >* /*ptrVector*/  > CbVectorMap;
-   typedef typename CbVectorMap::iterator CbVectorMapIter;
-
-   //////////////////////////////////////////////////////////////////////////
-   friend class TbCbVectorSenderMpiPool< T >; 
-   friend class TbCbVectorReceiverMpiPool< T >; 
-
-protected:
-   //////////////////////////////////////////////////////////////////////////
-   static MpiPoolPtrMap poolMap;
-public:
-   //////////////////////////////////////////////////////////////////////////
-   //STATIC MEMBERS
-   //////////////////////////////////////////////////////////////////////////
-   //createTbCbVectorMpiPool:
-   // poolKey      : Schluessel fuer eindeutige Indizierung in Map
-   // mpiRemoteRank: mpi-rank des Empfaengers/Senders
-   // mpiTag       : mpi-tag mit dem empfangen/gesendet wird
-   static MpiPoolPtr createTbCbVectorMpiPool(CbVectorKey poolKey, int mpiRemoteRank, int mpiTag, MPI_Comm comm, size_type startPoolSize = 20000 ) //startPoolSize*sizeof(T)/1024/1024 [MB]
-
-   {
-      if( poolMap.find(poolKey)!=poolMap.end() )
-      {
-         throw UbException(UB_EXARGS,"es ist bereits ein Pool mit dem key vorhanden!!!");
-      }
-
-      //pool erstellen
-      MpiPoolPtr mpiPool(new TbCbVectorMpiPool<T>(poolKey, mpiRemoteRank, mpiTag, comm, startPoolSize) ); 
-
-      //pool "speichern"
-      TbCbVectorMpiPool< value_type >::poolMap[poolKey] = mpiPool;
-
-      return mpiPool; 
-   }
-   static void deleteTbCbVectorMpiPool(CbVectorKey poolKey)
-   {
-      MpiPoolPtrMapIter it = TbCbVectorMpiPool< value_type >::poolMap.find(poolKey);
-      if( it==poolMap.end() )
-      {
-         throw UbException(UB_EXARGS,"kein Pool mit dem key vorhanden");
-      }
-      TbCbVectorMpiPool< value_type >::poolMap.erase(it);
-   }
-   /*==================================================================*/
-   static MpiPoolPtr getTbCbVectorMpiPool(CbVectorKey poolKey)
-   {
-      MpiPoolPtrMapIter it;
-      if( (it=TbCbVectorMpiPool< T >::poolMap.find(poolKey))!=TbCbVectorMpiPool< T >::poolMap.end() ) 
-      {
-         return it->second;
-      }
-      return MpiPoolPtr();
-   }
-   /*==================================================================*/
-   static std::string getInfoString()
-   {
-      std::stringstream out;  
-      out<<"TbCbVectorMpiPool<"<< typeid( T ).name()  << ") - Info:"<<std::endl;
-      for(MpiPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it)
-         out<<"pool with key("            <<std::setw(15)<<it->first<<") "
-         <<"stores "                  <<std::setw(12)<<it->second->getNofStoredVectors() <<" vectors " 
-         <<", elements to transfer = "<<std::setw(15)<<it->second->getPoolSize() 
-         <<" ( "<< it->second->getPoolSize()*sizeof( T ) / ( 1024.0 * 1024.0 ) << " MB )" <<std::endl;
-      return out.str();
-   }
-   /*==================================================================*/
-   // checks if all vectors have one to one pool-entries
-   static bool consistencyCheck()
-   {
-      for(MpiPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it)
-      {
-         if( !it->second-> CbVectorPool<T>::consistencyCheck() ) 
-         {
-            return false;         
-         }
-      }
-
-      return true;
-   }
-   //////////////////////////////////////////////////////////////////////////
-   static void eraseMap()
-   {
-      poolMap.clear();
-   }
-protected:
-   //////////////////////////////////////////////////////////////////////////
-   TbCbVectorMpiPool(CbVectorKey poolKey, int mpiRemoteRank, int mpiTag, MPI_Comm comm, size_type startPoolSize )
-      :    CbVectorPool< value_type >( startPoolSize ) 
-      , poolKey(poolKey)                           
-      , nofStoredVectors(0) //=Anzahl an Vectoren im Pool, wird bei send/receiveDataOrder gesetzt
-      , counterPrepareReceiveDataOrder(0)          
-      , counterSendDataOrder(0)                    
-      , counterReceiveDataOrder(0)                 
-      , counterPrepareForReceive(0)                
-      , counterReceive(0)                          
-      , counterPrepareForSend(0)                   
-      , counterSend(0)                             
-      , comm(comm)                                 
-      , receiveRequest(MPI_REQUEST_NULL)
-      //, sendRequest(MPI_REQUEST_NULL)
-      , mpiRemoteRank(mpiRemoteRank)               
-      , mpiTag(mpiTag)                              
-   {
-      if     ( (std::string)typeid(value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI_DOUBLE;
-      else if( (std::string)typeid(value_type).name()==(std::string)typeid(float).name()  ) mpiDataType = MPI_FLOAT;
-      else if( (std::string)typeid(value_type).name()==(std::string)typeid(int).name()    ) mpiDataType = MPI_INT;
-      else throw UbException(UB_EXARGS,"no MpiDataType for T"+(std::string)typeid(T).name());
-
-      for (int i = 0; i < 3; i++)
-      {
-         sendRequest[i] = MPI_REQUEST_NULL;
-      }
-   }
-
-public:
-   /*==================================================================*/
-   //returns key of Pool in MpiPoolMap
-   CbVectorKey  getPoolKey()    const { return  this->poolKey;       }
-   /*==================================================================*/
-   //returns rank of process pool data will be send to/received from
-   int  getRemoteRank() const { return  this->mpiRemoteRank; }
-   /*==================================================================*/
-   //returns tag of process pool data will be send to/received from
-   int  getRemoteTag()  const { return  this->mpiTag;        }
-
-protected:
-   /*==================================================================*/
-   void sendDataOrder()
-   {
-      counterSendDataOrder++;
-      if(counterSendDataOrder==this->cbVectorMap.size())
-      {
-         //allg.: bei MPI muss man darauf achten, dass bei unblocked operationen die puffer (aus dem oder in den 
-         //geschrieben wird auch noch vorhanden sind!!! wuerde man hier z.B. einen lokalen vector mit Isend() los-
-         //schicken, dann wurde der scope verlassen werden und der vector evtl geloescht werden, bevor mpi den
-         //vorgang abgeschlossen hat!!! ->  tmpOrderVec ist class-member!!!
-         unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1;
-         tmpSendOrderVec.resize(nofElements);//std::vector< unsigned > vec(nofElements);
-         unsigned index = 0;
-         tmpSendOrderVec[index++] = (unsigned)this->pool.size(); //= laenge des vectors
-         if(this->nextCbVectorStartIndexInPool != this->pool.size())  throw UbException(UB_EXARGS,"an dieser Stelle sollten nextStartIndex und pool.size() identisch sein!!!");
-         for(CbVectorMapIter it = this->cbVectorMap.begin(); it!=this->cbVectorMap.end(); ++it)
-         {
-            CbVectorKey vectorKey;
-            size_type   dataSize=0, startIndexInPool=0;
-            this->getCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize );
-            if(it->first != vectorKey) throw UbException(UB_EXARGS,"key mismatch!");
-
-            tmpSendOrderKeyVec += vectorKey;         //vectorKey == allocator.getAllocatorKey()
-            tmpSendOrderVec[index++] = (unsigned)vectorKey.length();
-            tmpSendOrderVec[index++] = (unsigned)startIndexInPool;  //startIndex in poolVector
-            tmpSendOrderVec[index++] = (unsigned)dataSize;          //dataSize
-         }
-         
-         MPI_Isend(&tmpSendOrderVec[0],(int)tmpSendOrderVec.size(), MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, &sendRequest[0]);
-         
-         tmpSendOrderKeyVecLength = (unsigned)tmpSendOrderKeyVec.length();
-         MPI_Isend(&tmpSendOrderKeyVecLength,1, MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, &sendRequest[1]);
-         MPI_Isend((char *)tmpSendOrderKeyVec.c_str(),tmpSendOrderKeyVecLength, MPI_CHAR, mpiRemoteRank, mpiTag, comm, &sendRequest[2]);
-
-
-         counterSendDataOrder=0;
-
-         nofStoredVectors = this->cbVectorMap.size();
-
-         UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendDataOrder()"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
-
-#ifdef _DEBUG
-         orgPoolVectorStartPointer = &this->pool[0];
-#endif
-      }
-   }
-   /*==================================================================*/
-   void receiveDataOrder()
-   {
-      counterReceiveDataOrder++;
-      if(counterReceiveDataOrder==this->cbVectorMap.size())
-      {
-         //receiveRequest.Wait();
-         unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1; //map MUSS auf beiden seiten gleich gross sein, sonst hat man ein grundsaetzliches problem ;-)
-
-         UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveDataOrder()"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
-
-         std::vector< unsigned > tmpRecvOrderVec;
-         tmpRecvOrderVec.resize(nofElements);
-
-         std::vector<char> tmpRecvOrderKeyVec;
-        
-         //MPI_Status status;
-         MPI_Recv(&tmpRecvOrderVec[0], nofElements, MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, MPI_STATUS_IGNORE);
-
-         unsigned rcount;
-         MPI_Recv(&rcount, 1, MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, MPI_STATUS_IGNORE);
-         tmpRecvOrderKeyVec.resize(rcount);
-         MPI_Recv(&tmpRecvOrderKeyVec[0], rcount, MPI_CHAR, mpiRemoteRank, mpiTag, comm, MPI_STATUS_IGNORE);
-
-         if(nofElements!=(unsigned)tmpRecvOrderVec.size())
-            throw UbException(UB_EXARGS,"error... vec size stimmt nicht");
-
-         unsigned index = 0;
-         size_type index2 = 0;
-         this->nextCbVectorStartIndexInPool = tmpRecvOrderVec[index++]; //= laenge des vectors
-         this->pool.resize(this->nextCbVectorStartIndexInPool);
-         CbVectorMapIter it = this->cbVectorMap.begin();
-         for(/*index*/; index<nofElements; index+=3, ++it)
-         {
-            size_type   vectorKeyLength  = (size_type)tmpRecvOrderVec.at(index  );
-            size_type   startIndexInPool = (size_type)tmpRecvOrderVec.at(index+1);
-            size_type   dataSize         = (size_type)tmpRecvOrderVec.at(index+2);
-            CbVectorKey vectorKey = CbVectorKey(&tmpRecvOrderKeyVec[index2], vectorKeyLength);
-            index2 += vectorKeyLength;
-
-            //if(it==this->cbVectorMap.end() || it->first != vectorKey ) 
-               //throw UbException(UB_EXARGS, "entweder hat map nicht die gleiche reihenfolge oder vectorKey = "+UbSystem::toString(vectorKey)+" nicht vorhanden");
-            if (it==this->cbVectorMap.end())
-               throw UbException(UB_EXARGS,"map ist leer");
-            else if (it->first != vectorKey)
-               throw UbException(UB_EXARGS, "vectorKey = "+UbSystem::toString(vectorKey)+" nicht vorhanden it->first =" + UbSystem::toString(it->first));
-
-            this->setCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize );
-            
-         }
-         if(it!=this->cbVectorMap.end())
-            throw UbException(UB_EXARGS,"error... in der map sind scheinbar noch weiter elemente vorhanden, die es auf der send seite nicht gibt...");
-
-         counterReceiveDataOrder = 0;
-         nofStoredVectors = this->cbVectorMap.size();
-
-#ifdef _DEBUG
-         orgPoolVectorStartPointer = &this->pool[0];
-#endif
-      }
-   }
-   /*==================================================================*/
-   void prepareForSendData()
-   {
-      //da sendDataOrder einen request verwendet muss man hier immer abfragen
-      if(counterPrepareForSend==0)
-      {
-         UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForSendData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
-         //if(sendRequest != MPI_REQUEST_NULL) MPI_Wait(&sendRequest, MPI_STATUS_IGNORE);
-         if(sendRequest[2] != MPI_REQUEST_NULL) MPI_Waitall(3, sendRequest, MPI_STATUS_IGNORE);
-         UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForSendData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
-      }
-
-      counterPrepareForSend++;
-
-      if(counterPrepareForSend==nofStoredVectors)
-      {
-         counterPrepareForSend=0;  
-      }
-
-
-      //A - non blocking
-      ////der ERSTE is entscheidend 
-      ////Grund: wenn man 
-      //// for(all trans) { trans->prepare(); trans->fillBuffer(); }
-      //// aufruft, dann wuerde u.U. der Buffer neu beschrieben werden obwohl noch nicht versendet wurde!!!
-      //counterPrepareForSend++;
-      //if(counterPrepareForSend==1)
-      //{
-      //   if(sendRequest != MPI::REQUEST_NULL) sendRequest.Wait();
-      //}
-      //
-      //if(counterPrepareForSend==nofStoredVectors)
-      //   counterPrepareForSend=0;  
-   }
-   /*==================================================================*/
-   void sendData()
-   {
-      //A - non blocking
-      //der LETZTE is entscheidend 
-      //counterSend++;
-      //if(counterSend==nofStoredVectors)
-      //{
-      //   //std::cout<<"Isend von "<<(int)nextStartIndex<<"elementen von "<<mpiRemoteRank<<" mit tag="<<mpiTag<<std::endl;
-      //   sendRequest = comm.Isend(&pool[0],(int)nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag);
-      //   counterSend=0;
-      //}
-      //B - blocking
-      //der LETZTE is entscheidend 
-      counterSend++;
-      if(counterSend==nofStoredVectors)
-      {
-         //std::cout<<"Isend von "<<(int)nextStartIndex<<"elementen von "<<mpiRemoteRank<<" mit tag="<<mpiTag<<std::endl;
-         UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
-
-         //synchronous send 
-         //comm.Ssend(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag);
-#ifdef _DEBUG
-         if(this->orgPoolVectorStartPointer != &this->pool[0] ) throw UbException(UB_EXARGS, "ups, pool array adress changed - unknown behavoir");
-#endif
-
-         //standard send
-         MPI_Send(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm);
-         UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
-////////////////////////////////////////////////////////////////////////////////////////////
-//DEBUG///////////////////////////////////////
-         //int irank;
-         //MPI_Comm_rank(MPI_COMM_WORLD, &irank);
-         //std::cout << "MPI_Send: " << irank <<  " "  << mpiRemoteRank << " "  <<mpiTag<<std::endl;
-///////////////////////////////////////////////////
-         counterSend=0;
-      }                           
-   }
-   /*==================================================================*/
-   void prepareForReceiveData()
-   {
-      //A - non blocking
-      //sobald der Letzte kann man den den request holen.
-      //andernfalls kann nicht gewaehrleistet werden, dass evtl noch mit dem buffer gearbeitet wird!!!
-      counterPrepareForReceive++;
-      if(counterPrepareForReceive==this->nofStoredVectors)
-      {
-         UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForReceiveData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
-#ifdef _DEBUG
-         if(this->orgPoolVectorStartPointer != &this->pool[0] ) throw UbException(UB_EXARGS, "ups, pool array adress changed - unknown behavoir");
-#endif
-         MPI_Irecv(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm, &receiveRequest);
-         UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForReceiveData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
-         counterPrepareForReceive=0;
-      }
-   }
-   /*==================================================================*/
-   void receiveData()
-   {
-      //A - non blocking
-      //sobald der ERSTE reinkommt muss man warten, bis received wurde!!!
-      //denn erst anschliessend stehen die empfangenen daten zur verfuegung
-      if(counterReceive==0)
-      {
-         UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
-         MPI_Wait(&receiveRequest, MPI_STATUS_IGNORE);
-         UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
-      }
-      counterReceive++;
-      if(counterReceive==this->nofStoredVectors) //alle receiver waren hier
-      {
-         counterReceive=0;
-      }
-
-      ////B - blocking
-      ////sobald der ERSTE reinkommt muss man warten, bis received wurde!!!
-      ////denn erst anschliessend stehen die empfangenen daten zur verfuegung
-      //if(counterReceive==0)
-      //{
-      //   comm.Recv(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag);
-      //}
-      //counterReceive++;
-      //if(counterReceive==this->nofStoredVectors) //alle receiver waren hier
-      //   counterReceive=0;
-   }
-
-protected:
-   CbVectorKey poolKey; //eindeutiger schluessel fuer pool
-   size_type nofStoredVectors;
-
-   size_type counterPrepareReceiveDataOrder;
-   size_type counterSendDataOrder;
-   size_type counterReceiveDataOrder;
-   size_type counterPrepareForReceive;
-   size_type counterReceive;
-   size_type counterPrepareForSend;
-   size_type counterSend;
-
-   std::vector< unsigned > tmpSendOrderVec; //wird zur temp speicherung der anordnung benoetigt
-   std::string tmpSendOrderKeyVec;
-   unsigned tmpSendOrderKeyVecLength;
-
-   MPI_Comm     comm;
-   MPI_Request  receiveRequest;
-   //MPI_Request  sendRequest;
-   MPI_Request  sendRequest[3];
-   //MPI_Status   sendStatus;
-   //MPI_Status   receiveStatus;
-   MPI_Datatype mpiDataType;
-
-   int mpiRemoteRank, mpiTag;
-
-#ifdef _DEBUG
-   T* orgPoolVectorStartPointer;
-#endif
-};
-
-template<typename T>
-typename TbCbVectorMpiPool<T>::MpiPoolPtrMap TbCbVectorMpiPool<T>::poolMap;
-
-//////////////////////////////////////////////////////////////////////////
-//  TbSenderMpiPool
-//////////////////////////////////////////////////////////////////////////
-template<typename T>
-class TbCbVectorSenderMpiPool : public TbTransmitter< CbVector< T >  >
-{
-public:
-   typedef CbVector< T > value_type;
-
-public:
-   TbCbVectorSenderMpiPool(std::string cbVectorKey, TbCbVectorMpiPool< T >* mpiVectorPool)
-      : mpiVectorPool(mpiVectorPool)
-   { 
-      this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey,this->mpiVectorPool) );
-   }
-   ~TbCbVectorSenderMpiPool()
-   {
-      if( this->mpiVectorPool->getNofStoredVectors()==1 ) //last entry!
-      {
-         TbCbVectorMpiPool< T >::deleteTbCbVectorMpiPool(this->mpiVectorPool->getPoolKey());  
-      }
-   }
-
-   bool isLocalTransmitter()  const { return false;                        }
-   bool isRemoteTransmitter() const { return !this->isLocalTransmitter();  }
-
-   void sendDataSize()          { this->mpiVectorPool->sendDataOrder(); }
-   void receiveDataSize()       { throw UbException(UB_EXARGS,"TbMpiPoolSender sends only");  }   
-   CbVector< T >& receiveData() { throw UbException(UB_EXARGS,"TbMpiPoolSender sends only");  }
-   void prepareForSend()        { this->mpiVectorPool->prepareForSendData(); }
-   void sendData()              { this->mpiVectorPool->sendData(); }
-
-   //info-section (usable for remote transmitter)
-   int  getSendTbRank()   const { return  this->mpiVectorPool->getRemoteRank(); }
-   int  getSendTbTag()    const { return  this->mpiVectorPool->getRemoteTag();  }
-   int  getRecvFromRank() const { throw UbException(UB_EXARGS,"TbCbVectorSenderMpiPool sends only"); }
-   int  getRecvFromTag()  const { throw UbException(UB_EXARGS,"TbCbVectorSenderMpiPool sends only"); }
-
-   std::string toString() const { return "TbCbVectorSenderMpiPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getSendTbRank())+"("+UbSystem::toString(getSendTbTag())+")"; }
-
-protected:
-   TbCbVectorMpiPool<T>* mpiVectorPool;
-};
-
-
-/*==================================================================*/
-template<typename T>
-class TbCbVectorReceiverMpiPool : public TbTransmitter< CbVector< T >  >
-{
-public:
-   typedef CbVector< T > value_type;   
-
-public:
-   TbCbVectorReceiverMpiPool(std::string cbVectorKey, TbCbVectorMpiPool< T >* mpiVectorPool)
-      : mpiVectorPool(mpiVectorPool)
-   { 
-      this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey, this->mpiVectorPool) );
-   }
-   ~TbCbVectorReceiverMpiPool()
-   {
-      if( this->mpiVectorPool->getNofStoredVectors()==1 ) //last entry!
-      {
-         TbCbVectorMpiPool< T >::deleteTbCbVectorMpiPool(this->mpiVectorPool->getPoolKey());  
-      }
-   }
-   bool isLocalTransmitter()  const { return false;                        }
-   bool isRemoteTransmitter() const { return !this->isLocalTransmitter();  }
-
-   void sendDataSize()      { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only");  }   
-   void receiveDataSize()   { this->mpiVectorPool->receiveDataOrder(); }  
-   void sendData()          { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); }
-   void prepareForReceive() { this->mpiVectorPool->prepareForReceiveData(); }
-   CbVector< T >& receiveData()
-   { 
-      this->mpiVectorPool->receiveData();
-      return this->getData();
-   }
-
-   //info-section (usable for remote transmitter)
-   int  getSendTbRank()   const { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); }
-   int  getSendTbTag()    const { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); }
-   int  getRecvFromRank() const { return  this->mpiVectorPool->getRemoteRank();  }
-   int  getRecvFromTag()  const { return  this->mpiVectorPool->getRemoteTag();  }
-
-   std::string toString() const { return "TbCbVectorReceiverMpiPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getRecvFromRank())+"("+UbSystem::toString(getRecvFromTag())+")"; }
-
-protected:
-   TbCbVectorMpiPool<T>* mpiVectorPool;
-};
-
-#endif //VF_MPI
-
-#endif //TBTRANSMITTERMPIPOOL_H
- 
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef TBTRANSMITTERMPIPOOL_H
+#define TBTRANSMITTERMPIPOOL_H
+
+#ifdef VF_MPI
+
+#include <iostream>
+#include <sstream>
+#include <iomanip>
+#include <vector>
+#include <map>
+
+#include <mpi.h>
+
+#include <basics/transmitter/TbTransmitter.h>
+#include <basics/container/CbVector.h>
+#include <basics/container/CbVectorPool.h>
+
+#include <PointerDefinitions.h>
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+//TbCbVectorMpiPoolSender/Receiver
+//diese verschicken immer einen VectorPool. Letztlich einen langen vector,
+//der eigentlich aus vielen kleinen besteht
+//jeder MpiPoolVector hat einen pointer auf die startadresse in diesem vector
+//die informationen werden im TbMpiVectorPool verwaltet
+//MpiPoolVector verhaelt sich nach aussen hin mit einschraenkungen wie ein std::vector
+//und kann somit bei den vector connector verwendet werden
+//man kann die klassen theoretisch verallgemeinern.
+
+template<typename T> class TbCbVectorSenderMpiPool;
+template<typename T> class TbCbVectorReceiverMpiPool;
+
+/*==================================================================*/
+template<typename T>
+class TbCbVectorMpiPool : public CbVectorPool<T>
+{
+public:
+   typedef SPtr< TbCbVectorMpiPool< T > > MpiPoolPtr;
+
+   //////////////////////////////////////////////////////////////////////////
+   typedef std::map<std::string, MpiPoolPtr >      MpiPoolPtrMap;
+   typedef typename MpiPoolPtrMap::iterator MpiPoolPtrMapIter;
+
+   //da BasisKlasse templateKlasse ist MUSS man hier die typedefs nochmal wiederholen!
+   typedef typename CbVector<T>::value_type value_type;
+   typedef typename CbVector<T>::size_type  size_type;
+   typedef std::vector< value_type >        Pool;
+
+   typedef std::string CbVectorKey;
+   typedef std::map< CbVectorKey, CbVector< value_type >* /*ptrVector*/  > CbVectorMap;
+   typedef typename CbVectorMap::iterator CbVectorMapIter;
+
+   //////////////////////////////////////////////////////////////////////////
+   friend class TbCbVectorSenderMpiPool< T >; 
+   friend class TbCbVectorReceiverMpiPool< T >; 
+
+protected:
+   //////////////////////////////////////////////////////////////////////////
+   static MpiPoolPtrMap poolMap;
+public:
+   //////////////////////////////////////////////////////////////////////////
+   //STATIC MEMBERS
+   //////////////////////////////////////////////////////////////////////////
+   //createTbCbVectorMpiPool:
+   // poolKey      : Schluessel fuer eindeutige Indizierung in Map
+   // mpiRemoteRank: mpi-rank des Empfaengers/Senders
+   // mpiTag       : mpi-tag mit dem empfangen/gesendet wird
+   static MpiPoolPtr createTbCbVectorMpiPool(CbVectorKey poolKey, int mpiRemoteRank, int mpiTag, MPI_Comm comm, size_type startPoolSize = 20000 ) //startPoolSize*sizeof(T)/1024/1024 [MB]
+
+   {
+      if( poolMap.find(poolKey)!=poolMap.end() )
+      {
+         throw UbException(UB_EXARGS,"es ist bereits ein Pool mit dem key vorhanden!!!");
+      }
+
+      //pool erstellen
+      MpiPoolPtr mpiPool(new TbCbVectorMpiPool<T>(poolKey, mpiRemoteRank, mpiTag, comm, startPoolSize) ); 
+
+      //pool "speichern"
+      TbCbVectorMpiPool< value_type >::poolMap[poolKey] = mpiPool;
+
+      return mpiPool; 
+   }
+   static void deleteTbCbVectorMpiPool(CbVectorKey poolKey)
+   {
+      MpiPoolPtrMapIter it = TbCbVectorMpiPool< value_type >::poolMap.find(poolKey);
+      if( it==poolMap.end() )
+      {
+         throw UbException(UB_EXARGS,"kein Pool mit dem key vorhanden");
+      }
+      TbCbVectorMpiPool< value_type >::poolMap.erase(it);
+   }
+   /*==================================================================*/
+   static MpiPoolPtr getTbCbVectorMpiPool(CbVectorKey poolKey)
+   {
+      MpiPoolPtrMapIter it;
+      if( (it=TbCbVectorMpiPool< T >::poolMap.find(poolKey))!=TbCbVectorMpiPool< T >::poolMap.end() ) 
+      {
+         return it->second;
+      }
+      return MpiPoolPtr();
+   }
+   /*==================================================================*/
+   static std::string getInfoString()
+   {
+      std::stringstream out;  
+      out<<"TbCbVectorMpiPool<"<< typeid( T ).name()  << ") - Info:"<<std::endl;
+      for(MpiPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it)
+         out<<"pool with key("            <<std::setw(15)<<it->first<<") "
+         <<"stores "                  <<std::setw(12)<<it->second->getNofStoredVectors() <<" vectors " 
+         <<", elements to transfer = "<<std::setw(15)<<it->second->getPoolSize() 
+         <<" ( "<< it->second->getPoolSize()*sizeof( T ) / ( 1024.0 * 1024.0 ) << " MB )" <<std::endl;
+      return out.str();
+   }
+   /*==================================================================*/
+   // checks if all vectors have one to one pool-entries
+   static bool consistencyCheck()
+   {
+      for(MpiPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it)
+      {
+         if( !it->second-> CbVectorPool<T>::consistencyCheck() ) 
+         {
+            return false;         
+         }
+      }
+
+      return true;
+   }
+   //////////////////////////////////////////////////////////////////////////
+   static void eraseMap()
+   {
+      poolMap.clear();
+   }
+protected:
+   //////////////////////////////////////////////////////////////////////////
+   TbCbVectorMpiPool(CbVectorKey poolKey, int mpiRemoteRank, int mpiTag, MPI_Comm comm, size_type startPoolSize )
+      :    CbVectorPool< value_type >( startPoolSize ) 
+      , poolKey(poolKey)                           
+      , nofStoredVectors(0) //=Anzahl an Vectoren im Pool, wird bei send/receiveDataOrder gesetzt
+      , counterPrepareReceiveDataOrder(0)          
+      , counterSendDataOrder(0)                    
+      , counterReceiveDataOrder(0)                 
+      , counterPrepareForReceive(0)                
+      , counterReceive(0)                          
+      , counterPrepareForSend(0)                   
+      , counterSend(0)                             
+      , comm(comm)                                 
+      , receiveRequest(MPI_REQUEST_NULL)
+      //, sendRequest(MPI_REQUEST_NULL)
+      , mpiRemoteRank(mpiRemoteRank)               
+      , mpiTag(mpiTag)                              
+   {
+      if     ( (std::string)typeid(value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI_DOUBLE;
+      else if( (std::string)typeid(value_type).name()==(std::string)typeid(float).name()  ) mpiDataType = MPI_FLOAT;
+      else if( (std::string)typeid(value_type).name()==(std::string)typeid(int).name()    ) mpiDataType = MPI_INT;
+      else throw UbException(UB_EXARGS,"no MpiDataType for T"+(std::string)typeid(T).name());
+
+      for (int i = 0; i < 3; i++)
+      {
+         sendRequest[i] = MPI_REQUEST_NULL;
+      }
+   }
+
+public:
+   /*==================================================================*/
+   //returns key of Pool in MpiPoolMap
+   CbVectorKey  getPoolKey()    const { return  this->poolKey;       }
+   /*==================================================================*/
+   //returns rank of process pool data will be send to/received from
+   int  getRemoteRank() const { return  this->mpiRemoteRank; }
+   /*==================================================================*/
+   //returns tag of process pool data will be send to/received from
+   int  getRemoteTag()  const { return  this->mpiTag;        }
+
+protected:
+   /*==================================================================*/
+   void sendDataOrder()
+   {
+      counterSendDataOrder++;
+      if(counterSendDataOrder==this->cbVectorMap.size())
+      {
+         //allg.: bei MPI muss man darauf achten, dass bei unblocked operationen die puffer (aus dem oder in den 
+         //geschrieben wird auch noch vorhanden sind!!! wuerde man hier z.B. einen lokalen vector mit Isend() los-
+         //schicken, dann wurde der scope verlassen werden und der vector evtl geloescht werden, bevor mpi den
+         //vorgang abgeschlossen hat!!! ->  tmpOrderVec ist class-member!!!
+         unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1;
+         tmpSendOrderVec.resize(nofElements);//std::vector< unsigned > vec(nofElements);
+         unsigned index = 0;
+         tmpSendOrderVec[index++] = (unsigned)this->pool.size(); //= laenge des vectors
+         if(this->nextCbVectorStartIndexInPool != this->pool.size())  throw UbException(UB_EXARGS,"an dieser Stelle sollten nextStartIndex und pool.size() identisch sein!!!");
+         for(CbVectorMapIter it = this->cbVectorMap.begin(); it!=this->cbVectorMap.end(); ++it)
+         {
+            CbVectorKey vectorKey;
+            size_type   dataSize=0, startIndexInPool=0;
+            this->getCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize );
+            if(it->first != vectorKey) throw UbException(UB_EXARGS,"key mismatch!");
+
+            tmpSendOrderKeyVec += vectorKey;         //vectorKey == allocator.getAllocatorKey()
+            tmpSendOrderVec[index++] = (unsigned)vectorKey.length();
+            tmpSendOrderVec[index++] = (unsigned)startIndexInPool;  //startIndex in poolVector
+            tmpSendOrderVec[index++] = (unsigned)dataSize;          //dataSize
+         }
+         
+         MPI_Isend(&tmpSendOrderVec[0],(int)tmpSendOrderVec.size(), MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, &sendRequest[0]);
+         
+         tmpSendOrderKeyVecLength = (unsigned)tmpSendOrderKeyVec.length();
+         MPI_Isend(&tmpSendOrderKeyVecLength,1, MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, &sendRequest[1]);
+         MPI_Isend((char *)tmpSendOrderKeyVec.c_str(),tmpSendOrderKeyVecLength, MPI_CHAR, mpiRemoteRank, mpiTag, comm, &sendRequest[2]);
+
+
+         counterSendDataOrder=0;
+
+         nofStoredVectors = this->cbVectorMap.size();
+
+         UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendDataOrder()"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
+
+#ifdef _DEBUG
+         orgPoolVectorStartPointer = &this->pool[0];
+#endif
+      }
+   }
+   /*==================================================================*/
+   void receiveDataOrder()
+   {
+      counterReceiveDataOrder++;
+      if(counterReceiveDataOrder==this->cbVectorMap.size())
+      {
+         //receiveRequest.Wait();
+         unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1; //map MUSS auf beiden seiten gleich gross sein, sonst hat man ein grundsaetzliches problem ;-)
+
+         UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveDataOrder()"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
+
+         std::vector< unsigned > tmpRecvOrderVec;
+         tmpRecvOrderVec.resize(nofElements);
+
+         std::vector<char> tmpRecvOrderKeyVec;
+        
+         //MPI_Status status;
+         MPI_Recv(&tmpRecvOrderVec[0], nofElements, MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, MPI_STATUS_IGNORE);
+
+         unsigned rcount;
+         MPI_Recv(&rcount, 1, MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, MPI_STATUS_IGNORE);
+         tmpRecvOrderKeyVec.resize(rcount);
+         MPI_Recv(&tmpRecvOrderKeyVec[0], rcount, MPI_CHAR, mpiRemoteRank, mpiTag, comm, MPI_STATUS_IGNORE);
+
+         if(nofElements!=(unsigned)tmpRecvOrderVec.size())
+            throw UbException(UB_EXARGS,"error... vec size stimmt nicht");
+
+         unsigned index = 0;
+         size_type index2 = 0;
+         this->nextCbVectorStartIndexInPool = tmpRecvOrderVec[index++]; //= laenge des vectors
+         this->pool.resize(this->nextCbVectorStartIndexInPool);
+         CbVectorMapIter it = this->cbVectorMap.begin();
+         for(/*index*/; index<nofElements; index+=3, ++it)
+         {
+            size_type   vectorKeyLength  = (size_type)tmpRecvOrderVec.at(index  );
+            size_type   startIndexInPool = (size_type)tmpRecvOrderVec.at(index+1);
+            size_type   dataSize         = (size_type)tmpRecvOrderVec.at(index+2);
+            CbVectorKey vectorKey = CbVectorKey(&tmpRecvOrderKeyVec[index2], vectorKeyLength);
+            index2 += vectorKeyLength;
+
+            //if(it==this->cbVectorMap.end() || it->first != vectorKey ) 
+               //throw UbException(UB_EXARGS, "entweder hat map nicht die gleiche reihenfolge oder vectorKey = "+UbSystem::toString(vectorKey)+" nicht vorhanden");
+            if (it==this->cbVectorMap.end())
+               throw UbException(UB_EXARGS,"map ist leer");
+            else if (it->first != vectorKey)
+               throw UbException(UB_EXARGS, "vectorKey = "+UbSystem::toString(vectorKey)+" nicht vorhanden it->first =" + UbSystem::toString(it->first));
+
+            this->setCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize );
+            
+         }
+         if(it!=this->cbVectorMap.end())
+            throw UbException(UB_EXARGS,"error... in der map sind scheinbar noch weiter elemente vorhanden, die es auf der send seite nicht gibt...");
+
+         counterReceiveDataOrder = 0;
+         nofStoredVectors = this->cbVectorMap.size();
+
+#ifdef _DEBUG
+         orgPoolVectorStartPointer = &this->pool[0];
+#endif
+      }
+   }
+   /*==================================================================*/
+   void prepareForSendData()
+   {
+      //da sendDataOrder einen request verwendet muss man hier immer abfragen
+      if(counterPrepareForSend==0)
+      {
+         UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForSendData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
+         //if(sendRequest != MPI_REQUEST_NULL) MPI_Wait(&sendRequest, MPI_STATUS_IGNORE);
+         if(sendRequest[2] != MPI_REQUEST_NULL) MPI_Waitall(3, sendRequest, MPI_STATUS_IGNORE);
+         UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForSendData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
+      }
+
+      counterPrepareForSend++;
+
+      if(counterPrepareForSend==nofStoredVectors)
+      {
+         counterPrepareForSend=0;  
+      }
+
+
+      //A - non blocking
+      ////der ERSTE is entscheidend 
+      ////Grund: wenn man 
+      //// for(all trans) { trans->prepare(); trans->fillBuffer(); }
+      //// aufruft, dann wuerde u.U. der Buffer neu beschrieben werden obwohl noch nicht versendet wurde!!!
+      //counterPrepareForSend++;
+      //if(counterPrepareForSend==1)
+      //{
+      //   if(sendRequest != MPI::REQUEST_NULL) sendRequest.Wait();
+      //}
+      //
+      //if(counterPrepareForSend==nofStoredVectors)
+      //   counterPrepareForSend=0;  
+   }
+   /*==================================================================*/
+   void sendData()
+   {
+      //A - non blocking
+      //der LETZTE is entscheidend 
+      //counterSend++;
+      //if(counterSend==nofStoredVectors)
+      //{
+      //   //std::cout<<"Isend von "<<(int)nextStartIndex<<"elementen von "<<mpiRemoteRank<<" mit tag="<<mpiTag<<std::endl;
+      //   sendRequest = comm.Isend(&pool[0],(int)nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag);
+      //   counterSend=0;
+      //}
+      //B - blocking
+      //der LETZTE is entscheidend 
+      counterSend++;
+      if(counterSend==nofStoredVectors)
+      {
+         //std::cout<<"Isend von "<<(int)nextStartIndex<<"elementen von "<<mpiRemoteRank<<" mit tag="<<mpiTag<<std::endl;
+         UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
+
+         //synchronous send 
+         //comm.Ssend(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag);
+#ifdef _DEBUG
+         if(this->orgPoolVectorStartPointer != &this->pool[0] ) throw UbException(UB_EXARGS, "ups, pool array adress changed - unknown behavoir");
+#endif
+
+         //standard send
+         MPI_Send(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm);
+         UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
+////////////////////////////////////////////////////////////////////////////////////////////
+//DEBUG///////////////////////////////////////
+         //int irank;
+         //MPI_Comm_rank(MPI_COMM_WORLD, &irank);
+         //std::cout << "MPI_Send: " << irank <<  " "  << mpiRemoteRank << " "  <<mpiTag<<std::endl;
+///////////////////////////////////////////////////
+         counterSend=0;
+      }                           
+   }
+   /*==================================================================*/
+   void prepareForReceiveData()
+   {
+      //A - non blocking
+      //sobald der Letzte kann man den den request holen.
+      //andernfalls kann nicht gewaehrleistet werden, dass evtl noch mit dem buffer gearbeitet wird!!!
+      counterPrepareForReceive++;
+      if(counterPrepareForReceive==this->nofStoredVectors)
+      {
+         UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForReceiveData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
+#ifdef _DEBUG
+         if(this->orgPoolVectorStartPointer != &this->pool[0] ) throw UbException(UB_EXARGS, "ups, pool array adress changed - unknown behavoir");
+#endif
+         MPI_Irecv(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm, &receiveRequest);
+         UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForReceiveData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
+         counterPrepareForReceive=0;
+      }
+   }
+   /*==================================================================*/
+   void receiveData()
+   {
+      //A - non blocking
+      //sobald der ERSTE reinkommt muss man warten, bis received wurde!!!
+      //denn erst anschliessend stehen die empfangenen daten zur verfuegung
+      if(counterReceive==0)
+      {
+         UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
+         MPI_Wait(&receiveRequest, MPI_STATUS_IGNORE);
+         UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag);
+      }
+      counterReceive++;
+      if(counterReceive==this->nofStoredVectors) //alle receiver waren hier
+      {
+         counterReceive=0;
+      }
+
+      ////B - blocking
+      ////sobald der ERSTE reinkommt muss man warten, bis received wurde!!!
+      ////denn erst anschliessend stehen die empfangenen daten zur verfuegung
+      //if(counterReceive==0)
+      //{
+      //   comm.Recv(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag);
+      //}
+      //counterReceive++;
+      //if(counterReceive==this->nofStoredVectors) //alle receiver waren hier
+      //   counterReceive=0;
+   }
+
+protected:
+   CbVectorKey poolKey; //eindeutiger schluessel fuer pool
+   size_type nofStoredVectors;
+
+   size_type counterPrepareReceiveDataOrder;
+   size_type counterSendDataOrder;
+   size_type counterReceiveDataOrder;
+   size_type counterPrepareForReceive;
+   size_type counterReceive;
+   size_type counterPrepareForSend;
+   size_type counterSend;
+
+   std::vector< unsigned > tmpSendOrderVec; //wird zur temp speicherung der anordnung benoetigt
+   std::string tmpSendOrderKeyVec;
+   unsigned tmpSendOrderKeyVecLength;
+
+   MPI_Comm     comm;
+   MPI_Request  receiveRequest;
+   //MPI_Request  sendRequest;
+   MPI_Request  sendRequest[3];
+   //MPI_Status   sendStatus;
+   //MPI_Status   receiveStatus;
+   MPI_Datatype mpiDataType;
+
+   int mpiRemoteRank, mpiTag;
+
+#ifdef _DEBUG
+   T* orgPoolVectorStartPointer;
+#endif
+};
+
+template<typename T>
+typename TbCbVectorMpiPool<T>::MpiPoolPtrMap TbCbVectorMpiPool<T>::poolMap;
+
+//////////////////////////////////////////////////////////////////////////
+//  TbSenderMpiPool
+//////////////////////////////////////////////////////////////////////////
+template<typename T>
+class TbCbVectorSenderMpiPool : public TbTransmitter< CbVector< T >  >
+{
+public:
+   typedef CbVector< T > value_type;
+
+public:
+   TbCbVectorSenderMpiPool(std::string cbVectorKey, TbCbVectorMpiPool< T >* mpiVectorPool)
+      : mpiVectorPool(mpiVectorPool)
+   { 
+      this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey,this->mpiVectorPool) );
+   }
+   ~TbCbVectorSenderMpiPool()
+   {
+      if( this->mpiVectorPool->getNofStoredVectors()==1 ) //last entry!
+      {
+         TbCbVectorMpiPool< T >::deleteTbCbVectorMpiPool(this->mpiVectorPool->getPoolKey());  
+      }
+   }
+
+   bool isLocalTransmitter()  const { return false;                        }
+   bool isRemoteTransmitter() const { return !this->isLocalTransmitter();  }
+
+   void sendDataSize()          { this->mpiVectorPool->sendDataOrder(); }
+   void receiveDataSize()       { throw UbException(UB_EXARGS,"TbMpiPoolSender sends only");  }   
+   CbVector< T >& receiveData() { throw UbException(UB_EXARGS,"TbMpiPoolSender sends only");  }
+   void prepareForSend()        { this->mpiVectorPool->prepareForSendData(); }
+   void sendData()              { this->mpiVectorPool->sendData(); }
+
+   //info-section (usable for remote transmitter)
+   int  getSendTbRank()   const { return  this->mpiVectorPool->getRemoteRank(); }
+   int  getSendTbTag()    const { return  this->mpiVectorPool->getRemoteTag();  }
+   int  getRecvFromRank() const { throw UbException(UB_EXARGS,"TbCbVectorSenderMpiPool sends only"); }
+   int  getRecvFromTag()  const { throw UbException(UB_EXARGS,"TbCbVectorSenderMpiPool sends only"); }
+
+   std::string toString() const { return "TbCbVectorSenderMpiPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getSendTbRank())+"("+UbSystem::toString(getSendTbTag())+")"; }
+
+protected:
+   TbCbVectorMpiPool<T>* mpiVectorPool;
+};
+
+
+/*==================================================================*/
+template<typename T>
+class TbCbVectorReceiverMpiPool : public TbTransmitter< CbVector< T >  >
+{
+public:
+   typedef CbVector< T > value_type;   
+
+public:
+   TbCbVectorReceiverMpiPool(std::string cbVectorKey, TbCbVectorMpiPool< T >* mpiVectorPool)
+      : mpiVectorPool(mpiVectorPool)
+   { 
+      this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey, this->mpiVectorPool) );
+   }
+   ~TbCbVectorReceiverMpiPool()
+   {
+      if( this->mpiVectorPool->getNofStoredVectors()==1 ) //last entry!
+      {
+         TbCbVectorMpiPool< T >::deleteTbCbVectorMpiPool(this->mpiVectorPool->getPoolKey());  
+      }
+   }
+   bool isLocalTransmitter()  const { return false;                        }
+   bool isRemoteTransmitter() const { return !this->isLocalTransmitter();  }
+
+   void sendDataSize()      { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only");  }   
+   void receiveDataSize()   { this->mpiVectorPool->receiveDataOrder(); }  
+   void sendData()          { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); }
+   void prepareForReceive() { this->mpiVectorPool->prepareForReceiveData(); }
+   CbVector< T >& receiveData()
+   { 
+      this->mpiVectorPool->receiveData();
+      return this->getData();
+   }
+
+   //info-section (usable for remote transmitter)
+   int  getSendTbRank()   const { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); }
+   int  getSendTbTag()    const { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); }
+   int  getRecvFromRank() const { return  this->mpiVectorPool->getRemoteRank();  }
+   int  getRecvFromTag()  const { return  this->mpiVectorPool->getRemoteTag();  }
+
+   std::string toString() const { return "TbCbVectorReceiverMpiPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getRecvFromRank())+"("+UbSystem::toString(getRecvFromTag())+")"; }
+
+protected:
+   TbCbVectorMpiPool<T>* mpiVectorPool;
+};
+
+#endif //VF_MPI
+
+#endif //TBTRANSMITTERMPIPOOL_H
+ 
diff --git a/source/ThirdParty/Library/basics/utilities/CMakePackage.txt b/source/VirtualFluidsBasic/basics/utilities/CMakePackage.txt
similarity index 96%
rename from source/ThirdParty/Library/basics/utilities/CMakePackage.txt
rename to source/VirtualFluidsBasic/basics/utilities/CMakePackage.txt
index 2bae505538e07aa6c724c29a4b8d472975ef29e0..0127c6fb70ba58900bfa7e273ffb1e02ece1c37e 100644
--- a/source/ThirdParty/Library/basics/utilities/CMakePackage.txt
+++ b/source/VirtualFluidsBasic/basics/utilities/CMakePackage.txt
@@ -1,21 +1,21 @@
-GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
-COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES outOption)
-
-IF(${outOption})
-   IF(WIN32)
-      ADD_DEFINITIONS( -DNOMINMAX )
-   ENDIF(WIN32) 
-   
-   IF(BOOST_VERSION)
-    OPTION(USE_THREADSAFE_LOGGER "ON=thread safe, OFF=not thread safe" ON)
-    IF(NOT ${outOption})
-      ADD_DEFINITIONS( -DNO_THREADSAFE_LOGGING)
-    ELSE()
-      SET(NECESSARY_BOOST_LIBS ${NECESSARY_BOOST_LIBS} thread)
-    ENDIF()
-   ELSE()
-    #um die thread safe zu machen benoetigt man boost
-    ADD_DEFINITIONS( -DNO_THREADSAFE_LOGGING)
-   ENDIF()
-  
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES outOption)
+
+IF(${outOption})
+   IF(WIN32)
+      ADD_DEFINITIONS( -DNOMINMAX )
+   ENDIF(WIN32) 
+   
+   IF(BOOST_VERSION)
+    OPTION(USE_THREADSAFE_LOGGER "ON=thread safe, OFF=not thread safe" ON)
+    IF(NOT ${outOption})
+      ADD_DEFINITIONS( -DNO_THREADSAFE_LOGGING)
+    ELSE()
+      SET(NECESSARY_BOOST_LIBS ${NECESSARY_BOOST_LIBS} thread)
+    ENDIF()
+   ELSE()
+    #um die thread safe zu machen benoetigt man boost
+    ADD_DEFINITIONS( -DNO_THREADSAFE_LOGGING)
+   ENDIF()
+  
 ENDIF()
\ No newline at end of file
diff --git a/source/ThirdParty/Library/basics/utilities/UbAutoRun.hpp b/source/VirtualFluidsBasic/basics/utilities/UbAutoRun.hpp
similarity index 98%
rename from source/ThirdParty/Library/basics/utilities/UbAutoRun.hpp
rename to source/VirtualFluidsBasic/basics/utilities/UbAutoRun.hpp
index c9ac45115bb4ff37c45d69e101e9a58d936e5d7e..50fcf37b648b87502516a34dab93260e619d9d95 100644
--- a/source/ThirdParty/Library/basics/utilities/UbAutoRun.hpp
+++ b/source/VirtualFluidsBasic/basics/utilities/UbAutoRun.hpp
@@ -1,58 +1,58 @@
-#ifndef UB_AUTORUN_HPP
-#define UB_AUTORUN_HPP
-
-#define UB_AUTO_RUN(func)                              UB_AUTO_RUN_(func,  __LINE__)
-#define UB_AUTO_RUN_(func, nID)                        UB_AUTO_RUN__(func, nID)
-#define UB_AUTO_RUN__(func, nID)                       UB_AUTO_RUN___(func, nID)
-#define UB_AUTO_RUN___(func, ID)                                                           \
-    namespace {                                                                         \
-        struct UbAutoRun##ID {                                                            \
-            UbAutoRun##ID() {                                                             \
-                func;                                                                   \
-            }                                                                           \
-        } UbAutoRunInst##ID;                                                              \
-    }
-
-    // More concise to implement UB_AUTO_RUN using the following, but BCB emits an ICE on it.
-    //static bool UB_AutoRun##ID = ( func , false);
-
-
-#define UB_AUTO_RUN_1(func)                            UB_AUTO_RUN_NAMED(func, 1)                   
-#define UB_AUTO_RUN_2(func)                            UB_AUTO_RUN_NAMED(func, 2)                   
-#define UB_AUTO_RUN_3(func)                            UB_AUTO_RUN_NAMED(func, 3)                   
-#define UB_AUTO_RUN_4(func)                            UB_AUTO_RUN_NAMED(func, 4)                   
-#define UB_AUTO_RUN_5(func)                            UB_AUTO_RUN_NAMED(func, 5)                   
-                                                       
-#define UB_AUTO_RUN_NAMED(func, name)                  UB_AUTO_RUN_NAMED_(func, name, __LINE__)
-#define UB_AUTO_RUN_NAMED_(func, name, nID)            UB_AUTO_RUN_NAMED__(func, name, nID)
-#define UB_AUTO_RUN_NAMED__(func, name, nID)           UB_AUTO_RUN___(func, _##name##_##nID)
-                                                       
-#define UB_AUTO_RUN_ONCE(func)                         UB_AUTO_RUN_ONCE_(func,  __LINE__)
-#define UB_AUTO_RUN_ONCE_(func, nID)                   UB_AUTO_RUN_ONCE__(func, nID)
-#define UB_AUTO_RUN_ONCE__(func, nID)                  UB_AUTO_RUN_ONCE___(func, nID)
-#define UB_AUTO_RUN_ONCE___(func, ID)                                                   \
-    struct UbAutoRunOnce##ID {                                                            \
-        UbAutoRunOnce##ID() {                                                             \
-            if (!init()) {                                                              \
-                init() = true;                                                          \
-                func;                                                                   \
-            }                                                                           \
-        }                                                                               \
-        static bool &init() {                                                           \
-            static bool bInit = false;                                                  \
-            return bInit;                                                               \
-        }                                                                               \
-    };                                                                                  \
-    static UbAutoRunOnce##ID AutoRunOnceInst##ID;
-
-#define UB_AUTO_RUN_ONCE_1(func)                           UB_AUTO_RUN_ONCE_NAMED(func, 1)                   
-#define UB_AUTO_RUN_ONCE_2(func)                           UB_AUTO_RUN_ONCE_NAMED(func, 2)                   
-#define UB_AUTO_RUN_ONCE_3(func)                           UB_AUTO_RUN_ONCE_NAMED(func, 3)                   
-#define UB_AUTO_RUN_ONCE_4(func)                           UB_AUTO_RUN_ONCE_NAMED(func, 4)                   
-#define UB_AUTO_RUN_ONCE_5(func)                           UB_AUTO_RUN_ONCE_NAMED(func, 5)                   
-                                                           
-#define UB_AUTO_RUN_ONCE_NAMED(func, name)                 UB_AUTO_RUN_ONCE_NAMED_(func, name, __LINE__)
-#define UB_AUTO_RUN_ONCE_NAMED_(func, name, nID)           UB_AUTO_RUN_ONCE_NAMED__(func, name, nID)
-#define UB_AUTO_RUN_ONCE_NAMED__(func, name, nID)          UB_AUTO_RUN_ONCE___(func, _##name##_##nID)
-
-#endif // ! UB_AUTORUN_HPP
+#ifndef UB_AUTORUN_HPP
+#define UB_AUTORUN_HPP
+
+#define UB_AUTO_RUN(func)                              UB_AUTO_RUN_(func,  __LINE__)
+#define UB_AUTO_RUN_(func, nID)                        UB_AUTO_RUN__(func, nID)
+#define UB_AUTO_RUN__(func, nID)                       UB_AUTO_RUN___(func, nID)
+#define UB_AUTO_RUN___(func, ID)                                                           \
+    namespace {                                                                         \
+        struct UbAutoRun##ID {                                                            \
+            UbAutoRun##ID() {                                                             \
+                func;                                                                   \
+            }                                                                           \
+        } UbAutoRunInst##ID;                                                              \
+    }
+
+    // More concise to implement UB_AUTO_RUN using the following, but BCB emits an ICE on it.
+    //static bool UB_AutoRun##ID = ( func , false);
+
+
+#define UB_AUTO_RUN_1(func)                            UB_AUTO_RUN_NAMED(func, 1)                   
+#define UB_AUTO_RUN_2(func)                            UB_AUTO_RUN_NAMED(func, 2)                   
+#define UB_AUTO_RUN_3(func)                            UB_AUTO_RUN_NAMED(func, 3)                   
+#define UB_AUTO_RUN_4(func)                            UB_AUTO_RUN_NAMED(func, 4)                   
+#define UB_AUTO_RUN_5(func)                            UB_AUTO_RUN_NAMED(func, 5)                   
+                                                       
+#define UB_AUTO_RUN_NAMED(func, name)                  UB_AUTO_RUN_NAMED_(func, name, __LINE__)
+#define UB_AUTO_RUN_NAMED_(func, name, nID)            UB_AUTO_RUN_NAMED__(func, name, nID)
+#define UB_AUTO_RUN_NAMED__(func, name, nID)           UB_AUTO_RUN___(func, _##name##_##nID)
+                                                       
+#define UB_AUTO_RUN_ONCE(func)                         UB_AUTO_RUN_ONCE_(func,  __LINE__)
+#define UB_AUTO_RUN_ONCE_(func, nID)                   UB_AUTO_RUN_ONCE__(func, nID)
+#define UB_AUTO_RUN_ONCE__(func, nID)                  UB_AUTO_RUN_ONCE___(func, nID)
+#define UB_AUTO_RUN_ONCE___(func, ID)                                                   \
+    struct UbAutoRunOnce##ID {                                                            \
+        UbAutoRunOnce##ID() {                                                             \
+            if (!init()) {                                                              \
+                init() = true;                                                          \
+                func;                                                                   \
+            }                                                                           \
+        }                                                                               \
+        static bool &init() {                                                           \
+            static bool bInit = false;                                                  \
+            return bInit;                                                               \
+        }                                                                               \
+    };                                                                                  \
+    static UbAutoRunOnce##ID AutoRunOnceInst##ID;
+
+#define UB_AUTO_RUN_ONCE_1(func)                           UB_AUTO_RUN_ONCE_NAMED(func, 1)                   
+#define UB_AUTO_RUN_ONCE_2(func)                           UB_AUTO_RUN_ONCE_NAMED(func, 2)                   
+#define UB_AUTO_RUN_ONCE_3(func)                           UB_AUTO_RUN_ONCE_NAMED(func, 3)                   
+#define UB_AUTO_RUN_ONCE_4(func)                           UB_AUTO_RUN_ONCE_NAMED(func, 4)                   
+#define UB_AUTO_RUN_ONCE_5(func)                           UB_AUTO_RUN_ONCE_NAMED(func, 5)                   
+                                                           
+#define UB_AUTO_RUN_ONCE_NAMED(func, name)                 UB_AUTO_RUN_ONCE_NAMED_(func, name, __LINE__)
+#define UB_AUTO_RUN_ONCE_NAMED_(func, name, nID)           UB_AUTO_RUN_ONCE_NAMED__(func, name, nID)
+#define UB_AUTO_RUN_ONCE_NAMED__(func, name, nID)          UB_AUTO_RUN_ONCE___(func, _##name##_##nID)
+
+#endif // ! UB_AUTORUN_HPP
diff --git a/source/ThirdParty/Library/basics/utilities/UbComparators.h b/source/VirtualFluidsBasic/basics/utilities/UbComparators.h
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbComparators.h
rename to source/VirtualFluidsBasic/basics/utilities/UbComparators.h
index 2d1448c93b6c0ee2b6361aad87a379140ffa0f49..ee809cf1c8ac1ef369ed0a9828401380d7da5300 100644
--- a/source/ThirdParty/Library/basics/utilities/UbComparators.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbComparators.h
@@ -1,208 +1,208 @@
-#ifndef UBCOMPARATORS_H 
-#define UBCOMPARATORS_H
-
-#include <functional> 
-
-/*=========================================================================*/
-/*  UbComparators                                                             */
-/*                                                                         */
-/**
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 16.08.2007
-*/ 
-
-namespace UbComparators
-{
-   //type_traits 
-   template <typename T> struct MemberInfo; //not defined for correct compiler errors!
-
-   // specialization for MemberFunctionsPtr
-   // C - class with return T method
-   template <typename T, typename C> 
-   struct MemberInfo<T C::*> 
-   { 
-      typedef T type; 
-      typedef C class_type; 
-
-      static       T& apply(       C& c, T C::* ptr ) { return c.*ptr; } 
-      static const T& apply( const C& c, T C::* ptr ) { return c.*ptr; } 
-   }; 
-   //specialization for MemberFunctionsPtr
-   //C - class with return T method
-   template <typename T, typename C> 
-   struct MemberInfo<T (C::*)()> 
-   { 
-      typedef T type; 
-      typedef C class_type; 
-
-      static T apply( C& c, T (C::*ptr)() ) { return (c.*ptr)(); } 
-   }; 
-   //specialization for const MemberFunctionsPtr
-   //C - class with return T method
-   template <typename T, typename C> 
-   struct MemberInfo<T (C::*)() const> 
-   { 
-      typedef T type; 
-      typedef C class_type; 
-
-      static T apply( const C& c, T (C::*ptr)() const ) { return (c.*ptr)(); } 
-   }; 
-
-   //MemberComparative-Class
-   template <typename Ptr, typename Comp = std::less<typename MemberInfo<Ptr>::type> > 
-   class MemComp 
-      : private Comp  // -> usage of Empty Base Class Optimization (EBCO) 
-   { 
-      typedef typename MemberInfo<Ptr>::class_type C; 
-
-   public: 
-      MemComp( Ptr ptr, Comp c = Comp() ) 
-         : Comp(c), mp_(ptr) 
-      {} 
-
-      bool operator()(C& lhs, C& rhs) 
-      { 
-         return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); 
-      } 
-      bool operator()(C& lhs, C& rhs) const 
-      { 
-         return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); 
-      } 
-      bool operator()(const C& lhs, const C& rhs) 
-      { 
-         return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); 
-      } 
-      bool operator()(const C& lhs, const C& rhs) const 
-      { 
-         return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); 
-      } 
-
-   private: 
-      Ptr mp_; 
-   }; 
-
-   // Factoryfunktionen 
-   template <typename Ptr> 
-   MemComp<Ptr> membercomp(Ptr p) 
-   { 
-      return MemComp<Ptr>(p); 
-   } 
-
-   template<typename Comp, typename Ptr> 
-   MemComp<Ptr, Comp> membercomp(Ptr p, Comp c = Comp()) 
-   { 
-      return MemComp<Ptr, Comp>(p, c); 
-   } 
-
-   template<template<typename> class Comp, typename Ptr> 
-   MemComp<Ptr, Comp<typename MemberInfo<Ptr>::type> > 
-      membercomp(Ptr p, Comp<typename MemberInfo<Ptr>::type> c = Comp<typename MemberInfo<Ptr>::type>()) 
-   {
-      return MemComp<Ptr, Comp<typename MemberInfo<Ptr>::type> >(p, c); 
-   } 
-
-    
-   //////////////////////////////////////////////////////////////////////////
-   //////////////////////////////////////////////////////////////////////////
-   //////////////////////////////////////////////////////////////////////////
-   //andere Variante (alerdings ist hier keine Deduction moeglich!!!)
-   //////////////////////////////////////////////////////////////////////////
-   //Vergleichs-Templates:
-   //Funktor zum "non-const" Methodenvergleich: liste.sort( compareMethods<Klasse, int, &Klasse::getVal1  );
-   template<typename K/*Klasse*/, typename M /*MethodenRueckgabeTyp*/, M (K::*fct)() /*MethodenPointer*/> // Allgemeiner Fall
-   struct compareMethods
-   {
-      bool operator()(K& r, K& l) const // da fct nicht const ist, kann auch K nicht const sein. das const hinter der deklaration besagt dass compareMethods const sein kann
-      { return (r.*fct)() < (l.*fct)();  }
-   };
-   //////////////////////////////////////////////////////////////////////////
-   //Funktor zum "const" Methodenvergleich: liste.sort( compareMethods<Klasse, int, &Klasse::getVal1  );
-   template<typename K/*Klasse*/, typename M /*MethodenRueckgabeTyp*/, M (K::*fct)() const /*MethodenPointer*/> // <- hier const 
-   struct compareConstMethods
-   {
-      bool operator()(const K& r, const K& l) const //hier koennen die K's auch const sein, muessen sie aber nicht (const hinzufuegen geht ja problemlos)
-      { return (r.*fct)() < (l.*fct)();  }
-   };
-   //////////////////////////////////////////////////////////////////////////
-   //Funktor zum Membervergleich: lise.sort( compareMember<Klasse, int, &Klasse::member>() );
-   template<typename K/*Klasse*/, typename M /*MemberTyp*/, M (K::*Member) /*MemberPointer*/> // <- hier const 
-   struct compareMember
-   { 
-      bool operator()(const K& r,const K& l) const
-      { return r.*Member < l.*Member; } 
-   };
-   //Bsp:
-   //class Klasse{ 
-   //public: 
-   //   Klasse(double val1, double val2 ) : val1(val1),val2(val2) {} 
-   //   double getVal1()       { return val1; } 
-   //   double getVal2() const { return val2; } // <- hier const
-   //   double val1, val2; 
-   //}; 
-   //int main(int argc, char** argv){ 
-   //   std::list<Klasse> l; 
-   //   l.push_back( Klasse(10,10) ); 
-   //   l.push_back( Klasse(1,5)   ); 
-   //   l.sort( compareMember<Klasse, double,  &Klasse::val1 >() ); 
-   //   l.sort( compareMethods<Klasse, double,  &Klasse::getVal1 >() ); 
-   //   l.sort( compareConstMethods<Klasse, double,  &Klasse::getVal1 >() ); 
-   //} 
-
-};
-
-#endif //UBCOMPARATOR_H
-
-//example
-// #include <basics/utilities/UbComparators.h" 
-// #include <list> 
-// using namespace std; 
-// using namespace UbComparators; 
-// 
-// struct S { 
-//    S(int i) :x(i) {} 
-//    int x; 
-//    float f() {return x;}; 
-//    double g() const {return x;} 
-// }; 
-// 
-// struct intComp { 
-//    bool operator()(int l, int r) const 
-//    { return l > r; } 
-// }; 
-// 
-// struct dblComp { 
-//    bool operator()(double l,  double r) const 
-//    { return l > r; } 
-// }; 
-// 
-// template <typename T> 
-// struct genComp { 
-//    bool operator()(const T& l, const T& r) const
-//    { return l > r; } 
-// }; 
-// 
-// 
-// int main() 
-// { 
-//    S a(1); 
-//    S b(2); 
-//    list<S> sList; 
-//    sList.push_back(a); 
-//    sList.push_back(b); 
-//    sList.sort(UbComparators::membercomp(&S::x,intComp()));  //calls overload (1) 
-//    sList.sort(UbComparators::membercomp<intComp>(&S::x));   //same 
-//    sList.sort(UbComparators::membercomp(&S::x));            //calls overload (5) 
-//    sList.sort(UbComparators::membercomp<genComp>(&S::x));   //calls overload(3) 
-//    sList.sort(UbComparators::membercomp(&S::x, genComp<int>())); //calls overload(1) 
-//    //same for nonconst function 
-//    sList.sort(UbComparators::membercomp(&S::f, dblComp())); //overload(2) 
-//    sList.sort(UbComparators::membercomp<dblComp>(&S::f));   //same      
-//    sList.sort(UbComparators::membercomp(&S::f));            //overload(6) 
-//    sList.sort(UbComparators::membercomp<genComp>(&S::f));   //overload(4) 
-//    //same for const function 
-//    sList.sort(UbComparators::membercomp(&S::g, dblComp())); //overload(2) 
-//    sList.sort(UbComparators::membercomp<dblComp>(&S::g));   //same      
-//    sList.sort(UbComparators::membercomp(&S::g));            //overload(6) 
-//    sList.sort(UbComparators::membercomp<genComp>(&S::g));   //overload(4) 
-// } 
+#ifndef UBCOMPARATORS_H 
+#define UBCOMPARATORS_H
+
+#include <functional> 
+
+/*=========================================================================*/
+/*  UbComparators                                                             */
+/*                                                                         */
+/**
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 16.08.2007
+*/ 
+
+namespace UbComparators
+{
+   //type_traits 
+   template <typename T> struct MemberInfo; //not defined for correct compiler errors!
+
+   // specialization for MemberFunctionsPtr
+   // C - class with return T method
+   template <typename T, typename C> 
+   struct MemberInfo<T C::*> 
+   { 
+      typedef T type; 
+      typedef C class_type; 
+
+      static       T& apply(       C& c, T C::* ptr ) { return c.*ptr; } 
+      static const T& apply( const C& c, T C::* ptr ) { return c.*ptr; } 
+   }; 
+   //specialization for MemberFunctionsPtr
+   //C - class with return T method
+   template <typename T, typename C> 
+   struct MemberInfo<T (C::*)()> 
+   { 
+      typedef T type; 
+      typedef C class_type; 
+
+      static T apply( C& c, T (C::*ptr)() ) { return (c.*ptr)(); } 
+   }; 
+   //specialization for const MemberFunctionsPtr
+   //C - class with return T method
+   template <typename T, typename C> 
+   struct MemberInfo<T (C::*)() const> 
+   { 
+      typedef T type; 
+      typedef C class_type; 
+
+      static T apply( const C& c, T (C::*ptr)() const ) { return (c.*ptr)(); } 
+   }; 
+
+   //MemberComparative-Class
+   template <typename Ptr, typename Comp = std::less<typename MemberInfo<Ptr>::type> > 
+   class MemComp 
+      : private Comp  // -> usage of Empty Base Class Optimization (EBCO) 
+   { 
+      typedef typename MemberInfo<Ptr>::class_type C; 
+
+   public: 
+      MemComp( Ptr ptr, Comp c = Comp() ) 
+         : Comp(c), mp_(ptr) 
+      {} 
+
+      bool operator()(C& lhs, C& rhs) 
+      { 
+         return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); 
+      } 
+      bool operator()(C& lhs, C& rhs) const 
+      { 
+         return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); 
+      } 
+      bool operator()(const C& lhs, const C& rhs) 
+      { 
+         return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); 
+      } 
+      bool operator()(const C& lhs, const C& rhs) const 
+      { 
+         return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); 
+      } 
+
+   private: 
+      Ptr mp_; 
+   }; 
+
+   // Factoryfunktionen 
+   template <typename Ptr> 
+   MemComp<Ptr> membercomp(Ptr p) 
+   { 
+      return MemComp<Ptr>(p); 
+   } 
+
+   template<typename Comp, typename Ptr> 
+   MemComp<Ptr, Comp> membercomp(Ptr p, Comp c = Comp()) 
+   { 
+      return MemComp<Ptr, Comp>(p, c); 
+   } 
+
+   template<template<typename> class Comp, typename Ptr> 
+   MemComp<Ptr, Comp<typename MemberInfo<Ptr>::type> > 
+      membercomp(Ptr p, Comp<typename MemberInfo<Ptr>::type> c = Comp<typename MemberInfo<Ptr>::type>()) 
+   {
+      return MemComp<Ptr, Comp<typename MemberInfo<Ptr>::type> >(p, c); 
+   } 
+
+    
+   //////////////////////////////////////////////////////////////////////////
+   //////////////////////////////////////////////////////////////////////////
+   //////////////////////////////////////////////////////////////////////////
+   //andere Variante (alerdings ist hier keine Deduction moeglich!!!)
+   //////////////////////////////////////////////////////////////////////////
+   //Vergleichs-Templates:
+   //Funktor zum "non-const" Methodenvergleich: liste.sort( compareMethods<Klasse, int, &Klasse::getVal1  );
+   template<typename K/*Klasse*/, typename M /*MethodenRueckgabeTyp*/, M (K::*fct)() /*MethodenPointer*/> // Allgemeiner Fall
+   struct compareMethods
+   {
+      bool operator()(K& r, K& l) const // da fct nicht const ist, kann auch K nicht const sein. das const hinter der deklaration besagt dass compareMethods const sein kann
+      { return (r.*fct)() < (l.*fct)();  }
+   };
+   //////////////////////////////////////////////////////////////////////////
+   //Funktor zum "const" Methodenvergleich: liste.sort( compareMethods<Klasse, int, &Klasse::getVal1  );
+   template<typename K/*Klasse*/, typename M /*MethodenRueckgabeTyp*/, M (K::*fct)() const /*MethodenPointer*/> // <- hier const 
+   struct compareConstMethods
+   {
+      bool operator()(const K& r, const K& l) const //hier koennen die K's auch const sein, muessen sie aber nicht (const hinzufuegen geht ja problemlos)
+      { return (r.*fct)() < (l.*fct)();  }
+   };
+   //////////////////////////////////////////////////////////////////////////
+   //Funktor zum Membervergleich: lise.sort( compareMember<Klasse, int, &Klasse::member>() );
+   template<typename K/*Klasse*/, typename M /*MemberTyp*/, M (K::*Member) /*MemberPointer*/> // <- hier const 
+   struct compareMember
+   { 
+      bool operator()(const K& r,const K& l) const
+      { return r.*Member < l.*Member; } 
+   };
+   //Bsp:
+   //class Klasse{ 
+   //public: 
+   //   Klasse(double val1, double val2 ) : val1(val1),val2(val2) {} 
+   //   double getVal1()       { return val1; } 
+   //   double getVal2() const { return val2; } // <- hier const
+   //   double val1, val2; 
+   //}; 
+   //int main(int argc, char** argv){ 
+   //   std::list<Klasse> l; 
+   //   l.push_back( Klasse(10,10) ); 
+   //   l.push_back( Klasse(1,5)   ); 
+   //   l.sort( compareMember<Klasse, double,  &Klasse::val1 >() ); 
+   //   l.sort( compareMethods<Klasse, double,  &Klasse::getVal1 >() ); 
+   //   l.sort( compareConstMethods<Klasse, double,  &Klasse::getVal1 >() ); 
+   //} 
+
+};
+
+#endif //UBCOMPARATOR_H
+
+//example
+// #include <basics/utilities/UbComparators.h" 
+// #include <list> 
+// using namespace std; 
+// using namespace UbComparators; 
+// 
+// struct S { 
+//    S(int i) :x(i) {} 
+//    int x; 
+//    float f() {return x;}; 
+//    double g() const {return x;} 
+// }; 
+// 
+// struct intComp { 
+//    bool operator()(int l, int r) const 
+//    { return l > r; } 
+// }; 
+// 
+// struct dblComp { 
+//    bool operator()(double l,  double r) const 
+//    { return l > r; } 
+// }; 
+// 
+// template <typename T> 
+// struct genComp { 
+//    bool operator()(const T& l, const T& r) const
+//    { return l > r; } 
+// }; 
+// 
+// 
+// int main() 
+// { 
+//    S a(1); 
+//    S b(2); 
+//    list<S> sList; 
+//    sList.push_back(a); 
+//    sList.push_back(b); 
+//    sList.sort(UbComparators::membercomp(&S::x,intComp()));  //calls overload (1) 
+//    sList.sort(UbComparators::membercomp<intComp>(&S::x));   //same 
+//    sList.sort(UbComparators::membercomp(&S::x));            //calls overload (5) 
+//    sList.sort(UbComparators::membercomp<genComp>(&S::x));   //calls overload(3) 
+//    sList.sort(UbComparators::membercomp(&S::x, genComp<int>())); //calls overload(1) 
+//    //same for nonconst function 
+//    sList.sort(UbComparators::membercomp(&S::f, dblComp())); //overload(2) 
+//    sList.sort(UbComparators::membercomp<dblComp>(&S::f));   //same      
+//    sList.sort(UbComparators::membercomp(&S::f));            //overload(6) 
+//    sList.sort(UbComparators::membercomp<genComp>(&S::f));   //overload(4) 
+//    //same for const function 
+//    sList.sort(UbComparators::membercomp(&S::g, dblComp())); //overload(2) 
+//    sList.sort(UbComparators::membercomp<dblComp>(&S::g));   //same      
+//    sList.sort(UbComparators::membercomp(&S::g));            //overload(6) 
+//    sList.sort(UbComparators::membercomp<genComp>(&S::g));   //overload(4) 
+// } 
diff --git a/source/ThirdParty/Library/basics/utilities/UbConverter.cpp b/source/VirtualFluidsBasic/basics/utilities/UbConverter.cpp
similarity index 96%
rename from source/ThirdParty/Library/basics/utilities/UbConverter.cpp
rename to source/VirtualFluidsBasic/basics/utilities/UbConverter.cpp
index ad5a99923c0985192555d6ed95efd7502a0efe18..dcdf17f5d39f4d8c2be285fb15d3e6c5bae306cd 100644
--- a/source/ThirdParty/Library/basics/utilities/UbConverter.cpp
+++ b/source/VirtualFluidsBasic/basics/utilities/UbConverter.cpp
@@ -1,96 +1,96 @@
-#include <basics/utilities/UbConverter.h>
-
-const std::string UbConverter::base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                                              "abcdefghijklmnopqrstuvwxyz"
-                                              "0123456789+/";
-
-
-std::string UbConverter::base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) 
-{
-   std::string ret;
-   int i = 0;
-   int j = 0;
-   unsigned char char_array_3[3];
-   unsigned char char_array_4[4];
-
-   while (in_len--)
-   {
-      char_array_3[i++] = *(bytes_to_encode++);
-      if( i==3)
-      {
-         char_array_4[0] = ( char_array_3[0] & 0xfc) >> 2;
-         char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
-         char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
-         char_array_4[3] = char_array_3[2] & 0x3f;
-
-         for( i=0; i<4 ; i++)
-            ret += base64_chars[char_array_4[i]];
-         i=0;
-      }
-   }
-
-   if( i )
-   {
-      for( j=i; j<3; j++)
-         char_array_3[j] = '\0';
-
-      char_array_4[0] = ( char_array_3[0] & 0xfc) >> 2;
-      char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
-      char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
-      char_array_4[3] = char_array_3[2] & 0x3f;
-
-      for ( j=0; j<i+1; j++)
-         ret += base64_chars[char_array_4[j]];
-
-      while( i++<3 )
-         ret += '=';
-   }
-
-   return ret;
-}
-/*=======================================================*/
-std::string UbConverter::base64_decode(std::string const& encoded_string) 
-{
-   int in_len = (int)encoded_string.size();
-   int i = 0;
-   int j = 0;
-   int in_ = 0;
-   unsigned char char_array_4[4], char_array_3[3];
-   std::string ret;
-
-   while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) 
-   {
-      char_array_4[i++] = encoded_string[in_]; in_++;
-      if(i ==4)
-      {
-         for (i = 0; i <4; i++)
-            char_array_4[i] = (unsigned char)base64_chars.find(char_array_4[i]);
-
-         char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
-         char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
-         char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
-
-         for (i = 0; (i < 3); i++)
-            ret += char_array_3[i];
-         i = 0;
-      }
-   }
-
-   if( i )
-   {
-      for(j = i; j <4; j++)
-         char_array_4[j] = 0;
-
-      for(j = 0; j <4; j++)
-         char_array_4[j] = (unsigned char)base64_chars.find(char_array_4[j]);
-
-      char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
-      char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
-      char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
-
-      for(j = 0; (j < i - 1); j++) 
-         ret += char_array_3[j];
-   }
-
-   return ret;
-}
+#include <basics/utilities/UbConverter.h>
+
+const std::string UbConverter::base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                                              "abcdefghijklmnopqrstuvwxyz"
+                                              "0123456789+/";
+
+
+std::string UbConverter::base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) 
+{
+   std::string ret;
+   int i = 0;
+   int j = 0;
+   unsigned char char_array_3[3];
+   unsigned char char_array_4[4];
+
+   while (in_len--)
+   {
+      char_array_3[i++] = *(bytes_to_encode++);
+      if( i==3)
+      {
+         char_array_4[0] = ( char_array_3[0] & 0xfc) >> 2;
+         char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
+         char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
+         char_array_4[3] = char_array_3[2] & 0x3f;
+
+         for( i=0; i<4 ; i++)
+            ret += base64_chars[char_array_4[i]];
+         i=0;
+      }
+   }
+
+   if( i )
+   {
+      for( j=i; j<3; j++)
+         char_array_3[j] = '\0';
+
+      char_array_4[0] = ( char_array_3[0] & 0xfc) >> 2;
+      char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
+      char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
+      char_array_4[3] = char_array_3[2] & 0x3f;
+
+      for ( j=0; j<i+1; j++)
+         ret += base64_chars[char_array_4[j]];
+
+      while( i++<3 )
+         ret += '=';
+   }
+
+   return ret;
+}
+/*=======================================================*/
+std::string UbConverter::base64_decode(std::string const& encoded_string) 
+{
+   int in_len = (int)encoded_string.size();
+   int i = 0;
+   int j = 0;
+   int in_ = 0;
+   unsigned char char_array_4[4], char_array_3[3];
+   std::string ret;
+
+   while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) 
+   {
+      char_array_4[i++] = encoded_string[in_]; in_++;
+      if(i ==4)
+      {
+         for (i = 0; i <4; i++)
+            char_array_4[i] = (unsigned char)base64_chars.find(char_array_4[i]);
+
+         char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
+         char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
+         char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
+
+         for (i = 0; (i < 3); i++)
+            ret += char_array_3[i];
+         i = 0;
+      }
+   }
+
+   if( i )
+   {
+      for(j = i; j <4; j++)
+         char_array_4[j] = 0;
+
+      for(j = 0; j <4; j++)
+         char_array_4[j] = (unsigned char)base64_chars.find(char_array_4[j]);
+
+      char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
+      char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
+      char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
+
+      for(j = 0; (j < i - 1); j++) 
+         ret += char_array_3[j];
+   }
+
+   return ret;
+}
diff --git a/source/ThirdParty/Library/basics/utilities/UbConverter.h b/source/VirtualFluidsBasic/basics/utilities/UbConverter.h
similarity index 96%
rename from source/ThirdParty/Library/basics/utilities/UbConverter.h
rename to source/VirtualFluidsBasic/basics/utilities/UbConverter.h
index 51e713cd47e832848d47a9db022078666222b3e6..7fd99c689e2098a3422003e658ce91a7cfb958dc 100644
--- a/source/ThirdParty/Library/basics/utilities/UbConverter.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbConverter.h
@@ -1,49 +1,49 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBCONVERTER_H 
-#define UBCONVERTER_H 
-
-#include <cstdlib> 
-#include <ctime> 
-#include <cassert> 
-#include <string>
-
-/*=========================================================================*/
-/*  UBConverter                                                             */
-/*                                                                         */
-//
-// encodes  vals to   e.g. base64
-// dencodes vals from e.g. base64
-// author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-// version 1.0 - 22.10.2007
-
-
-class UbConverter
-{
-public:
-   static std::string base64_encode(unsigned char const* , unsigned int len);
-   static std::string base64_decode(std::string const& s);
-
-   static inline bool is_base64(const unsigned char& c)
-   {
-      return (isalnum(c) || (c == '+') || (c == '/'));
-   }
-
-protected:
-   UbConverter() {}
-   ~UbConverter() {}
-
-private:
-   UbConverter(const UbConverter&);  // not implemented.
-   void operator=(const UbConverter&);  //not implemented.
-
-   static const std::string base64_chars;
-};
-
-
-
-#endif //UBCONVERTER_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBCONVERTER_H 
+#define UBCONVERTER_H 
+
+#include <cstdlib> 
+#include <ctime> 
+#include <cassert> 
+#include <string>
+
+/*=========================================================================*/
+/*  UBConverter                                                             */
+/*                                                                         */
+//
+// encodes  vals to   e.g. base64
+// dencodes vals from e.g. base64
+// author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+// version 1.0 - 22.10.2007
+
+
+class UbConverter
+{
+public:
+   static std::string base64_encode(unsigned char const* , unsigned int len);
+   static std::string base64_decode(std::string const& s);
+
+   static inline bool is_base64(const unsigned char& c)
+   {
+      return (isalnum(c) || (c == '+') || (c == '/'));
+   }
+
+protected:
+   UbConverter() {}
+   ~UbConverter() {}
+
+private:
+   UbConverter(const UbConverter&);  // not implemented.
+   void operator=(const UbConverter&);  //not implemented.
+
+   static const std::string base64_chars;
+};
+
+
+
+#endif //UBCONVERTER_H
diff --git a/source/ThirdParty/Library/basics/utilities/UbEqual.h b/source/VirtualFluidsBasic/basics/utilities/UbEqual.h
similarity index 98%
rename from source/ThirdParty/Library/basics/utilities/UbEqual.h
rename to source/VirtualFluidsBasic/basics/utilities/UbEqual.h
index e838aca00223d0e0064784dc555ee51d13efe144..8c01318af8a6c750f115466e26f3e86da21e0641 100644
--- a/source/ThirdParty/Library/basics/utilities/UbEqual.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbEqual.h
@@ -1,120 +1,120 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBEQUAL_H
-#define UBEQUAL_H
-
-#include<cmath>
-
-//////////////////////////////////////////////////////////////////////////
-//isUbEqual<T1,T2>(a,b)
-//vergleicht die gleichtheit der beiden werte a und b
-//
-//std-maessig wird hierfür der operator== verwendet
-//
-//Ausnahme: floating-points
-//hier wird jeweils der "genauere typ zum ungenaueren gecastet und dann verglichen"
-//e.g.: double d=1.2; int i=1; bool check = isUbEqual(d,i); -> true
-//
-//bei klassen muss hier operator== fuer const objecte implementiert sein!!!
-//e.g.: bool operator==(const Test&) const { if(blabla) return true; else return false; }
-//
-//
-//author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-//version 1.0 - 25.03.2008
-//////////////////////////////////////////////////////////////////////////
-
-//std-trait, fuer alle nicht spezifischen typen:
-template < typename T1, typename T2 >
-struct UbEqualTrait
-{
-   typedef T1 High;
-   typedef T1 Low;
-};
-
-//std-trait, fuer gleiche T
-template < typename T >
-struct UbEqualTrait< T, T >
-{
-   typedef T High;
-   typedef T Low;
-};
-
-//spezialisierung für diverse Typen-Tuples
-template<> struct UbEqualTrait< short, int >          { typedef int         High; typedef short  Low; };
-template<> struct UbEqualTrait< short, long >         { typedef long        High; typedef short  Low; };
-template<> struct UbEqualTrait< short, float >        { typedef float       High; typedef short  Low; };
-template<> struct UbEqualTrait< short, double >       { typedef double      High; typedef short  Low; };
-template<> struct UbEqualTrait< short, long double >  { typedef long double High; typedef short  Low; };
-
-template<> struct UbEqualTrait< int, short >          { typedef int         High; typedef short  Low; };
-template<> struct UbEqualTrait< int, long >           { typedef long        High; typedef int    Low; };
-template<> struct UbEqualTrait< int, float >          { typedef float       High; typedef int    Low; };
-template<> struct UbEqualTrait< int, double >         { typedef double      High; typedef int    Low; };
-template<> struct UbEqualTrait< int, long double >    { typedef long double High; typedef int    Low; };
-
-template<> struct UbEqualTrait< long, short >         { typedef long        High; typedef short  Low; };
-template<> struct UbEqualTrait< long, int >           { typedef long        High; typedef int    Low; };
-template<> struct UbEqualTrait< long, float >         { typedef float       High; typedef long   Low; };
-template<> struct UbEqualTrait< long, double >        { typedef double      High; typedef long   Low; };
-template<> struct UbEqualTrait< long, long double >   { typedef long double High; typedef long   Low; };
-
-template<> struct UbEqualTrait< float, short >        { typedef float       High; typedef short  Low; };
-template<> struct UbEqualTrait< float, int >          { typedef float       High; typedef int    Low; };
-template<> struct UbEqualTrait< float, long >         { typedef float       High; typedef long   Low; };
-template<> struct UbEqualTrait< float, double >       { typedef double      High; typedef float  Low; };
-template<> struct UbEqualTrait< float, long double >  { typedef long double High; typedef float  Low; };
-
-template<> struct UbEqualTrait< double, short >       { typedef double      High; typedef short  Low; };
-template<> struct UbEqualTrait< double, int >         { typedef double      High; typedef int    Low; };
-template<> struct UbEqualTrait< double, long >        { typedef double      High; typedef long   Low; };
-template<> struct UbEqualTrait< double, float >       { typedef double      High; typedef float  Low; };
-template<> struct UbEqualTrait< double, long double > { typedef long double High; typedef double Low; };
-
-template<> struct UbEqualTrait< long double, short >  { typedef long double High; typedef short  Low; };
-template<> struct UbEqualTrait< long double, int >    { typedef long double High; typedef int    Low; };
-template<> struct UbEqualTrait< long double, long >   { typedef long double High; typedef long   Low; };
-template<> struct UbEqualTrait< long double, float >  { typedef long double High; typedef float  Low; };
-template<> struct UbEqualTrait< long double, double > { typedef long double High; typedef double Low; };
-
-//////////////////////////////////////////////////////////////////////////
-//fuer Allgmeine-Typen ( operator== ):
-template< typename T1, typename T2 >
-inline bool specific_equal(const T1& a, const T2& b) { return a==b; }
-
-//////////////////////////////////////////////////////////////////////////
-//fuer floating point build-in-type
-//float.float
-template< /*float,float*/>
-inline bool specific_equal< float, float >(const float& a, const float& b) {  return std::fabs( a - b ) < 1E-8; }
-
-template</*double,double*/>
-inline bool specific_equal< double, double >(const double& a, const double& b) { return std::fabs( a - b ) < 1E-13; }
-
-template</*long double,long double*/>
-inline bool specific_equal< long double, long double >(const long double& a, const long double& b) { return std::fabs( a - b ) < 1E-16; }
-
-//////////////////////////////////////////////////////////////////////////
-//globale isUbEqual - Funktion
-template< typename T1, typename T2 >
-inline bool isUbEqual(const T1& a, const T2& b)
-{
-   typedef typename UbEqualTrait<T1,T2>::Low Low;
-   return specific_equal< Low, Low >(static_cast< Low >( a ),static_cast< Low >( b ));
-};
-
-//////////////////////////////////////////////////////////////////////////
-//UbEqual-Functor
-template< typename T1, typename T2 >
-struct UbEqual
-{
-   bool operator()(const T1& a, const T2& b)
-   {
-      return isUbEqual(a,b);
-   }
-};
-
-#endif //UBEQUAL_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBEQUAL_H
+#define UBEQUAL_H
+
+#include<cmath>
+
+//////////////////////////////////////////////////////////////////////////
+//isUbEqual<T1,T2>(a,b)
+//vergleicht die gleichtheit der beiden werte a und b
+//
+//std-maessig wird hierfür der operator== verwendet
+//
+//Ausnahme: floating-points
+//hier wird jeweils der "genauere typ zum ungenaueren gecastet und dann verglichen"
+//e.g.: double d=1.2; int i=1; bool check = isUbEqual(d,i); -> true
+//
+//bei klassen muss hier operator== fuer const objecte implementiert sein!!!
+//e.g.: bool operator==(const Test&) const { if(blabla) return true; else return false; }
+//
+//
+//author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+//version 1.0 - 25.03.2008
+//////////////////////////////////////////////////////////////////////////
+
+//std-trait, fuer alle nicht spezifischen typen:
+template < typename T1, typename T2 >
+struct UbEqualTrait
+{
+   typedef T1 High;
+   typedef T1 Low;
+};
+
+//std-trait, fuer gleiche T
+template < typename T >
+struct UbEqualTrait< T, T >
+{
+   typedef T High;
+   typedef T Low;
+};
+
+//spezialisierung für diverse Typen-Tuples
+template<> struct UbEqualTrait< short, int >          { typedef int         High; typedef short  Low; };
+template<> struct UbEqualTrait< short, long >         { typedef long        High; typedef short  Low; };
+template<> struct UbEqualTrait< short, float >        { typedef float       High; typedef short  Low; };
+template<> struct UbEqualTrait< short, double >       { typedef double      High; typedef short  Low; };
+template<> struct UbEqualTrait< short, long double >  { typedef long double High; typedef short  Low; };
+
+template<> struct UbEqualTrait< int, short >          { typedef int         High; typedef short  Low; };
+template<> struct UbEqualTrait< int, long >           { typedef long        High; typedef int    Low; };
+template<> struct UbEqualTrait< int, float >          { typedef float       High; typedef int    Low; };
+template<> struct UbEqualTrait< int, double >         { typedef double      High; typedef int    Low; };
+template<> struct UbEqualTrait< int, long double >    { typedef long double High; typedef int    Low; };
+
+template<> struct UbEqualTrait< long, short >         { typedef long        High; typedef short  Low; };
+template<> struct UbEqualTrait< long, int >           { typedef long        High; typedef int    Low; };
+template<> struct UbEqualTrait< long, float >         { typedef float       High; typedef long   Low; };
+template<> struct UbEqualTrait< long, double >        { typedef double      High; typedef long   Low; };
+template<> struct UbEqualTrait< long, long double >   { typedef long double High; typedef long   Low; };
+
+template<> struct UbEqualTrait< float, short >        { typedef float       High; typedef short  Low; };
+template<> struct UbEqualTrait< float, int >          { typedef float       High; typedef int    Low; };
+template<> struct UbEqualTrait< float, long >         { typedef float       High; typedef long   Low; };
+template<> struct UbEqualTrait< float, double >       { typedef double      High; typedef float  Low; };
+template<> struct UbEqualTrait< float, long double >  { typedef long double High; typedef float  Low; };
+
+template<> struct UbEqualTrait< double, short >       { typedef double      High; typedef short  Low; };
+template<> struct UbEqualTrait< double, int >         { typedef double      High; typedef int    Low; };
+template<> struct UbEqualTrait< double, long >        { typedef double      High; typedef long   Low; };
+template<> struct UbEqualTrait< double, float >       { typedef double      High; typedef float  Low; };
+template<> struct UbEqualTrait< double, long double > { typedef long double High; typedef double Low; };
+
+template<> struct UbEqualTrait< long double, short >  { typedef long double High; typedef short  Low; };
+template<> struct UbEqualTrait< long double, int >    { typedef long double High; typedef int    Low; };
+template<> struct UbEqualTrait< long double, long >   { typedef long double High; typedef long   Low; };
+template<> struct UbEqualTrait< long double, float >  { typedef long double High; typedef float  Low; };
+template<> struct UbEqualTrait< long double, double > { typedef long double High; typedef double Low; };
+
+//////////////////////////////////////////////////////////////////////////
+//fuer Allgmeine-Typen ( operator== ):
+template< typename T1, typename T2 >
+inline bool specific_equal(const T1& a, const T2& b) { return a==b; }
+
+//////////////////////////////////////////////////////////////////////////
+//fuer floating point build-in-type
+//float.float
+template< /*float,float*/>
+inline bool specific_equal< float, float >(const float& a, const float& b) {  return std::fabs( a - b ) < 1E-8; }
+
+template</*double,double*/>
+inline bool specific_equal< double, double >(const double& a, const double& b) { return std::fabs( a - b ) < 1E-13; }
+
+template</*long double,long double*/>
+inline bool specific_equal< long double, long double >(const long double& a, const long double& b) { return std::fabs( a - b ) < 1E-16; }
+
+//////////////////////////////////////////////////////////////////////////
+//globale isUbEqual - Funktion
+template< typename T1, typename T2 >
+inline bool isUbEqual(const T1& a, const T2& b)
+{
+   typedef typename UbEqualTrait<T1,T2>::Low Low;
+   return specific_equal< Low, Low >(static_cast< Low >( a ),static_cast< Low >( b ));
+};
+
+//////////////////////////////////////////////////////////////////////////
+//UbEqual-Functor
+template< typename T1, typename T2 >
+struct UbEqual
+{
+   bool operator()(const T1& a, const T2& b)
+   {
+      return isUbEqual(a,b);
+   }
+};
+
+#endif //UBEQUAL_H
diff --git a/source/ThirdParty/Library/basics/utilities/UbException.h b/source/VirtualFluidsBasic/basics/utilities/UbException.h
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbException.h
rename to source/VirtualFluidsBasic/basics/utilities/UbException.h
index c9e338081658ba9187576a60d34e3d16fe36c78e..45b013d11b7237eefd12f7d28f18e55e57789599 100644
--- a/source/ThirdParty/Library/basics/utilities/UbException.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbException.h
@@ -1,161 +1,161 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBEXCEPTION_H
-#define UBEXCEPTION_H
-
-#include <vector>
-#include <iostream>
-#include <string>
-#include <sstream>
-#include <stdexcept>
-
-#include "./UbTuple.h"
-
-/*=========================================================================*/
-/*  UbException                                                             */
-/*                                                                         */
-/**
-This Class provides the base for exception handling.
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0  - 23.11.04
-@version 1.5  - 14.03.08
-@version 1.6  - 31.03.08 derivation from std::run_time_error
-@version 1.6a - helper marco UB_EXARGS
-*/ 
-
-/*
-usage: UB_THROW( UbException("error message") );
-       UB_THROW( UbException(__FILE__, __LINE__,"error message") );
-       UB_THROW( UbException(__FILE__, __LINE__,UB_FUNCTION,"error message") );
-       UB_THROW( UbException(UB_EXARGS,"error") ); //same as above
-*/
-
-//Macro UB_FUNCTION: figures out the method/function name (platform dependant)
-#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600))
- # define UB_FUNCTION __PRETTY_FUNCTION__
-#elif defined(__DMC__) && (__DMC__ >= 0x810)
- # define UB_FUNCTION __PRETTY_FUNCTION__
-#elif defined(__FUNCSIG__)
- # define UB_FUNCTION __FUNCSIG__
-#elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500))
- # define UB_FUNCTION __FUNCTION__
-#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
- # define UB_FUNCTION __FUNC__
-#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
- # define UB_FUNCTION __func__
-#else
- # define UB_FUNCTION "(unknown)"
-#endif
-
-//Helper Marco
-#define UB_EXARGS __FILE__,__LINE__,UB_FUNCTION
-
-#ifdef CAB_BOOST
-   #define UB_THROW(e) throw boost::enable_current_exception(e)
-#else
-   #define UB_THROW(e) throw e
-#endif
-
-class UbException : public std::runtime_error
-{
-public:
-   typedef UbTuple< std::string, int, std::string, std::string > ExceptionData;
-public:
-   //////////////////////////////////////////////////////////////////////////
-   //constructors
-   UbException()
-      : std::runtime_error("")
-   { 
-   }
-   /*==========================================================*/
-   UbException(const std::string& str)
-      : std::runtime_error("")
-   {
-      this->addInfo(str);		
-   }
-   /*==========================================================*/
-   UbException(const std::string& file, const int& line, const std::string& err_str)
-      : std::runtime_error("")
-   {
-      this->addInfo(file,line,"unknown",err_str);		
-   }
-   /*==========================================================*/
-   //UbException(const char* file, const int& line, const char* function, const std::string& err_str)
-   UbException(const std::string& file, const int& line, const std::string& function, const std::string& err_str)
-      : std::runtime_error("")
-   {
-      this->addInfo(file,line,function,err_str);		
-   }
-   //////////////////////////////////////////////////////////////////////////
-   //destructor
-   virtual ~UbException() throw() { }
-   //////////////////////////////////////////////////////////////////////////
-   //virtual public methods
-   //returns  exception-string
-   virtual const char* what() const throw()
-   {
-      exceptionString = this->toString();
-      return exceptionString.c_str();  //ansonsten ist das Verhalten anschließend undefiniert!
-   }
-   /*==========================================================*/
-   virtual void addInfo(const std::string& err_str)	 
-   { 
-      exceptionData.push_back( makeUbTuple( (std::string)"-", 0, (std::string)"unknown", err_str) ); 
-   }
-   /*==========================================================*/
-   //add exception
-   virtual void addInfo(const std::string& file, const int& line, const std::string& function, const std::string& err_str)	 
-   { 
-      exceptionData.push_back( makeUbTuple( file, line, function, err_str ) ); 
-   }
-   /*==========================================================*/
-   //returns exception-string with all calles exceptions
-   virtual const std::vector<std::string> getInfo() const
-   { 
-      std::vector<std::string> tmp;
-      for(std::size_t i=0; i<exceptionData.size(); i++)
-      {
-         std::stringstream str;
-         str << val<1>( exceptionData[i] ) << ", " 
-             << val<2>( exceptionData[i] ) << ", " 
-             << val<3>( exceptionData[i] ) << ", " 
-             << val<4>( exceptionData[i] );
-         tmp.push_back( str.str());
-      }
-      return tmp; 
-   }
-   /*==========================================================*/
-   //returns exception-string with all calles exceptions and detailes informations
-   virtual std::string toString() const
-   { 
-      std::stringstream str("UbExeption");
-      
-      for(std::size_t i=0; i<exceptionData.size(); i++)
-         str<<(std::string)"caller[" << i << "]\n"
-            <<"  - file:     "<< val<1>( exceptionData[i] )<<"\n"
-            <<"  - line:     "<< val<2>( exceptionData[i] )<<"\n"
-            <<"  - function: "<< val<3>( exceptionData[i] )<<"\n"
-            <<"  - what:     "<< val<4>( exceptionData[i] )<< std::endl; 
-
-      return str.str();
-   }
-
-protected:
-   //////////////////////////////////////////////////////////////////////////
-   //protected member
-   std::vector< ExceptionData > exceptionData;
-   mutable std::string exceptionString;
-};
-
-//overlading operator <<
-inline std::ostream& operator<<(std::ostream& os, const UbException& e)
-{
-   return os<<e.toString();
-}
-
-#endif //UBEXCEPTION_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBEXCEPTION_H
+#define UBEXCEPTION_H
+
+#include <vector>
+#include <iostream>
+#include <string>
+#include <sstream>
+#include <stdexcept>
+
+#include "./UbTuple.h"
+
+/*=========================================================================*/
+/*  UbException                                                             */
+/*                                                                         */
+/**
+This Class provides the base for exception handling.
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0  - 23.11.04
+@version 1.5  - 14.03.08
+@version 1.6  - 31.03.08 derivation from std::run_time_error
+@version 1.6a - helper marco UB_EXARGS
+*/ 
+
+/*
+usage: UB_THROW( UbException("error message") );
+       UB_THROW( UbException(__FILE__, __LINE__,"error message") );
+       UB_THROW( UbException(__FILE__, __LINE__,UB_FUNCTION,"error message") );
+       UB_THROW( UbException(UB_EXARGS,"error") ); //same as above
+*/
+
+//Macro UB_FUNCTION: figures out the method/function name (platform dependant)
+#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600))
+ # define UB_FUNCTION __PRETTY_FUNCTION__
+#elif defined(__DMC__) && (__DMC__ >= 0x810)
+ # define UB_FUNCTION __PRETTY_FUNCTION__
+#elif defined(__FUNCSIG__)
+ # define UB_FUNCTION __FUNCSIG__
+#elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500))
+ # define UB_FUNCTION __FUNCTION__
+#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
+ # define UB_FUNCTION __FUNC__
+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
+ # define UB_FUNCTION __func__
+#else
+ # define UB_FUNCTION "(unknown)"
+#endif
+
+//Helper Marco
+#define UB_EXARGS __FILE__,__LINE__,UB_FUNCTION
+
+#ifdef CAB_BOOST
+   #define UB_THROW(e) throw boost::enable_current_exception(e)
+#else
+   #define UB_THROW(e) throw e
+#endif
+
+class UbException : public std::runtime_error
+{
+public:
+   typedef UbTuple< std::string, int, std::string, std::string > ExceptionData;
+public:
+   //////////////////////////////////////////////////////////////////////////
+   //constructors
+   UbException()
+      : std::runtime_error("")
+   { 
+   }
+   /*==========================================================*/
+   UbException(const std::string& str)
+      : std::runtime_error("")
+   {
+      this->addInfo(str);		
+   }
+   /*==========================================================*/
+   UbException(const std::string& file, const int& line, const std::string& err_str)
+      : std::runtime_error("")
+   {
+      this->addInfo(file,line,"unknown",err_str);		
+   }
+   /*==========================================================*/
+   //UbException(const char* file, const int& line, const char* function, const std::string& err_str)
+   UbException(const std::string& file, const int& line, const std::string& function, const std::string& err_str)
+      : std::runtime_error("")
+   {
+      this->addInfo(file,line,function,err_str);		
+   }
+   //////////////////////////////////////////////////////////////////////////
+   //destructor
+   virtual ~UbException() throw() { }
+   //////////////////////////////////////////////////////////////////////////
+   //virtual public methods
+   //returns  exception-string
+   virtual const char* what() const throw()
+   {
+      exceptionString = this->toString();
+      return exceptionString.c_str();  //ansonsten ist das Verhalten anschließend undefiniert!
+   }
+   /*==========================================================*/
+   virtual void addInfo(const std::string& err_str)	 
+   { 
+      exceptionData.push_back( makeUbTuple( (std::string)"-", 0, (std::string)"unknown", err_str) ); 
+   }
+   /*==========================================================*/
+   //add exception
+   virtual void addInfo(const std::string& file, const int& line, const std::string& function, const std::string& err_str)	 
+   { 
+      exceptionData.push_back( makeUbTuple( file, line, function, err_str ) ); 
+   }
+   /*==========================================================*/
+   //returns exception-string with all calles exceptions
+   virtual const std::vector<std::string> getInfo() const
+   { 
+      std::vector<std::string> tmp;
+      for(std::size_t i=0; i<exceptionData.size(); i++)
+      {
+         std::stringstream str;
+         str << val<1>( exceptionData[i] ) << ", " 
+             << val<2>( exceptionData[i] ) << ", " 
+             << val<3>( exceptionData[i] ) << ", " 
+             << val<4>( exceptionData[i] );
+         tmp.push_back( str.str());
+      }
+      return tmp; 
+   }
+   /*==========================================================*/
+   //returns exception-string with all calles exceptions and detailes informations
+   virtual std::string toString() const
+   { 
+      std::stringstream str("UbExeption");
+      
+      for(std::size_t i=0; i<exceptionData.size(); i++)
+         str<<(std::string)"caller[" << i << "]\n"
+            <<"  - file:     "<< val<1>( exceptionData[i] )<<"\n"
+            <<"  - line:     "<< val<2>( exceptionData[i] )<<"\n"
+            <<"  - function: "<< val<3>( exceptionData[i] )<<"\n"
+            <<"  - what:     "<< val<4>( exceptionData[i] )<< std::endl; 
+
+      return str.str();
+   }
+
+protected:
+   //////////////////////////////////////////////////////////////////////////
+   //protected member
+   std::vector< ExceptionData > exceptionData;
+   mutable std::string exceptionString;
+};
+
+//overlading operator <<
+inline std::ostream& operator<<(std::ostream& os, const UbException& e)
+{
+   return os<<e.toString();
+}
+
+#endif //UBEXCEPTION_H
diff --git a/source/ThirdParty/Library/basics/utilities/UbFileInput.h b/source/VirtualFluidsBasic/basics/utilities/UbFileInput.h
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbFileInput.h
rename to source/VirtualFluidsBasic/basics/utilities/UbFileInput.h
index 3b08a7fdb532c3b5b45cc14d3315dd1eee52b379..2c57b175faf491b65abd28f9538038b3947ec58f 100644
--- a/source/ThirdParty/Library/basics/utilities/UbFileInput.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbFileInput.h
@@ -1,97 +1,97 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBFILEINPUT_H
-#define UBFILEINPUT_H
-
-#include <fstream>
-#include <iostream>
-#include <string>
-
-#include <cstdlib> //atoi
-#include <cstring> //strstr
-
-#include <basics/utilities/UbException.h>
-
-/*=========================================================================*/
-/*  UbFileInput                                                            */
-/*                                                                         */
-/**
-...
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 23.11.04
-*/
-
-/*
-usage: ...
-*/
-
-class UbFileInput
-{
-public:
-   enum FILETYPE {ASCII, BINARY};      
-
-public:
-   UbFileInput() : filename(""), commentindicator('C') { }
-   virtual ~UbFileInput() { infile.close(); }
-
-   virtual bool        operator!() { return !(infile); }
-   virtual bool        isOpen()    { return !(!(infile)); }
-
-   virtual bool        open(std::string filename)=0;
-   virtual void        close() { infile.close(); }
-   virtual int         eof()   { return infile.eof(); }
-
-   virtual void        skipLine()=0;					// Springt zur naechsten Zeile
-	virtual void        readLine()=0;
-   virtual std::string readStringLine()=0;
-	virtual int		     readInteger()=0;				// Liest einen Int-Wert ein
-   virtual std::size_t readSize_t()=0;
-   virtual double	     readDouble()=0;				   // Liest einen double-Wert ein
-	virtual float	     readFloat()=0;				   // Liest einen float-Wert ein
-	virtual bool  	     readBool()=0;				   // Liest einen bool-Wert ein
-   virtual char  	     readChar()=0;				   // Liest einen char-Wert ein
-   virtual std::string readString()=0;			      // Liest ein Wort ein
-	virtual std::string readLineTill(char stop)=0;	// Liest gesamte Zeile ein bis zu einem bestimmten Zeichen
-	virtual std::string parseString()=0;	         // Liest
-
-   virtual void        setCommentIndicator(char commentindicator) {this->commentindicator = commentindicator;}
-
-   virtual bool        containsString( const std::string& var)=0;
-   virtual void        setPosAfterLineWithString( const std::string& var)=0;
-   virtual int		     readIntegerAfterString( const std::string& var)=0;
-   virtual double	     readDoubleAfterString( const std::string& var)=0;
-   virtual bool        readBoolAfterString( const std::string& var)=0;
-   virtual std::string readStringAfterString( const std::string& var)=0;
-
-   virtual std::string getFileName() {return this->filename;}
-
-   //returns file extension:
-   //e.g. "./../test/ich.inp" -> "inp", "./../test/ich" -> ""
-   virtual std::string getFileExtension()
-   {
-      std::size_t pos1 = filename.rfind("/");
-      if(pos1==std::string::npos) pos1 = 0;
-      std::size_t pos2 = filename.rfind(".");
-      if(pos2!=std::string::npos && pos2>pos1)
-         return filename.substr(pos2+1);
-
-      return "";
-   }
-
-   //returns "ASCII", "BINARY"
-   virtual FILETYPE getFileType()=0;
-
-protected:
-   std::ifstream infile;
-   std::string   filename;
-   char          commentindicator;
-};
-
-#endif //UBFILEINPUT_H
-
-
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBFILEINPUT_H
+#define UBFILEINPUT_H
+
+#include <fstream>
+#include <iostream>
+#include <string>
+
+#include <cstdlib> //atoi
+#include <cstring> //strstr
+
+#include <basics/utilities/UbException.h>
+
+/*=========================================================================*/
+/*  UbFileInput                                                            */
+/*                                                                         */
+/**
+...
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 23.11.04
+*/
+
+/*
+usage: ...
+*/
+
+class UbFileInput
+{
+public:
+   enum FILETYPE {ASCII, BINARY};      
+
+public:
+   UbFileInput() : filename(""), commentindicator('C') { }
+   virtual ~UbFileInput() { infile.close(); }
+
+   virtual bool        operator!() { return !(infile); }
+   virtual bool        isOpen()    { return !(!(infile)); }
+
+   virtual bool        open(std::string filename)=0;
+   virtual void        close() { infile.close(); }
+   virtual int         eof()   { return infile.eof(); }
+
+   virtual void        skipLine()=0;					// Springt zur naechsten Zeile
+	virtual void        readLine()=0;
+   virtual std::string readStringLine()=0;
+	virtual int		     readInteger()=0;				// Liest einen Int-Wert ein
+   virtual std::size_t readSize_t()=0;
+   virtual double	     readDouble()=0;				   // Liest einen double-Wert ein
+	virtual float	     readFloat()=0;				   // Liest einen float-Wert ein
+	virtual bool  	     readBool()=0;				   // Liest einen bool-Wert ein
+   virtual char  	     readChar()=0;				   // Liest einen char-Wert ein
+   virtual std::string readString()=0;			      // Liest ein Wort ein
+	virtual std::string readLineTill(char stop)=0;	// Liest gesamte Zeile ein bis zu einem bestimmten Zeichen
+	virtual std::string parseString()=0;	         // Liest
+
+   virtual void        setCommentIndicator(char commentindicator) {this->commentindicator = commentindicator;}
+
+   virtual bool        containsString( const std::string& var)=0;
+   virtual void        setPosAfterLineWithString( const std::string& var)=0;
+   virtual int		     readIntegerAfterString( const std::string& var)=0;
+   virtual double	     readDoubleAfterString( const std::string& var)=0;
+   virtual bool        readBoolAfterString( const std::string& var)=0;
+   virtual std::string readStringAfterString( const std::string& var)=0;
+
+   virtual std::string getFileName() {return this->filename;}
+
+   //returns file extension:
+   //e.g. "./../test/ich.inp" -> "inp", "./../test/ich" -> ""
+   virtual std::string getFileExtension()
+   {
+      std::size_t pos1 = filename.rfind("/");
+      if(pos1==std::string::npos) pos1 = 0;
+      std::size_t pos2 = filename.rfind(".");
+      if(pos2!=std::string::npos && pos2>pos1)
+         return filename.substr(pos2+1);
+
+      return "";
+   }
+
+   //returns "ASCII", "BINARY"
+   virtual FILETYPE getFileType()=0;
+
+protected:
+   std::ifstream infile;
+   std::string   filename;
+   char          commentindicator;
+};
+
+#endif //UBFILEINPUT_H
+
+
diff --git a/source/ThirdParty/Library/basics/utilities/UbFileInputASCII.cpp b/source/VirtualFluidsBasic/basics/utilities/UbFileInputASCII.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbFileInputASCII.cpp
rename to source/VirtualFluidsBasic/basics/utilities/UbFileInputASCII.cpp
index d17d69cf9c3555f3ab742ec5922e3872ba93b796..9feeefbf7ff03d9c9c545baed87837cbd55eba94 100644
--- a/source/ThirdParty/Library/basics/utilities/UbFileInputASCII.cpp
+++ b/source/VirtualFluidsBasic/basics/utilities/UbFileInputASCII.cpp
@@ -1,227 +1,227 @@
-#include <basics/utilities/UbFileInputASCII.h>
-#include <cstring>
-
-using namespace std;
-
-UbFileInputASCII::UbFileInputASCII(string filename)
-{
-	this->filename         = filename;
-   this->commentindicator = 'C';
-
-   infile.open(filename.c_str());
-
-   //if(!infile) UB_THROW( UbException((string)("UbFileInputASCII::UbFileInputASCII(string filename, int how) couldn't open file:\n "+filename)) );
-}
-/*==========================================================*/
-bool UbFileInputASCII::open(string filename)
-{
-   infile.close();
-   infile.clear(); //setzt flags zurueck
-
-   this->filename = filename;
-   infile.open(this->filename.c_str());
-
-   return infile.is_open();
-}
-/*==========================================================*/
-int UbFileInputASCII::readInteger()
-{
-	int dummy;
-	infile>>dummy;
-	return dummy;
-}
-/*==========================================================*/
-string UbFileInputASCII::getFileName()
-{
-	return this->filename;
-}
-
-/*==========================================================*/
-void UbFileInputASCII::skipLine()
-{
-	string dummy;
-	getline(infile, dummy);
-}
-/*==========================================================*/
-void UbFileInputASCII::readLine()
-{
-	string dummy;
-	getline(infile, dummy);
-}
-/*==========================================================*/
-string UbFileInputASCII::readStringLine()
-{
-   string dummy;
-   getline(infile, dummy);
-   return dummy;
-}
-/*==========================================================*/
-string UbFileInputASCII::readLineTill(char stop)
-{
-	string dummy;
-	getline(infile, dummy, stop);
-	return dummy;
-}
-/*==========================================================*/
-string UbFileInputASCII::parseString()
-{
-	string dummy;
-	getline(infile, dummy, ' ');
-	return dummy;
-}
-/*==========================================================*/
-double UbFileInputASCII::readDouble()
-{
-   double dummy;
-   infile>>dummy;
-   return dummy;
-}
-/*==========================================================*/
-float UbFileInputASCII::readFloat()
-{
-   float dummy;
-   infile>>dummy;
-   return dummy;
-}
-/*==========================================================*/
-string UbFileInputASCII::readString()
-{
-	string dummy;
-	infile>>dummy;
-	return dummy;
-}
-/*==========================================================*/
-char UbFileInputASCII::readChar()
-{
-   int dummy;
-   infile>>dummy;
-   return (char)dummy;
-}
-/*==========================================================*/
-std::size_t UbFileInputASCII::readSize_t()
-{
-   std::size_t dummy;
-   infile>>dummy;
-   return dummy;
-}
-/*==========================================================*/
-void UbFileInputASCII::setPosAfterLineWithString(const string& var)
-{
-   infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
-   char line[512];
-   do
-   {
-      infile.getline(line,512);
-      if(infile.eof()) UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> string "+var+" wasn't found in "+this->filename) );
-   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt
-}
-/*==========================================================*/
-bool UbFileInputASCII::containsString(const string& var)
-{
-   infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!)
-
-   infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
-   char line[512];
-   do
-   {
-      infile.getline(line,512);
-      if(infile.eof()) return false;
-   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt
-
-   return true;
-}
-/*==========================================================*/
-int UbFileInputASCII::readIntegerAfterString(const string& var)
-// last change [10.3.2004] at [9:46]
-//suchts in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
-//z.B. timesteps 9
-{
-   infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!)
-   
-   infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
-
-   char line[512];
-
-   do
-   {
-      infile.getline(line,512);
-      if(infile.eof()) UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> "+var+" wasn't found in "+this->filename) );
-   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt
-
-   strcpy (line, (line+strlen(var.c_str())));	    // zeile um "varname" kuerzen
-   while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1));	// Whitespaces entfernen
-
-   return(atoi(line));						// Umwandlung in int
-}
-/*==========================================================*/
-// last change [10.3.2004] at [9:46]
-//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
-//z.B. nue 9.5
-double UbFileInputASCII::readDoubleAfterString(const string& var)
-{
-   infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!)
-   
-   infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
-
-   char line[512];
-
-   do
-   {
-      infile.getline(line,512);
-      if(infile.eof()) UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> "+var+" wasn't found in "+this->filename) );
-   }while (/*!strncmp(varname,line,sizeof(varname))==0*/strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt
-
-
-   strcpy (line, (line+strlen(var.c_str())));	    // zeile um "varname" kuerzen
-   while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1));	// Whitespaces entfernen
-
-   return (atof(line));			// Umwandlung in double
-}
-/*==========================================================*/
-//  [9.9.2002]
-// liefert string-Wert der hinter dem uebergebenen char feld in der datei infile steht
-// zudem wird der wert in die uebergebene variable value uebertragen (falls man das ergebniss als char benoetig)
-string UbFileInputASCII::readStringAfterString(const string& var)//,char *value)
-{
-   infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!)
-   
-   infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
-
-   char line[512];
-   //string line_copy[512];
-
-   do{
-      infile.getline(line,512);
-      if(infile.eof()) UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> "+var+" wasn't found in "+this->filename) );
-   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt
-
-   strcpy (line, (line+strlen(var.c_str())));										// zeile um "varname" kuerzen
-   while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1));	// Whitespaces entfernen
-
-   char *p;
-   p=strtok(line," "); //schneidet alles "ab und inklusive space " nach namen ab
-   p=strtok(line,"\t");//schneidet alles "ab und inklusive tab   " nach namen ab
-
-   return static_cast<string>(p);			// Umwandlung in string
-}
-/*==========================================================*/
-// last change [10.3.2004] at [9:46]
-//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
-//z.B. nue 9.5
-bool UbFileInputASCII::readBoolAfterString(const string& var)
-{
-   if(this->readStringAfterString(var)      == "true" ) return true;
-   else if(this->readStringAfterString(var) == "false") return false;
-   else UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> expression after "+var+" is not equal to 'true' or 'false' in "+this->filename) );
-}
-/*==========================================================*/
-// last change [10.3.2004] at [9:46]
-//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
-//z.B. nue 9.5
-bool UbFileInputASCII::readBool()
-{
-   string tmp = this->readString();
-   if(     tmp == "true" ) return true;
-   else if(tmp == "false") return false;
-   else UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> expression=\""+tmp+"\" is not equal to 'true' or 'false' in "+this->filename) );
-}
+#include <basics/utilities/UbFileInputASCII.h>
+#include <cstring>
+
+using namespace std;
+
+UbFileInputASCII::UbFileInputASCII(string filename)
+{
+	this->filename         = filename;
+   this->commentindicator = 'C';
+
+   infile.open(filename.c_str());
+
+   //if(!infile) UB_THROW( UbException((string)("UbFileInputASCII::UbFileInputASCII(string filename, int how) couldn't open file:\n "+filename)) );
+}
+/*==========================================================*/
+bool UbFileInputASCII::open(string filename)
+{
+   infile.close();
+   infile.clear(); //setzt flags zurueck
+
+   this->filename = filename;
+   infile.open(this->filename.c_str());
+
+   return infile.is_open();
+}
+/*==========================================================*/
+int UbFileInputASCII::readInteger()
+{
+	int dummy;
+	infile>>dummy;
+	return dummy;
+}
+/*==========================================================*/
+string UbFileInputASCII::getFileName()
+{
+	return this->filename;
+}
+
+/*==========================================================*/
+void UbFileInputASCII::skipLine()
+{
+	string dummy;
+	getline(infile, dummy);
+}
+/*==========================================================*/
+void UbFileInputASCII::readLine()
+{
+	string dummy;
+	getline(infile, dummy);
+}
+/*==========================================================*/
+string UbFileInputASCII::readStringLine()
+{
+   string dummy;
+   getline(infile, dummy);
+   return dummy;
+}
+/*==========================================================*/
+string UbFileInputASCII::readLineTill(char stop)
+{
+	string dummy;
+	getline(infile, dummy, stop);
+	return dummy;
+}
+/*==========================================================*/
+string UbFileInputASCII::parseString()
+{
+	string dummy;
+	getline(infile, dummy, ' ');
+	return dummy;
+}
+/*==========================================================*/
+double UbFileInputASCII::readDouble()
+{
+   double dummy;
+   infile>>dummy;
+   return dummy;
+}
+/*==========================================================*/
+float UbFileInputASCII::readFloat()
+{
+   float dummy;
+   infile>>dummy;
+   return dummy;
+}
+/*==========================================================*/
+string UbFileInputASCII::readString()
+{
+	string dummy;
+	infile>>dummy;
+	return dummy;
+}
+/*==========================================================*/
+char UbFileInputASCII::readChar()
+{
+   int dummy;
+   infile>>dummy;
+   return (char)dummy;
+}
+/*==========================================================*/
+std::size_t UbFileInputASCII::readSize_t()
+{
+   std::size_t dummy;
+   infile>>dummy;
+   return dummy;
+}
+/*==========================================================*/
+void UbFileInputASCII::setPosAfterLineWithString(const string& var)
+{
+   infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
+   char line[512];
+   do
+   {
+      infile.getline(line,512);
+      if(infile.eof()) UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> string "+var+" wasn't found in "+this->filename) );
+   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt
+}
+/*==========================================================*/
+bool UbFileInputASCII::containsString(const string& var)
+{
+   infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!)
+
+   infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
+   char line[512];
+   do
+   {
+      infile.getline(line,512);
+      if(infile.eof()) return false;
+   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt
+
+   return true;
+}
+/*==========================================================*/
+int UbFileInputASCII::readIntegerAfterString(const string& var)
+// last change [10.3.2004] at [9:46]
+//suchts in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
+//z.B. timesteps 9
+{
+   infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!)
+   
+   infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
+
+   char line[512];
+
+   do
+   {
+      infile.getline(line,512);
+      if(infile.eof()) UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> "+var+" wasn't found in "+this->filename) );
+   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt
+
+   strcpy (line, (line+strlen(var.c_str())));	    // zeile um "varname" kuerzen
+   while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1));	// Whitespaces entfernen
+
+   return(atoi(line));						// Umwandlung in int
+}
+/*==========================================================*/
+// last change [10.3.2004] at [9:46]
+//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
+//z.B. nue 9.5
+double UbFileInputASCII::readDoubleAfterString(const string& var)
+{
+   infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!)
+   
+   infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
+
+   char line[512];
+
+   do
+   {
+      infile.getline(line,512);
+      if(infile.eof()) UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> "+var+" wasn't found in "+this->filename) );
+   }while (/*!strncmp(varname,line,sizeof(varname))==0*/strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt
+
+
+   strcpy (line, (line+strlen(var.c_str())));	    // zeile um "varname" kuerzen
+   while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1));	// Whitespaces entfernen
+
+   return (atof(line));			// Umwandlung in double
+}
+/*==========================================================*/
+//  [9.9.2002]
+// liefert string-Wert der hinter dem uebergebenen char feld in der datei infile steht
+// zudem wird der wert in die uebergebene variable value uebertragen (falls man das ergebniss als char benoetig)
+string UbFileInputASCII::readStringAfterString(const string& var)//,char *value)
+{
+   infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!)
+   
+   infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
+
+   char line[512];
+   //string line_copy[512];
+
+   do{
+      infile.getline(line,512);
+      if(infile.eof()) UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> "+var+" wasn't found in "+this->filename) );
+   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt
+
+   strcpy (line, (line+strlen(var.c_str())));										// zeile um "varname" kuerzen
+   while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1));	// Whitespaces entfernen
+
+   char *p;
+   p=strtok(line," "); //schneidet alles "ab und inklusive space " nach namen ab
+   p=strtok(line,"\t");//schneidet alles "ab und inklusive tab   " nach namen ab
+
+   return static_cast<string>(p);			// Umwandlung in string
+}
+/*==========================================================*/
+// last change [10.3.2004] at [9:46]
+//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
+//z.B. nue 9.5
+bool UbFileInputASCII::readBoolAfterString(const string& var)
+{
+   if(this->readStringAfterString(var)      == "true" ) return true;
+   else if(this->readStringAfterString(var) == "false") return false;
+   else UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> expression after "+var+" is not equal to 'true' or 'false' in "+this->filename) );
+}
+/*==========================================================*/
+// last change [10.3.2004] at [9:46]
+//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
+//z.B. nue 9.5
+bool UbFileInputASCII::readBool()
+{
+   string tmp = this->readString();
+   if(     tmp == "true" ) return true;
+   else if(tmp == "false") return false;
+   else UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> expression=\""+tmp+"\" is not equal to 'true' or 'false' in "+this->filename) );
+}
diff --git a/source/ThirdParty/Library/basics/utilities/UbFileInputASCII.h b/source/VirtualFluidsBasic/basics/utilities/UbFileInputASCII.h
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbFileInputASCII.h
rename to source/VirtualFluidsBasic/basics/utilities/UbFileInputASCII.h
index 77c07137bbaf9c9b542ac1b1e939729af15dd85f..019418f8091177fba974a2a4cc30453d9fab12a1 100644
--- a/source/ThirdParty/Library/basics/utilities/UbFileInputASCII.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbFileInputASCII.h
@@ -1,73 +1,73 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBFILEINPUTASCII_H
-#define UBFILEINPUTASCII_H
-
-#include <fstream>
-#include <iostream>
-#include <string>
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbFileInput.h>
-
-/*=========================================================================*/
-/*  UbFileInputASCII                                                       */
-/*                                                                         */
-/**
-...
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 23.11.04
-*/ 
-
-/*
-usage: ...
-*/
-
-class UbFileInputASCII : public UbFileInput
-{                               
-public:
-   UbFileInputASCII() : UbFileInput() { }
-   UbFileInputASCII(std::string filename);
-	
-   bool open(std::string filename);
-
-   std::string getFileName();				
-	void	      skipLine();					   // Springt zur naechsten Zeile
-
-   void        readLine();		 
-   std::string readStringLine();				
-	int		   readInteger();				   // Liest einen Int-Wert ein
-   std::size_t readSize_t();
-   double	   readDouble();				   // Liest einen double-Wert ein
-	float 	   readFloat();				   // Liest einen float-Wert ein
-	bool  	   readBool();				      // Liest einen bool-Wert ein
-   char        readChar();                // Liest einen char-Wert ein
-   std::string	readString();				   // Liest ein Wort ein
-	std::string	readLineTill(char stop);	// Liest gesamte Zeile ein bis zu einem bestimmten Zeichen
-	std::string	parseString();	
-
-   bool        containsString(const std::string& var);
-   void        setPosAfterLineWithString(const std::string& var);
-   int		   readIntegerAfterString(const std::string& var);
-   double	   readDoubleAfterString(const std::string& var);
-   bool        readBoolAfterString(const std::string& var);
-   std::string readStringAfterString(const std::string& var);
-
-   FILETYPE getFileType() { return ASCII; }
-
-   template< typename T >
-   friend inline UbFileInputASCII& operator>>(UbFileInputASCII& file, T& data) 
-   {
-      file.infile>>data;
-      return file;
-   }
-};
-
-#endif //UBFILEINPUTASCII_H
-
-
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBFILEINPUTASCII_H
+#define UBFILEINPUTASCII_H
+
+#include <fstream>
+#include <iostream>
+#include <string>
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbFileInput.h>
+
+/*=========================================================================*/
+/*  UbFileInputASCII                                                       */
+/*                                                                         */
+/**
+...
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 23.11.04
+*/ 
+
+/*
+usage: ...
+*/
+
+class UbFileInputASCII : public UbFileInput
+{                               
+public:
+   UbFileInputASCII() : UbFileInput() { }
+   UbFileInputASCII(std::string filename);
+	
+   bool open(std::string filename);
+
+   std::string getFileName();				
+	void	      skipLine();					   // Springt zur naechsten Zeile
+
+   void        readLine();		 
+   std::string readStringLine();				
+	int		   readInteger();				   // Liest einen Int-Wert ein
+   std::size_t readSize_t();
+   double	   readDouble();				   // Liest einen double-Wert ein
+	float 	   readFloat();				   // Liest einen float-Wert ein
+	bool  	   readBool();				      // Liest einen bool-Wert ein
+   char        readChar();                // Liest einen char-Wert ein
+   std::string	readString();				   // Liest ein Wort ein
+	std::string	readLineTill(char stop);	// Liest gesamte Zeile ein bis zu einem bestimmten Zeichen
+	std::string	parseString();	
+
+   bool        containsString(const std::string& var);
+   void        setPosAfterLineWithString(const std::string& var);
+   int		   readIntegerAfterString(const std::string& var);
+   double	   readDoubleAfterString(const std::string& var);
+   bool        readBoolAfterString(const std::string& var);
+   std::string readStringAfterString(const std::string& var);
+
+   FILETYPE getFileType() { return ASCII; }
+
+   template< typename T >
+   friend inline UbFileInputASCII& operator>>(UbFileInputASCII& file, T& data) 
+   {
+      file.infile>>data;
+      return file;
+   }
+};
+
+#endif //UBFILEINPUTASCII_H
+
+
diff --git a/source/ThirdParty/Library/basics/utilities/UbFileInputBinary.cpp b/source/VirtualFluidsBasic/basics/utilities/UbFileInputBinary.cpp
similarity index 96%
rename from source/ThirdParty/Library/basics/utilities/UbFileInputBinary.cpp
rename to source/VirtualFluidsBasic/basics/utilities/UbFileInputBinary.cpp
index 0bcf60ce0ca665403e95d6f0f5366e03c18382fb..a7071b367df58a6f51f04ab2c69d15ca0fe27665 100644
--- a/source/ThirdParty/Library/basics/utilities/UbFileInputBinary.cpp
+++ b/source/VirtualFluidsBasic/basics/utilities/UbFileInputBinary.cpp
@@ -1,150 +1,150 @@
-#include <basics/utilities/UbFileInputBinary.h>
-#include <cstring>
-
-using namespace std;
-
-/*==========================================================*/
-UbFileInputBinary::UbFileInputBinary(string filename)
-{
-	this->filename = filename;
-   infile.open(filename.c_str(), ios::in | ios::binary);
-}
-/*==========================================================*/
-bool UbFileInputBinary::open(string filename)
-{
-   infile.close();
-   infile.clear(); //setzt flags zurueck
-   
-   this->filename = filename;
-   infile.open(this->filename.c_str(), ios::in | ios::binary);
-
-   return infile.is_open();
-}
-/*==========================================================*/
-int UbFileInputBinary::readInteger()				
-{
-   int dummy;
-   infile.read((char*)&dummy,sizeof(int));
-   return dummy; 
-}
-/*==========================================================*/
-std::size_t UbFileInputBinary::readSize_t()				
-{
-   std::size_t dummy;
-   infile.read((char*)&dummy,sizeof(std::size_t));
-   return dummy;
-}
-/*==========================================================*/
-double UbFileInputBinary::readDouble()	
-{
-   double dummy;
-   infile.read((char*)&dummy,sizeof(double));
-   return dummy; 
-}
-/*==========================================================*/
-float UbFileInputBinary::readFloat()	
-{
-	float dummy;
-	infile.read((char*)&dummy,sizeof(float));
-	return dummy; 
-}
-/*==========================================================*/
-char UbFileInputBinary::readChar()	
-{
-   char dummy;
-   infile.read((char*)&dummy,sizeof(char));
-   return dummy; 
-}
-/*==========================================================*/
-string UbFileInputBinary::readString()	
-{
-   char c;
-   infile.read(&c,sizeof(char));
-   while(c==' ' || c=='\t') infile.read(&c,sizeof(char));  
-   
-   string dummy;
-   dummy+=c;
-
-   infile.read(&c,sizeof(char));
-   while(c!='\0' && c!=' ' && c!='\t' && c!='\n')
-   {
-      dummy+=c;
-      infile.read(&c,sizeof(char));
-   }
-   return dummy;
-}
-/*==========================================================*/
-bool UbFileInputBinary::readBool()	
-{
-   bool dummy;
-   infile.read((char*)&dummy,sizeof(bool));
-   return dummy; 
-}
-/*==========================================================*/
-void UbFileInputBinary::skipLine()				
-{
-   char c;
-   do{
-      infile.read(&c,sizeof(char));
-   }while(c!='\n');
-}
-/*==========================================================*/
-void UbFileInputBinary::readLine()				
-{
-   char c;
-   infile.read(&c,sizeof(char));
-   while(c!='\n') infile.read(&c,sizeof(char));
-}
-/*==========================================================*/
-string UbFileInputBinary::readStringLine()				
-{
-   char c;
-   string dummy;
-   infile.read(&c,sizeof(char));
-   while(c!='\n')
-   {
-      dummy+=c;
-      infile.read(&c,sizeof(char));
-   }
-   return dummy;
-}
-/*==========================================================*/
-string UbFileInputBinary::readLineTill(char stop)				
-{
-   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
-}
-/*==========================================================*/
-string UbFileInputBinary::parseString()				
-{
-   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
-}
-/*==========================================================*/
-bool UbFileInputBinary::containsString(const string& var)
-{
-   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
-}
-/*==========================================================*/
-void UbFileInputBinary::setPosAfterLineWithString(const string& var)
-{
-   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
-}
-/*==========================================================*/
-int UbFileInputBinary::readIntegerAfterString(const string& var)
-{
-   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
-}
-/*==========================================================*/
-double UbFileInputBinary::readDoubleAfterString(const string& var)	
-{
-   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
-}
-/*==========================================================*/
-string UbFileInputBinary::readStringAfterString(const string& var)	
-{
-   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
-}
-/*==========================================================*/
-bool UbFileInputBinary::readBoolAfterString(const string& var)	
-{
-   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
-}
+#include <basics/utilities/UbFileInputBinary.h>
+#include <cstring>
+
+using namespace std;
+
+/*==========================================================*/
+UbFileInputBinary::UbFileInputBinary(string filename)
+{
+	this->filename = filename;
+   infile.open(filename.c_str(), ios::in | ios::binary);
+}
+/*==========================================================*/
+bool UbFileInputBinary::open(string filename)
+{
+   infile.close();
+   infile.clear(); //setzt flags zurueck
+   
+   this->filename = filename;
+   infile.open(this->filename.c_str(), ios::in | ios::binary);
+
+   return infile.is_open();
+}
+/*==========================================================*/
+int UbFileInputBinary::readInteger()				
+{
+   int dummy;
+   infile.read((char*)&dummy,sizeof(int));
+   return dummy; 
+}
+/*==========================================================*/
+std::size_t UbFileInputBinary::readSize_t()				
+{
+   std::size_t dummy;
+   infile.read((char*)&dummy,sizeof(std::size_t));
+   return dummy;
+}
+/*==========================================================*/
+double UbFileInputBinary::readDouble()	
+{
+   double dummy;
+   infile.read((char*)&dummy,sizeof(double));
+   return dummy; 
+}
+/*==========================================================*/
+float UbFileInputBinary::readFloat()	
+{
+	float dummy;
+	infile.read((char*)&dummy,sizeof(float));
+	return dummy; 
+}
+/*==========================================================*/
+char UbFileInputBinary::readChar()	
+{
+   char dummy;
+   infile.read((char*)&dummy,sizeof(char));
+   return dummy; 
+}
+/*==========================================================*/
+string UbFileInputBinary::readString()	
+{
+   char c;
+   infile.read(&c,sizeof(char));
+   while(c==' ' || c=='\t') infile.read(&c,sizeof(char));  
+   
+   string dummy;
+   dummy+=c;
+
+   infile.read(&c,sizeof(char));
+   while(c!='\0' && c!=' ' && c!='\t' && c!='\n')
+   {
+      dummy+=c;
+      infile.read(&c,sizeof(char));
+   }
+   return dummy;
+}
+/*==========================================================*/
+bool UbFileInputBinary::readBool()	
+{
+   bool dummy;
+   infile.read((char*)&dummy,sizeof(bool));
+   return dummy; 
+}
+/*==========================================================*/
+void UbFileInputBinary::skipLine()				
+{
+   char c;
+   do{
+      infile.read(&c,sizeof(char));
+   }while(c!='\n');
+}
+/*==========================================================*/
+void UbFileInputBinary::readLine()				
+{
+   char c;
+   infile.read(&c,sizeof(char));
+   while(c!='\n') infile.read(&c,sizeof(char));
+}
+/*==========================================================*/
+string UbFileInputBinary::readStringLine()				
+{
+   char c;
+   string dummy;
+   infile.read(&c,sizeof(char));
+   while(c!='\n')
+   {
+      dummy+=c;
+      infile.read(&c,sizeof(char));
+   }
+   return dummy;
+}
+/*==========================================================*/
+string UbFileInputBinary::readLineTill(char stop)				
+{
+   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
+}
+/*==========================================================*/
+string UbFileInputBinary::parseString()				
+{
+   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
+}
+/*==========================================================*/
+bool UbFileInputBinary::containsString(const string& var)
+{
+   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
+}
+/*==========================================================*/
+void UbFileInputBinary::setPosAfterLineWithString(const string& var)
+{
+   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
+}
+/*==========================================================*/
+int UbFileInputBinary::readIntegerAfterString(const string& var)
+{
+   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
+}
+/*==========================================================*/
+double UbFileInputBinary::readDoubleAfterString(const string& var)	
+{
+   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
+}
+/*==========================================================*/
+string UbFileInputBinary::readStringAfterString(const string& var)	
+{
+   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
+}
+/*==========================================================*/
+bool UbFileInputBinary::readBoolAfterString(const string& var)	
+{
+   UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") );
+}
diff --git a/source/ThirdParty/Library/basics/utilities/UbFileInputBinary.h b/source/VirtualFluidsBasic/basics/utilities/UbFileInputBinary.h
similarity index 92%
rename from source/ThirdParty/Library/basics/utilities/UbFileInputBinary.h
rename to source/VirtualFluidsBasic/basics/utilities/UbFileInputBinary.h
index 1e994ba792ccf82941cd6cf2aba87e5edeb9f51e..c410c822fbc97d5e7924efacf3987d8af657a0b6 100644
--- a/source/ThirdParty/Library/basics/utilities/UbFileInputBinary.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbFileInputBinary.h
@@ -1,71 +1,82 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBFILEINPUTBINARY_H
-#define UBFILEINPUTBINARY_H
-
-#include <fstream>
-#include <iostream>
-#include <string>
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbFileInput.h>
-
-/*=========================================================================*/
-/*  UbFileInputBinary                                                      */
-/*                                                                         */
-/**
-...
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 23.11.04
-*/ 
-
-/*
-usage: ...
-*/
-
-class UbFileInputBinary : public UbFileInput
-{                               
-public:
-   UbFileInputBinary() : UbFileInput() {  }
-   UbFileInputBinary(std::string filename);
-	
-	bool        open(std::string filename);
-
-   void	      skipLine();					   // Springt zur naechsten Zeile
-	void        readLine();		 
-   std::string readStringLine();				
-   std::size_t readSize_t();				
-   int		   readInteger();				   // Liest einen Int-Wert ein
-	double	   readDouble();				   // Liest einen double-Wert ein
-	float 	   readFloat();				   // Liest einen float-Wert ein
-	bool  	   readBool();				      // Liest einen bool-Wert ein
-   char        readChar();                // Liest einen char-Wert ein
-   std::string	readString();				   // Liest ein Wort ein
-	std::string	readLineTill(char stop);	// Liest gesamte Zeile ein bis zu einem bestimmten Zeichen
-	std::string	parseString();	// Liest 
-
-   bool        containsString(const std::string& var);
-   void        setPosAfterLineWithString(const std::string& var);
-   int		   readIntegerAfterString(const std::string& var);
-   double	   readDoubleAfterString(const std::string& var);
-   bool        readBoolAfterString(const std::string& var);
-   std::string readStringAfterString(const std::string& var);
-
-   FILETYPE getFileType() { return BINARY; }
-
-   template< typename T >
-   friend inline UbFileInputBinary& operator>>(UbFileInputBinary& file, T& data) 
-   {
-      file.infile.read((char*)&data,sizeof(T));
-      return file;
-   }
-};
-
-#endif
-
-
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBFILEINPUTBINARY_H
+#define UBFILEINPUTBINARY_H
+
+#include <fstream>
+#include <iostream>
+#include <string>
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbFileInput.h>
+
+/*=========================================================================*/
+/*  UbFileInputBinary                                                      */
+/*                                                                         */
+/**
+...
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 23.11.04
+*/ 
+
+/*
+usage: ...
+*/
+
+class UbFileInputBinary : public UbFileInput
+{                               
+public:
+   UbFileInputBinary() : UbFileInput() {  }
+   UbFileInputBinary(std::string filename);
+	
+	bool        open(std::string filename);
+
+   void	      skipLine();					   // Springt zur naechsten Zeile
+	void        readLine();		 
+   std::string readStringLine();				
+   std::size_t readSize_t();				
+   int		   readInteger();				   // Liest einen Int-Wert ein
+	double	   readDouble();				   // Liest einen double-Wert ein
+	float 	   readFloat();				   // Liest einen float-Wert ein
+	bool  	   readBool();				      // Liest einen bool-Wert ein
+   char        readChar();                // Liest einen char-Wert ein
+   std::string	readString();				   // Liest ein Wort ein
+	std::string	readLineTill(char stop);	// Liest gesamte Zeile ein bis zu einem bestimmten Zeichen
+	std::string	parseString();	// Liest 
+
+   bool        containsString(const std::string& var);
+   void        setPosAfterLineWithString(const std::string& var);
+   int		   readIntegerAfterString(const std::string& var);
+   double	   readDoubleAfterString(const std::string& var);
+   bool        readBoolAfterString(const std::string& var);
+   std::string readStringAfterString(const std::string& var);
+
+   FILETYPE getFileType() { return BINARY; }
+
+   template< typename T >
+   friend inline UbFileInputBinary& operator>>(UbFileInputBinary& file, T& data) 
+   {
+      file.infile.read((char*)&data,sizeof(T));
+      return file;
+   }
+
+   template< typename T>
+   void readVector(std::vector<T>& v)
+   {
+      size_t size = v.size();
+      if (size > 0)
+      {
+         infile.read((char*)&v[0], sizeof(T)*size);
+      }
+   }
+
+};
+
+#endif
+
+
diff --git a/source/ThirdParty/Library/basics/utilities/UbFileOutput.h b/source/VirtualFluidsBasic/basics/utilities/UbFileOutput.h
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbFileOutput.h
rename to source/VirtualFluidsBasic/basics/utilities/UbFileOutput.h
index c55dd82fcf5074e66f709fb662dd680732dacbc3..2ee5ac92fa1a59c31044bc7da95382805b09a389 100644
--- a/source/ThirdParty/Library/basics/utilities/UbFileOutput.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbFileOutput.h
@@ -1,93 +1,93 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBFILEOUTPUT_H
-#define UBFILEOUTPUT_H            
-
-#include <iomanip>
-#include <fstream>
-#include <iostream>
-#include <string>
-
-#include <basics/utilities/UbException.h>
-
-/*=========================================================================*/
-/*  UbFileOutput                                                             */
-/*                                                                         */
-/**
-...
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 23.11.04
-*/ 
-
-/*
-usage: ...
-*/
-
-class UbFileOutput
-{
-public:
-   enum CREATEOPTION {OUTFILE=0, INANDOUTFILE=1, APPENDFILE=2};      
-   enum FILETYPE {ASCII, BINARY};      
-
-public:
-   UbFileOutput() : filename(""), commentindicator('C') {  }
-   UbFileOutput(const std::string& filename)  : filename(filename), commentindicator('C') { }             
-   virtual ~UbFileOutput() { outfile.flush();outfile.close(); }
-
-   virtual bool open(const std::string& filename, CREATEOPTION opt=OUTFILE) = 0;
-
-   virtual bool operator!() { return !(outfile); }
-   virtual bool isOpen()    { return !(!(outfile)); }
-   
-   virtual void flush() { outfile.flush(); }
-   virtual void close() { outfile.close(); }
-   
-   virtual void writeInteger(const int& value, const int& width=0)=0;
-	virtual void writeDouble(const double& value, const int& width=0)=0;
-	virtual void writeFloat(const float& value, const int& width=0)=0;
-   virtual void writeBool(const bool& value, const int& width=0)=0;
-   virtual void writeSize_t(const std::size_t& value, const int& width=0)=0;
-   virtual void writeChar(const char& value, const int& width=0)=0;
-   virtual void writeString(const std::string& value, const int& width=0)=0;
-   virtual void writeStringOnly(const std::string& value)=0;
-	virtual void writeLine(const std::string& value, const int& width=0)=0;
-	virtual void writeLine()=0;
-
-	virtual void writeCommentLine(const std::string& line)=0;
-	virtual void writeCommentLine(char indicator, const std::string& line)=0;
-   virtual void writeCopyOfFile(const std::string& filename)=0;
-	
-   virtual void setCommentIndicator(char commentindicator) {this->commentindicator = commentindicator;} 
-   
-   virtual void setPrecision(const int& precision)=0;
-   virtual int  getPrecision()=0;
-
-   //returns "ASCII", "BINARY"
-   virtual FILETYPE getFileType()=0;
-
-   //returns file extension:
-   //e.g. "./../test/ich.inp" -> "inp", "./../test/ich" -> ""
-   virtual std::string getFileExtension()  
-   {
-	   std::size_t pos1 = filename.rfind("/");
-      if(pos1==std::string::npos) pos1 = 0;
-      std::size_t pos2 = filename.rfind(".");
-      if(pos2!=std::string::npos && pos2>pos1)
-         return filename.substr(pos2+1);
-
-      return "";
-   }				
-
-   virtual std::string  getFileName() {return this->filename;}
-protected:
-   std::ofstream outfile;
-   std::string   filename; 
-   char          commentindicator; 
-};
-
-#endif //UBFILEOUTPUT_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBFILEOUTPUT_H
+#define UBFILEOUTPUT_H            
+
+#include <iomanip>
+#include <fstream>
+#include <iostream>
+#include <string>
+
+#include <basics/utilities/UbException.h>
+
+/*=========================================================================*/
+/*  UbFileOutput                                                             */
+/*                                                                         */
+/**
+...
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 23.11.04
+*/ 
+
+/*
+usage: ...
+*/
+
+class UbFileOutput
+{
+public:
+   enum CREATEOPTION {OUTFILE=0, INANDOUTFILE=1, APPENDFILE=2};      
+   enum FILETYPE {ASCII, BINARY};      
+
+public:
+   UbFileOutput() : filename(""), commentindicator('C') {  }
+   UbFileOutput(const std::string& filename)  : filename(filename), commentindicator('C') { }             
+   virtual ~UbFileOutput() { outfile.flush();outfile.close(); }
+
+   virtual bool open(const std::string& filename, CREATEOPTION opt=OUTFILE) = 0;
+
+   virtual bool operator!() { return !(outfile); }
+   virtual bool isOpen()    { return !(!(outfile)); }
+   
+   virtual void flush() { outfile.flush(); }
+   virtual void close() { outfile.close(); }
+   
+   virtual void writeInteger(const int& value, const int& width=0)=0;
+	virtual void writeDouble(const double& value, const int& width=0)=0;
+	virtual void writeFloat(const float& value, const int& width=0)=0;
+   virtual void writeBool(const bool& value, const int& width=0)=0;
+   virtual void writeSize_t(const std::size_t& value, const int& width=0)=0;
+   virtual void writeChar(const char& value, const int& width=0)=0;
+   virtual void writeString(const std::string& value, const int& width=0)=0;
+   virtual void writeStringOnly(const std::string& value)=0;
+	virtual void writeLine(const std::string& value, const int& width=0)=0;
+	virtual void writeLine()=0;
+
+	virtual void writeCommentLine(const std::string& line)=0;
+	virtual void writeCommentLine(char indicator, const std::string& line)=0;
+   virtual void writeCopyOfFile(const std::string& filename)=0;
+	
+   virtual void setCommentIndicator(char commentindicator) {this->commentindicator = commentindicator;} 
+   
+   virtual void setPrecision(const int& precision)=0;
+   virtual int  getPrecision()=0;
+
+   //returns "ASCII", "BINARY"
+   virtual FILETYPE getFileType()=0;
+
+   //returns file extension:
+   //e.g. "./../test/ich.inp" -> "inp", "./../test/ich" -> ""
+   virtual std::string getFileExtension()  
+   {
+	   std::size_t pos1 = filename.rfind("/");
+      if(pos1==std::string::npos) pos1 = 0;
+      std::size_t pos2 = filename.rfind(".");
+      if(pos2!=std::string::npos && pos2>pos1)
+         return filename.substr(pos2+1);
+
+      return "";
+   }				
+
+   virtual std::string  getFileName() {return this->filename;}
+protected:
+   std::ofstream outfile;
+   std::string   filename; 
+   char          commentindicator; 
+};
+
+#endif //UBFILEOUTPUT_H
diff --git a/source/ThirdParty/Library/basics/utilities/UbFileOutputASCII.cpp b/source/VirtualFluidsBasic/basics/utilities/UbFileOutputASCII.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbFileOutputASCII.cpp
rename to source/VirtualFluidsBasic/basics/utilities/UbFileOutputASCII.cpp
index d68a766be8622f1138f6a0e22863b0962141f0bc..a195f9616cf4880ed31f8e2d42e33f1fd2f53aaa 100644
--- a/source/ThirdParty/Library/basics/utilities/UbFileOutputASCII.cpp
+++ b/source/VirtualFluidsBasic/basics/utilities/UbFileOutputASCII.cpp
@@ -1,177 +1,177 @@
-#include <basics/utilities/UbFileOutputASCII.h>
-#include <basics/utilities/UbSystem.h>
-#include <basics/utilities/UbInfinity.h>
-#include <basics/utilities/UbMath.h>
-#include <cstring>
-
-using namespace std;
-
-UbFileOutputASCII::UbFileOutputASCII(const string& filename, const bool& createPath, const int& precision)
-   : UbFileOutput(filename)
-{
-	this->commentindicator = 'C'; 
-	this->setPrecision(20);
-
-   outfile.open(filename.c_str(),ios::out);
-   
-   if(!outfile && createPath) 
-   {
-      outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(filename);
-      if(path.size()>0) 
-      {
-         UbSystem::makeDirectory(path);
-         outfile.open(filename.c_str(),ios::out);
-      }
-   }
-
-      if(!outfile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) );
-}
-/*==========================================================*/
-UbFileOutputASCII::UbFileOutputASCII(const std::string& filename, CREATEOPTION opt, const bool& createPath, const int& precision)
-   : UbFileOutput(filename)
-{
-	this->commentindicator = 'C'; 
-   this->setPrecision(precision);
-	
-   if(!this->open(filename,opt) && createPath) 
-   {
-      outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(filename);
-      if(path.size()>0) UbSystem::makeDirectory(path);
-
-      this->open(filename,opt);
-   }
-
-   if(!outfile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) );
-}
-/*==========================================================*/
-bool UbFileOutputASCII::open(const std::string& filename, CREATEOPTION opt)
-{
-   outfile.close();
-   outfile.clear(); //setzt flags zurueck
-   this->filename = filename;
-
-   if     (opt==UbFileOutput::OUTFILE      ) outfile.open(this->filename.c_str(),ios::out); 
-   else if(opt==UbFileOutput::INANDOUTFILE ) outfile.open(this->filename.c_str(),ios::out | ios::in);
-   else if(opt==UbFileOutput::APPENDFILE   ) outfile.open(this->filename.c_str(),ios::app);
-   else UB_THROW( UbException(UB_EXARGS,"undefined CREATEOPTION") );
-
-   return outfile.is_open();
-}
-/*==========================================================*/
-void UbFileOutputASCII::writeBool(const bool& value, const int& width)				
-{
-   outfile.width(width);
-   if(value) outfile<<"true ";
-   else      outfile<<"false ";
-}
-/*==========================================================*/
-void UbFileOutputASCII::writeDouble(const double& value, const int& width)				
-{
-   outfile.width(width);
-   //Problem: Ub::inf wird gerundet 
-   //         -> beim Einlesen ist der Wert evtl zu gross und es kommt murks raus 
-   //         -> max Laenge darstellen und gut ist
-   if(UbMath::equal(value, (double)Ub::inf) )
-   {
-      ios_base::fmtflags flags = outfile.flags();
-      outfile<<setprecision(std::numeric_limits<double>::digits10+2);
-      outfile<<value<<" ";
-      outfile.flags(flags);
-      return;
-   }
-   outfile<<value<<" ";
-}
-/*==========================================================*/
-void UbFileOutputASCII::writeFloat(const float& value, const int& width)				
-{
-   outfile.width(width);
-   //Problem: Ub::inf wird gerundet 
-   //         -> beim Einlesen ist der Wert evtl zu gross und es kommt murks raus 
-   //         -> max Laenge darstellen und gut ist
-   if(UbMath::equal(value, (float)Ub::inf) )
-   {
-      ios_base::fmtflags flags = outfile.flags();
-      outfile<<setprecision(std::numeric_limits<float>::digits10+2);
-      outfile<<value<<" ";
-      outfile.flags(flags);
-      return;
-   }
-   outfile<<value<<" ";
-}
-/*==========================================================*/
-void UbFileOutputASCII::setPrecision(const int& precision)				
-{
-   outfile<<setprecision(precision);
-}
-/*==========================================================*/
-void UbFileOutputASCII::writeInteger(const int& value, const int& width)				
-{
-   outfile.width(width);
-   outfile<<value<<" ";
-}
-/*==========================================================*/
-void UbFileOutputASCII::writeSize_t(const std::size_t& value, const int& width)
-{
-   outfile.width(width);
-   outfile<<value<<" ";
-}
-/*==========================================================*/
-void UbFileOutputASCII::writeChar(const char& value, const int& width)
-{
-   outfile.width(width);
-   outfile<<(int)value<<" ";	
-}
-/*==========================================================*/
-void UbFileOutputASCII::writeString(const string& value, const int& width)				
-{
-   outfile.width(width);
-   outfile<<value.c_str()<<" ";	
-}
-/*==========================================================*/
-void UbFileOutputASCII::writeStringOnly(const string& value)				
-{
-	outfile<<value.c_str();	
-}
-
-/*==========================================================*/
-void UbFileOutputASCII::writeLine(const string& value, const int& width)				
-{
-   outfile.width(width);
-   outfile<<value.c_str()<<endl;	
-}
-/*==========================================================*/
-void UbFileOutputASCII::writeLine()				
-{
-	outfile<<endl;	
-}
-/*==========================================================*/
-void UbFileOutputASCII::writeCommentLine(const string& line) 
-{
-   this->writeCommentLine(this->commentindicator, line); 
-}
-/*==========================================================*/
-void UbFileOutputASCII::writeCommentLine(char indicator, const string& line) 
-{
-	this->outfile<<indicator<<line<<endl;
-}
-/*==========================================================*/
-void UbFileOutputASCII::writeCopyOfFile(const string& filename)
-{
-   ifstream infile(filename.c_str());
-   if(!infile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) );
-
-   try
-   {
-      char c;
-      while(infile.get(c)) 
-      {
-         outfile.put(c);  //=out<<c;
-      }
-      outfile.flush();
-      infile.close();
-   }
-   catch(std::exception& e) { UB_THROW( UbException(UB_EXARGS,"catched std::exception, error: "+(std::string)e.what()) ); }
-   catch(...)               { UB_THROW( UbException(UB_EXARGS,"unknown error") ); }
-}
+#include <basics/utilities/UbFileOutputASCII.h>
+#include <basics/utilities/UbSystem.h>
+#include <basics/utilities/UbInfinity.h>
+#include <basics/utilities/UbMath.h>
+#include <cstring>
+
+using namespace std;
+
+UbFileOutputASCII::UbFileOutputASCII(const string& filename, const bool& createPath, const int& precision)
+   : UbFileOutput(filename)
+{
+	this->commentindicator = 'C'; 
+	this->setPrecision(20);
+
+   outfile.open(filename.c_str(),ios::out);
+   
+   if(!outfile && createPath) 
+   {
+      outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(filename);
+      if(path.size()>0) 
+      {
+         UbSystem::makeDirectory(path);
+         outfile.open(filename.c_str(),ios::out);
+      }
+   }
+
+      if(!outfile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) );
+}
+/*==========================================================*/
+UbFileOutputASCII::UbFileOutputASCII(const std::string& filename, CREATEOPTION opt, const bool& createPath, const int& precision)
+   : UbFileOutput(filename)
+{
+	this->commentindicator = 'C'; 
+   this->setPrecision(precision);
+	
+   if(!this->open(filename,opt) && createPath) 
+   {
+      outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(filename);
+      if(path.size()>0) UbSystem::makeDirectory(path);
+
+      this->open(filename,opt);
+   }
+
+   if(!outfile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) );
+}
+/*==========================================================*/
+bool UbFileOutputASCII::open(const std::string& filename, CREATEOPTION opt)
+{
+   outfile.close();
+   outfile.clear(); //setzt flags zurueck
+   this->filename = filename;
+
+   if     (opt==UbFileOutput::OUTFILE      ) outfile.open(this->filename.c_str(),ios::out); 
+   else if(opt==UbFileOutput::INANDOUTFILE ) outfile.open(this->filename.c_str(),ios::out | ios::in);
+   else if(opt==UbFileOutput::APPENDFILE   ) outfile.open(this->filename.c_str(),ios::app);
+   else UB_THROW( UbException(UB_EXARGS,"undefined CREATEOPTION") );
+
+   return outfile.is_open();
+}
+/*==========================================================*/
+void UbFileOutputASCII::writeBool(const bool& value, const int& width)				
+{
+   outfile.width(width);
+   if(value) outfile<<"true ";
+   else      outfile<<"false ";
+}
+/*==========================================================*/
+void UbFileOutputASCII::writeDouble(const double& value, const int& width)				
+{
+   outfile.width(width);
+   //Problem: Ub::inf wird gerundet 
+   //         -> beim Einlesen ist der Wert evtl zu gross und es kommt murks raus 
+   //         -> max Laenge darstellen und gut ist
+   if(UbMath::equal(value, (double)Ub::inf) )
+   {
+      ios_base::fmtflags flags = outfile.flags();
+      outfile<<setprecision(std::numeric_limits<double>::digits10+2);
+      outfile<<value<<" ";
+      outfile.flags(flags);
+      return;
+   }
+   outfile<<value<<" ";
+}
+/*==========================================================*/
+void UbFileOutputASCII::writeFloat(const float& value, const int& width)				
+{
+   outfile.width(width);
+   //Problem: Ub::inf wird gerundet 
+   //         -> beim Einlesen ist der Wert evtl zu gross und es kommt murks raus 
+   //         -> max Laenge darstellen und gut ist
+   if(UbMath::equal(value, (float)Ub::inf) )
+   {
+      ios_base::fmtflags flags = outfile.flags();
+      outfile<<setprecision(std::numeric_limits<float>::digits10+2);
+      outfile<<value<<" ";
+      outfile.flags(flags);
+      return;
+   }
+   outfile<<value<<" ";
+}
+/*==========================================================*/
+void UbFileOutputASCII::setPrecision(const int& precision)				
+{
+   outfile<<setprecision(precision);
+}
+/*==========================================================*/
+void UbFileOutputASCII::writeInteger(const int& value, const int& width)				
+{
+   outfile.width(width);
+   outfile<<value<<" ";
+}
+/*==========================================================*/
+void UbFileOutputASCII::writeSize_t(const std::size_t& value, const int& width)
+{
+   outfile.width(width);
+   outfile<<value<<" ";
+}
+/*==========================================================*/
+void UbFileOutputASCII::writeChar(const char& value, const int& width)
+{
+   outfile.width(width);
+   outfile<<(int)value<<" ";	
+}
+/*==========================================================*/
+void UbFileOutputASCII::writeString(const string& value, const int& width)				
+{
+   outfile.width(width);
+   outfile<<value.c_str()<<" ";	
+}
+/*==========================================================*/
+void UbFileOutputASCII::writeStringOnly(const string& value)				
+{
+	outfile<<value.c_str();	
+}
+
+/*==========================================================*/
+void UbFileOutputASCII::writeLine(const string& value, const int& width)				
+{
+   outfile.width(width);
+   outfile<<value.c_str()<<endl;	
+}
+/*==========================================================*/
+void UbFileOutputASCII::writeLine()				
+{
+	outfile<<endl;	
+}
+/*==========================================================*/
+void UbFileOutputASCII::writeCommentLine(const string& line) 
+{
+   this->writeCommentLine(this->commentindicator, line); 
+}
+/*==========================================================*/
+void UbFileOutputASCII::writeCommentLine(char indicator, const string& line) 
+{
+	this->outfile<<indicator<<line<<endl;
+}
+/*==========================================================*/
+void UbFileOutputASCII::writeCopyOfFile(const string& filename)
+{
+   ifstream infile(filename.c_str());
+   if(!infile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) );
+
+   try
+   {
+      char c;
+      while(infile.get(c)) 
+      {
+         outfile.put(c);  //=out<<c;
+      }
+      outfile.flush();
+      infile.close();
+   }
+   catch(std::exception& e) { UB_THROW( UbException(UB_EXARGS,"catched std::exception, error: "+(std::string)e.what()) ); }
+   catch(...)               { UB_THROW( UbException(UB_EXARGS,"unknown error") ); }
+}
diff --git a/source/ThirdParty/Library/basics/utilities/UbFileOutputASCII.h b/source/VirtualFluidsBasic/basics/utilities/UbFileOutputASCII.h
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbFileOutputASCII.h
rename to source/VirtualFluidsBasic/basics/utilities/UbFileOutputASCII.h
index c0accdfbefc4f78aefc4812ff6f10fbce7e13ac7..065abe9222b03bc65da179e15a50e6524c6f407d 100644
--- a/source/ThirdParty/Library/basics/utilities/UbFileOutputASCII.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbFileOutputASCII.h
@@ -1,72 +1,72 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBFILEOUTPUTASCII_H
-#define UBFILEOUTPUTASCII_H
-
-#include <iomanip>
-#include <fstream>
-#include <iostream>
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbFileOutput.h>
-
-/*=========================================================================*/
-/*  UbFileOutputASCII                                                             */
-/*                                                                         */
-/**
-...
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 23.11.04
-*/ 
-
-/*
-usage: ...
-*/
-
-class UbFileOutputASCII : public UbFileOutput
-{
-public:
-   UbFileOutputASCII() : UbFileOutput() {}
-   UbFileOutputASCII(const std::string& filename, const bool& createPath=true,  const int& precision=15);             
-   UbFileOutputASCII(const std::string& filename, CREATEOPTION opt, const bool& createPath=true, const int& precision=15);
-   
-   bool open(const std::string& filename, CREATEOPTION opt=OUTFILE);
-   
-   void writeBool(const bool& value, const int& width=0);
-   void writeDouble(const double& value, const int& width=0);
-	void writeFloat(const float& value, const int& width=0);
-	void writeInteger(const int& value, const int& width=0);
-   void writeSize_t(const std::size_t& value, const int& width=0);
-   void writeChar(const char& value, const int& width=0);
-   void writeString(const std::string& value, const int& width=0);
-   void writeStringOnly(const std::string& value);
-   void writeLine(const std::string& value, const int& width=0);
-   void writeLine();
-  
-   void setPrecision(const int& precision);
-   int  getPrecision() { return (int)outfile.precision(); }
-
-   void setCommentIndicator(char commentindicator) {this->commentindicator = commentindicator;} 
-   
-   void writeCommentLine(const std::string& line);
-   void writeCommentLine(char indicator, const std::string& line);
-   void writeCopyOfFile(const std::string& filename);
-
-   FILETYPE getFileType() { return ASCII; }
-
-   template< typename T >
-   friend inline UbFileOutputASCII& operator<<(UbFileOutputASCII& file, const T& data) 
-   {
-      file.outfile<<data;
-      return file;
-   }
-};
-
-#endif
-
-
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBFILEOUTPUTASCII_H
+#define UBFILEOUTPUTASCII_H
+
+#include <iomanip>
+#include <fstream>
+#include <iostream>
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbFileOutput.h>
+
+/*=========================================================================*/
+/*  UbFileOutputASCII                                                             */
+/*                                                                         */
+/**
+...
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 23.11.04
+*/ 
+
+/*
+usage: ...
+*/
+
+class UbFileOutputASCII : public UbFileOutput
+{
+public:
+   UbFileOutputASCII() : UbFileOutput() {}
+   UbFileOutputASCII(const std::string& filename, const bool& createPath=true,  const int& precision=15);             
+   UbFileOutputASCII(const std::string& filename, CREATEOPTION opt, const bool& createPath=true, const int& precision=15);
+   
+   bool open(const std::string& filename, CREATEOPTION opt=OUTFILE);
+   
+   void writeBool(const bool& value, const int& width=0);
+   void writeDouble(const double& value, const int& width=0);
+	void writeFloat(const float& value, const int& width=0);
+	void writeInteger(const int& value, const int& width=0);
+   void writeSize_t(const std::size_t& value, const int& width=0);
+   void writeChar(const char& value, const int& width=0);
+   void writeString(const std::string& value, const int& width=0);
+   void writeStringOnly(const std::string& value);
+   void writeLine(const std::string& value, const int& width=0);
+   void writeLine();
+  
+   void setPrecision(const int& precision);
+   int  getPrecision() { return (int)outfile.precision(); }
+
+   void setCommentIndicator(char commentindicator) {this->commentindicator = commentindicator;} 
+   
+   void writeCommentLine(const std::string& line);
+   void writeCommentLine(char indicator, const std::string& line);
+   void writeCopyOfFile(const std::string& filename);
+
+   FILETYPE getFileType() { return ASCII; }
+
+   template< typename T >
+   friend inline UbFileOutputASCII& operator<<(UbFileOutputASCII& file, const T& data) 
+   {
+      file.outfile<<data;
+      return file;
+   }
+};
+
+#endif
+
+
diff --git a/source/ThirdParty/Library/basics/utilities/UbFileOutputBinary.cpp b/source/VirtualFluidsBasic/basics/utilities/UbFileOutputBinary.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbFileOutputBinary.cpp
rename to source/VirtualFluidsBasic/basics/utilities/UbFileOutputBinary.cpp
index 144adbc76b1b020f049f237bbd23c496110ebd9a..bc0cbad6664b27ca7c1da6720aa2cc7149967ab7 100644
--- a/source/ThirdParty/Library/basics/utilities/UbFileOutputBinary.cpp
+++ b/source/VirtualFluidsBasic/basics/utilities/UbFileOutputBinary.cpp
@@ -1,180 +1,180 @@
-#include <basics/utilities/UbFileOutputBinary.h>
-#include <basics/utilities/UbSystem.h>
-#include <cstring>
-
-using namespace std;
-
-/*==========================================================*/
-UbFileOutputBinary::UbFileOutputBinary(const string& filename, const bool& createPath)
-{
-   this->filename         = filename;
-   this->commentindicator = 'C'; 
-
-   outfile.open(filename.c_str(),ios::out | ios::binary);
-
-   if(!outfile && createPath) 
-   {
-      string path = UbSystem::getPathFromString(filename);
-      if(path.size()>0)
-      {
-         outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-         UbSystem::makeDirectory(path);
-         outfile.open(filename.c_str(),ios::out | ios::binary);
-      }
-   }
-
-   if(!outfile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) );
-
-}
-/*==========================================================*/
-UbFileOutputBinary::UbFileOutputBinary(const string& filename,UbFileOutput::CREATEOPTION opt, const bool& createPath)
-{
-   this->filename         = filename;
-   this->commentindicator = 'C'; 
-
-   this->open(filename,opt);
-
-   if(!this->open(filename,opt) && createPath) 
-   {
-      string path = UbSystem::getPathFromString(filename);
-      if(path.size()>0)
-      {
-         outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-         UbSystem::makeDirectory(path,20);
-
-         this->open(filename,opt);     
-      }      
-   }
-
-   if(!outfile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) );
-}
-/*==========================================================*/
-bool UbFileOutputBinary::open(const string& filename, UbFileOutput::CREATEOPTION opt)
-{
-   outfile.close();
-   outfile.clear(); //setzt flags zurueck
-
-   this->filename         = filename;
-
-   if     (opt==UbFileOutput::OUTFILE    )  outfile.open(this->filename.c_str(),ios::out | ios::binary);
-   else if(opt==UbFileOutput::APPENDFILE )  outfile.open(this->filename.c_str(),ios::app | ios::binary);
-   else if(opt==UbFileOutput::INANDOUTFILE) UB_THROW( UbException(UB_EXARGS,"undefined CREATEOPTION - INANDOUTFILE not possible for BINARY files") );
-   else UB_THROW( UbException(UB_EXARGS,"undefined CREATEOPTION") );
-
-   return outfile.is_open();
-}
-/*==========================================================*/
-void UbFileOutputBinary::writeBool(const bool& value, const int& width)				
-{
-   outfile.write((char*)&value,sizeof(bool));
-}
-/*==========================================================*/
-void UbFileOutputBinary::writeDouble(const double& value, const int& width)				
-{
-   outfile.write((char*)&value,sizeof(double));
-}
-/*==========================================================*/
-void UbFileOutputBinary::writeFloat(const float& value, const int& width)				
-{
-	outfile.write((char*)&value,sizeof(float));
-}
-/*==========================================================*/
-void UbFileOutputBinary::setPrecision(const int& precision)				
-{
-   UB_THROW( UbException(UB_EXARGS,"no way") );
-}
-/*==========================================================*/
-int UbFileOutputBinary::getPrecision()				
-{
-   UB_THROW( UbException(UB_EXARGS,"no way") );
-}
-/*==========================================================*/
-void UbFileOutputBinary::writeInteger(const int& value, const int& width)				
-{
-   outfile.write((char*)&value,sizeof(value));
-}
-/*==========================================================*/
-void UbFileOutputBinary::writeSize_t(const std::size_t& value, const int& width)
-{
-   outfile.write((char*)&value,sizeof(value));
-}
-/*==========================================================*/
-void UbFileOutputBinary::writeChar(const char& value, const int& width)				
-{
-   outfile.write((char*)&value,sizeof(value));
-}
-/*==========================================================*/
-void UbFileOutputBinary::writeString(const string& value, const int& width)				
-{
-   char c='\0';
-   unsigned int length = (unsigned)value.length();
-   
-   unsigned pos;
-   //whitespaces und tabs am stringanfang uebergehen
-   for(pos=0; pos<length; pos++)
-      if( value[pos]!=' ' && value[pos]!='\t' ) break;
-
-   while(pos<length)
-   {
-      while(pos<length && value[pos]!=' ' && value[pos]!='\t' && value[pos]!='\0')
-      {
-         outfile.write((char*)&(value[pos++]),sizeof(char));
-      }
-
-      outfile.write(&c,sizeof(char));
-      pos++;
-
-      while(pos<length && (value[pos]==' ' || value[pos]=='\t' || value[pos]=='\0') )
-      {
-         pos++;
-      }
-   }
-}
-/*==========================================================*/
-void UbFileOutputBinary::writeStringOnly(const string& value)				
-{
-   UbException(UB_EXARGS,"no way... causes to many errors");
-}
-/*==========================================================*/
-void UbFileOutputBinary::writeLine(const std::string& value, const int& width)				
-{
-   this->writeString(value);
-   char c='\n';
-   outfile.write(&c,sizeof(char));
-}
-/*==========================================================*/
-void UbFileOutputBinary::writeLine()				
-{
-   char c='\n';
-   outfile.write(&c,sizeof(char));   
-}
-/*==========================================================*/
-void UbFileOutputBinary::writeCommentLine(const string& line) 
-{
-   try        { this->writeCommentLine(this->commentindicator, line); }
-   catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown error") ); }
-}
-/*==========================================================*/
-void UbFileOutputBinary::writeCommentLine(char indicator, const string& line) 
-{
-   string dummy = indicator + line;
-   this->writeLine(dummy);
-}
-/*==========================================================*/
-void UbFileOutputBinary::writeCopyOfFile(const string& filename)
-{
-   ifstream infile(filename.c_str(),ios::in | ios::binary);
-   if(!infile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) );
-
-   try
-   {
-      char c;
-      while(infile.get(c)) 
-      {
-         outfile.put(c);  //=out<<c;
-      }
-      outfile.flush();
-      infile.close();
-   }
-   catch(...) {UB_THROW( UbException(UB_EXARGS,"unknown error") );}
-}
+#include <basics/utilities/UbFileOutputBinary.h>
+#include <basics/utilities/UbSystem.h>
+#include <cstring>
+
+using namespace std;
+
+/*==========================================================*/
+UbFileOutputBinary::UbFileOutputBinary(const string& filename, const bool& createPath)
+{
+   this->filename         = filename;
+   this->commentindicator = 'C'; 
+
+   outfile.open(filename.c_str(),ios::out | ios::binary);
+
+   if(!outfile && createPath) 
+   {
+      string path = UbSystem::getPathFromString(filename);
+      if(path.size()>0)
+      {
+         outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+         UbSystem::makeDirectory(path);
+         outfile.open(filename.c_str(),ios::out | ios::binary);
+      }
+   }
+
+   if(!outfile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) );
+
+}
+/*==========================================================*/
+UbFileOutputBinary::UbFileOutputBinary(const string& filename,UbFileOutput::CREATEOPTION opt, const bool& createPath)
+{
+   this->filename         = filename;
+   this->commentindicator = 'C'; 
+
+   this->open(filename,opt);
+
+   if(!this->open(filename,opt) && createPath) 
+   {
+      string path = UbSystem::getPathFromString(filename);
+      if(path.size()>0)
+      {
+         outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+         UbSystem::makeDirectory(path,20);
+
+         this->open(filename,opt);     
+      }      
+   }
+
+   if(!outfile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) );
+}
+/*==========================================================*/
+bool UbFileOutputBinary::open(const string& filename, UbFileOutput::CREATEOPTION opt)
+{
+   outfile.close();
+   outfile.clear(); //setzt flags zurueck
+
+   this->filename         = filename;
+
+   if     (opt==UbFileOutput::OUTFILE    )  outfile.open(this->filename.c_str(),ios::out | ios::binary);
+   else if(opt==UbFileOutput::APPENDFILE )  outfile.open(this->filename.c_str(),ios::app | ios::binary);
+   else if(opt==UbFileOutput::INANDOUTFILE) UB_THROW( UbException(UB_EXARGS,"undefined CREATEOPTION - INANDOUTFILE not possible for BINARY files") );
+   else UB_THROW( UbException(UB_EXARGS,"undefined CREATEOPTION") );
+
+   return outfile.is_open();
+}
+/*==========================================================*/
+void UbFileOutputBinary::writeBool(const bool& value, const int& width)				
+{
+   outfile.write((char*)&value,sizeof(bool));
+}
+/*==========================================================*/
+void UbFileOutputBinary::writeDouble(const double& value, const int& width)				
+{
+   outfile.write((char*)&value,sizeof(double));
+}
+/*==========================================================*/
+void UbFileOutputBinary::writeFloat(const float& value, const int& width)				
+{
+	outfile.write((char*)&value,sizeof(float));
+}
+/*==========================================================*/
+void UbFileOutputBinary::setPrecision(const int& precision)				
+{
+   UB_THROW( UbException(UB_EXARGS,"no way") );
+}
+/*==========================================================*/
+int UbFileOutputBinary::getPrecision()				
+{
+   UB_THROW( UbException(UB_EXARGS,"no way") );
+}
+/*==========================================================*/
+void UbFileOutputBinary::writeInteger(const int& value, const int& width)				
+{
+   outfile.write((char*)&value,sizeof(value));
+}
+/*==========================================================*/
+void UbFileOutputBinary::writeSize_t(const std::size_t& value, const int& width)
+{
+   outfile.write((char*)&value,sizeof(value));
+}
+/*==========================================================*/
+void UbFileOutputBinary::writeChar(const char& value, const int& width)				
+{
+   outfile.write((char*)&value,sizeof(value));
+}
+/*==========================================================*/
+void UbFileOutputBinary::writeString(const string& value, const int& width)				
+{
+   char c='\0';
+   unsigned int length = (unsigned)value.length();
+   
+   unsigned pos;
+   //whitespaces und tabs am stringanfang uebergehen
+   for(pos=0; pos<length; pos++)
+      if( value[pos]!=' ' && value[pos]!='\t' ) break;
+
+   while(pos<length)
+   {
+      while(pos<length && value[pos]!=' ' && value[pos]!='\t' && value[pos]!='\0')
+      {
+         outfile.write((char*)&(value[pos++]),sizeof(char));
+      }
+
+      outfile.write(&c,sizeof(char));
+      pos++;
+
+      while(pos<length && (value[pos]==' ' || value[pos]=='\t' || value[pos]=='\0') )
+      {
+         pos++;
+      }
+   }
+}
+/*==========================================================*/
+void UbFileOutputBinary::writeStringOnly(const string& value)				
+{
+   UbException(UB_EXARGS,"no way... causes to many errors");
+}
+/*==========================================================*/
+void UbFileOutputBinary::writeLine(const std::string& value, const int& width)				
+{
+   this->writeString(value);
+   char c='\n';
+   outfile.write(&c,sizeof(char));
+}
+/*==========================================================*/
+void UbFileOutputBinary::writeLine()				
+{
+   char c='\n';
+   outfile.write(&c,sizeof(char));   
+}
+/*==========================================================*/
+void UbFileOutputBinary::writeCommentLine(const string& line) 
+{
+   try        { this->writeCommentLine(this->commentindicator, line); }
+   catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown error") ); }
+}
+/*==========================================================*/
+void UbFileOutputBinary::writeCommentLine(char indicator, const string& line) 
+{
+   string dummy = indicator + line;
+   this->writeLine(dummy);
+}
+/*==========================================================*/
+void UbFileOutputBinary::writeCopyOfFile(const string& filename)
+{
+   ifstream infile(filename.c_str(),ios::in | ios::binary);
+   if(!infile) UB_THROW( UbException(UB_EXARGS,"couldn't open file:\n "+filename) );
+
+   try
+   {
+      char c;
+      while(infile.get(c)) 
+      {
+         outfile.put(c);  //=out<<c;
+      }
+      outfile.flush();
+      infile.close();
+   }
+   catch(...) {UB_THROW( UbException(UB_EXARGS,"unknown error") );}
+}
diff --git a/source/ThirdParty/Library/basics/utilities/UbFileOutputBinary.h b/source/VirtualFluidsBasic/basics/utilities/UbFileOutputBinary.h
similarity index 92%
rename from source/ThirdParty/Library/basics/utilities/UbFileOutputBinary.h
rename to source/VirtualFluidsBasic/basics/utilities/UbFileOutputBinary.h
index fac53e7ac439f4fe55410043f5830ff72fc4c852..76c50246793f61f294fe8305fb9fd46f0a807842 100644
--- a/source/ThirdParty/Library/basics/utilities/UbFileOutputBinary.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbFileOutputBinary.h
@@ -1,70 +1,80 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBFILEOUTPUTBINARY_H
-#define UBFILEOUTPUTBINARY_H
-
-#include <iomanip>
-#include <fstream>
-#include <iostream>
-
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbFileOutput.h>
-
-/*=========================================================================*/
-/*  UbFileOutputBinary                                                             */
-/*                                                                         */
-/**
-...
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 23.11.04
-*/ 
-
-/*
-usage: ...
-*/
-
-class UbFileOutputBinary : public UbFileOutput
-{
-public:
-   UbFileOutputBinary() : UbFileOutput() {}
-   UbFileOutputBinary(const std::string& filename, const bool& createPath=true);
-   UbFileOutputBinary(const std::string& filename, UbFileOutput::CREATEOPTION opt, const bool& createPath);
-   
-   bool open(const std::string& filename, UbFileOutput::CREATEOPTION opt=OUTFILE);
-
-   void writeInteger(const int& value, const int& width=0);
-   void writeDouble(const double& value, const int& width=0);
-	void writeFloat(const float& value, const int& width=0);
-	void writeBool(const bool& value, const int& width=0);
-   void writeChar(const char& value, const int& width=0);
-   void writeSize_t(const std::size_t& value, const int& width=0);
-   void writeString(const std::string& value, const int& width=0);
-   void writeStringOnly(const std::string& value);
-   void writeLine(const std::string& value, const int& width=0);
-   void writeLine();
-   void writeCommentLine(const std::string& line);
-   void writeCommentLine(char indicator, const std::string& line);
-   void writeCopyOfFile(const std::string& filename);
-
-   void setPrecision(const int& precision);
-   int  getPrecision();
-
-   FILETYPE getFileType() { return BINARY; }
-
-   template< typename T >
-   friend inline UbFileOutputBinary& operator<<(UbFileOutputBinary& file, const T& data) 
-   {
-      file.outfile.write((char*)&data,sizeof(T));
-      return file;
-   }
-};
-
-#endif
-
-
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBFILEOUTPUTBINARY_H
+#define UBFILEOUTPUTBINARY_H
+
+#include <iomanip>
+#include <fstream>
+#include <iostream>
+
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbFileOutput.h>
+
+/*=========================================================================*/
+/*  UbFileOutputBinary                                                             */
+/*                                                                         */
+/**
+...
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 23.11.04
+*/ 
+
+/*
+usage: ...
+*/
+
+class UbFileOutputBinary : public UbFileOutput
+{
+public:
+   UbFileOutputBinary() : UbFileOutput() {}
+   UbFileOutputBinary(const std::string& filename, const bool& createPath=true);
+   UbFileOutputBinary(const std::string& filename, UbFileOutput::CREATEOPTION opt, const bool& createPath);
+   
+   bool open(const std::string& filename, UbFileOutput::CREATEOPTION opt=OUTFILE);
+
+   void writeInteger(const int& value, const int& width=0);
+   void writeDouble(const double& value, const int& width=0);
+	void writeFloat(const float& value, const int& width=0);
+	void writeBool(const bool& value, const int& width=0);
+   void writeChar(const char& value, const int& width=0);
+   void writeSize_t(const std::size_t& value, const int& width=0);
+   void writeString(const std::string& value, const int& width=0);
+   void writeStringOnly(const std::string& value);
+   void writeLine(const std::string& value, const int& width=0);
+   void writeLine();
+   void writeCommentLine(const std::string& line);
+   void writeCommentLine(char indicator, const std::string& line);
+   void writeCopyOfFile(const std::string& filename);
+
+   void setPrecision(const int& precision);
+   int  getPrecision();
+
+   FILETYPE getFileType() { return BINARY; }
+
+   template< typename T >
+   friend inline UbFileOutputBinary& operator<<(UbFileOutputBinary& file, const T& data) 
+   {
+      file.outfile.write((char*)&data,sizeof(T));
+      return file;
+   }
+
+   template< typename T>
+   void writeVector(std::vector<T>& v)
+   {
+      size_t size = v.size();
+      if (size > 0)
+      {
+         outfile.write((char*)&v[0],sizeof(T)*size);
+      }
+   }
+};
+
+#endif
+
+
diff --git a/source/ThirdParty/Library/basics/utilities/UbInfinity.h b/source/VirtualFluidsBasic/basics/utilities/UbInfinity.h
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbInfinity.h
rename to source/VirtualFluidsBasic/basics/utilities/UbInfinity.h
index 18546b8ad9d29c6c6119446243953ae235342724..5c889c894285fc7e4191fc44915a23de911692c8 100644
--- a/source/ThirdParty/Library/basics/utilities/UbInfinity.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbInfinity.h
@@ -1,180 +1,180 @@
-#ifndef UB_INFINITY_H
-#define UB_INFINITY_H
-#include <limits>
-
-#include <basics/utilities/UbLimits.h>
-#include <basics/utilities/UbSystem.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-//
-//  UbNegInfinity
-//  Anm: keine template klasse, da man am Ende eine Instanz "inf" verwendet
-//       die in "verschiedene"(!!!) Typen konvertiert werden kann und nicht 
-//       nur in den template Typ!
-//  Note: The UbNegInfinity class cannot be instantiated on its own, but works 
-//        as a base class for the Infinity class.
-//////////////////////////////////////////////////////////////////////////
-class UbNegInfinity
-{
- public:
-   //name Conversion operators 
-   inline operator signed char() const { return UbLimits<signed char>::ninf(); }
-   inline operator char()        const { return UbLimits<char>::ninf();        }
-   inline operator wchar_t()     const { return UbLimits<wchar_t>::ninf();     }
-   inline operator short()       const { return UbLimits<short>::ninf();       }
-   inline operator int()         const { return UbLimits<int>::ninf();         }
-   inline operator long()        const { return UbLimits<long>::ninf();        }
-   inline operator float()       const { return UbLimits<float>::ninf();       }
-   inline operator double()      const { return UbLimits<double>::ninf();      }
-   inline operator long double() const { return UbLimits<long double>::ninf(); }
-
-   // This function compares built-in data types with their largest possible value. The function
-   // only works for built-in data types. The attempt to compare user-defined class types will
-   // result in a compile time error.
-   template< typename T >
-   inline bool equal( const T& rhs ) const
-   {
-      UB_STATIC_ASSERT( std::numeric_limits<T>::is_specialized );
-      return UbLimits<T>::ninf() == rhs;
-   }
- protected:
-    inline UbNegInfinity() {}
-
- private:
-   UbNegInfinity( const UbNegInfinity& ninf );             //copy constructor (private & undefined)
-   UbNegInfinity& operator=( const UbNegInfinity& ninf );  //copy assignment operator (private & undefined)
-   void* operator&() const;                                //address operator (private & undefined)
-};
-
-//=================================================================================================
-//
-//  GLOBAL OPERATORS
-//
-//=================================================================================================
-template< typename T >
-inline bool operator==( const UbNegInfinity& lhs, const T& rhs )
-{
-   return lhs.equal( rhs );
-}
-//*************************************************************************************************
-template< typename T >
-inline bool operator==( const T& lhs, const UbNegInfinity& rhs )
-{
-   return rhs.equal( lhs );
-}
-//*************************************************************************************************
-template< typename T >
-inline bool operator!=( const UbNegInfinity& lhs, const T& rhs )
-{
-   return !lhs.equal( rhs );
-}
-//*************************************************************************************************
-template< typename T >
-inline bool operator!=( const T& lhs, const UbNegInfinity& rhs )
-{
-   return !rhs.equal( lhs );
-}
-
-//////////////////////////////////////////////////////////////////////////
-//
-//  UbInfinity
-//
-//////////////////////////////////////////////////////////////////////////
-class UbInfinity : public UbNegInfinity //um später -UbInfinity leichter zu implementieren!!!
-{
- public:
-   inline UbInfinity() 
-      : UbNegInfinity()
-    {}
-   
-   inline operator unsigned char()  const  { return UbLimits<unsigned char>::inf();  }
-   inline operator signed char()    const  { return UbLimits<signed char>::inf();    }
-   inline operator char()           const  { return UbLimits<char>::inf();           }
-   inline operator wchar_t()        const  { return UbLimits<wchar_t>::inf();        }
-   inline operator unsigned short() const  { return UbLimits<unsigned short>::inf(); }
-   inline operator short()          const  { return UbLimits<short>::inf();          }
-   inline operator unsigned int()   const  { return UbLimits<unsigned int>::inf();   }
-   inline operator int()            const  { return UbLimits<int>::inf();            }
-   inline operator unsigned long()  const  { return UbLimits<unsigned long>::inf();  }
-   inline operator long()           const  { return UbLimits<long>::inf();           }
-   inline operator float()          const  { return UbLimits<float>::inf();          }
-   inline operator double()         const  { return UbLimits<double>::inf();         }
-   inline operator long double()    const  { return UbLimits<long double>::inf();    }
-
-   inline const UbNegInfinity& operator-() const { return static_cast<const UbNegInfinity&>( *this ); }
-
-   /*==========================================================*/
-   template< typename T >
-   inline bool equal( const T& rhs ) const
-   {
-      UB_STATIC_ASSERT( std::numeric_limits<T>::is_specialized );
-      return UbLimits<T>::inf() == rhs;
-   }
-
- private:
-   UbInfinity( const UbInfinity& inf );             //Copy constructor (private & undefined)
-   UbInfinity& operator=( const UbInfinity& inf );  //Copy assignment operator (private & undefined)
-   void* operator&() const;                         //Address operator (private & undefined)
-};
-
-//////////////////////////////////////////////////////////////////////////
-//  GLOBAL OPERATORS
-//////////////////////////////////////////////////////////////////////////
-template< typename T >
-inline bool operator==( const UbInfinity& lhs, const T& rhs );
-
-template< typename T >
-inline bool operator==( const T& lhs, const UbInfinity& rhs );
-
-template< typename T >
-inline bool operator!=( const UbInfinity& lhs, const T& rhs );
-
-template< typename T >
-inline bool operator!=( const T& lhs, const UbInfinity& rhs );
-//@}
-//*************************************************************************************************
-
-
-//*************************************************************************************************
-/*!\brief Equality comparison between an Infinity object and a built-in data type.
-// \ingroup util
-//
-// This operator works only for built-in data types. The attempt to compare user-defined class
-// types will result in a compile time error.
-*/
-template< typename T >
-inline bool operator==( const UbInfinity& lhs, const T& rhs )
-{
-   return lhs.equal( rhs );
-}
-//*************************************************************************************************
-template< typename T >
-inline bool operator==( const T& lhs, const UbInfinity& rhs )
-{
-   return rhs.equal( lhs );
-}
-//*************************************************************************************************
-template< typename T >
-inline bool operator!=( const UbInfinity& lhs, const T& rhs )
-{
-   return !lhs.equal( rhs );
-}
-//*************************************************************************************************
-template< typename T >
-inline bool operator!=( const T& lhs, const UbInfinity& rhs )
-{
-   return !rhs.equal( lhs );
-}
-//*************************************************************************************************
-
-//////////////////////////////////////////////////////////////////////////
-//  GLOBAL INFINITY VALUE
-//////////////////////////////////////////////////////////////////////////
-namespace Ub
-{
-   //e.g. double x = UbSystem::inf;  float x = -Ub::inf; 
-   const UbInfinity inf; 
-} 
-
-#endif //UB_INFINITY_H
+#ifndef UB_INFINITY_H
+#define UB_INFINITY_H
+#include <limits>
+
+#include <basics/utilities/UbLimits.h>
+#include <basics/utilities/UbSystem.h>
+
+
+//////////////////////////////////////////////////////////////////////////
+//
+//  UbNegInfinity
+//  Anm: keine template klasse, da man am Ende eine Instanz "inf" verwendet
+//       die in "verschiedene"(!!!) Typen konvertiert werden kann und nicht 
+//       nur in den template Typ!
+//  Note: The UbNegInfinity class cannot be instantiated on its own, but works 
+//        as a base class for the Infinity class.
+//////////////////////////////////////////////////////////////////////////
+class UbNegInfinity
+{
+ public:
+   //name Conversion operators 
+   inline operator signed char() const { return UbLimits<signed char>::ninf(); }
+   inline operator char()        const { return UbLimits<char>::ninf();        }
+   inline operator wchar_t()     const { return UbLimits<wchar_t>::ninf();     }
+   inline operator short()       const { return UbLimits<short>::ninf();       }
+   inline operator int()         const { return UbLimits<int>::ninf();         }
+   inline operator long()        const { return UbLimits<long>::ninf();        }
+   inline operator float()       const { return UbLimits<float>::ninf();       }
+   inline operator double()      const { return UbLimits<double>::ninf();      }
+   inline operator long double() const { return UbLimits<long double>::ninf(); }
+
+   // This function compares built-in data types with their largest possible value. The function
+   // only works for built-in data types. The attempt to compare user-defined class types will
+   // result in a compile time error.
+   template< typename T >
+   inline bool equal( const T& rhs ) const
+   {
+      UB_STATIC_ASSERT( std::numeric_limits<T>::is_specialized );
+      return UbLimits<T>::ninf() == rhs;
+   }
+ protected:
+    inline UbNegInfinity() {}
+
+ private:
+   UbNegInfinity( const UbNegInfinity& ninf );             //copy constructor (private & undefined)
+   UbNegInfinity& operator=( const UbNegInfinity& ninf );  //copy assignment operator (private & undefined)
+   void* operator&() const;                                //address operator (private & undefined)
+};
+
+//=================================================================================================
+//
+//  GLOBAL OPERATORS
+//
+//=================================================================================================
+template< typename T >
+inline bool operator==( const UbNegInfinity& lhs, const T& rhs )
+{
+   return lhs.equal( rhs );
+}
+//*************************************************************************************************
+template< typename T >
+inline bool operator==( const T& lhs, const UbNegInfinity& rhs )
+{
+   return rhs.equal( lhs );
+}
+//*************************************************************************************************
+template< typename T >
+inline bool operator!=( const UbNegInfinity& lhs, const T& rhs )
+{
+   return !lhs.equal( rhs );
+}
+//*************************************************************************************************
+template< typename T >
+inline bool operator!=( const T& lhs, const UbNegInfinity& rhs )
+{
+   return !rhs.equal( lhs );
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+//  UbInfinity
+//
+//////////////////////////////////////////////////////////////////////////
+class UbInfinity : public UbNegInfinity //um später -UbInfinity leichter zu implementieren!!!
+{
+ public:
+   inline UbInfinity() 
+      : UbNegInfinity()
+    {}
+   
+   inline operator unsigned char()  const  { return UbLimits<unsigned char>::inf();  }
+   inline operator signed char()    const  { return UbLimits<signed char>::inf();    }
+   inline operator char()           const  { return UbLimits<char>::inf();           }
+   inline operator wchar_t()        const  { return UbLimits<wchar_t>::inf();        }
+   inline operator unsigned short() const  { return UbLimits<unsigned short>::inf(); }
+   inline operator short()          const  { return UbLimits<short>::inf();          }
+   inline operator unsigned int()   const  { return UbLimits<unsigned int>::inf();   }
+   inline operator int()            const  { return UbLimits<int>::inf();            }
+   inline operator unsigned long()  const  { return UbLimits<unsigned long>::inf();  }
+   inline operator long()           const  { return UbLimits<long>::inf();           }
+   inline operator float()          const  { return UbLimits<float>::inf();          }
+   inline operator double()         const  { return UbLimits<double>::inf();         }
+   inline operator long double()    const  { return UbLimits<long double>::inf();    }
+
+   inline const UbNegInfinity& operator-() const { return static_cast<const UbNegInfinity&>( *this ); }
+
+   /*==========================================================*/
+   template< typename T >
+   inline bool equal( const T& rhs ) const
+   {
+      UB_STATIC_ASSERT( std::numeric_limits<T>::is_specialized );
+      return UbLimits<T>::inf() == rhs;
+   }
+
+ private:
+   UbInfinity( const UbInfinity& inf );             //Copy constructor (private & undefined)
+   UbInfinity& operator=( const UbInfinity& inf );  //Copy assignment operator (private & undefined)
+   void* operator&() const;                         //Address operator (private & undefined)
+};
+
+//////////////////////////////////////////////////////////////////////////
+//  GLOBAL OPERATORS
+//////////////////////////////////////////////////////////////////////////
+template< typename T >
+inline bool operator==( const UbInfinity& lhs, const T& rhs );
+
+template< typename T >
+inline bool operator==( const T& lhs, const UbInfinity& rhs );
+
+template< typename T >
+inline bool operator!=( const UbInfinity& lhs, const T& rhs );
+
+template< typename T >
+inline bool operator!=( const T& lhs, const UbInfinity& rhs );
+//@}
+//*************************************************************************************************
+
+
+//*************************************************************************************************
+/*!\brief Equality comparison between an Infinity object and a built-in data type.
+// \ingroup util
+//
+// This operator works only for built-in data types. The attempt to compare user-defined class
+// types will result in a compile time error.
+*/
+template< typename T >
+inline bool operator==( const UbInfinity& lhs, const T& rhs )
+{
+   return lhs.equal( rhs );
+}
+//*************************************************************************************************
+template< typename T >
+inline bool operator==( const T& lhs, const UbInfinity& rhs )
+{
+   return rhs.equal( lhs );
+}
+//*************************************************************************************************
+template< typename T >
+inline bool operator!=( const UbInfinity& lhs, const T& rhs )
+{
+   return !lhs.equal( rhs );
+}
+//*************************************************************************************************
+template< typename T >
+inline bool operator!=( const T& lhs, const UbInfinity& rhs )
+{
+   return !rhs.equal( lhs );
+}
+//*************************************************************************************************
+
+//////////////////////////////////////////////////////////////////////////
+//  GLOBAL INFINITY VALUE
+//////////////////////////////////////////////////////////////////////////
+namespace Ub
+{
+   //e.g. double x = UbSystem::inf;  float x = -Ub::inf; 
+   const UbInfinity inf; 
+} 
+
+#endif //UB_INFINITY_H
diff --git a/source/ThirdParty/Library/basics/utilities/UbKeys.h b/source/VirtualFluidsBasic/basics/utilities/UbKeys.h
similarity index 96%
rename from source/ThirdParty/Library/basics/utilities/UbKeys.h
rename to source/VirtualFluidsBasic/basics/utilities/UbKeys.h
index 0d241dc98d3833e0e933f47e7edfeb6492bd4119..b58299b0000445446de4a5886966f966f863f686 100644
--- a/source/ThirdParty/Library/basics/utilities/UbKeys.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbKeys.h
@@ -1,285 +1,285 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBKEYS_H
-#define UBKEYS_H
-
-#include <iostream>
-
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-/*=========================================================================*/
-/*  UbKeys                                                             */
-/*                                                                         */
-/**
-namespace for global Keys (e.g. for STL-maps)
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 08.08.07
-*/ 
-
-/*
-usage: ...
-*/
-
-namespace UbKeys
-{
-   //nested class
-   template< typename T1, typename T2 = T1 >
-   class Key2 
-   {
-   public:
-      //////////////////////////////////////////////////////////////////////////
-      //Konstruktoren
-      Key2(const T1& t1, const T2& t2) 
-         : t1(t1), t2(t2)
-      { 
-      }
-      /*==========================================================*/
-      Key2& operator=(const Key2& srcKey) 
-      {
-         if(this == &srcKey ) return *this;
-
-         t1    = srcKey.t1;
-         t2    = srcKey.t2;
-
-         return *this;
-      }
-      /*==========================================================*/
-      T1 getT1() const { return t1; }
-      T2 getT2() const { return t2; }
-
-      //////////////////////////////////////////////////////////////////////////
-      //global ueberladene Operatoren
-      friend inline bool operator<(const Key2& lhsKey,const Key2& rhsKey)  
-      {
-         if( lhsKey.t1 < rhsKey.t1 ) return true;
-         if( lhsKey.t1 > rhsKey.t1 ) return false;
-         if( lhsKey.t2 < rhsKey.t2 ) return true;
-
-         return false;
-      }
-      /*==========================================================*/
-      friend inline bool operator==(const Key2& lhsKey, const Key2& rhsKey)  
-      {
-         if(lhsKey.t1 != rhsKey.t1 ) return false;
-         if(lhsKey.t2 != rhsKey.t2 ) return false;
-
-         return true;
-      }
-      //ueberladene Operatoren
-      friend inline bool operator!=(const Key2& lhsKey, const Key2& rhsKey)  
-      {
-         return !(lhsKey == rhsKey); 
-      }
-      //ueberladene Operatoren
-      /*==========================================================*/
-      friend inline std::ostream& operator << (std::ostream& os, const Key2& key) 
-      {
-         os<<"Key2<"<<typeid(T1).name()<<","<<typeid(T2).name()<<">,("<<key.t1<<","<<key.t2<<")";
-         return os;
-      }
-      /*==========================================================*/
-      #ifdef CAB_RCF
-	      template<class Archive>
-	      void serialize(Archive & ar, const unsigned int version)
-	      {
-		      ar & t1;
-		      ar & t2;
-	      }
-      #endif //CAB_RCF
-
-   private:
-      //////////////////////////////////////////////////////////////////////////
-      //private Member
-      T1 t1;
-      T2 t2;
-
-   };
-
-   //////////////////////////////////////////////////////////////////////////
-   //
-   //////////////////////////////////////////////////////////////////////////
-   template< typename T1, typename T2 = T1, typename T3 = T1 >
-   class Key3 
-   {
-   public:
-      //////////////////////////////////////////////////////////////////////////
-      //Konstruktoren
-      Key3() : t1(0), t2(0), t3(0)
-      {
-
-      }
-      Key3(const T1& t1, const T2& t2, const T3& t3) 
-         : t1(t1), t2(t2), t3(t3)
-      { 
-      }
-      /*==========================================================*/
-      T1 getT1() const { return t1; }
-      T2 getT2() const { return t2; }
-      T3 getT3() const { return t3; }
-      /*==========================================================*/
-      Key3& operator=(const Key3& srcKey) 
-      {
-         if(this == &srcKey ) return *this;
-
-         t1    = srcKey.t1;
-         t2    = srcKey.t2;
-         t3    = srcKey.t3;
-
-         return *this;
-      }
-
-      //////////////////////////////////////////////////////////////////////////
-      //global ueberladene Operatoren
-      friend inline bool operator<(const Key3& lhsKey,const Key3& rhsKey)  
-      {
-         if( lhsKey.t1 < rhsKey.t1 ) return true;
-         if( lhsKey.t1 > rhsKey.t1 ) return false;
-         if( lhsKey.t2 < rhsKey.t2 ) return true;
-         if( lhsKey.t2 > rhsKey.t2 ) return false;
-         if( lhsKey.t3 < rhsKey.t3 ) return true;
-
-         return false;
-      }
-      /*==========================================================*/
-      friend inline bool operator==(const Key3& lhsKey,const Key3& rhsKey)  
-      {
-         if(lhsKey.t1 != rhsKey.t1 ) return false;
-         if(lhsKey.t2 != rhsKey.t2 ) return false;
-         if(lhsKey.t3 != rhsKey.t3 ) return false;
-
-         return true;
-      }
-      /*==========================================================*/
-      //ueberladene Operatoren
-      friend inline bool operator!=(const Key3& lhsKey, const Key3& rhsKey) 
-      {
-         return !(lhsKey == rhsKey); 
-      }
-
-      //ueberladene Operatoren
-      /*==========================================================*/
-      friend inline std::ostream& operator << (std::ostream& os, const Key3& key) 
-      {
-         os<<"Key3<"<<typeid(T1).name()<<","<<typeid(T2).name()<<","<<typeid(T3).name();
-         os<<">,("<<key.t1<<","<<key.t2<<","<<key.t3<<")";
-         return os;
-      }
-      /*==========================================================*/
-      #ifdef CAB_RCF
-	      template<class Archive>
-	      void serialize(Archive & ar, const unsigned int version)
-	      {
-		      ar & t1;
-		      ar & t2;
-            ar & t3;
-         }
-      #endif //CAB_RCF
-
-   private:
-      //////////////////////////////////////////////////////////////////////////
-      //private Member
-      T1 t1;
-      T2 t2;
-      T3 t3;
-   };
-
-   //////////////////////////////////////////////////////////////////////////
-   //
-   //////////////////////////////////////////////////////////////////////////
-   template< typename T1, typename T2 = T1, typename T3 = T1, typename T4 = T1 >
-   class Key4 
-   {
-   public:
-      //////////////////////////////////////////////////////////////////////////
-      //Konstruktoren
-      Key4(const T1& t1, const T2& t2, const T3& t3, const T4& t4) 
-         : t1(t1), t2(t2), t3(t3), t4(t4)
-      { 
-      }
-      /*==========================================================*/
-      T1 getT1() const { return t1; }
-      T2 getT2() const { return t2; }
-      T3 getT3() const { return t3; }
-      T4 getT4() const { return t4; }
-      /*==========================================================*/
-      Key4& operator=(const Key4& srcKey) 
-      {
-         if(this == &srcKey ) return *this;
-
-         t1    = srcKey.t1;
-         t2    = srcKey.t2;
-         t3    = srcKey.t3;
-         t4    = srcKey.t4;
-
-         return *this;
-      }
-      //////////////////////////////////////////////////////////////////////////
-      //global ueberladene Operatoren
-      friend inline bool operator<(const Key4& lhsKey,const Key4& rhsKey)  
-      {
-         if( lhsKey.t1 < rhsKey.t1 ) return true;
-         if( lhsKey.t1 > rhsKey.t1 ) return false;
-         if( lhsKey.t2 < rhsKey.t2 ) return true;
-         if( lhsKey.t2 > rhsKey.t2 ) return false;
-         if( lhsKey.t3 < rhsKey.t3 ) return true;
-         if( lhsKey.t3 > rhsKey.t3 ) return false;
-         if( lhsKey.t4 < rhsKey.t4 ) return true;
-
-         return false;
-      }
-      /*==========================================================*/
-      friend inline bool operator==(const Key4& lhsKey,const Key4& rhsKey)  
-      {
-         if(lhsKey.t1 != rhsKey.t1 ) return false;
-         if(lhsKey.t2 != rhsKey.t2 ) return false;
-         if(lhsKey.t3 != rhsKey.t3 ) return false;
-         if(lhsKey.t4 != rhsKey.t4 ) return false;
-
-         return true;
-      }
-
-      //ueberladene Operatoren
-      friend inline bool operator!=(const Key4& lhsKey, const Key4& rhsKey) 
-      {
-         return !(lhsKey == rhsKey); 
-      }
-      //ueberladene Operatoren
-      /*==========================================================*/
-      friend inline std::ostream& operator << (std::ostream& os, const Key4& key) 
-      {
-         os<<"Key4<"<<typeid(T1).name()<<","<<typeid(T2).name()<<","<<typeid(T3).name()<<","<<typeid(T4).name();
-         os<<">,("<<key.t1<<","<<key.t2<<","<<key.t3<<","<<key.t4<<")";
-         return os;
-      }
-      /*==========================================================*/
-      #ifdef CAB_RCF
-	      template<class Archive>
-	      void serialize(Archive & ar, const unsigned int version)
-	      {
-		      ar & t1;
-		      ar & t2;
-            ar & t3;
-            ar & t4;
-         }
-      #endif //CAB_RCF
-
-   private:
-      //////////////////////////////////////////////////////////////////////////
-      //private Member
-      T1 t1;
-      T2 t2;
-      T3 t3;
-      T4 t4;
-
-   };
-}
-
-#endif //UBKEYS_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBKEYS_H
+#define UBKEYS_H
+
+#include <iostream>
+
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+/*=========================================================================*/
+/*  UbKeys                                                             */
+/*                                                                         */
+/**
+namespace for global Keys (e.g. for STL-maps)
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 08.08.07
+*/ 
+
+/*
+usage: ...
+*/
+
+namespace UbKeys
+{
+   //nested class
+   template< typename T1, typename T2 = T1 >
+   class Key2 
+   {
+   public:
+      //////////////////////////////////////////////////////////////////////////
+      //Konstruktoren
+      Key2(const T1& t1, const T2& t2) 
+         : t1(t1), t2(t2)
+      { 
+      }
+      /*==========================================================*/
+      Key2& operator=(const Key2& srcKey) 
+      {
+         if(this == &srcKey ) return *this;
+
+         t1    = srcKey.t1;
+         t2    = srcKey.t2;
+
+         return *this;
+      }
+      /*==========================================================*/
+      T1 getT1() const { return t1; }
+      T2 getT2() const { return t2; }
+
+      //////////////////////////////////////////////////////////////////////////
+      //global ueberladene Operatoren
+      friend inline bool operator<(const Key2& lhsKey,const Key2& rhsKey)  
+      {
+         if( lhsKey.t1 < rhsKey.t1 ) return true;
+         if( lhsKey.t1 > rhsKey.t1 ) return false;
+         if( lhsKey.t2 < rhsKey.t2 ) return true;
+
+         return false;
+      }
+      /*==========================================================*/
+      friend inline bool operator==(const Key2& lhsKey, const Key2& rhsKey)  
+      {
+         if(lhsKey.t1 != rhsKey.t1 ) return false;
+         if(lhsKey.t2 != rhsKey.t2 ) return false;
+
+         return true;
+      }
+      //ueberladene Operatoren
+      friend inline bool operator!=(const Key2& lhsKey, const Key2& rhsKey)  
+      {
+         return !(lhsKey == rhsKey); 
+      }
+      //ueberladene Operatoren
+      /*==========================================================*/
+      friend inline std::ostream& operator << (std::ostream& os, const Key2& key) 
+      {
+         os<<"Key2<"<<typeid(T1).name()<<","<<typeid(T2).name()<<">,("<<key.t1<<","<<key.t2<<")";
+         return os;
+      }
+      /*==========================================================*/
+      #ifdef CAB_RCF
+	      template<class Archive>
+	      void serialize(Archive & ar, const unsigned int version)
+	      {
+		      ar & t1;
+		      ar & t2;
+	      }
+      #endif //CAB_RCF
+
+   private:
+      //////////////////////////////////////////////////////////////////////////
+      //private Member
+      T1 t1;
+      T2 t2;
+
+   };
+
+   //////////////////////////////////////////////////////////////////////////
+   //
+   //////////////////////////////////////////////////////////////////////////
+   template< typename T1, typename T2 = T1, typename T3 = T1 >
+   class Key3 
+   {
+   public:
+      //////////////////////////////////////////////////////////////////////////
+      //Konstruktoren
+      Key3() : t1(0), t2(0), t3(0)
+      {
+
+      }
+      Key3(const T1& t1, const T2& t2, const T3& t3) 
+         : t1(t1), t2(t2), t3(t3)
+      { 
+      }
+      /*==========================================================*/
+      T1 getT1() const { return t1; }
+      T2 getT2() const { return t2; }
+      T3 getT3() const { return t3; }
+      /*==========================================================*/
+      Key3& operator=(const Key3& srcKey) 
+      {
+         if(this == &srcKey ) return *this;
+
+         t1    = srcKey.t1;
+         t2    = srcKey.t2;
+         t3    = srcKey.t3;
+
+         return *this;
+      }
+
+      //////////////////////////////////////////////////////////////////////////
+      //global ueberladene Operatoren
+      friend inline bool operator<(const Key3& lhsKey,const Key3& rhsKey)  
+      {
+         if( lhsKey.t1 < rhsKey.t1 ) return true;
+         if( lhsKey.t1 > rhsKey.t1 ) return false;
+         if( lhsKey.t2 < rhsKey.t2 ) return true;
+         if( lhsKey.t2 > rhsKey.t2 ) return false;
+         if( lhsKey.t3 < rhsKey.t3 ) return true;
+
+         return false;
+      }
+      /*==========================================================*/
+      friend inline bool operator==(const Key3& lhsKey,const Key3& rhsKey)  
+      {
+         if(lhsKey.t1 != rhsKey.t1 ) return false;
+         if(lhsKey.t2 != rhsKey.t2 ) return false;
+         if(lhsKey.t3 != rhsKey.t3 ) return false;
+
+         return true;
+      }
+      /*==========================================================*/
+      //ueberladene Operatoren
+      friend inline bool operator!=(const Key3& lhsKey, const Key3& rhsKey) 
+      {
+         return !(lhsKey == rhsKey); 
+      }
+
+      //ueberladene Operatoren
+      /*==========================================================*/
+      friend inline std::ostream& operator << (std::ostream& os, const Key3& key) 
+      {
+         os<<"Key3<"<<typeid(T1).name()<<","<<typeid(T2).name()<<","<<typeid(T3).name();
+         os<<">,("<<key.t1<<","<<key.t2<<","<<key.t3<<")";
+         return os;
+      }
+      /*==========================================================*/
+      #ifdef CAB_RCF
+	      template<class Archive>
+	      void serialize(Archive & ar, const unsigned int version)
+	      {
+		      ar & t1;
+		      ar & t2;
+            ar & t3;
+         }
+      #endif //CAB_RCF
+
+   private:
+      //////////////////////////////////////////////////////////////////////////
+      //private Member
+      T1 t1;
+      T2 t2;
+      T3 t3;
+   };
+
+   //////////////////////////////////////////////////////////////////////////
+   //
+   //////////////////////////////////////////////////////////////////////////
+   template< typename T1, typename T2 = T1, typename T3 = T1, typename T4 = T1 >
+   class Key4 
+   {
+   public:
+      //////////////////////////////////////////////////////////////////////////
+      //Konstruktoren
+      Key4(const T1& t1, const T2& t2, const T3& t3, const T4& t4) 
+         : t1(t1), t2(t2), t3(t3), t4(t4)
+      { 
+      }
+      /*==========================================================*/
+      T1 getT1() const { return t1; }
+      T2 getT2() const { return t2; }
+      T3 getT3() const { return t3; }
+      T4 getT4() const { return t4; }
+      /*==========================================================*/
+      Key4& operator=(const Key4& srcKey) 
+      {
+         if(this == &srcKey ) return *this;
+
+         t1    = srcKey.t1;
+         t2    = srcKey.t2;
+         t3    = srcKey.t3;
+         t4    = srcKey.t4;
+
+         return *this;
+      }
+      //////////////////////////////////////////////////////////////////////////
+      //global ueberladene Operatoren
+      friend inline bool operator<(const Key4& lhsKey,const Key4& rhsKey)  
+      {
+         if( lhsKey.t1 < rhsKey.t1 ) return true;
+         if( lhsKey.t1 > rhsKey.t1 ) return false;
+         if( lhsKey.t2 < rhsKey.t2 ) return true;
+         if( lhsKey.t2 > rhsKey.t2 ) return false;
+         if( lhsKey.t3 < rhsKey.t3 ) return true;
+         if( lhsKey.t3 > rhsKey.t3 ) return false;
+         if( lhsKey.t4 < rhsKey.t4 ) return true;
+
+         return false;
+      }
+      /*==========================================================*/
+      friend inline bool operator==(const Key4& lhsKey,const Key4& rhsKey)  
+      {
+         if(lhsKey.t1 != rhsKey.t1 ) return false;
+         if(lhsKey.t2 != rhsKey.t2 ) return false;
+         if(lhsKey.t3 != rhsKey.t3 ) return false;
+         if(lhsKey.t4 != rhsKey.t4 ) return false;
+
+         return true;
+      }
+
+      //ueberladene Operatoren
+      friend inline bool operator!=(const Key4& lhsKey, const Key4& rhsKey) 
+      {
+         return !(lhsKey == rhsKey); 
+      }
+      //ueberladene Operatoren
+      /*==========================================================*/
+      friend inline std::ostream& operator << (std::ostream& os, const Key4& key) 
+      {
+         os<<"Key4<"<<typeid(T1).name()<<","<<typeid(T2).name()<<","<<typeid(T3).name()<<","<<typeid(T4).name();
+         os<<">,("<<key.t1<<","<<key.t2<<","<<key.t3<<","<<key.t4<<")";
+         return os;
+      }
+      /*==========================================================*/
+      #ifdef CAB_RCF
+	      template<class Archive>
+	      void serialize(Archive & ar, const unsigned int version)
+	      {
+		      ar & t1;
+		      ar & t2;
+            ar & t3;
+            ar & t4;
+         }
+      #endif //CAB_RCF
+
+   private:
+      //////////////////////////////////////////////////////////////////////////
+      //private Member
+      T1 t1;
+      T2 t2;
+      T3 t3;
+      T4 t4;
+
+   };
+}
+
+#endif //UBKEYS_H
diff --git a/source/ThirdParty/Library/basics/utilities/UbLimits.h b/source/VirtualFluidsBasic/basics/utilities/UbLimits.h
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbLimits.h
rename to source/VirtualFluidsBasic/basics/utilities/UbLimits.h
index 9313f0620a138785dd9b7e6c334917806da93c30..30b03f2d9e494d8a3b42841441cc10bbd3fcac01 100644
--- a/source/ThirdParty/Library/basics/utilities/UbLimits.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbLimits.h
@@ -1,139 +1,139 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UB_LIMITS_H
-#define UB_LIMITS_H
-
-
-//*************************************************************************************************
-// Includes
-//*************************************************************************************************
-
-#include <limits>
-
-//////////////////////////////////////////////////////////////////////////
-//  CLASS DEFINITION
-//////////////////////////////////////////////////////////////////////////
-template< typename T >
-struct UbLimits  {};
-
-//////////////////////////////////////////////////////////////////////////
-//  SPECIALIZATIONS
-//////////////////////////////////////////////////////////////////////////
-template<>
-struct UbLimits<unsigned char>
-{
-   //return the largest possible positive unsigned char value
-   static inline unsigned char inf() { return std::numeric_limits<unsigned char>::max(); }
-};
-//*************************************************************************************************
-template<>
-struct UbLimits<char>
-{
-   //return the largest possible positive char value. */
-   static inline char inf () { return std::numeric_limits<char>::max(); }
-   //return the largest possible negative char value
-   static inline char ninf() { return std::numeric_limits<char>::min(); }
-};
-//*************************************************************************************************
-template<>
-struct UbLimits<signed char>
-{
-   //return the largest possible positive signed char value
-   static inline signed char inf () { return std::numeric_limits<signed char>::max(); }
-
-   //return The largest possible negative signed char value
-   static inline signed char ninf() { return std::numeric_limits<signed char>::min(); }
-};
-//*************************************************************************************************
-template<>
-struct UbLimits<wchar_t>
-{
-   //return The largest possible positive wchar_t value
-   static inline wchar_t inf () { return std::numeric_limits<wchar_t>::max(); }
-   //return The largest possible negative wchar_t value
-   static inline wchar_t ninf() { return std::numeric_limits<wchar_t>::min(); }
-};
-//*************************************************************************************************
-template<>
-struct UbLimits<unsigned short>
-{
-   //return The largest possible positive unsigned short value
-   static inline unsigned short inf() { return std::numeric_limits<unsigned short>::max(); }
-};
-//*************************************************************************************************
-template<>
-struct UbLimits<short>
-{
-   //return The largest possible positive short value
-   static inline short inf () { return std::numeric_limits<short>::max(); }
-   //return The largest possible negative short value
-   static inline short ninf() { return std::numeric_limits<short>::min(); }
-};
-//*************************************************************************************************
-template<>
-struct UbLimits<unsigned int>
-{
-   //return The largest possible positive unsigned int value
-   static inline unsigned int inf() { return std::numeric_limits<unsigned int>::max(); }
-};
-//*************************************************************************************************
-template<>
-struct UbLimits<int>
-{
-   //return The largest possible positive int value
-   static inline int inf () { return std::numeric_limits<int>::max(); }
-
-   //return The largest possible negative int value
-   static inline int ninf() { return std::numeric_limits<int>::min(); }
-};
-//*************************************************************************************************
-template<>
-struct UbLimits<unsigned long>
-{
-   //return The largest possible positive unsigned long value
-   static inline unsigned long inf() { return std::numeric_limits<unsigned long>::max(); }
-};
-//*************************************************************************************************
-template<>
-struct UbLimits<long>
-{
-   //return The largest possible positive long value
-   static inline long inf () { return std::numeric_limits<long>::max(); }
-
-   //return The largest possible negative long value
-   static inline long ninf() { return std::numeric_limits<long>::min(); }
-};
-//*************************************************************************************************
-template<>
-struct UbLimits<float>
-{
-   //return The largest possible positive float value
-   static inline float inf () { return  std::numeric_limits<float>::max(); }
-
-   //return The largest possible negative float value
-   static inline float ninf() { return -std::numeric_limits<float>::max(); }
-};
-//*************************************************************************************************
-template<>
-struct UbLimits<double>
-{
-   //return The largest possible positive double value
-   static inline double inf () { return  std::numeric_limits<double>::max(); }
-   //return The largest possible negative double value
-   static inline double ninf() { return -std::numeric_limits<double>::max(); }
-};
-//*************************************************************************************************
-template<>
-struct UbLimits<long double>
-{
-   //return The largest possible positive long double value
-   static inline long double inf () { return  std::numeric_limits<long double>::max(); }
-   //return The largest possible negative long double value
-   static inline long double ninf() { return -std::numeric_limits<long double>::max(); }
-};
-
-#endif //UB_LIMITS_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UB_LIMITS_H
+#define UB_LIMITS_H
+
+
+//*************************************************************************************************
+// Includes
+//*************************************************************************************************
+
+#include <limits>
+
+//////////////////////////////////////////////////////////////////////////
+//  CLASS DEFINITION
+//////////////////////////////////////////////////////////////////////////
+template< typename T >
+struct UbLimits  {};
+
+//////////////////////////////////////////////////////////////////////////
+//  SPECIALIZATIONS
+//////////////////////////////////////////////////////////////////////////
+template<>
+struct UbLimits<unsigned char>
+{
+   //return the largest possible positive unsigned char value
+   static inline unsigned char inf() { return std::numeric_limits<unsigned char>::max(); }
+};
+//*************************************************************************************************
+template<>
+struct UbLimits<char>
+{
+   //return the largest possible positive char value. */
+   static inline char inf () { return std::numeric_limits<char>::max(); }
+   //return the largest possible negative char value
+   static inline char ninf() { return std::numeric_limits<char>::min(); }
+};
+//*************************************************************************************************
+template<>
+struct UbLimits<signed char>
+{
+   //return the largest possible positive signed char value
+   static inline signed char inf () { return std::numeric_limits<signed char>::max(); }
+
+   //return The largest possible negative signed char value
+   static inline signed char ninf() { return std::numeric_limits<signed char>::min(); }
+};
+//*************************************************************************************************
+template<>
+struct UbLimits<wchar_t>
+{
+   //return The largest possible positive wchar_t value
+   static inline wchar_t inf () { return std::numeric_limits<wchar_t>::max(); }
+   //return The largest possible negative wchar_t value
+   static inline wchar_t ninf() { return std::numeric_limits<wchar_t>::min(); }
+};
+//*************************************************************************************************
+template<>
+struct UbLimits<unsigned short>
+{
+   //return The largest possible positive unsigned short value
+   static inline unsigned short inf() { return std::numeric_limits<unsigned short>::max(); }
+};
+//*************************************************************************************************
+template<>
+struct UbLimits<short>
+{
+   //return The largest possible positive short value
+   static inline short inf () { return std::numeric_limits<short>::max(); }
+   //return The largest possible negative short value
+   static inline short ninf() { return std::numeric_limits<short>::min(); }
+};
+//*************************************************************************************************
+template<>
+struct UbLimits<unsigned int>
+{
+   //return The largest possible positive unsigned int value
+   static inline unsigned int inf() { return std::numeric_limits<unsigned int>::max(); }
+};
+//*************************************************************************************************
+template<>
+struct UbLimits<int>
+{
+   //return The largest possible positive int value
+   static inline int inf () { return std::numeric_limits<int>::max(); }
+
+   //return The largest possible negative int value
+   static inline int ninf() { return std::numeric_limits<int>::min(); }
+};
+//*************************************************************************************************
+template<>
+struct UbLimits<unsigned long>
+{
+   //return The largest possible positive unsigned long value
+   static inline unsigned long inf() { return std::numeric_limits<unsigned long>::max(); }
+};
+//*************************************************************************************************
+template<>
+struct UbLimits<long>
+{
+   //return The largest possible positive long value
+   static inline long inf () { return std::numeric_limits<long>::max(); }
+
+   //return The largest possible negative long value
+   static inline long ninf() { return std::numeric_limits<long>::min(); }
+};
+//*************************************************************************************************
+template<>
+struct UbLimits<float>
+{
+   //return The largest possible positive float value
+   static inline float inf () { return  std::numeric_limits<float>::max(); }
+
+   //return The largest possible negative float value
+   static inline float ninf() { return -std::numeric_limits<float>::max(); }
+};
+//*************************************************************************************************
+template<>
+struct UbLimits<double>
+{
+   //return The largest possible positive double value
+   static inline double inf () { return  std::numeric_limits<double>::max(); }
+   //return The largest possible negative double value
+   static inline double ninf() { return -std::numeric_limits<double>::max(); }
+};
+//*************************************************************************************************
+template<>
+struct UbLimits<long double>
+{
+   //return The largest possible positive long double value
+   static inline long double inf () { return  std::numeric_limits<long double>::max(); }
+   //return The largest possible negative long double value
+   static inline long double ninf() { return -std::numeric_limits<long double>::max(); }
+};
+
+#endif //UB_LIMITS_H
diff --git a/source/ThirdParty/Library/basics/utilities/UbLogger.cpp b/source/VirtualFluidsBasic/basics/utilities/UbLogger.cpp
similarity index 95%
rename from source/ThirdParty/Library/basics/utilities/UbLogger.cpp
rename to source/VirtualFluidsBasic/basics/utilities/UbLogger.cpp
index f487a02ed08408d632ccab624b657f0283686ad5..3c433a13030339c656a96d16a19d0f8f9819c7b8 100644
--- a/source/ThirdParty/Library/basics/utilities/UbLogger.cpp
+++ b/source/VirtualFluidsBasic/basics/utilities/UbLogger.cpp
@@ -1,8 +1,8 @@
-#include <basics/utilities/UbLogger.h>
-
-#if defined(CAB_BOOST) && !defined(NO_THREADSAFE_LOGGING)
-
-boost::mutex Output2Stream::mtx;
-
-#endif // CAB_BOOST
-
+#include <basics/utilities/UbLogger.h>
+
+#if defined(CAB_BOOST) && !defined(NO_THREADSAFE_LOGGING)
+
+boost::mutex Output2Stream::mtx;
+
+#endif // CAB_BOOST
+
diff --git a/source/ThirdParty/Library/basics/utilities/UbLogger.h b/source/VirtualFluidsBasic/basics/utilities/UbLogger.h
similarity index 100%
rename from source/ThirdParty/Library/basics/utilities/UbLogger.h
rename to source/VirtualFluidsBasic/basics/utilities/UbLogger.h
diff --git a/source/ThirdParty/Library/basics/utilities/UbMath.cpp b/source/VirtualFluidsBasic/basics/utilities/UbMath.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbMath.cpp
rename to source/VirtualFluidsBasic/basics/utilities/UbMath.cpp
index 14c5fcf3b89b9559a43d9877b42e7ce2a74aefd2..aabcbb9acbee598531a91a0b1bcf9846b234690f 100644
--- a/source/ThirdParty/Library/basics/utilities/UbMath.cpp
+++ b/source/VirtualFluidsBasic/basics/utilities/UbMath.cpp
@@ -1,6 +1,6 @@
-#include <basics/utilities/UbMath.h>
-#include <basics/utilities/UbInfinity.h>
-#include <cstring> //for memcmp
-
-       
-const double UbMath::PI = 4.0* std::atan(1.0);   //3.1415926535897932384626433832795
+#include <basics/utilities/UbMath.h>
+#include <basics/utilities/UbInfinity.h>
+#include <cstring> //for memcmp
+
+       
+const double UbMath::PI = 4.0* std::atan(1.0);   //3.1415926535897932384626433832795
diff --git a/source/ThirdParty/Library/basics/utilities/UbMath.h b/source/VirtualFluidsBasic/basics/utilities/UbMath.h
similarity index 100%
rename from source/ThirdParty/Library/basics/utilities/UbMath.h
rename to source/VirtualFluidsBasic/basics/utilities/UbMath.h
diff --git a/source/ThirdParty/Library/basics/utilities/UbNupsTimer.h b/source/VirtualFluidsBasic/basics/utilities/UbNupsTimer.h
similarity index 96%
rename from source/ThirdParty/Library/basics/utilities/UbNupsTimer.h
rename to source/VirtualFluidsBasic/basics/utilities/UbNupsTimer.h
index 8320aa7de8c5e465edaa032a1816f016e6133bc7..cd99df78e1e6a0b764e853567bcadfb0372cd423 100644
--- a/source/ThirdParty/Library/basics/utilities/UbNupsTimer.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbNupsTimer.h
@@ -1,93 +1,93 @@
-#ifndef UBNUPSTIMER_H
-#define UBNUPSTIMER_H
-
-#include <basics/utilities/UbTiming.h>
-#include <sstream>
-#include <vector>
-
-
-/*=========================================================================*/
-/*  UbNupsTimer                                                             */
-/*                                                                         */
-/**
-This Class provides the base for ...
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 01.11.04
-*/ 
-class UbNupsTimer : public UbTiming
-{
-public:
-   UbNupsTimer() : UbTiming()
-   {
-      mTempNodes = 0.0;
-      mNofNodes.resize(0);
-      mDurations.resize(0);
-   }
-   /*==========================================================*/
-   UbNupsTimer(std::string name) : UbTiming(name)
-   {
-      mNofNodes.resize(0);
-      mDurations.resize(0);
-      mTempNodes = 0.0;
-   }
-   /*==========================================================*/
-   void initTiming()
-   {
-      UbTiming::initTiming();
-      mNofNodes.resize(0);
-      mDurations.resize(0);
-      mTempNodes   = 0.0;
-   }
-   /*==========================================================*/
-   void startTiming(double nofNodes)
-   {
-      mTempNodes=nofNodes;
-      UbTiming::startTiming();
-   }
-   /*==========================================================*/
-   void endTiming()
-   {
-      UbTiming::endTiming();
-      //save #node and time informations
-      mNofNodes.push_back(mTempNodes);
-      mDurations.push_back(UbTiming::getDuration());
-      //reset internal timecounter
-      UbTiming::initTiming();
-   }
-   /*==========================================================*/
-   double getAverageNups()
-   { 
-      double averageNups = 0.0;
-      for(int i=0;i<(int)mNofNodes.size();i++)
-         averageNups+=mNofNodes.at(i)/mDurations.at(i);
-      
-      return averageNups/(double)mNofNodes.size(); 
-   }
-   /*==========================================================*/
-   double getSumOfDuration()
-   {
-      double duration = 0.0;
-      for(int i=0;i<(int)mDurations.size();i++) duration+=mDurations.at(i);
-      return duration;
-   }
-   /*==========================================================*/
-   std::string getNupsString()
-   {
-      std::stringstream ss;
-      ss<<"saved nups informations"<<std::endl;
-      for(int i=0;i<(int)mNofNodes.size();i++)
-         ss<<mNofNodes.at(i)<<"nodes/"<<mDurations.at(i)<<"sec="<<mNofNodes.at(i)/mDurations.at(i)<<"nups\n";
-      return ss.str();
-   }
-
-protected:
-
-private:
-   std::vector<double> mNofNodes;
-   std::vector<double> mDurations;
-   
-   double mTempNodes;
-};
-
-#endif
+#ifndef UBNUPSTIMER_H
+#define UBNUPSTIMER_H
+
+#include <basics/utilities/UbTiming.h>
+#include <sstream>
+#include <vector>
+
+
+/*=========================================================================*/
+/*  UbNupsTimer                                                             */
+/*                                                                         */
+/**
+This Class provides the base for ...
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 01.11.04
+*/ 
+class UbNupsTimer : public UbTiming
+{
+public:
+   UbNupsTimer() : UbTiming()
+   {
+      mTempNodes = 0.0;
+      mNofNodes.resize(0);
+      mDurations.resize(0);
+   }
+   /*==========================================================*/
+   UbNupsTimer(std::string name) : UbTiming(name)
+   {
+      mNofNodes.resize(0);
+      mDurations.resize(0);
+      mTempNodes = 0.0;
+   }
+   /*==========================================================*/
+   void initTiming()
+   {
+      UbTiming::initTiming();
+      mNofNodes.resize(0);
+      mDurations.resize(0);
+      mTempNodes   = 0.0;
+   }
+   /*==========================================================*/
+   void startTiming(double nofNodes)
+   {
+      mTempNodes=nofNodes;
+      UbTiming::startTiming();
+   }
+   /*==========================================================*/
+   void endTiming()
+   {
+      UbTiming::endTiming();
+      //save #node and time informations
+      mNofNodes.push_back(mTempNodes);
+      mDurations.push_back(UbTiming::getDuration());
+      //reset internal timecounter
+      UbTiming::initTiming();
+   }
+   /*==========================================================*/
+   double getAverageNups()
+   { 
+      double averageNups = 0.0;
+      for(int i=0;i<(int)mNofNodes.size();i++)
+         averageNups+=mNofNodes.at(i)/mDurations.at(i);
+      
+      return averageNups/(double)mNofNodes.size(); 
+   }
+   /*==========================================================*/
+   double getSumOfDuration()
+   {
+      double duration = 0.0;
+      for(int i=0;i<(int)mDurations.size();i++) duration+=mDurations.at(i);
+      return duration;
+   }
+   /*==========================================================*/
+   std::string getNupsString()
+   {
+      std::stringstream ss;
+      ss<<"saved nups informations"<<std::endl;
+      for(int i=0;i<(int)mNofNodes.size();i++)
+         ss<<mNofNodes.at(i)<<"nodes/"<<mDurations.at(i)<<"sec="<<mNofNodes.at(i)/mDurations.at(i)<<"nups\n";
+      return ss.str();
+   }
+
+protected:
+
+private:
+   std::vector<double> mNofNodes;
+   std::vector<double> mDurations;
+   
+   double mTempNodes;
+};
+
+#endif
diff --git a/source/ThirdParty/Library/basics/utilities/UbObservable.h b/source/VirtualFluidsBasic/basics/utilities/UbObservable.h
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbObservable.h
rename to source/VirtualFluidsBasic/basics/utilities/UbObservable.h
index a1ab9cafbe4443680dc728d1f8907a1ba34c1462..05086076777effdf5462bd8aea85b282f09defe5 100644
--- a/source/ThirdParty/Library/basics/utilities/UbObservable.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbObservable.h
@@ -1,259 +1,259 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBOBSERVABLE_H
-#define UBOBSERVABLE_H
-
-#include <list>               
-#include <iostream>
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-#include <basics/utilities/UbObserver.h>
-
-class UbObserver;
-
-/*=========================================================================*/
-/*  Beobachtbares Objekt                                                   */
-/*                                                                         */
-/**
-  This class provides Observables. The Observeres which observe this
-  Observable are stored in an observerlist.
-  IMPORTANT: objectWillBeDeleted is called at UbObserver::~UbObserver
-             this destructor is called AFTER the destructor of the
-             child classes. if you down_cast the pointer sent with the
-             objectWillBeDeleted(UbObserver* objpointer) then have to go this:
-               
-               if(dynamic_cast<UbObserver*>(observedObj)==objpointer) 
-                     (e.g.) observedObj=NULL;
-   example: see end of file
-
-   a copy of an UbservableObject will NOT copy the observerList
-  <UL>
-    <LI><B>Extending:</B> This UbObservable is the observable object itself. Extending should be used
-	where object types can be extended from UbObservable.
-    <LI><B>Associating:</B> Initialization is done via the constructor <tt>UbObservable(ObservableObject)</tt>.
-	Associating may be used, where object types to be observed could not be extended from UbObservable.
-  </UL>
-  <BR><BR><HR>        
-  @author <A HREF="mailto:geller@cab.bau.tu-bs.de">S. Geller</A>
-  @author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-  @version 1.2 - 13.07.05
-  @see UbObserver
-*/
-
-class UbObservable 
-{
-protected:
-   /*======================================================================*/
-   /*  Konstruktoren                                                       */
-   /*                                                                      */
-   /**
-     Creates a UbObservable itself to be the object to be observed.
-     Usually this constructor is used in extended classes.
-   */
-   UbObservable()
-   {
-   }
-   
-   UbObservable(const UbObservable& src)
-   {
-      //no copy of observers !!!
-   }
-   
-   //falls irgendein schlaumeier den =operator von UbObservable aufrufen sollte,
-   //dann macht diesr auch keine kopie! (Allg: zuweisungsoperatoren werden nie vererbt
-   UbObservable& operator=(const UbObservable& src)
-   {
-      return *this;
-   }
-   
-   //   /**
-   //     Creates a UbObservable for the specified Object to be observed.
-   //     Usually this constructor is used in associating UbObservable.
-   //     @param object Object to be observed
-   //   */
-public:
-   /*======================================================================*/
-   /*  Destruktor                                                          */
-   /*                                                                      */
-   /**
-   */
-   virtual ~UbObservable()
-   {
-      this->notifyObserversObjectWillBeDeleted();
-   } 
-
-   /*======================================================================*/
-   /*  methods                                                            */
-   /*                                                                      */
-   
-   /**
-   Adds an UbObserver to the observerlist.
-   @param observer the observer to add to this observable (note that an observer may observe one observable more than once)
-   */
-   virtual void addObserver(UbObserver* observer)
-   {
-      if(!observer) return;
-      for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();++pos)
-      {
-         if(*pos == observer) return;
-      }
-      this->mObserverList.push_back(observer);
-   }
-   /**
-   Deletes an UbObserver from the observerlist.
-   @param observer the observer to remove from this observable (note that all observers identical are deleted)
-   ( delete means delete Heap... but here we're only removing a pointer)
-   */
-   virtual void removeObserver(UbObserver* observer)
-   {
-      if(!observer) return;
-      this->mObserverList.remove(observer);
-
-   }
-   /**
-   Deletes all Observers from the observerlist.
-   ( delete means delete Heap... but here we're only removing a pointer)
-   */
-   virtual void removeAllObservers()
-   {
-      this->mObserverList.clear();
-   }
-   
-   /**
-     Checks whether the specified UbObserver observes this observable.
-     @param observer the observer to remove from this observable (note that all observers identical are deleted)
-     @return true if the specified observer observes this observable
-   */
-   virtual bool isObservedBy(UbObserver* observer)
-   {
-      if(!observer) return false;
-      for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();++pos)
-      {
-         if(*pos == observer) return true;
-      }
-      return false;
-   }
-   /**
-     Notifies all of its observers that something happened. Does nothing, if the observed object is null.
-     Calls the Method UbObserver.objectChanged(Object) with the object of this observable as parameter.
-     The Method UbObserver.objectChanged(Object) must be defined
-     by each class implementing the interface TiObserver
-   */
-   virtual void notifyObserversObjectChanged()
-   {
-      std::list<UbObserver*>::iterator tmp_pos; //es kann sein, dass der aktuelle observer waehrend
-                                           //objectChanged() removed wird...
-      for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();)
-      {
-        //cout<<"in notifyObserversObjectChanged\n";
-        //cout<<this->mObserverList.size()<<endl;
-
-         tmp_pos = pos++; // erst tmp_pos=pos und dann pos++
-         (*tmp_pos)->objectChanged(this);
-      }
-   }
-
-   std::list<UbObserver*>* getObserverList() { return &mObserverList;}
-
-   virtual std::string toString() { return "UbObservable - toString()"; }
-
-#ifdef CAB_RCF
-   template<typename Archive>
-   void serialize(Archive & ar, const unsigned int version)
-   {
-      //do nothing!
-   }
-#endif //CAB_RCF
-
-private:
-   /**
-     Notifies all of its observers that something happened. Does nothing, if the observed object is null.
-     Calls the Method UbObserver.objectChanged(Object) with the object of this observable as parameter.
-     The Method UbObserver.objectChanged(Object) must be defined
-     by each class implementing the interface TiObserver
-   */
-   virtual void notifyObserversObjectWillBeDeleted()
-   {
-      std::list<UbObserver*>::iterator tmp_pos; //es kann sein, dass der aktuelle observer waehrend
-                                          //objectWillBeDeleted() removed wird...
-      for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();)
-      {
-         //cout<<"in notifyObserversObjectWillBeDeleted\n";
-         //cout<<this->mObserverList.size()<<endl;
-
-         tmp_pos = pos++;
-         (*tmp_pos)->objectWillBeDeleted(this);
-      }
-   }
-
-   std::list<UbObserver*> mObserverList;
-};
-/*=========================================================================*/
-
-
-#ifdef RCF_USE_SF_SERIALIZATION
-   SF_NO_CTOR(UbObservable);
-#endif //RCF_USE_SF_SERIALIZATION
-
-#endif
-
-////  E X A M P L E 
-////===================
-//class Point : public UbObservable
-//{
-//public:
-//   Point(){x=y=0;}
-//   ~Point(){}
-//   void setXCorrdinates(int x,int y)
-//   {
-//     this->x = x; this->y = y;
-//     this->notifyObserverObjectChanged();
-//   }
-//private:
-//   int x,y;
-//};
-//class VisPoint : public UbObserver
-//{
-//public:
-//   VisPoint(Point* point)
-//   { 
-//      this->point = point;
-//      this->point->addObserver(this);
-//   }
-//   ~VisPoint()
-//   {
-//      if(this->point) point->removeObserver(this);
-//   }
-//   void update() { /* do some actualisation stuff */ }
-//   void objectChanged(UbObservable* changedObject)
-//   {
-//      Point* point = dynamic_cast<Point*>(changedObject);
-//      if( !this->point || this->point != point ) return;
-//      this->repaint();
-//   }
-//   void objectWillBeDeleted(UbObservable* objectForDeletion)
-//   {
-//      if(!this->point) return;
-//      UbObservable* obsobjet = dynamic_cast<UbObservable*>(this->point);
-//      if(obsobjet == objectForDeletion) this->point = NULL;
-//      ///////////////////////////////////////////////////////////////////
-//      //*********************************************************************//
-//      //INGEGEN erster annahmen nicht verwenden, da es nicht immer funktioniert
-//      //z.B. bei mehrfachvererbung haut es nicht hin!
-//      ////      Point* point = reinterpret_cast<point*>(objectForDeletion);
-//      ////if(!this->point || objectForDeletion != this->point) return;
-//      ////this->point = NULL;
-//      //*********************************************************************//
-//      //was hingegen immer moeglich sein sollte:
-//      //if(dynamic_cast<void*>(objectForDeletion)==dynamic_cast<void*>(this->point))
-//   }
-//private:
-//   Point* point;
-//};
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBOBSERVABLE_H
+#define UBOBSERVABLE_H
+
+#include <list>               
+#include <iostream>
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+#include <basics/utilities/UbObserver.h>
+
+class UbObserver;
+
+/*=========================================================================*/
+/*  Beobachtbares Objekt                                                   */
+/*                                                                         */
+/**
+  This class provides Observables. The Observeres which observe this
+  Observable are stored in an observerlist.
+  IMPORTANT: objectWillBeDeleted is called at UbObserver::~UbObserver
+             this destructor is called AFTER the destructor of the
+             child classes. if you down_cast the pointer sent with the
+             objectWillBeDeleted(UbObserver* objpointer) then have to go this:
+               
+               if(dynamic_cast<UbObserver*>(observedObj)==objpointer) 
+                     (e.g.) observedObj=NULL;
+   example: see end of file
+
+   a copy of an UbservableObject will NOT copy the observerList
+  <UL>
+    <LI><B>Extending:</B> This UbObservable is the observable object itself. Extending should be used
+	where object types can be extended from UbObservable.
+    <LI><B>Associating:</B> Initialization is done via the constructor <tt>UbObservable(ObservableObject)</tt>.
+	Associating may be used, where object types to be observed could not be extended from UbObservable.
+  </UL>
+  <BR><BR><HR>        
+  @author <A HREF="mailto:geller@cab.bau.tu-bs.de">S. Geller</A>
+  @author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+  @version 1.2 - 13.07.05
+  @see UbObserver
+*/
+
+class UbObservable 
+{
+protected:
+   /*======================================================================*/
+   /*  Konstruktoren                                                       */
+   /*                                                                      */
+   /**
+     Creates a UbObservable itself to be the object to be observed.
+     Usually this constructor is used in extended classes.
+   */
+   UbObservable()
+   {
+   }
+   
+   UbObservable(const UbObservable& src)
+   {
+      //no copy of observers !!!
+   }
+   
+   //falls irgendein schlaumeier den =operator von UbObservable aufrufen sollte,
+   //dann macht diesr auch keine kopie! (Allg: zuweisungsoperatoren werden nie vererbt
+   UbObservable& operator=(const UbObservable& src)
+   {
+      return *this;
+   }
+   
+   //   /**
+   //     Creates a UbObservable for the specified Object to be observed.
+   //     Usually this constructor is used in associating UbObservable.
+   //     @param object Object to be observed
+   //   */
+public:
+   /*======================================================================*/
+   /*  Destruktor                                                          */
+   /*                                                                      */
+   /**
+   */
+   virtual ~UbObservable()
+   {
+      this->notifyObserversObjectWillBeDeleted();
+   } 
+
+   /*======================================================================*/
+   /*  methods                                                            */
+   /*                                                                      */
+   
+   /**
+   Adds an UbObserver to the observerlist.
+   @param observer the observer to add to this observable (note that an observer may observe one observable more than once)
+   */
+   virtual void addObserver(UbObserver* observer)
+   {
+      if(!observer) return;
+      for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();++pos)
+      {
+         if(*pos == observer) return;
+      }
+      this->mObserverList.push_back(observer);
+   }
+   /**
+   Deletes an UbObserver from the observerlist.
+   @param observer the observer to remove from this observable (note that all observers identical are deleted)
+   ( delete means delete Heap... but here we're only removing a pointer)
+   */
+   virtual void removeObserver(UbObserver* observer)
+   {
+      if(!observer) return;
+      this->mObserverList.remove(observer);
+
+   }
+   /**
+   Deletes all Observers from the observerlist.
+   ( delete means delete Heap... but here we're only removing a pointer)
+   */
+   virtual void removeAllObservers()
+   {
+      this->mObserverList.clear();
+   }
+   
+   /**
+     Checks whether the specified UbObserver observes this observable.
+     @param observer the observer to remove from this observable (note that all observers identical are deleted)
+     @return true if the specified observer observes this observable
+   */
+   virtual bool isObservedBy(UbObserver* observer)
+   {
+      if(!observer) return false;
+      for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();++pos)
+      {
+         if(*pos == observer) return true;
+      }
+      return false;
+   }
+   /**
+     Notifies all of its observers that something happened. Does nothing, if the observed object is null.
+     Calls the Method UbObserver.objectChanged(Object) with the object of this observable as parameter.
+     The Method UbObserver.objectChanged(Object) must be defined
+     by each class implementing the interface TiObserver
+   */
+   virtual void notifyObserversObjectChanged()
+   {
+      std::list<UbObserver*>::iterator tmp_pos; //es kann sein, dass der aktuelle observer waehrend
+                                           //objectChanged() removed wird...
+      for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();)
+      {
+        //cout<<"in notifyObserversObjectChanged\n";
+        //cout<<this->mObserverList.size()<<endl;
+
+         tmp_pos = pos++; // erst tmp_pos=pos und dann pos++
+         (*tmp_pos)->objectChanged(this);
+      }
+   }
+
+   std::list<UbObserver*>* getObserverList() { return &mObserverList;}
+
+   virtual std::string toString() { return "UbObservable - toString()"; }
+
+#ifdef CAB_RCF
+   template<typename Archive>
+   void serialize(Archive & ar, const unsigned int version)
+   {
+      //do nothing!
+   }
+#endif //CAB_RCF
+
+private:
+   /**
+     Notifies all of its observers that something happened. Does nothing, if the observed object is null.
+     Calls the Method UbObserver.objectChanged(Object) with the object of this observable as parameter.
+     The Method UbObserver.objectChanged(Object) must be defined
+     by each class implementing the interface TiObserver
+   */
+   virtual void notifyObserversObjectWillBeDeleted()
+   {
+      std::list<UbObserver*>::iterator tmp_pos; //es kann sein, dass der aktuelle observer waehrend
+                                          //objectWillBeDeleted() removed wird...
+      for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();)
+      {
+         //cout<<"in notifyObserversObjectWillBeDeleted\n";
+         //cout<<this->mObserverList.size()<<endl;
+
+         tmp_pos = pos++;
+         (*tmp_pos)->objectWillBeDeleted(this);
+      }
+   }
+
+   std::list<UbObserver*> mObserverList;
+};
+/*=========================================================================*/
+
+
+#ifdef RCF_USE_SF_SERIALIZATION
+   SF_NO_CTOR(UbObservable);
+#endif //RCF_USE_SF_SERIALIZATION
+
+#endif
+
+////  E X A M P L E 
+////===================
+//class Point : public UbObservable
+//{
+//public:
+//   Point(){x=y=0;}
+//   ~Point(){}
+//   void setXCorrdinates(int x,int y)
+//   {
+//     this->x = x; this->y = y;
+//     this->notifyObserverObjectChanged();
+//   }
+//private:
+//   int x,y;
+//};
+//class VisPoint : public UbObserver
+//{
+//public:
+//   VisPoint(Point* point)
+//   { 
+//      this->point = point;
+//      this->point->addObserver(this);
+//   }
+//   ~VisPoint()
+//   {
+//      if(this->point) point->removeObserver(this);
+//   }
+//   void update() { /* do some actualisation stuff */ }
+//   void objectChanged(UbObservable* changedObject)
+//   {
+//      Point* point = dynamic_cast<Point*>(changedObject);
+//      if( !this->point || this->point != point ) return;
+//      this->repaint();
+//   }
+//   void objectWillBeDeleted(UbObservable* objectForDeletion)
+//   {
+//      if(!this->point) return;
+//      UbObservable* obsobjet = dynamic_cast<UbObservable*>(this->point);
+//      if(obsobjet == objectForDeletion) this->point = NULL;
+//      ///////////////////////////////////////////////////////////////////
+//      //*********************************************************************//
+//      //INGEGEN erster annahmen nicht verwenden, da es nicht immer funktioniert
+//      //z.B. bei mehrfachvererbung haut es nicht hin!
+//      ////      Point* point = reinterpret_cast<point*>(objectForDeletion);
+//      ////if(!this->point || objectForDeletion != this->point) return;
+//      ////this->point = NULL;
+//      //*********************************************************************//
+//      //was hingegen immer moeglich sein sollte:
+//      //if(dynamic_cast<void*>(objectForDeletion)==dynamic_cast<void*>(this->point))
+//   }
+//private:
+//   Point* point;
+//};
diff --git a/source/ThirdParty/Library/basics/utilities/UbObserver.h b/source/VirtualFluidsBasic/basics/utilities/UbObserver.h
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbObserver.h
rename to source/VirtualFluidsBasic/basics/utilities/UbObserver.h
index 6008481f65fffca2853ab6409d492ac7f9183050..601e2993acb98e8d5b2f9ad912f1b90662c33fcb 100644
--- a/source/ThirdParty/Library/basics/utilities/UbObserver.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbObserver.h
@@ -1,55 +1,55 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBOBSERVER_H
-#define UBOBSERVER_H
-
-class UbObservable;
-/*=========================================================================*/
-/*  Observer                                                               */
-/*                                                                         */
-/**
-This interface must be implemented by classes which want to
-observe other objects.
-IMPORTANT: if you delete an observer, ensure to remove Observer from
-           all his oberved observable objects before!!!
-example: see end of UbObservable.h-file
-<BR><BR><HR>
-@author <A HREF="mailto:geller@cab.bau.tu-bs.de">S. Geller</A>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.1 - 20.11.04
-*/
-
-class UbObserver 
-{
-protected:
-
-   UbObserver(){}
-
-public:
-
-   virtual ~UbObserver(){}
-
-   /*======================================================================*/
-   /*  Methoden                                                            */
-   /*                                                                      */
-   /**
-   This function is called when the observable indicated that an object
-   has changed.
-   @param changedObject Object which has changed
-   */
-   virtual void objectChanged(UbObservable* changedObject)=0;
-   /**
-   This function is called when the observable indicated that an object
-   should be deleted.
-   @param objectForDeletion Object which should be deleted
-   */
-   virtual void objectWillBeDeleted(UbObservable* objectForDeletion)=0;
-};
-
-#endif
-
-
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBOBSERVER_H
+#define UBOBSERVER_H
+
+class UbObservable;
+/*=========================================================================*/
+/*  Observer                                                               */
+/*                                                                         */
+/**
+This interface must be implemented by classes which want to
+observe other objects.
+IMPORTANT: if you delete an observer, ensure to remove Observer from
+           all his oberved observable objects before!!!
+example: see end of UbObservable.h-file
+<BR><BR><HR>
+@author <A HREF="mailto:geller@cab.bau.tu-bs.de">S. Geller</A>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.1 - 20.11.04
+*/
+
+class UbObserver 
+{
+protected:
+
+   UbObserver(){}
+
+public:
+
+   virtual ~UbObserver(){}
+
+   /*======================================================================*/
+   /*  Methoden                                                            */
+   /*                                                                      */
+   /**
+   This function is called when the observable indicated that an object
+   has changed.
+   @param changedObject Object which has changed
+   */
+   virtual void objectChanged(UbObservable* changedObject)=0;
+   /**
+   This function is called when the observable indicated that an object
+   should be deleted.
+   @param objectForDeletion Object which should be deleted
+   */
+   virtual void objectWillBeDeleted(UbObservable* objectForDeletion)=0;
+};
+
+#endif
+
+
diff --git a/source/ThirdParty/Library/basics/utilities/UbPointerWrapper.h b/source/VirtualFluidsBasic/basics/utilities/UbPointerWrapper.h
similarity index 96%
rename from source/ThirdParty/Library/basics/utilities/UbPointerWrapper.h
rename to source/VirtualFluidsBasic/basics/utilities/UbPointerWrapper.h
index 3fcf0b599c3f87971bbd9f4ee316cb26a9a55275..dbb65d39f08eea99d924026a1ba3604a362fe02f 100644
--- a/source/ThirdParty/Library/basics/utilities/UbPointerWrapper.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbPointerWrapper.h
@@ -1,36 +1,36 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBPOINTERWRAPPER_H
-#define UBPOINTERWRAPPER_H
-
-//kappselt dynamische Objekte zur remote uebetragung
-//bei RCF werden z.B. aufgrund GC alle lokalen Objekte und 
-//"nackte" Pointer die automatisch als shared_ptr initialisert 
-//werde nach Methoden-Aufruf zerstoert
-//hierfuer kann man dann den UbPointerWrapper verwenden
-
-template<typename T>
-class UbPointerWrapper
-{
-public:
-	UbPointerWrapper() : pointer(NULL) {}
-	
-	UbPointerWrapper(T* pointer) : pointer(pointer) {}
-
-   T* get() { return pointer; }
-
-   template<class Archive>
-	void serialize(Archive& ar, const unsigned int version) 
-   {
-		ar & pointer;
-	}
-
-private:
-   T* pointer;
-};
-
-#endif //UBPOINTERWRAPPER_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBPOINTERWRAPPER_H
+#define UBPOINTERWRAPPER_H
+
+//kappselt dynamische Objekte zur remote uebetragung
+//bei RCF werden z.B. aufgrund GC alle lokalen Objekte und 
+//"nackte" Pointer die automatisch als shared_ptr initialisert 
+//werde nach Methoden-Aufruf zerstoert
+//hierfuer kann man dann den UbPointerWrapper verwenden
+
+template<typename T>
+class UbPointerWrapper
+{
+public:
+	UbPointerWrapper() : pointer(NULL) {}
+	
+	UbPointerWrapper(T* pointer) : pointer(pointer) {}
+
+   T* get() { return pointer; }
+
+   template<class Archive>
+	void serialize(Archive& ar, const unsigned int version) 
+   {
+		ar & pointer;
+	}
+
+private:
+   T* pointer;
+};
+
+#endif //UBPOINTERWRAPPER_H
diff --git a/source/ThirdParty/Library/basics/utilities/UbRandom.h b/source/VirtualFluidsBasic/basics/utilities/UbRandom.h
similarity index 96%
rename from source/ThirdParty/Library/basics/utilities/UbRandom.h
rename to source/VirtualFluidsBasic/basics/utilities/UbRandom.h
index b4429579eeb94f7a0381bc0f0a19d24845bd3e36..dd3b4671e69e504db5f3fdb3cba0c4a2ad7c8b43 100644
--- a/source/ThirdParty/Library/basics/utilities/UbRandom.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbRandom.h
@@ -1,60 +1,60 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBRANDOM_H 
-#define UBRANDOM_H 
-
-#include <cstdlib> 
-#include <ctime> 
-#include <cassert> 
-#include <cmath> 
-
-/*=========================================================================*/
-/*  UbRandom                                                             */
-/*                                                                         */
-/**
-generates a random number
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 04.10.2007
-*/ 
-/*
-usage: 
-   int main() 
-   { 
-      char* hand[] = {"Schere", "Stein", "Papier"}; 
-      for (unsigned u = 0; u < 20; u++) 
-      { 
-         cout << hand[UbRandom::rand(0, 2, 1)] << endl; 
-      } 
-
-      return 0; 
-   } 
-*/
-
-class UbRandom 
-{ 
-private: 
-   UbRandom() { std::srand(static_cast<int>(std::time(NULL)));  } 
-
-public: 
-   //returns arbitrary int value element of [min ; max]
-   static inline int rand(const int& min, const int& max) 
-   { 
-      static UbRandom dummy; 
-      assert(max - min < RAND_MAX); 
-      return ( min + std::rand() % (max - min + 1) ); 
-   } 
-   //returns arbitrary float value element of "( (max - min) / gran ) * [min ; max]"
-   //with other words: val = min+n*(max-min)/gran, n=0..gran-1
-   static inline double rand(const double& min, const double& max, const double& gran)
-   {
-      static UbRandom dummy; 
-      return (min + std::floor( std::rand() / (1.0 + RAND_MAX) * gran)* (max - min) / gran);
-   }
-}; 
-
-#endif //UBRANDOM_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBRANDOM_H 
+#define UBRANDOM_H 
+
+#include <cstdlib> 
+#include <ctime> 
+#include <cassert> 
+#include <cmath> 
+
+/*=========================================================================*/
+/*  UbRandom                                                             */
+/*                                                                         */
+/**
+generates a random number
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 04.10.2007
+*/ 
+/*
+usage: 
+   int main() 
+   { 
+      char* hand[] = {"Schere", "Stein", "Papier"}; 
+      for (unsigned u = 0; u < 20; u++) 
+      { 
+         cout << hand[UbRandom::rand(0, 2, 1)] << endl; 
+      } 
+
+      return 0; 
+   } 
+*/
+
+class UbRandom 
+{ 
+private: 
+   UbRandom() { std::srand(static_cast<int>(std::time(NULL)));  } 
+
+public: 
+   //returns arbitrary int value element of [min ; max]
+   static inline int rand(const int& min, const int& max) 
+   { 
+      static UbRandom dummy; 
+      assert(max - min < RAND_MAX); 
+      return ( min + std::rand() % (max - min + 1) ); 
+   } 
+   //returns arbitrary float value element of "( (max - min) / gran ) * [min ; max]"
+   //with other words: val = min+n*(max-min)/gran, n=0..gran-1
+   static inline double rand(const double& min, const double& max, const double& gran)
+   {
+      static UbRandom dummy; 
+      return (min + std::floor( std::rand() / (1.0 + RAND_MAX) * gran)* (max - min) / gran);
+   }
+}; 
+
+#endif //UBRANDOM_H
diff --git a/source/ThirdParty/Library/basics/utilities/UbScheduler.h b/source/VirtualFluidsBasic/basics/utilities/UbScheduler.h
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbScheduler.h
rename to source/VirtualFluidsBasic/basics/utilities/UbScheduler.h
index 46af1348e3bba70e4ed3121fa8a57e9b6b971344..7fb991699ee526a52b00c2a4fa990e9bf28a2f8d 100644
--- a/source/ThirdParty/Library/basics/utilities/UbScheduler.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbScheduler.h
@@ -1,384 +1,384 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBSCHEDULER_H
-#define UBSCHEDULER_H
-
-#include <iostream>
-#include <string>
-#include <limits>
-#include <cassert> 
-#include <sstream>
-#include <iomanip>
-#include <algorithm>
-
-#include <basics/utilities/UbSystem.h>
-#include <basics/utilities/UbMath.h>
-#include <basics/utilities/UbInfinity.h>
-#include <basics/utilities/UbComparators.h>
-#include <basics/utilities/UbFileOutput.h>
-#include <basics/utilities/UbFileInput.h>
-
-/*=========================================================================*/
-/*  UbScheduler                                                            */
-/*                                                                         */
-/**
-namespace for global system-functions
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@author <A HREF="mailto:hegewald@cab.bau.tu-bs.de">J. Hegewald</A>
-@version 1.0 - 06.09.06
-@version 1.1 - 09.09.06
-@version 1.2 - 03.07.08 - nun auch isDue(t) mehrmals fuer dasselbe t moeglich
-                          isDue(t) auch fuer t < lastUsedT
-                          bug entfernt, der bei Schedule (5,0,500) auch 505 als Due zurückgibt!
-*/ 
-
-/*
-usage: ...
-*/
-
-// this class is not thread save
-//
-
-class UbScheduler
-{
-public:
-   class UbSchedule
-   {
-      friend class UbScheduler;
-   public:
-      UbSchedule() :  step(Ub::inf), begin(Ub::inf), end(Ub::inf) { }
-      UbSchedule(const double& step, const double& begin=0.0, const double& end=Ub::inf) 
-         : step(step), begin(begin), end(end) 
-      {  
-      }
-      double getStep()  const { return this->step;  }
-      double getBegin() const { return this->begin; }
-      double getEnd()   const { return this->end;   }
-      
-      /*==========================================================*/
-      std::string toString() { std::stringstream text; text<<*this; return text.str(); }
-      /*==========================================================*/
-      friend inline std::ostream& operator << (std::ostream& os, const UbSchedule& schedule) 
-      {
-         os<<"Schedule[start,end,step]=["<<schedule.begin<<", "<<schedule.end<<", "<<schedule.step<<"]";
-         return os;
-      }
-
-      //------------- implements CAB serialization ----- start
-      virtual void write(UbFileOutput* out)
-      {
-         out->writeDouble( begin );
-         out->writeDouble( end );
-         out->writeDouble( step );
-      }
-      virtual void read(UbFileInput* in)
-      {
-         begin = in->readDouble();
-         end   = in->readDouble();
-         step  = in->readDouble();
-      }
-  
-
-   private:
-      double step, begin, end;
-   };
-
-public:
-   UbScheduler() 
-   {
-      this->initVals();
-   }
-   /*==========================================================*/                         
-   UbScheduler(const double& step,const double& begin=0, const double& end=Ub::inf ) 
-   {
-      this->initVals();
-      this->addSchedule(step,begin,end);
-   }
-   /*==========================================================*/
-   UbScheduler(const UbSchedule& schedule) 
-   {
-      this->initVals();
-      this->addSchedule(schedule);
-   }
-   /*==========================================================*/
-   virtual ~UbScheduler() {}
-   /*==========================================================*/
-   inline void addSchedule(const UbSchedule& schedule)
-   {
-      this->addSchedule(schedule.step, schedule.begin, schedule.end);
-   }
-   /*==========================================================*/
-   bool addSchedule(const double& step, const double& begin, double end)
-   {
-      if( UbMath::zero(step) || begin>end )
-      { 
-         std::cerr<<"UbScheduler::addSchedule - invalid Schedule:\n\t"<<UbSchedule(step, begin, end)<<std::endl;
-         return false; 
-      }
-      
-      if( UbMath::less( end, (double)Ub::inf )  )
-      {
-         //es kann vorkommen, dass man mit dem intervall nicht genau auf den letzten wert kommt
-         //(z.B. step=2; start=0; end=9; -> ende wird angepasst)
-         //also wenn end-begin>Ub::inf ist, dann geht es halt nicht.. ein cast in long double half hier nichts
-         double multiplier=0.0;
-         double fractpart =  modf( (end-begin)/step, &multiplier);
-         if( !UbMath::zero(fractpart) )
-         {
-            //tmp-speicherung (fuer cerr)
-            fractpart = end;
-            //neues ende
-            end = begin+multiplier*step;
-            
-            std::cerr<<"Warning: UbScheduler::addSchedule - "
-                      <<"end of schedule was adapted to intervall \n\t"
-                      <<"from "<< UbSchedule(step, begin, fractpart) <<" to "<< UbSchedule(step, begin, end) <<std::endl;
-         }
-      }
-
-      //nu aber:
-      schedules.push_back(UbSchedule(step, begin, end));
-
-      if( end>maxT ) maxT = end;
-
-      double potentialDueTime;
-      if(   calcNextDueTimeForSchedule(schedules.back(), lastUsedT, potentialDueTime)
-         && potentialDueTime < nextDueTime   )
-      {
-         nextDueTime = potentialDueTime;
-      }
-
-      return true;
-   }
-   /*==========================================================*/
-   //returns true if scheduler contains schedules
-   bool   hasSchedules() const { return !schedules.empty(); }
-   /*==========================================================*/
-   //time bei dem das letzte mal isDue(time) true war
-   double getLastDueTime() const { return lastDueTime; }
-   /*==========================================================*/
-   //time bei dem das naechste mal isDue(time) true ergibt
-   double getNextDueTime() const { return nextDueTime; }
-   /*==========================================================*/
-   //maxDueTime (maxTime der Schedules!
-   double getMaxDueTime()  const { return this->maxT; }
-   /*==========================================================*/
-   bool isDue(const double& t)
-   {
-      lastUsedT = t;
-      if( UbMath::greaterEqual(t,nextDueTime) ) 
-      {
-         //groesser maxT is nicht
-         if( UbMath::greater(t,maxT) )  return false;
-         
-         //temp var
-         double actDueTime = nextDueTime;
-
-         //um Suche nach nextDueTime bei "Zukunfts-t" zu optimieren, setzt man die "start"-suchzeit auf "t-1":
-         nextDueTime = t-1; //t-1 deshlab, damit falls z.B. while Schleife nicht durchlaufen wird
-                            //die folgende if Abfrage nicht faelschlicher Weise true ist!
-         while( UbMath::greaterEqual(t,nextDueTime) && !UbMath::equal(nextDueTime, maxT) )
-         {
-            double tmpNextDueTime = maxT, potentialDueTime=-1.0;
-            for(std::size_t i=0; i<schedules.size(); i++)
-            {
-               if(   calcNextDueTimeForSchedule(schedules[i], nextDueTime, potentialDueTime)
-                  && potentialDueTime < tmpNextDueTime                 )
-               {
-                  assert( nextDueTime < potentialDueTime );
-                  tmpNextDueTime = potentialDueTime;
-               }
-            }
-            actDueTime  = nextDueTime;
-            nextDueTime = tmpNextDueTime;
-         } 
-
-         //wenn t = der aktuuellen oder gar schon der nächstmöglichen ist (hierbei wurde
-         //zuvor actDueTime und nextDueTime ggf. angepasst)
-         //Bsp.: nextDuTime war 5, aber für t=400 gilt andere schedule -> Bsp actDue=350 und nextDue 405
-         if(    UbMath::equal(t,actDueTime)    
-             || UbMath::equal(t,nextDueTime) ) 
-         {
-            lastDueTime = t;
-            return true;
-         }
-      }
-      else if( UbMath::lessEqual(t, lastDueTime) ) 
-      {
-         if(UbMath::equal(t, lastDueTime) ) return true; //braucht man, wenn man für dasselbe t isDue(t) aufruft
-         else  
-         {
-            //Fall: Zeit liegt faktisch in der Vergangenheit -> neu initialsisieren
-            double tmpNextDueTime = maxT, potentialDueTime=-1.0;
-            for(size_t i=0; i<schedules.size(); i++)
-            {
-               if(   calcNextDueTimeForSchedule(schedules[i], t-1, potentialDueTime)
-                  && potentialDueTime < tmpNextDueTime                 )
-               {
-                  tmpNextDueTime = potentialDueTime;
-               }
-            }
-            nextDueTime = tmpNextDueTime;
-
-            return UbMath::equal(t, nextDueTime);
-         }
-      }
-
-      return false;
-   }
-   /*==========================================================*/
-   inline double getMinBegin( ) const
-   {
-      if( schedules.empty() ) return Ub::inf;
-      return std::min_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getBegin) )->getBegin();
-   }
-   /*==========================================================*/
-   inline double getMaxBegin( ) const
-   {
-      if( schedules.empty() ) return Ub::inf;
-      return std::max_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getBegin) )->getBegin();
-   }
-   /*==========================================================*/
-   inline double getMinEnd( ) const
-   {
-      if( schedules.empty() ) return Ub::inf;
-      return std::min_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getEnd) )->getEnd();
-   }
-   /*==========================================================*/
-   inline double getMaxEnd( ) const
-   {
-      if( schedules.empty() ) return Ub::inf;
-      return std::max_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getEnd) )->getEnd();
-   }
-   /*==========================================================*/
-   inline double getMinStep( ) const
-   {
-      if( schedules.empty() ) return Ub::inf;
-      return std::min_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getStep) )->getStep();
-   }
-   /*==========================================================*/
-   inline double getMaxStep( ) const
-   {
-      if( schedules.empty() ) return Ub::inf;
-      return std::max_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getStep) )->getStep();
-   }
-   /*==========================================================*/
-   inline std::string toString() const
-   {
-      std::stringstream text;
-      text<<*this;
-      return text.str();
-   }
-   /*==========================================================*/
-   friend inline std::ostream& operator << (std::ostream& os, const UbScheduler& scheduler) 
-   {
-      os<<"UbScheduler\n";
-      os<<"Schedule |       start       |        end        |     intervall     "<<std::endl;
-      for(std::size_t i=0; i<scheduler.schedules.size(); i++)
-         os<<std::setw(9)<<i<<"|"
-           <<std::setw(19)<<scheduler.schedules[i].getBegin()<<"|"
-           <<std::setw(19)<<scheduler.schedules[i].getEnd()  <<"|"
-           <<std::setw(19)<<scheduler.schedules[i].getStep() <<std::endl;
-      return os;
-   }
-
-   //------------- implements CAB serialization ----- start
-   virtual void write(UbFileOutput* out)
-   {
-      out->writeSize_t( schedules.size() );
-      
-      for(std::size_t i=0; i<schedules.size(); i++)
-         schedules[i].write(out);
-   }
-   virtual void read(UbFileInput* in)
-   {
-      this->initVals();
-
-      std::size_t nofSchedules = in->readSize_t();
-      for(std::size_t i=0; i<nofSchedules; i++)
-      {
-         UbSchedule schedule;
-         schedule.read(in);
-         this->addSchedule(schedule);
-      }
-   }
-
-protected:
-   /*==========================================================*/
-   void initVals()
-   {
-      lastUsedT   = -Ub::inf; 
-      lastDueTime = -Ub::inf;
-      nextDueTime =  Ub::inf;
-      maxT        = -Ub::inf;
-   }
-   /*==========================================================*/
-   // calculates next due time for a schedule 
-   // with  nextDueTime > searchStart
-   bool calcNextDueTimeForSchedule(const UbSchedule& schedule, const double& searchStart, double& nextDueTime )
-   {
-      if     ( UbMath::greater(searchStart, schedule.end  ) ) return false;
-      else if( UbMath::less(   searchStart, schedule.begin) ) nextDueTime = schedule.begin;
-      else                            
-      {
-         nextDueTime = schedule.begin + ((int)((searchStart-schedule.begin)/schedule.step)+1)*schedule.step;
-         if(   UbMath::less(   nextDueTime, searchStart )
-            || UbMath::greater(nextDueTime, schedule.end) ) 
-         {
-            return false;
-         }
-      }
-      return true;
-   }
-
-protected:
-   double lastUsedT;
-   double lastDueTime;
-   double nextDueTime;
-   double maxT;
-   
-   std::vector<UbSchedule> schedules;
-};
-
-typedef UbScheduler::UbSchedule UbSchedule;
-// inline std::ostream& operator<<( std::ostream& os, const UbScheduler& scheduler )
-// {
-//    os<<"UbScheduler\n";
-//    os<<"Schedule |       start       |        end        |     intervall     "<<std::endl;
-//    for(std::size_t i=0; i<scheduler.schedules.size(); i++)
-//       os<<std::setw(9)<<i<<"|"
-//         <<std::setw(19)<<scheduler.schedules[i].getBegin()<<"|"
-//         <<std::setw(19)<<scheduler.schedules[i].getEnd()  <<"|"
-//         <<std::setw(19)<<scheduler.schedules[i].getStep() <<std::endl;
-//    return os;
-// }
-
-#endif //UBSCHEDULER_H
-
-
-
-//int main(int argc, char** argv)            
-//{   
-//	UbScheduler writeSchedule;
-////	writeSchedule.addSchedule(0,2000,100);
-////	writeSchedule.addSchedule(3005,4500,300);
-////	writeSchedule.addSchedule(0,10,1);
-////	writeSchedule.addSchedule(0,100001,100);
-//	writeSchedule.addSchedule(0,2,1);
-//	writeSchedule.addSchedule(0,100001,200);
-//
-//	for(int t = 0; t < 1001; t++)
-//	{
-//		if(writeSchedule.isDue(t))
-//		{
-//			cout<<"due@ "<<t<<endl;
-//		}
-//	}
-//	return 0;
-//}
-
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBSCHEDULER_H
+#define UBSCHEDULER_H
+
+#include <iostream>
+#include <string>
+#include <limits>
+#include <cassert> 
+#include <sstream>
+#include <iomanip>
+#include <algorithm>
+
+#include <basics/utilities/UbSystem.h>
+#include <basics/utilities/UbMath.h>
+#include <basics/utilities/UbInfinity.h>
+#include <basics/utilities/UbComparators.h>
+#include <basics/utilities/UbFileOutput.h>
+#include <basics/utilities/UbFileInput.h>
+
+/*=========================================================================*/
+/*  UbScheduler                                                            */
+/*                                                                         */
+/**
+namespace for global system-functions
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@author <A HREF="mailto:hegewald@cab.bau.tu-bs.de">J. Hegewald</A>
+@version 1.0 - 06.09.06
+@version 1.1 - 09.09.06
+@version 1.2 - 03.07.08 - nun auch isDue(t) mehrmals fuer dasselbe t moeglich
+                          isDue(t) auch fuer t < lastUsedT
+                          bug entfernt, der bei Schedule (5,0,500) auch 505 als Due zurückgibt!
+*/ 
+
+/*
+usage: ...
+*/
+
+// this class is not thread save
+//
+
+class UbScheduler
+{
+public:
+   class UbSchedule
+   {
+      friend class UbScheduler;
+   public:
+      UbSchedule() :  step(Ub::inf), begin(Ub::inf), end(Ub::inf) { }
+      UbSchedule(const double& step, const double& begin=0.0, const double& end=Ub::inf) 
+         : step(step), begin(begin), end(end) 
+      {  
+      }
+      double getStep()  const { return this->step;  }
+      double getBegin() const { return this->begin; }
+      double getEnd()   const { return this->end;   }
+      
+      /*==========================================================*/
+      std::string toString() { std::stringstream text; text<<*this; return text.str(); }
+      /*==========================================================*/
+      friend inline std::ostream& operator << (std::ostream& os, const UbSchedule& schedule) 
+      {
+         os<<"Schedule[start,end,step]=["<<schedule.begin<<", "<<schedule.end<<", "<<schedule.step<<"]";
+         return os;
+      }
+
+      //------------- implements CAB serialization ----- start
+      virtual void write(UbFileOutput* out)
+      {
+         out->writeDouble( begin );
+         out->writeDouble( end );
+         out->writeDouble( step );
+      }
+      virtual void read(UbFileInput* in)
+      {
+         begin = in->readDouble();
+         end   = in->readDouble();
+         step  = in->readDouble();
+      }
+  
+
+   private:
+      double step, begin, end;
+   };
+
+public:
+   UbScheduler() 
+   {
+      this->initVals();
+   }
+   /*==========================================================*/                         
+   UbScheduler(const double& step,const double& begin=0, const double& end=Ub::inf ) 
+   {
+      this->initVals();
+      this->addSchedule(step,begin,end);
+   }
+   /*==========================================================*/
+   UbScheduler(const UbSchedule& schedule) 
+   {
+      this->initVals();
+      this->addSchedule(schedule);
+   }
+   /*==========================================================*/
+   virtual ~UbScheduler() {}
+   /*==========================================================*/
+   inline void addSchedule(const UbSchedule& schedule)
+   {
+      this->addSchedule(schedule.step, schedule.begin, schedule.end);
+   }
+   /*==========================================================*/
+   bool addSchedule(const double& step, const double& begin, double end)
+   {
+      if( UbMath::zero(step) || begin>end )
+      { 
+         std::cerr<<"UbScheduler::addSchedule - invalid Schedule:\n\t"<<UbSchedule(step, begin, end)<<std::endl;
+         return false; 
+      }
+      
+      if( UbMath::less( end, (double)Ub::inf )  )
+      {
+         //es kann vorkommen, dass man mit dem intervall nicht genau auf den letzten wert kommt
+         //(z.B. step=2; start=0; end=9; -> ende wird angepasst)
+         //also wenn end-begin>Ub::inf ist, dann geht es halt nicht.. ein cast in long double half hier nichts
+         double multiplier=0.0;
+         double fractpart =  modf( (end-begin)/step, &multiplier);
+         if( !UbMath::zero(fractpart) )
+         {
+            //tmp-speicherung (fuer cerr)
+            fractpart = end;
+            //neues ende
+            end = begin+multiplier*step;
+            
+            std::cerr<<"Warning: UbScheduler::addSchedule - "
+                      <<"end of schedule was adapted to intervall \n\t"
+                      <<"from "<< UbSchedule(step, begin, fractpart) <<" to "<< UbSchedule(step, begin, end) <<std::endl;
+         }
+      }
+
+      //nu aber:
+      schedules.push_back(UbSchedule(step, begin, end));
+
+      if( end>maxT ) maxT = end;
+
+      double potentialDueTime;
+      if(   calcNextDueTimeForSchedule(schedules.back(), lastUsedT, potentialDueTime)
+         && potentialDueTime < nextDueTime   )
+      {
+         nextDueTime = potentialDueTime;
+      }
+
+      return true;
+   }
+   /*==========================================================*/
+   //returns true if scheduler contains schedules
+   bool   hasSchedules() const { return !schedules.empty(); }
+   /*==========================================================*/
+   //time bei dem das letzte mal isDue(time) true war
+   double getLastDueTime() const { return lastDueTime; }
+   /*==========================================================*/
+   //time bei dem das naechste mal isDue(time) true ergibt
+   double getNextDueTime() const { return nextDueTime; }
+   /*==========================================================*/
+   //maxDueTime (maxTime der Schedules!
+   double getMaxDueTime()  const { return this->maxT; }
+   /*==========================================================*/
+   bool isDue(const double& t)
+   {
+      lastUsedT = t;
+      if( UbMath::greaterEqual(t,nextDueTime) ) 
+      {
+         //groesser maxT is nicht
+         if( UbMath::greater(t,maxT) )  return false;
+         
+         //temp var
+         double actDueTime = nextDueTime;
+
+         //um Suche nach nextDueTime bei "Zukunfts-t" zu optimieren, setzt man die "start"-suchzeit auf "t-1":
+         nextDueTime = t-1; //t-1 deshlab, damit falls z.B. while Schleife nicht durchlaufen wird
+                            //die folgende if Abfrage nicht faelschlicher Weise true ist!
+         while( UbMath::greaterEqual(t,nextDueTime) && !UbMath::equal(nextDueTime, maxT) )
+         {
+            double tmpNextDueTime = maxT, potentialDueTime=-1.0;
+            for(std::size_t i=0; i<schedules.size(); i++)
+            {
+               if(   calcNextDueTimeForSchedule(schedules[i], nextDueTime, potentialDueTime)
+                  && potentialDueTime < tmpNextDueTime                 )
+               {
+                  assert( nextDueTime < potentialDueTime );
+                  tmpNextDueTime = potentialDueTime;
+               }
+            }
+            actDueTime  = nextDueTime;
+            nextDueTime = tmpNextDueTime;
+         } 
+
+         //wenn t = der aktuuellen oder gar schon der nächstmöglichen ist (hierbei wurde
+         //zuvor actDueTime und nextDueTime ggf. angepasst)
+         //Bsp.: nextDuTime war 5, aber für t=400 gilt andere schedule -> Bsp actDue=350 und nextDue 405
+         if(    UbMath::equal(t,actDueTime)    
+             || UbMath::equal(t,nextDueTime) ) 
+         {
+            lastDueTime = t;
+            return true;
+         }
+      }
+      else if( UbMath::lessEqual(t, lastDueTime) ) 
+      {
+         if(UbMath::equal(t, lastDueTime) ) return true; //braucht man, wenn man für dasselbe t isDue(t) aufruft
+         else  
+         {
+            //Fall: Zeit liegt faktisch in der Vergangenheit -> neu initialsisieren
+            double tmpNextDueTime = maxT, potentialDueTime=-1.0;
+            for(size_t i=0; i<schedules.size(); i++)
+            {
+               if(   calcNextDueTimeForSchedule(schedules[i], t-1, potentialDueTime)
+                  && potentialDueTime < tmpNextDueTime                 )
+               {
+                  tmpNextDueTime = potentialDueTime;
+               }
+            }
+            nextDueTime = tmpNextDueTime;
+
+            return UbMath::equal(t, nextDueTime);
+         }
+      }
+
+      return false;
+   }
+   /*==========================================================*/
+   inline double getMinBegin( ) const
+   {
+      if( schedules.empty() ) return Ub::inf;
+      return std::min_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getBegin) )->getBegin();
+   }
+   /*==========================================================*/
+   inline double getMaxBegin( ) const
+   {
+      if( schedules.empty() ) return Ub::inf;
+      return std::max_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getBegin) )->getBegin();
+   }
+   /*==========================================================*/
+   inline double getMinEnd( ) const
+   {
+      if( schedules.empty() ) return Ub::inf;
+      return std::min_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getEnd) )->getEnd();
+   }
+   /*==========================================================*/
+   inline double getMaxEnd( ) const
+   {
+      if( schedules.empty() ) return Ub::inf;
+      return std::max_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getEnd) )->getEnd();
+   }
+   /*==========================================================*/
+   inline double getMinStep( ) const
+   {
+      if( schedules.empty() ) return Ub::inf;
+      return std::min_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getStep) )->getStep();
+   }
+   /*==========================================================*/
+   inline double getMaxStep( ) const
+   {
+      if( schedules.empty() ) return Ub::inf;
+      return std::max_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getStep) )->getStep();
+   }
+   /*==========================================================*/
+   inline std::string toString() const
+   {
+      std::stringstream text;
+      text<<*this;
+      return text.str();
+   }
+   /*==========================================================*/
+   friend inline std::ostream& operator << (std::ostream& os, const UbScheduler& scheduler) 
+   {
+      os<<"UbScheduler\n";
+      os<<"Schedule |       start       |        end        |     intervall     "<<std::endl;
+      for(std::size_t i=0; i<scheduler.schedules.size(); i++)
+         os<<std::setw(9)<<i<<"|"
+           <<std::setw(19)<<scheduler.schedules[i].getBegin()<<"|"
+           <<std::setw(19)<<scheduler.schedules[i].getEnd()  <<"|"
+           <<std::setw(19)<<scheduler.schedules[i].getStep() <<std::endl;
+      return os;
+   }
+
+   //------------- implements CAB serialization ----- start
+   virtual void write(UbFileOutput* out)
+   {
+      out->writeSize_t( schedules.size() );
+      
+      for(std::size_t i=0; i<schedules.size(); i++)
+         schedules[i].write(out);
+   }
+   virtual void read(UbFileInput* in)
+   {
+      this->initVals();
+
+      std::size_t nofSchedules = in->readSize_t();
+      for(std::size_t i=0; i<nofSchedules; i++)
+      {
+         UbSchedule schedule;
+         schedule.read(in);
+         this->addSchedule(schedule);
+      }
+   }
+
+protected:
+   /*==========================================================*/
+   void initVals()
+   {
+      lastUsedT   = -Ub::inf; 
+      lastDueTime = -Ub::inf;
+      nextDueTime =  Ub::inf;
+      maxT        = -Ub::inf;
+   }
+   /*==========================================================*/
+   // calculates next due time for a schedule 
+   // with  nextDueTime > searchStart
+   bool calcNextDueTimeForSchedule(const UbSchedule& schedule, const double& searchStart, double& nextDueTime )
+   {
+      if     ( UbMath::greater(searchStart, schedule.end  ) ) return false;
+      else if( UbMath::less(   searchStart, schedule.begin) ) nextDueTime = schedule.begin;
+      else                            
+      {
+         nextDueTime = schedule.begin + ((int)((searchStart-schedule.begin)/schedule.step)+1)*schedule.step;
+         if(   UbMath::less(   nextDueTime, searchStart )
+            || UbMath::greater(nextDueTime, schedule.end) ) 
+         {
+            return false;
+         }
+      }
+      return true;
+   }
+
+protected:
+   double lastUsedT;
+   double lastDueTime;
+   double nextDueTime;
+   double maxT;
+   
+   std::vector<UbSchedule> schedules;
+};
+
+typedef UbScheduler::UbSchedule UbSchedule;
+// inline std::ostream& operator<<( std::ostream& os, const UbScheduler& scheduler )
+// {
+//    os<<"UbScheduler\n";
+//    os<<"Schedule |       start       |        end        |     intervall     "<<std::endl;
+//    for(std::size_t i=0; i<scheduler.schedules.size(); i++)
+//       os<<std::setw(9)<<i<<"|"
+//         <<std::setw(19)<<scheduler.schedules[i].getBegin()<<"|"
+//         <<std::setw(19)<<scheduler.schedules[i].getEnd()  <<"|"
+//         <<std::setw(19)<<scheduler.schedules[i].getStep() <<std::endl;
+//    return os;
+// }
+
+#endif //UBSCHEDULER_H
+
+
+
+//int main(int argc, char** argv)            
+//{   
+//	UbScheduler writeSchedule;
+////	writeSchedule.addSchedule(0,2000,100);
+////	writeSchedule.addSchedule(3005,4500,300);
+////	writeSchedule.addSchedule(0,10,1);
+////	writeSchedule.addSchedule(0,100001,100);
+//	writeSchedule.addSchedule(0,2,1);
+//	writeSchedule.addSchedule(0,100001,200);
+//
+//	for(int t = 0; t < 1001; t++)
+//	{
+//		if(writeSchedule.isDue(t))
+//		{
+//			cout<<"due@ "<<t<<endl;
+//		}
+//	}
+//	return 0;
+//}
+
diff --git a/source/ThirdParty/Library/basics/utilities/UbStaticPathMap.cpp b/source/VirtualFluidsBasic/basics/utilities/UbStaticPathMap.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbStaticPathMap.cpp
rename to source/VirtualFluidsBasic/basics/utilities/UbStaticPathMap.cpp
index 7772fc5d822487033d53af7caeb49b956ba7a201..b68cc5ba1445d870e45b57e45ba1eaa5462ca44d 100644
--- a/source/ThirdParty/Library/basics/utilities/UbStaticPathMap.cpp
+++ b/source/VirtualFluidsBasic/basics/utilities/UbStaticPathMap.cpp
@@ -1,4 +1,4 @@
-#include <basics/utilities/UbStaticPathMap.h>
-
-UbStaticPathMap::PathMap UbStaticPathMap::pathMap;
-const std::string UbStaticPathMap::GLOBAL = "UbStaticPathMap::GLOBAL";
+#include <basics/utilities/UbStaticPathMap.h>
+
+UbStaticPathMap::PathMap UbStaticPathMap::pathMap;
+const std::string UbStaticPathMap::GLOBAL = "UbStaticPathMap::GLOBAL";
diff --git a/source/ThirdParty/Library/basics/utilities/UbStaticPathMap.h b/source/VirtualFluidsBasic/basics/utilities/UbStaticPathMap.h
similarity index 96%
rename from source/ThirdParty/Library/basics/utilities/UbStaticPathMap.h
rename to source/VirtualFluidsBasic/basics/utilities/UbStaticPathMap.h
index 20e5b7e8fb294ba8da532aac010d8f85a878fd1c..a188843c3a2411fd198b74f71ce0e712fbfcb5ae 100644
--- a/source/ThirdParty/Library/basics/utilities/UbStaticPathMap.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbStaticPathMap.h
@@ -1,71 +1,71 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBSTATICPATHMAP_H
-#define UBSTATICPATHMAP_H
-
-#include <iostream>
-#include <string>
-#include <map>
-
-#include <basics/utilities/UbSystem.h>
-
-/*=========================================================================*/
-/*  UbStaticPathMap                                                             */
-/*                                                                         */
-/**
-...
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 12.10.2007
-*/ 
-
-/*
-stores pathnames for pathIDs (e.g. on different processes different paths with same pathID)
-adding an path autom. changes "\" to "/" and removed last "/" if exists
-
-*/
-
-class UbStaticPathMap
-{
-   typedef std::map< std::string, std::string > PathMap;
-public:
-   static const std::string GLOBAL;
-public:
-
-   static std::string addAndMakePath(const std::string& id, const std::string& path)
-   {
-      std::string tmpPath = UbStaticPathMap::addPath(id,path);
-      if( !tmpPath.empty() ) UbSystem::makeDirectory(tmpPath,20);
-      return tmpPath;
-   }
-   static std::string addPath(const std::string& id, const std::string& path)
-   {
-      std::string tmpPath = UbSystem::replaceInString(path,"\\","/");
-      if(tmpPath.rfind("/") == tmpPath.size()-1) tmpPath.resize(tmpPath.size()-1);
-      pathMap[id] = tmpPath;   
-      return tmpPath;
-   }
-   static std::string getPath(const std::string& id)
-   {
-      PathMap::iterator it = pathMap.find(id);
-      if(it == pathMap.end()) return "";
-      return it->second;
-   }
-   static void removePath(const std::string& id)
-   {
-      pathMap.erase(id);
-   }
-
-protected:
-   static PathMap pathMap;
-
-private:
-   UbStaticPathMap() {}
-   UbStaticPathMap(const UbStaticPathMap&) {}
-};
-
-#endif //UBSTATICPATHMAP_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBSTATICPATHMAP_H
+#define UBSTATICPATHMAP_H
+
+#include <iostream>
+#include <string>
+#include <map>
+
+#include <basics/utilities/UbSystem.h>
+
+/*=========================================================================*/
+/*  UbStaticPathMap                                                             */
+/*                                                                         */
+/**
+...
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 12.10.2007
+*/ 
+
+/*
+stores pathnames for pathIDs (e.g. on different processes different paths with same pathID)
+adding an path autom. changes "\" to "/" and removed last "/" if exists
+
+*/
+
+class UbStaticPathMap
+{
+   typedef std::map< std::string, std::string > PathMap;
+public:
+   static const std::string GLOBAL;
+public:
+
+   static std::string addAndMakePath(const std::string& id, const std::string& path)
+   {
+      std::string tmpPath = UbStaticPathMap::addPath(id,path);
+      if( !tmpPath.empty() ) UbSystem::makeDirectory(tmpPath,20);
+      return tmpPath;
+   }
+   static std::string addPath(const std::string& id, const std::string& path)
+   {
+      std::string tmpPath = UbSystem::replaceInString(path,"\\","/");
+      if(tmpPath.rfind("/") == tmpPath.size()-1) tmpPath.resize(tmpPath.size()-1);
+      pathMap[id] = tmpPath;   
+      return tmpPath;
+   }
+   static std::string getPath(const std::string& id)
+   {
+      PathMap::iterator it = pathMap.find(id);
+      if(it == pathMap.end()) return "";
+      return it->second;
+   }
+   static void removePath(const std::string& id)
+   {
+      pathMap.erase(id);
+   }
+
+protected:
+   static PathMap pathMap;
+
+private:
+   UbStaticPathMap() {}
+   UbStaticPathMap(const UbStaticPathMap&) {}
+};
+
+#endif //UBSTATICPATHMAP_H
diff --git a/source/ThirdParty/Library/basics/utilities/UbString.h b/source/VirtualFluidsBasic/basics/utilities/UbString.h
similarity index 94%
rename from source/ThirdParty/Library/basics/utilities/UbString.h
rename to source/VirtualFluidsBasic/basics/utilities/UbString.h
index 516ee76ea90d44d33983fa3a1a531f98211e3dd1..f93fe7ae6a6243a4bcd48adfd7ce872b2e0b3a36 100644
--- a/source/ThirdParty/Library/basics/utilities/UbString.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbString.h
@@ -1,24 +1,24 @@
-//unnoetig: UbSystem::toString() verwenden,... andere Richtung: stringTo... oder am besten boost::lexical_cast
-
-
-//#ifndef UBSTRING_H
-//#define UBSTRING_H
-//#include <string>
-//#include <sstream>
-//
-//using namespace std;
-//
-//class UbString
-//{
-//public:
-//   static void IntToString(int i, string& res)
-//   {
-//      ostringstream temp;
-//      temp << i;
-//      res = temp.str();
-//   }
-//protected:
-//private:
-//};
-//
-//#endif //end UBSTRING_H
+//unnoetig: UbSystem::toString() verwenden,... andere Richtung: stringTo... oder am besten boost::lexical_cast
+
+
+//#ifndef UBSTRING_H
+//#define UBSTRING_H
+//#include <string>
+//#include <sstream>
+//
+//using namespace std;
+//
+//class UbString
+//{
+//public:
+//   static void IntToString(int i, string& res)
+//   {
+//      ostringstream temp;
+//      temp << i;
+//      res = temp.str();
+//   }
+//protected:
+//private:
+//};
+//
+//#endif //end UBSTRING_H
diff --git a/source/ThirdParty/Library/basics/utilities/UbStringInputASCII.cpp b/source/VirtualFluidsBasic/basics/utilities/UbStringInputASCII.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbStringInputASCII.cpp
rename to source/VirtualFluidsBasic/basics/utilities/UbStringInputASCII.cpp
index cf104b9fd8c182621b67975e9693f8cd78d91b84..094b6a5b877c7d9a1b5508b469381fe46d86888f 100644
--- a/source/ThirdParty/Library/basics/utilities/UbStringInputASCII.cpp
+++ b/source/VirtualFluidsBasic/basics/utilities/UbStringInputASCII.cpp
@@ -1,211 +1,211 @@
-#include <basics/utilities/UbStringInputASCII.h>
-#include <cstring>
-
-using namespace std;
-
-
-UbStringInputASCII::UbStringInputASCII(string inputString) : UbFileInputASCII("")
-{
-	instream.str(inputString);
-	
-	
-//	this->filename         = filename;
-//   this->commentindicator = 'C'; 
-//   
-//   infile.open(filename.c_str());
-
-}
-/*==========================================================*/
-int UbStringInputASCII::readInteger()				
-{
-	int dummy;
-	instream>>dummy;
-	return dummy;
-}
-/*==========================================================*/
-std::size_t UbStringInputASCII::readSize_t()				
-{
-   std::size_t dummy;
-   instream>>dummy;
-   return dummy;
-}
-/*==========================================================*/
-string UbStringInputASCII::getFileName()				
-{
-	return this->filename;
-}
-
-/*==========================================================*/
-void UbStringInputASCII::skipLine()				
-{
-	string dummy;
-	getline(instream, dummy);
-}
-/*==========================================================*/
-void UbStringInputASCII::readLine()				
-{
-	string dummy;
-	getline(instream, dummy);
-}
-/*==========================================================*/
-string UbStringInputASCII::readStringLine()				
-{
-   string dummy;
-   getline(instream, dummy);
-   return dummy;
-}
-/*==========================================================*/
-string UbStringInputASCII::readLineTill(char stop)				
-{
-	string dummy;
-	getline(instream, dummy, stop);
-	return dummy;
-}
-/*==========================================================*/
-string UbStringInputASCII::parseString()				
-{
-	string dummy;
-	getline(instream, dummy, ' ');
-	return dummy;
-}
-/*==========================================================*/
-double UbStringInputASCII::readDouble()	
-{
-   double dummy;
-   instream>>dummy;
-   return dummy;
-}
-/*==========================================================*/
-float UbStringInputASCII::readFloat()	
-{
-   float dummy;
-   instream>>dummy;
-   return dummy;
-}
-/*==========================================================*/
-char UbStringInputASCII::readChar()	
-{
-   char dummy;
-   instream>>dummy;
-   return dummy;
-}
-/*==========================================================*/
-string UbStringInputASCII::readString()	
-{
-	string dummy;
-	instream>>dummy;
-	return dummy;
-}
-/*==========================================================*/
-bool UbStringInputASCII::containsString(string var)
-{
-   instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
-   char line[512];								
-   do
-   { 
-      instream.getline(line,512);
-      if(instream.eof()) return false;
-   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt	
-   
-   return true;
-}
-/*==========================================================*/
-void UbStringInputASCII::setPosAfterLineWithString(string var)
-{
-   instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
-   char line[512];								
-   do
-   { 
-      instream.getline(line,512);
-      if(instream.eof()) UB_THROW( UbException(UB_EXARGS,var+" wasn't found in "+this->filename) );
-   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt	
-}
-/*==========================================================*/
-int UbStringInputASCII::readIntegerAfterString(string var)
-// last change [10.3.2004] at [9:46] 
-//suchts in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
-//z.B. timesteps 9
-{
-   instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
-
-   char line[512];								
-
-   do
-   { 
-      instream.getline(line,512);
-      if(instream.eof()) UB_THROW( UbException(UB_EXARGS,var+" wasn't found in "+this->filename) );
-   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt	
-
-   strcpy (line, (line+strlen(var.c_str())));	    // zeile um "varname" kuerzen 
-   while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1));	// Whitespaces entfernen
-
-   return(atoi(line));						// Umwandlung in int 					
-}
-/*==========================================================*/
-// last change [10.3.2004] at [9:46] 
-//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
-//z.B. nue 9.5
-double UbStringInputASCII::readDoubleAfterString(string var)	
-{
-   instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
-
-   char line[512];								
-
-   do
-   { 
-      instream.getline(line,512);
-      if(instream.eof()) UB_THROW( UbException(UB_EXARGS,var+" wasn't found in "+this->filename) );
-   }while (/*!strncmp(varname,line,sizeof(varname))==0*/strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt	
-
-
-   strcpy (line, (line+strlen(var.c_str())));	    // zeile um "varname" kuerzen 
-   while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1));	// Whitespaces entfernen
-
-   return (atof(line));			// Umwandlung in double 					
-}
-/*==========================================================*/
-//  [9.9.2002]
-// liefert sring-Wert der hinter dem uebergebenen char feld in der datei instream steht
-// zudem wird der wert in die uebergebene variable value uebertragen (falls man das ergebniss als char benoetig)
-string UbStringInputASCII::readStringAfterString(string var)	
-{
-   instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
-
-   char line[512];								
-   //string line_copy[512];
-
-   do{ 
-      instream.getline(line,512);
-      if(instream.eof()) UB_THROW( UbException(UB_EXARGS,var+" wasn't found in "+this->filename) );
-   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt	
-
-   strcpy (line, (line+strlen(var.c_str())));										// zeile um "varname" kuerzen 
-   while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1));	// Whitespaces entfernen
-
-   char *p;
-   p=strtok(line," "); //schneidet alles "ab und inklusive space " nach namen ab
-   p=strtok(line,"\t");//schneidet alles "ab und inklusive tab   " nach namen ab
-
-   return (string)p;			// Umwandlung in string					
-}
-/*==========================================================*/
-// last change [10.3.2004] at [9:46] 
-//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
-//z.B. nue 9.5
-bool UbStringInputASCII::readBoolAfterString(string var)	
-{
-   if(this->readStringAfterString(var.c_str())      == "true" ) return true;
-   else if(this->readStringAfterString(var.c_str()) == "false") return false;
-   else UB_THROW( UbException(UB_EXARGS,var+" is not equal to 'true' or 'false' in "+this->filename) );
-}
-/*==========================================================*/
-// last change [10.3.2004] at [9:46] 
-//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
-//z.B. nue 9.5
-bool UbStringInputASCII::readBool()	
-{
-   string tmp = this->readString();
-   if(     tmp == "true" ) return true;
-   else if(tmp == "false") return false;
-   else UB_THROW( UbException(UB_EXARGS,"expression is not equal to 'true' or 'false' in "+this->filename) );
-}
+#include <basics/utilities/UbStringInputASCII.h>
+#include <cstring>
+
+using namespace std;
+
+
+UbStringInputASCII::UbStringInputASCII(string inputString) : UbFileInputASCII("")
+{
+	instream.str(inputString);
+	
+	
+//	this->filename         = filename;
+//   this->commentindicator = 'C'; 
+//   
+//   infile.open(filename.c_str());
+
+}
+/*==========================================================*/
+int UbStringInputASCII::readInteger()				
+{
+	int dummy;
+	instream>>dummy;
+	return dummy;
+}
+/*==========================================================*/
+std::size_t UbStringInputASCII::readSize_t()				
+{
+   std::size_t dummy;
+   instream>>dummy;
+   return dummy;
+}
+/*==========================================================*/
+string UbStringInputASCII::getFileName()				
+{
+	return this->filename;
+}
+
+/*==========================================================*/
+void UbStringInputASCII::skipLine()				
+{
+	string dummy;
+	getline(instream, dummy);
+}
+/*==========================================================*/
+void UbStringInputASCII::readLine()				
+{
+	string dummy;
+	getline(instream, dummy);
+}
+/*==========================================================*/
+string UbStringInputASCII::readStringLine()				
+{
+   string dummy;
+   getline(instream, dummy);
+   return dummy;
+}
+/*==========================================================*/
+string UbStringInputASCII::readLineTill(char stop)				
+{
+	string dummy;
+	getline(instream, dummy, stop);
+	return dummy;
+}
+/*==========================================================*/
+string UbStringInputASCII::parseString()				
+{
+	string dummy;
+	getline(instream, dummy, ' ');
+	return dummy;
+}
+/*==========================================================*/
+double UbStringInputASCII::readDouble()	
+{
+   double dummy;
+   instream>>dummy;
+   return dummy;
+}
+/*==========================================================*/
+float UbStringInputASCII::readFloat()	
+{
+   float dummy;
+   instream>>dummy;
+   return dummy;
+}
+/*==========================================================*/
+char UbStringInputASCII::readChar()	
+{
+   char dummy;
+   instream>>dummy;
+   return dummy;
+}
+/*==========================================================*/
+string UbStringInputASCII::readString()	
+{
+	string dummy;
+	instream>>dummy;
+	return dummy;
+}
+/*==========================================================*/
+bool UbStringInputASCII::containsString(string var)
+{
+   instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
+   char line[512];								
+   do
+   { 
+      instream.getline(line,512);
+      if(instream.eof()) return false;
+   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt	
+   
+   return true;
+}
+/*==========================================================*/
+void UbStringInputASCII::setPosAfterLineWithString(string var)
+{
+   instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
+   char line[512];								
+   do
+   { 
+      instream.getline(line,512);
+      if(instream.eof()) UB_THROW( UbException(UB_EXARGS,var+" wasn't found in "+this->filename) );
+   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt	
+}
+/*==========================================================*/
+int UbStringInputASCII::readIntegerAfterString(string var)
+// last change [10.3.2004] at [9:46] 
+//suchts in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
+//z.B. timesteps 9
+{
+   instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
+
+   char line[512];								
+
+   do
+   { 
+      instream.getline(line,512);
+      if(instream.eof()) UB_THROW( UbException(UB_EXARGS,var+" wasn't found in "+this->filename) );
+   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt	
+
+   strcpy (line, (line+strlen(var.c_str())));	    // zeile um "varname" kuerzen 
+   while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1));	// Whitespaces entfernen
+
+   return(atoi(line));						// Umwandlung in int 					
+}
+/*==========================================================*/
+// last change [10.3.2004] at [9:46] 
+//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
+//z.B. nue 9.5
+double UbStringInputASCII::readDoubleAfterString(string var)	
+{
+   instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
+
+   char line[512];								
+
+   do
+   { 
+      instream.getline(line,512);
+      if(instream.eof()) UB_THROW( UbException(UB_EXARGS,var+" wasn't found in "+this->filename) );
+   }while (/*!strncmp(varname,line,sizeof(varname))==0*/strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt	
+
+
+   strcpy (line, (line+strlen(var.c_str())));	    // zeile um "varname" kuerzen 
+   while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1));	// Whitespaces entfernen
+
+   return (atof(line));			// Umwandlung in double 					
+}
+/*==========================================================*/
+//  [9.9.2002]
+// liefert sring-Wert der hinter dem uebergebenen char feld in der datei instream steht
+// zudem wird der wert in die uebergebene variable value uebertragen (falls man das ergebniss als char benoetig)
+string UbStringInputASCII::readStringAfterString(string var)	
+{
+   instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen
+
+   char line[512];								
+   //string line_copy[512];
+
+   do{ 
+      instream.getline(line,512);
+      if(instream.eof()) UB_THROW( UbException(UB_EXARGS,var+" wasn't found in "+this->filename) );
+   }while (strstr(line,var.c_str()) != line);		// Ende Schleife, wenn varname ganz in zeile vorkommt	
+
+   strcpy (line, (line+strlen(var.c_str())));										// zeile um "varname" kuerzen 
+   while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1));	// Whitespaces entfernen
+
+   char *p;
+   p=strtok(line," "); //schneidet alles "ab und inklusive space " nach namen ab
+   p=strtok(line,"\t");//schneidet alles "ab und inklusive tab   " nach namen ab
+
+   return (string)p;			// Umwandlung in string					
+}
+/*==========================================================*/
+// last change [10.3.2004] at [9:46] 
+//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
+//z.B. nue 9.5
+bool UbStringInputASCII::readBoolAfterString(string var)	
+{
+   if(this->readStringAfterString(var.c_str())      == "true" ) return true;
+   else if(this->readStringAfterString(var.c_str()) == "false") return false;
+   else UB_THROW( UbException(UB_EXARGS,var+" is not equal to 'true' or 'false' in "+this->filename) );
+}
+/*==========================================================*/
+// last change [10.3.2004] at [9:46] 
+//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck
+//z.B. nue 9.5
+bool UbStringInputASCII::readBool()	
+{
+   string tmp = this->readString();
+   if(     tmp == "true" ) return true;
+   else if(tmp == "false") return false;
+   else UB_THROW( UbException(UB_EXARGS,"expression is not equal to 'true' or 'false' in "+this->filename) );
+}
diff --git a/source/ThirdParty/Library/basics/utilities/UbStringInputASCII.h b/source/VirtualFluidsBasic/basics/utilities/UbStringInputASCII.h
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbStringInputASCII.h
rename to source/VirtualFluidsBasic/basics/utilities/UbStringInputASCII.h
index 787048e071daf501e988d2baf9ebd861f04bf6cf..06db6d68cd54adc0ccafc697408dae9c4ff8b73a 100644
--- a/source/ThirdParty/Library/basics/utilities/UbStringInputASCII.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbStringInputASCII.h
@@ -1,55 +1,55 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBSTRINGINPUTASCII_H
-#define UBSTRINGINPUTASCII_H
-
-#include <fstream>
-#include <iostream>
-#include <string>
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbFileInput.h>
-
-#include <basics/utilities/UbFileInputASCII.h>
-
-class UbStringInputASCII : public UbFileInputASCII
-{                               
-public:
-	UbStringInputASCII(std::string inputString);
-	
-	std::string getFileName();				
-	void	      skipLine();					   // Springt zur naechsten Zeile
-
-   void        readLine();		 
-   std::string readStringLine();				
-   std::size_t readSize_t();				
-   int		   readInteger();				   // Liest einen Int-Wert ein
-   double	   readDouble();				   // Liest einen double-Wert ein
-	float 	   readFloat();				   // Liest einen float-Wert ein
-	bool  	   readBool();				      // Liest einen bool-Wert ein
-   char        readChar();                // Liest einen char-Wert ein
-   std::string	readString();				   // Liest ein Wort ein
-	std::string	readLineTill(char stop);	// Liest gesamte Zeile ein bis zu einem bestimmten Zeichen
-	std::string	parseString();	
-
-   bool        containsString(std::string var);
-   void        setPosAfterLineWithString(std::string var);
-   int		   readIntegerAfterString(std::string var);
-   double	   readDoubleAfterString(std::string var);
-   bool        readBoolAfterString(std::string var);
-   std::string readStringAfterString(std::string var);
-
-   FILETYPE getFileType() { return ASCII; }
-
-private:
-	std::istringstream instream;
-};
-
-
-#endif
-
-
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBSTRINGINPUTASCII_H
+#define UBSTRINGINPUTASCII_H
+
+#include <fstream>
+#include <iostream>
+#include <string>
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbFileInput.h>
+
+#include <basics/utilities/UbFileInputASCII.h>
+
+class UbStringInputASCII : public UbFileInputASCII
+{                               
+public:
+	UbStringInputASCII(std::string inputString);
+	
+	std::string getFileName();				
+	void	      skipLine();					   // Springt zur naechsten Zeile
+
+   void        readLine();		 
+   std::string readStringLine();				
+   std::size_t readSize_t();				
+   int		   readInteger();				   // Liest einen Int-Wert ein
+   double	   readDouble();				   // Liest einen double-Wert ein
+	float 	   readFloat();				   // Liest einen float-Wert ein
+	bool  	   readBool();				      // Liest einen bool-Wert ein
+   char        readChar();                // Liest einen char-Wert ein
+   std::string	readString();				   // Liest ein Wort ein
+	std::string	readLineTill(char stop);	// Liest gesamte Zeile ein bis zu einem bestimmten Zeichen
+	std::string	parseString();	
+
+   bool        containsString(std::string var);
+   void        setPosAfterLineWithString(std::string var);
+   int		   readIntegerAfterString(std::string var);
+   double	   readDoubleAfterString(std::string var);
+   bool        readBoolAfterString(std::string var);
+   std::string readStringAfterString(std::string var);
+
+   FILETYPE getFileType() { return ASCII; }
+
+private:
+	std::istringstream instream;
+};
+
+
+#endif
+
+
diff --git a/source/ThirdParty/Library/basics/utilities/UbSystem.h b/source/VirtualFluidsBasic/basics/utilities/UbSystem.h
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbSystem.h
rename to source/VirtualFluidsBasic/basics/utilities/UbSystem.h
index 907d28d6278fa5a7f16a3e02b4928a61327edf36..630a9b4e6ff187950b65edb0204051e161371297 100644
--- a/source/ThirdParty/Library/basics/utilities/UbSystem.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbSystem.h
@@ -1,535 +1,535 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBSYSTEM_H
-#define UBSYSTEM_H
-
-#if defined(_WIN32) || defined(_WIN64)
-   #define UBSYSTEM_WINDOWS
-   #include <process.h>
-   #include <io.h>
-   #include <direct.h>
-   //#ifndef _WINSOCK2API_  //ansonsten gibt es mecker bei #include "Windows.h" und ::Sleep()
-   //   #define _WINSOCK2API_
-   //   #include<WinSock2.h> 
-   //#endif
-  #include <windows.h>
-  //#include <Windows.h>
-  //#include <tchar.h>
-#elif defined(__APPLE__)
-   #define UBSYSTEM_APPLE
-   #include "dirent.h"
-   #include "sys/stat.h"
-   #include <sys/syscall.h>
-   #include <sys/stat.h>
-#elif (defined(__amd64) || defined(__amd64__) || defined(__unix__) || defined(__CYGWIN__)) && !defined(__AIX__) 
-   #define UBSYSTEM_LINUX
-   #include "dirent.h"
-   #include "sys/stat.h"
-   #include <sys/syscall.h>
-   #include <sys/stat.h>
-   #include <unistd.h>
-   #include <string.h>
-#elif defined(__AIX__)
-   #define UBSYSTEM_AIX
-   #include "dirent.h"
-   #include <unistd.h>
-   #include <sys/stat.h>
-   #include <sys/types.h>
-#else
-   #error "UbSystem::UnknownMachine"
-#endif
-
-
-
-#if defined(min) || defined(max) //daruch kann man sich spaeter #undef min; #undef max erparen
-#   error add NOMINMAX to preprocessor defines
-#endif
-
-
-#include <iostream>
-#include <iomanip>
-#include <string>
-#include <sstream>
-#include <algorithm>
-#include <typeinfo>
-#include <cctype> //for toupper
-#include <ctime>
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbLogger.h>
-
-#if defined(CAB_BOOST)
-#include <boost/thread.hpp>
-#endif // CAB_BOOST
-
-//DEFINE TO STRING
-//e.g. #define FOO hallo
-//     -> QUOTEME(FOO) == "hallo"
-#define _QUOTEME(x) #x
-#define QUOTEME(x) _QUOTEME(x)
-
-//allg.:
-//const int * C1        -> C1 is variable pointer to a constant integer
-//int const * C2        -> C2 is variable pointer to a constant integer (same as above)
-//int * const C3        -> C3 is constant pointer to a variable integer
-//int const * const C4  -> C4 is constant pointer to a constant integer
-
-//////////////////////////////////////////////////////////////////////////
-//UbSystem
-//////////////////////////////////////////////////////////////////////////
-namespace UbSystem
-{
-   template<bool> struct ub_static_assert;     //deklaration (ub_xxx da static_assert in C++0x ein keyword werden wird)
-   template<> struct ub_static_assert<true>{}; //deklaration + definition der spezialisierung fuer "true"
-                                               //ub_static_assert<false> fuehrt zu compiler fehler, da dafuer
-                                               //keine implementierung vorhanden!  //UB_STATIC_ASSERT(false)
-
-   /*==========================================================*/
-   inline void sleepMs(const unsigned int& msec)
-   {
-      #if defined UBSYSTEM_WINDOWS
-         ::Sleep(  (msec==0) ? 1 : msec );  // +1 here causes a context switch if SleepMSec(0) is called
-      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX)
-         ::usleep(1000*msec);
-      #else
-         #error "UbSystem::sleepMSec - UnknownMachine"
-      #endif
-   }
-   /*==========================================================*/
-   inline void sleepS(const unsigned int& sec)
-   {
-      #if defined UBSYSTEM_WINDOWS
-         ::Sleep( (sec==0) ? 1 : sec*1000 );  // +1 here causes a context switch if sleepS(0) is called
-      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX)
-         ::sleep(sec);
-      #else
-         #error "UbSystem::sleepS - UnknownMachine"
-      #endif
-   }
-   /*==========================================================*/
-   //checks if the bits of bitmask are set in value
-   template<typename T>
-   inline bool bitCheck(const T& value, const T& bitmask)
-   {
-      return  ( (value & bitmask) == bitmask);
-   }
-   /*==========================================================*/
-   //checks if the bits of bitmask are set in value
-   template<typename T>
-   inline void setBit(T& value, const T& bitmask)
-   {
-      value |= bitmask;
-   }
-   /*==========================================================*/
-   template<typename T>
-   inline void unsetBit(T& value, const T& bitmask)
-   {
-      value &= ~bitmask;
-   }
-   /*==========================================================*/
-   //returns bitmask as string e.g. 0001 0100 1101
-   template<typename T>
-   inline std::string getBitString(const T& value)
-   {
-      std::stringstream text;
-      for(int i=sizeof(value)*8-1/*8 bits per byte*/; i>=0; i--)
-      {
-         text<<(char) ( ((value>>i) & 1) + '0');
-         if(i%4 == 0 && i>0) text<<' ';
-      }
-      return text.str();
-   }
-   /*==========================================================*/
-   //converts string to type T
-   // usage: int x = stringTo<int>("123");
-   template<typename T>
-   inline T stringTo(const std::string& s)
-   {
-     std::istringstream iss(s);
-     T x;
-     iss >> x;
-     if(!iss)
-        UB_THROW( UbException(UB_EXARGS," cannot convert \""+s+"\" to type <"+static_cast<std::string>(typeid(x).name())+">") );
-
-     return x;
-   }
-   /*==========================================================*/
-   // usage: string s = toString(x);
-   template<typename T>
-   inline std::string toString(const T& x, int precision=15)
-   {
-     std::ostringstream oss;
-     oss<<std::setprecision(precision);
-     oss<<x;
-     return oss.str();
-   }
-   /*==========================================================*/
-   //e.g. str="iHcsnW" -> "IHCSNW"
-   inline std::string toUpperString(const std::string& str)
-   {
-      std::string tmp(str);
-      std::transform(tmp.begin(),tmp.end(),tmp.begin(), static_cast<int (*)(int)>(std::toupper));
-
-      return tmp;
-   }
-   /*==========================================================*/
-   //e.g. str="iHcsnW" -> "ihcsnw"
-   inline std::string toLowerString(const std::string& str)
-   {
-      std::string tmp(str);
-      std::transform(tmp.begin(),tmp.end(),tmp.begin(), static_cast<int (*)(int)>(std::tolower));
-
-      return tmp;
-   }
-   /*==========================================================*/
-   // usage: std::string s = replaceInString(str,"\\","/");
-   //        std::string s = replaceInString(str,"ich","du");
-   static std::string replaceInString(std::string original, const std::string& replace, const std::string& replaceWith )
-   {
-      size_t pos=0;
-      while( (pos=original.find(replace,pos))!=std::string::npos )
-      {
-         original.replace(pos,replace.size(),replaceWith);
-         pos+=replaceWith.size();
-      }
-      return original;
-   }
-   /*==========================================================*/
-   //returns content of an enviroment variable
-   inline std::string getEnv(const std::string& var)
-   {
-      char* str = getenv( var.c_str());
-      if(  str == NULL  ) 
-      {
-         return std::string("");
-      }
-      
-      return static_cast<std::string>( str );
-   }
-   /*==========================================================*/
-   inline bool isDirectory(const std::string& dir, const unsigned& attemptions = 3)
-   {
-      if( dir.empty() ) 
-         UB_THROW( UbException(UB_EXARGS,"dir is empty") );
-      
-      std::string path = UbSystem::replaceInString(dir,"\\","/");
-
-      #if defined UBSYSTEM_WINDOWS
-         #ifndef _UNICODE 
-            if( _access(path.c_str(), 0  ) == -1 ) return false;
-         #else
-            if( _waccess(path.c_str(), 0 ) == -1 ) return false;
-         #endif
-      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX)
-         struct stat stFileInfo;
-         if( stat(path.c_str(),&stFileInfo) != 0) 
-         {
-            return false;
-         } 
-      #endif
-      
-      return true;
-   }
-   /*==========================================================*/
-   // usage:  makeDirectory("c:/temp");
-   //         makeDirectory("c:/temp/");
-   // return: true  -> successful
-   //         false -> failed
-   #if defined(CAB_BOOST) 
-      static boost::mutex mtx_makeDirectory;
-   #endif
-   inline bool makeDirectory(const std::string& dir, const unsigned& attemptions = 3)
-   {
-      UBLOG(logDEBUG5,"UbSystem::makeDirectory - start, dir="<<dir<<" #attemptions="<<attemptions);
-
-      if( dir.empty() ) UB_THROW( UbException(UB_EXARGS,"dir is empty") );
-      std::string path = UbSystem::replaceInString(dir,"\\","/");
-
-      bool dirCreated = true;
-      #if defined UBSYSTEM_WINDOWS
-         if(path[path.size()-1] != '/') path+="/";
-         size_t  pos = 0;
-         while( ( pos=path.find("/",pos+1) ) != std::string::npos )
-         {
-            std::string tmpdir = path.substr(0,pos);
-            #if defined(CAB_BOOST) 
-            boost::mutex::scoped_lock lock(mtx_makeDirectory);
-            #endif
-            if( 
-                #ifndef _UNICODE 
-                 _access(tmpdir.c_str(), 0 ) == -1 && _mkdir(tmpdir.c_str() ) == -1
-                #else
-                 _waccess(tmpdir.c_str(), 0) == -1 && _wmkdir(tmpdir.c_str()) == -1
-                #endif
-               )
-               {
-                  UBLOG(logDEBUG5,"UbSystem::makeDirectory-  dir=\""<<tmpdir<<"\" doesn't exit or makedir failed");
-                  dirCreated = false;
-                  break;
-               }
-         }
-      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX)
-         std::string command = "mkdir -p \""+path+"\"";
-         {
-            #if defined(CAB_BOOST) 
-               boost::mutex::scoped_lock lock(mtx_makeDirectory);
-            #endif
-            if(system(command.c_str())!=0)
-            {
-               UBLOG(logDEBUG5,"UbSystem::makeDirectory-  dir=\""<<path<<"\" doesn't exit or makedir failed");
-               dirCreated = false;
-            }
-         }
-      #else
-         #error "UbSystem::makeDirectory - UnknownMachine"
-      #endif
-
-      if(!dirCreated && attemptions > 1)
-      {
-         UBLOG(logDEBUG5,"UbSystem::makeDirectory - internal call of UbSystem::makeDirectory");
-         UbSystem::sleepMs(500);
-         dirCreated = UbSystem::makeDirectory(path, attemptions-1);
-      }
-      
-      UBLOG(logDEBUG5,"UbSystem::makeDirectory - end (success="<<dirCreated<<", attemptions = "<<attemptions<<")");
-      return dirCreated;
-   }
-   /*==========================================================*/
-#if defined(CAB_BOOST) 
-   static boost::mutex mtx_removeDirectory;
-#endif
-   inline int removeDirectory(const std::string& dir)
-   {
-      #if defined(CAB_BOOST) 
-         boost::mutex::scoped_lock lock(mtx_removeDirectory);
-      #endif
-      std::string command = "rmdir \""+dir+"\"";
-      return std::system(command.c_str());
-   }
-   /*==========================================================*/
-   // usage  : getPathFromString("c:/temp/foo.txt");
-   //returns: "c:/temp"
-   // usage  : getPathFromString("c:\\temp\\foo.txt");
-   //returns: "c:/temp"
-   // usage  : getPathFromString("foo.txt");
-   // returns: ""
-   inline std::string getPathFromString(const std::string& fileStringWithPath)
-   {
-      std::string tmp = UbSystem::replaceInString(fileStringWithPath,"\\","/");
-      std::size_t last = tmp.rfind("/");
-      if(last!=std::string::npos) tmp.resize(last);
-      else                        tmp = "";
-      return tmp;
-   }
-   /*==========================================================*/
-   // usage  : getFilenameFromString("c:/temp/foo.txt");
-   // returns: "foo.txt"
-   // usage  : getFilenameFromString("c:/temp/foo.txt",false);
-   // returns: "foo"
-   // usage  : getFilenameFromString("c:/temp/");
-   // returns: ""
-   inline std::string getFilenameFromString(const std::string& fileStringWithPath, bool withExtension = true)
-   {
-      std::string tmp = UbSystem::replaceInString(fileStringWithPath,"\\","/");
-      
-      //remove path
-      std::size_t last = tmp.rfind("/");
-      if(last!=std::string::npos && (last+1)<tmp.size()) tmp.erase(0,last+1);
-      
-      //remove extension
-      if(!withExtension)
-      {
-         last = tmp.rfind(".");
-         if(last!=std::string::npos) tmp.erase(last);
-      }
-
-      return tmp;
-   }
-   /*==========================================================*/
-   inline int getProcessID()
-   {
-      #if defined UBSYSTEM_WINDOWS
-         return _getpid();
-      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX)
-         return getpid();
-      #else
-         #error "int UbSystem::getProcessID() - UnknownMachine"
-      #endif
-   }
-   /*==========================================================*/
-   inline unsigned long getCurrentThreadID()
-   {
-      #if defined UBSYSTEM_WINDOWS
-         return (unsigned long)GetCurrentThreadId();
-      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE)
-         return (unsigned long)syscall(SYS_gettid);
-      #elif defined(UBSYSTEM_AIX)
-         return (unsigned long) getpid(); //WORKAROUND for IBM (for get thread id is another function necessary) 
-      #else
-         #error "unsigned long UbSystem::getCurrentThreadID() - UnknownMachine"
-      #endif
-   }
-   /*==========================================================*/
-   inline bool isBigEndian()
-   {
-      short word = 0x4321;
-      if((*(char*)& word) != 0x21 ) return true;
-      else                           return false;
-   }
-   /*==========================================================*/
-   inline bool isLittleEndian()
-   {
-      return !isBigEndian();
-   }
-   /*==========================================================*/
-   inline std::string getTimeStamp()
-   {
-      time_t t = time(NULL);
-      tm* localTime = localtime(&t); 	
-      
-      std::stringstream tmp;
-      tmp.fill('0');
-      
-      tmp << localTime->tm_year+1900 
-          << "." << std::setw(2) <<localTime->tm_mon+1
-          << "." << std::setw(2) << localTime->tm_mday 
-          << "@" << std::setw(2) << localTime->tm_hour  
-          << "." << std::setw(2) << localTime->tm_min   
-          << "." << std::setw(2) << localTime->tm_sec  ;
-
-      return tmp.str();
-   }
-   /*==========================================================*/
-   //swap Byte Order
-   //usage: int test = 8;
-   //       swapByteOrder((unsigned char*)& test, sizeof(int))
-   //#define ByteSwap5(x) ByteSwap((unsigned char *) &x,sizeof(x))
-   inline void swapByteOrder(unsigned char* toSwap, int length)
-   {
-      register int i = 0;
-      register int j = length-1;
-      while(i<j)
-      {
-         std::swap(toSwap[i], toSwap[j]);
-         i++, j--;
-      }
-   }
-   //////////////////////////////////////////////////////////////////////////
-   //get host name
-   inline std::string getMachineName()
-   {
-      char Name[150];
-      int i = 0;
-
-#ifdef UBSYSTEM_WINDOWS
-      TCHAR infoBuf[150];
-      DWORD bufCharCount = 150;
-      memset(Name, 0, 150);
-      if (GetComputerName(infoBuf, &bufCharCount))
-      {
-         for (i = 0; i<150; i++)
-         {
-            Name[i] = infoBuf[i];
-         }
-      }
-      else
-      {
-         strcpy(Name, "Unknown_Host_Name");
-      }
-#else
-      memset(Name, 0, 150);
-      gethostname(Name, 150);
-#endif
-      return std::string(Name);
-   }
-
-   //////////////////////////////////////////////////////////////////////////
-   // generic IfThenElse - start
-   //////////////////////////////////////////////////////////////////////////
-   // primary template: yield second or third argument depending on first argument
-   template<bool C, typename Ta, typename Tb>
-   class IfThenElse;
-
-   // partial specialization: true yields second argument
-   template<typename Ta, typename Tb>
-   class IfThenElse<true, Ta, Tb> {
-   public:
-      typedef Ta ResultT;
-   };
-
-   // partial specialization: false yields third argument
-   template<typename Ta, typename Tb>
-   class IfThenElse<false, Ta, Tb> {
-   public:
-      typedef Tb ResultT;
-   };
-   //////////////////////////////////////////////////////////////////////////
-   // generic IfThenElse - end
-   //////////////////////////////////////////////////////////////////////////
-
-   //////////////////////////////////////////////////////////////////////////
-   //help struct for overloading methods in template classes for specific types
-   //////////////////////////////////////////////////////////////////////////
-   template< typename T>
-   struct type2type
-   {
-      typedef T type;
-   };
-
-
-   //////////////////////////////////////////////////////////////////////////
-   // pair selector
-   //////////////////////////////////////////////////////////////////////////
-   template <typename Pair>
-   struct select1st
-   {
-      typedef Pair argument_type ;
-      typedef typename Pair::first_type result_type ;
-
-      const result_type&  operator()(const argument_type &p) const
-      {
-         return p.first ;
-      }
-   };
-
-   template <typename Pair>
-   struct select2nd
-   {
-      typedef Pair argument_type ;
-      typedef typename Pair::second_type result_type ;
-
-      const result_type& operator()(const argument_type &p) const
-      {
-         return p.second ;
-      }
-   };
-
-};
-
-#define UB_STATIC_ASSERT(expr) static_cast<void>(sizeof( UbSystem::ub_static_assert<expr> ));
-//zum ueberpruefen von STATISCHEN ausdruecken waehrend der compile-zeit
-//--> Ausdruecke muessen schon ZUR compilerzeit auswertbar sein !!!
-//Anwendung z.B. zur Ueberpruefung von Funktionalitaeten, wie z.B. bei UbMath::getNegativeInfinity<double>();
-//
-//Grund fuer macro ist einfach, dass es besser anzuwenden ist in der praxis!
-//ansonsten würde es so aussehen:
-//     UbSystem::ub_static_assert< aaa == 1 > test();
-//    da ist  UB_STATIC_ASSERT(aaa == 1); schoener
-//
-//um das zu vermeiden machtman hier diesen static_cast<void>(sizeof(...) )
-//Code-Snippet:
-// struct Test { const static bool m_const_bool = true; bool m_bool; };
-// int main() {
-//  UB_STATIC_ASSERT( Test::m_const_bool == true );
-//  --> okay, assert bestanden
-//  UB_STATIC_ASSERT( Test::m_const_bool == false); //:
-//  --> assert nicht bestanden z.B. error C2027: use of undefined type 'UbSystem::ub_static_assert<__formal> with __formal = false --> funzt nicht. fehler im code
-//  UB_STATIC_ASSERT( Test::m_bool == true );
-//  --> nicht erlaubt, da m_bool nicht statisch und nicht const ist.
-//}
-
-#endif //UBSYSTEM_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBSYSTEM_H
+#define UBSYSTEM_H
+
+#if defined(_WIN32) || defined(_WIN64)
+   #define UBSYSTEM_WINDOWS
+   #include <process.h>
+   #include <io.h>
+   #include <direct.h>
+   //#ifndef _WINSOCK2API_  //ansonsten gibt es mecker bei #include "Windows.h" und ::Sleep()
+   //   #define _WINSOCK2API_
+   //   #include<WinSock2.h> 
+   //#endif
+  #include <windows.h>
+  //#include <Windows.h>
+  //#include <tchar.h>
+#elif defined(__APPLE__)
+   #define UBSYSTEM_APPLE
+   #include "dirent.h"
+   #include "sys/stat.h"
+   #include <sys/syscall.h>
+   #include <sys/stat.h>
+#elif (defined(__amd64) || defined(__amd64__) || defined(__unix__) || defined(__CYGWIN__)) && !defined(__AIX__) 
+   #define UBSYSTEM_LINUX
+   #include "dirent.h"
+   #include "sys/stat.h"
+   #include <sys/syscall.h>
+   #include <sys/stat.h>
+   #include <unistd.h>
+   #include <string.h>
+#elif defined(__AIX__)
+   #define UBSYSTEM_AIX
+   #include "dirent.h"
+   #include <unistd.h>
+   #include <sys/stat.h>
+   #include <sys/types.h>
+#else
+   #error "UbSystem::UnknownMachine"
+#endif
+
+
+
+#if defined(min) || defined(max) //daruch kann man sich spaeter #undef min; #undef max erparen
+#   error add NOMINMAX to preprocessor defines
+#endif
+
+
+#include <iostream>
+#include <iomanip>
+#include <string>
+#include <sstream>
+#include <algorithm>
+#include <typeinfo>
+#include <cctype> //for toupper
+#include <ctime>
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbLogger.h>
+
+#if defined(CAB_BOOST)
+#include <boost/thread.hpp>
+#endif // CAB_BOOST
+
+//DEFINE TO STRING
+//e.g. #define FOO hallo
+//     -> QUOTEME(FOO) == "hallo"
+#define _QUOTEME(x) #x
+#define QUOTEME(x) _QUOTEME(x)
+
+//allg.:
+//const int * C1        -> C1 is variable pointer to a constant integer
+//int const * C2        -> C2 is variable pointer to a constant integer (same as above)
+//int * const C3        -> C3 is constant pointer to a variable integer
+//int const * const C4  -> C4 is constant pointer to a constant integer
+
+//////////////////////////////////////////////////////////////////////////
+//UbSystem
+//////////////////////////////////////////////////////////////////////////
+namespace UbSystem
+{
+   template<bool> struct ub_static_assert;     //deklaration (ub_xxx da static_assert in C++0x ein keyword werden wird)
+   template<> struct ub_static_assert<true>{}; //deklaration + definition der spezialisierung fuer "true"
+                                               //ub_static_assert<false> fuehrt zu compiler fehler, da dafuer
+                                               //keine implementierung vorhanden!  //UB_STATIC_ASSERT(false)
+
+   /*==========================================================*/
+   inline void sleepMs(const unsigned int& msec)
+   {
+      #if defined UBSYSTEM_WINDOWS
+         ::Sleep(  (msec==0) ? 1 : msec );  // +1 here causes a context switch if SleepMSec(0) is called
+      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX)
+         ::usleep(1000*msec);
+      #else
+         #error "UbSystem::sleepMSec - UnknownMachine"
+      #endif
+   }
+   /*==========================================================*/
+   inline void sleepS(const unsigned int& sec)
+   {
+      #if defined UBSYSTEM_WINDOWS
+         ::Sleep( (sec==0) ? 1 : sec*1000 );  // +1 here causes a context switch if sleepS(0) is called
+      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX)
+         ::sleep(sec);
+      #else
+         #error "UbSystem::sleepS - UnknownMachine"
+      #endif
+   }
+   /*==========================================================*/
+   //checks if the bits of bitmask are set in value
+   template<typename T>
+   inline bool bitCheck(const T& value, const T& bitmask)
+   {
+      return  ( (value & bitmask) == bitmask);
+   }
+   /*==========================================================*/
+   //checks if the bits of bitmask are set in value
+   template<typename T>
+   inline void setBit(T& value, const T& bitmask)
+   {
+      value |= bitmask;
+   }
+   /*==========================================================*/
+   template<typename T>
+   inline void unsetBit(T& value, const T& bitmask)
+   {
+      value &= ~bitmask;
+   }
+   /*==========================================================*/
+   //returns bitmask as string e.g. 0001 0100 1101
+   template<typename T>
+   inline std::string getBitString(const T& value)
+   {
+      std::stringstream text;
+      for(int i=sizeof(value)*8-1/*8 bits per byte*/; i>=0; i--)
+      {
+         text<<(char) ( ((value>>i) & 1) + '0');
+         if(i%4 == 0 && i>0) text<<' ';
+      }
+      return text.str();
+   }
+   /*==========================================================*/
+   //converts string to type T
+   // usage: int x = stringTo<int>("123");
+   template<typename T>
+   inline T stringTo(const std::string& s)
+   {
+     std::istringstream iss(s);
+     T x;
+     iss >> x;
+     if(!iss)
+        UB_THROW( UbException(UB_EXARGS," cannot convert \""+s+"\" to type <"+static_cast<std::string>(typeid(x).name())+">") );
+
+     return x;
+   }
+   /*==========================================================*/
+   // usage: string s = toString(x);
+   template<typename T>
+   inline std::string toString(const T& x, int precision=15)
+   {
+     std::ostringstream oss;
+     oss<<std::setprecision(precision);
+     oss<<x;
+     return oss.str();
+   }
+   /*==========================================================*/
+   //e.g. str="iHcsnW" -> "IHCSNW"
+   inline std::string toUpperString(const std::string& str)
+   {
+      std::string tmp(str);
+      std::transform(tmp.begin(),tmp.end(),tmp.begin(), static_cast<int (*)(int)>(std::toupper));
+
+      return tmp;
+   }
+   /*==========================================================*/
+   //e.g. str="iHcsnW" -> "ihcsnw"
+   inline std::string toLowerString(const std::string& str)
+   {
+      std::string tmp(str);
+      std::transform(tmp.begin(),tmp.end(),tmp.begin(), static_cast<int (*)(int)>(std::tolower));
+
+      return tmp;
+   }
+   /*==========================================================*/
+   // usage: std::string s = replaceInString(str,"\\","/");
+   //        std::string s = replaceInString(str,"ich","du");
+   static std::string replaceInString(std::string original, const std::string& replace, const std::string& replaceWith )
+   {
+      size_t pos=0;
+      while( (pos=original.find(replace,pos))!=std::string::npos )
+      {
+         original.replace(pos,replace.size(),replaceWith);
+         pos+=replaceWith.size();
+      }
+      return original;
+   }
+   /*==========================================================*/
+   //returns content of an enviroment variable
+   inline std::string getEnv(const std::string& var)
+   {
+      char* str = getenv( var.c_str());
+      if(  str == NULL  ) 
+      {
+         return std::string("");
+      }
+      
+      return static_cast<std::string>( str );
+   }
+   /*==========================================================*/
+   inline bool isDirectory(const std::string& dir, const unsigned& attemptions = 3)
+   {
+      if( dir.empty() ) 
+         UB_THROW( UbException(UB_EXARGS,"dir is empty") );
+      
+      std::string path = UbSystem::replaceInString(dir,"\\","/");
+
+      #if defined UBSYSTEM_WINDOWS
+         #ifndef _UNICODE 
+            if( _access(path.c_str(), 0  ) == -1 ) return false;
+         #else
+            if( _waccess(path.c_str(), 0 ) == -1 ) return false;
+         #endif
+      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX)
+         struct stat stFileInfo;
+         if( stat(path.c_str(),&stFileInfo) != 0) 
+         {
+            return false;
+         } 
+      #endif
+      
+      return true;
+   }
+   /*==========================================================*/
+   // usage:  makeDirectory("c:/temp");
+   //         makeDirectory("c:/temp/");
+   // return: true  -> successful
+   //         false -> failed
+   #if defined(CAB_BOOST) 
+      static boost::mutex mtx_makeDirectory;
+   #endif
+   inline bool makeDirectory(const std::string& dir, const unsigned& attemptions = 3)
+   {
+      UBLOG(logDEBUG5,"UbSystem::makeDirectory - start, dir="<<dir<<" #attemptions="<<attemptions);
+
+      if( dir.empty() ) UB_THROW( UbException(UB_EXARGS,"dir is empty") );
+      std::string path = UbSystem::replaceInString(dir,"\\","/");
+
+      bool dirCreated = true;
+      #if defined UBSYSTEM_WINDOWS
+         if(path[path.size()-1] != '/') path+="/";
+         size_t  pos = 0;
+         while( ( pos=path.find("/",pos+1) ) != std::string::npos )
+         {
+            std::string tmpdir = path.substr(0,pos);
+            #if defined(CAB_BOOST) 
+            boost::mutex::scoped_lock lock(mtx_makeDirectory);
+            #endif
+            if( 
+                #ifndef _UNICODE 
+                 _access(tmpdir.c_str(), 0 ) == -1 && _mkdir(tmpdir.c_str() ) == -1
+                #else
+                 _waccess(tmpdir.c_str(), 0) == -1 && _wmkdir(tmpdir.c_str()) == -1
+                #endif
+               )
+               {
+                  UBLOG(logDEBUG5,"UbSystem::makeDirectory-  dir=\""<<tmpdir<<"\" doesn't exit or makedir failed");
+                  dirCreated = false;
+                  break;
+               }
+         }
+      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX)
+         std::string command = "mkdir -p \""+path+"\"";
+         {
+            #if defined(CAB_BOOST) 
+               boost::mutex::scoped_lock lock(mtx_makeDirectory);
+            #endif
+            if(system(command.c_str())!=0)
+            {
+               UBLOG(logDEBUG5,"UbSystem::makeDirectory-  dir=\""<<path<<"\" doesn't exit or makedir failed");
+               dirCreated = false;
+            }
+         }
+      #else
+         #error "UbSystem::makeDirectory - UnknownMachine"
+      #endif
+
+      if(!dirCreated && attemptions > 1)
+      {
+         UBLOG(logDEBUG5,"UbSystem::makeDirectory - internal call of UbSystem::makeDirectory");
+         UbSystem::sleepMs(500);
+         dirCreated = UbSystem::makeDirectory(path, attemptions-1);
+      }
+      
+      UBLOG(logDEBUG5,"UbSystem::makeDirectory - end (success="<<dirCreated<<", attemptions = "<<attemptions<<")");
+      return dirCreated;
+   }
+   /*==========================================================*/
+#if defined(CAB_BOOST) 
+   static boost::mutex mtx_removeDirectory;
+#endif
+   inline int removeDirectory(const std::string& dir)
+   {
+      #if defined(CAB_BOOST) 
+         boost::mutex::scoped_lock lock(mtx_removeDirectory);
+      #endif
+      std::string command = "rmdir \""+dir+"\"";
+      return std::system(command.c_str());
+   }
+   /*==========================================================*/
+   // usage  : getPathFromString("c:/temp/foo.txt");
+   //returns: "c:/temp"
+   // usage  : getPathFromString("c:\\temp\\foo.txt");
+   //returns: "c:/temp"
+   // usage  : getPathFromString("foo.txt");
+   // returns: ""
+   inline std::string getPathFromString(const std::string& fileStringWithPath)
+   {
+      std::string tmp = UbSystem::replaceInString(fileStringWithPath,"\\","/");
+      std::size_t last = tmp.rfind("/");
+      if(last!=std::string::npos) tmp.resize(last);
+      else                        tmp = "";
+      return tmp;
+   }
+   /*==========================================================*/
+   // usage  : getFilenameFromString("c:/temp/foo.txt");
+   // returns: "foo.txt"
+   // usage  : getFilenameFromString("c:/temp/foo.txt",false);
+   // returns: "foo"
+   // usage  : getFilenameFromString("c:/temp/");
+   // returns: ""
+   inline std::string getFilenameFromString(const std::string& fileStringWithPath, bool withExtension = true)
+   {
+      std::string tmp = UbSystem::replaceInString(fileStringWithPath,"\\","/");
+      
+      //remove path
+      std::size_t last = tmp.rfind("/");
+      if(last!=std::string::npos && (last+1)<tmp.size()) tmp.erase(0,last+1);
+      
+      //remove extension
+      if(!withExtension)
+      {
+         last = tmp.rfind(".");
+         if(last!=std::string::npos) tmp.erase(last);
+      }
+
+      return tmp;
+   }
+   /*==========================================================*/
+   inline int getProcessID()
+   {
+      #if defined UBSYSTEM_WINDOWS
+         return _getpid();
+      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX)
+         return getpid();
+      #else
+         #error "int UbSystem::getProcessID() - UnknownMachine"
+      #endif
+   }
+   /*==========================================================*/
+   inline unsigned long getCurrentThreadID()
+   {
+      #if defined UBSYSTEM_WINDOWS
+         return (unsigned long)GetCurrentThreadId();
+      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE)
+         return (unsigned long)syscall(SYS_gettid);
+      #elif defined(UBSYSTEM_AIX)
+         return (unsigned long) getpid(); //WORKAROUND for IBM (for get thread id is another function necessary) 
+      #else
+         #error "unsigned long UbSystem::getCurrentThreadID() - UnknownMachine"
+      #endif
+   }
+   /*==========================================================*/
+   inline bool isBigEndian()
+   {
+      short word = 0x4321;
+      if((*(char*)& word) != 0x21 ) return true;
+      else                           return false;
+   }
+   /*==========================================================*/
+   inline bool isLittleEndian()
+   {
+      return !isBigEndian();
+   }
+   /*==========================================================*/
+   inline std::string getTimeStamp()
+   {
+      time_t t = time(NULL);
+      tm* localTime = localtime(&t); 	
+      
+      std::stringstream tmp;
+      tmp.fill('0');
+      
+      tmp << localTime->tm_year+1900 
+          << "." << std::setw(2) <<localTime->tm_mon+1
+          << "." << std::setw(2) << localTime->tm_mday 
+          << "@" << std::setw(2) << localTime->tm_hour  
+          << "." << std::setw(2) << localTime->tm_min   
+          << "." << std::setw(2) << localTime->tm_sec  ;
+
+      return tmp.str();
+   }
+   /*==========================================================*/
+   //swap Byte Order
+   //usage: int test = 8;
+   //       swapByteOrder((unsigned char*)& test, sizeof(int))
+   //#define ByteSwap5(x) ByteSwap((unsigned char *) &x,sizeof(x))
+   inline void swapByteOrder(unsigned char* toSwap, int length)
+   {
+      register int i = 0;
+      register int j = length-1;
+      while(i<j)
+      {
+         std::swap(toSwap[i], toSwap[j]);
+         i++, j--;
+      }
+   }
+   //////////////////////////////////////////////////////////////////////////
+   //get host name
+   inline std::string getMachineName()
+   {
+      char Name[150];
+      int i = 0;
+
+#ifdef UBSYSTEM_WINDOWS
+      TCHAR infoBuf[150];
+      DWORD bufCharCount = 150;
+      memset(Name, 0, 150);
+      if (GetComputerName(infoBuf, &bufCharCount))
+      {
+         for (i = 0; i<150; i++)
+         {
+            Name[i] = infoBuf[i];
+         }
+      }
+      else
+      {
+         strcpy(Name, "Unknown_Host_Name");
+      }
+#else
+      memset(Name, 0, 150);
+      gethostname(Name, 150);
+#endif
+      return std::string(Name);
+   }
+
+   //////////////////////////////////////////////////////////////////////////
+   // generic IfThenElse - start
+   //////////////////////////////////////////////////////////////////////////
+   // primary template: yield second or third argument depending on first argument
+   template<bool C, typename Ta, typename Tb>
+   class IfThenElse;
+
+   // partial specialization: true yields second argument
+   template<typename Ta, typename Tb>
+   class IfThenElse<true, Ta, Tb> {
+   public:
+      typedef Ta ResultT;
+   };
+
+   // partial specialization: false yields third argument
+   template<typename Ta, typename Tb>
+   class IfThenElse<false, Ta, Tb> {
+   public:
+      typedef Tb ResultT;
+   };
+   //////////////////////////////////////////////////////////////////////////
+   // generic IfThenElse - end
+   //////////////////////////////////////////////////////////////////////////
+
+   //////////////////////////////////////////////////////////////////////////
+   //help struct for overloading methods in template classes for specific types
+   //////////////////////////////////////////////////////////////////////////
+   template< typename T>
+   struct type2type
+   {
+      typedef T type;
+   };
+
+
+   //////////////////////////////////////////////////////////////////////////
+   // pair selector
+   //////////////////////////////////////////////////////////////////////////
+   template <typename Pair>
+   struct select1st
+   {
+      typedef Pair argument_type ;
+      typedef typename Pair::first_type result_type ;
+
+      const result_type&  operator()(const argument_type &p) const
+      {
+         return p.first ;
+      }
+   };
+
+   template <typename Pair>
+   struct select2nd
+   {
+      typedef Pair argument_type ;
+      typedef typename Pair::second_type result_type ;
+
+      const result_type& operator()(const argument_type &p) const
+      {
+         return p.second ;
+      }
+   };
+
+};
+
+#define UB_STATIC_ASSERT(expr) static_cast<void>(sizeof( UbSystem::ub_static_assert<expr> ));
+//zum ueberpruefen von STATISCHEN ausdruecken waehrend der compile-zeit
+//--> Ausdruecke muessen schon ZUR compilerzeit auswertbar sein !!!
+//Anwendung z.B. zur Ueberpruefung von Funktionalitaeten, wie z.B. bei UbMath::getNegativeInfinity<double>();
+//
+//Grund fuer macro ist einfach, dass es besser anzuwenden ist in der praxis!
+//ansonsten würde es so aussehen:
+//     UbSystem::ub_static_assert< aaa == 1 > test();
+//    da ist  UB_STATIC_ASSERT(aaa == 1); schoener
+//
+//um das zu vermeiden machtman hier diesen static_cast<void>(sizeof(...) )
+//Code-Snippet:
+// struct Test { const static bool m_const_bool = true; bool m_bool; };
+// int main() {
+//  UB_STATIC_ASSERT( Test::m_const_bool == true );
+//  --> okay, assert bestanden
+//  UB_STATIC_ASSERT( Test::m_const_bool == false); //:
+//  --> assert nicht bestanden z.B. error C2027: use of undefined type 'UbSystem::ub_static_assert<__formal> with __formal = false --> funzt nicht. fehler im code
+//  UB_STATIC_ASSERT( Test::m_bool == true );
+//  --> nicht erlaubt, da m_bool nicht statisch und nicht const ist.
+//}
+
+#endif //UBSYSTEM_H
diff --git a/source/ThirdParty/Library/basics/utilities/UbTableModel.cpp b/source/VirtualFluidsBasic/basics/utilities/UbTableModel.cpp
similarity index 95%
rename from source/ThirdParty/Library/basics/utilities/UbTableModel.cpp
rename to source/VirtualFluidsBasic/basics/utilities/UbTableModel.cpp
index eca533129a77a21e3515939b72f848e8f611c9d4..12e69b068646db62f966d14d50b295812e5b05ba 100644
--- a/source/ThirdParty/Library/basics/utilities/UbTableModel.cpp
+++ b/source/VirtualFluidsBasic/basics/utilities/UbTableModel.cpp
@@ -1,20 +1,20 @@
-#include <basics/utilities/UbTableModel.h>
-
-UbTableModel::UbTableModel()
-{
-}
-
-UbTableModel::~UbTableModel()
-{
-	//this->notifyObserversObjectWillBeDeleted();
-}
-
-//void UbTableModel::objectChanged(UbObservable* changedObject)
-//{
-//	this->notifyObserversObjectChanged();	
-//}
-//
-//void UbTableModel::objectWillBeDeleted(UbObservable* objectForDeletion)
-//{
-//	objectForDeletion->removeObserver(this);
-//}
+#include <basics/utilities/UbTableModel.h>
+
+UbTableModel::UbTableModel()
+{
+}
+
+UbTableModel::~UbTableModel()
+{
+	//this->notifyObserversObjectWillBeDeleted();
+}
+
+//void UbTableModel::objectChanged(UbObservable* changedObject)
+//{
+//	this->notifyObserversObjectChanged();	
+//}
+//
+//void UbTableModel::objectWillBeDeleted(UbObservable* objectForDeletion)
+//{
+//	objectForDeletion->removeObserver(this);
+//}
diff --git a/source/ThirdParty/Library/basics/utilities/UbTableModel.h b/source/VirtualFluidsBasic/basics/utilities/UbTableModel.h
similarity index 97%
rename from source/ThirdParty/Library/basics/utilities/UbTableModel.h
rename to source/VirtualFluidsBasic/basics/utilities/UbTableModel.h
index 4a12d63b3881238daeb261b35b599ccbb7b64890..957201a5115555402b005708e3e553e172105942 100644
--- a/source/ThirdParty/Library/basics/utilities/UbTableModel.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbTableModel.h
@@ -1,37 +1,37 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBTABLEMODEL_H
-#define UBTABLEMODEL_H
-
-#include <iostream>
-
-class UbTableModel 
-{
-public:
-   const static int COL_TYPE_STRING  = 1;
-   const static int COL_TYPE_BOOL    = 2;
-   const static int COL_TYPE_INTEGER = 3;
-   const static int COL_TYPE_DOUBLE  = 4;
-
-	UbTableModel();
-	virtual ~UbTableModel();
-
-	//////////////////////////////////////////////////////////////////////////
-	//void objectChanged(UbObservable*);
-	//void objectWillBeDeleted(UbObservable*);
-
-	virtual int getColumnNumber() = 0;
-	virtual int getRowNumber()    = 0;
-   virtual std::string getColumnLabel(int column) = 0;
-	virtual int getColumnType(int column) = 0;
-	virtual std::string getStringValue(int row, int col) = 0;
-   virtual void setStringValue(int row, int col, std::string str) = 0;
-	virtual int getSelectedRowIndex() = 0;
-	//virtual bool GetBoolValue(int row, int col) = 0;
-};
-
-#endif //UBTABLEMODEL_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBTABLEMODEL_H
+#define UBTABLEMODEL_H
+
+#include <iostream>
+
+class UbTableModel 
+{
+public:
+   const static int COL_TYPE_STRING  = 1;
+   const static int COL_TYPE_BOOL    = 2;
+   const static int COL_TYPE_INTEGER = 3;
+   const static int COL_TYPE_DOUBLE  = 4;
+
+	UbTableModel();
+	virtual ~UbTableModel();
+
+	//////////////////////////////////////////////////////////////////////////
+	//void objectChanged(UbObservable*);
+	//void objectWillBeDeleted(UbObservable*);
+
+	virtual int getColumnNumber() = 0;
+	virtual int getRowNumber()    = 0;
+   virtual std::string getColumnLabel(int column) = 0;
+	virtual int getColumnType(int column) = 0;
+	virtual std::string getStringValue(int row, int col) = 0;
+   virtual void setStringValue(int row, int col, std::string str) = 0;
+	virtual int getSelectedRowIndex() = 0;
+	//virtual bool GetBoolValue(int row, int col) = 0;
+};
+
+#endif //UBTABLEMODEL_H
diff --git a/source/ThirdParty/Library/basics/utilities/UbTiming.h b/source/VirtualFluidsBasic/basics/utilities/UbTiming.h
similarity index 96%
rename from source/ThirdParty/Library/basics/utilities/UbTiming.h
rename to source/VirtualFluidsBasic/basics/utilities/UbTiming.h
index 5f768fea3d98129f7359f1576c46032ea42cf763..18c87edaef4fd70fbd454b3eeac30ccecdfdb1cf 100644
--- a/source/ThirdParty/Library/basics/utilities/UbTiming.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbTiming.h
@@ -1,429 +1,429 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBTIMING_H
-#define UBTIMING_H
-
-#include <string>
-#include <limits>
-#include <iostream>
-#include <sstream>
-#include <vector>
-#include <ctime>
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-#ifdef VF_MPI
-   #include <mpi.h>
-   #include <basics/parallel/PbMpi.h>
-#endif //VF_MPI
-
-/*=========================================================================*/
-//  UbTiming - Time Measuring                                              
-//                                                                         
-//
-//
-//This Class provides the base for ...
-//<BR><BR>
-//@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-//@author <A HREF="mailto:geller@cab.bau.tu-bs.de">S. Geller</A>
-//@version 1.1 - 14.02.06
-// 
-
-class UbTiming
-{
-public:
-	UbTiming()
-   {
-      this->duration		= 0.0;
-      this->deltaT		= 0.0;
-      this->startTime	= 0;
-      this->name        = "noname";
-   }
-   /*==========================================================*/
-   UbTiming(const std::string& name)
-   {
-      this->duration		= 0.0;
-      this->deltaT		= 0.0;
-      this->startTime	= 0;
-      this->name        = name;
-   }
-   /*==========================================================*/
-   virtual ~UbTiming() {}  
-   /*==========================================================*/
-   virtual void initTiming()
-   {
-      this->duration = 0.0;	
-   }
-   /*==========================================================*/
-   virtual void startTiming()
-   {
-      #if defined(VF_MPI) && !defined(CAB_RUBY)
-         this->startTime = PbMpi::Wtime();
-      #else
-         this->startTime = (double)clock();	
-      #endif //VF_MPI 
-   }
-   /*==========================================================*/
-   virtual void initAndStartTiming()
-   {
-      this->initTiming();
-      this->startTiming();
-   }
-   /*==========================================================*/
-   virtual void endTiming()
-   {
-      this->stopTiming();
-   }
-   /*==========================================================*/
-   virtual void stopTiming()
-   {
-      #if defined(VF_MPI) && !defined(CAB_RUBY)
-            this->deltaT   = PbMpi::Wtime()-this->startTime;
-      #else
-         this->deltaT   = ((double)clock()-this->startTime)/(double)CLOCKS_PER_SEC;
-      #endif //VF_MPI 
-
-      this->duration += this->deltaT;
-   }
-   /*==========================================================*/
-   virtual double getDuration() const
-   {
-      return this->duration;
-   }
-   /*==========================================================*/
-   virtual void setName(const std::string& name)
-   {
-      this->name = name;
-   }
-   /*==========================================================*/
-   virtual std::string getName() const
-   { 
-      return this->name; 
-   }
-   /*==========================================================*/
-   void start()
-   {
-      this->duration = 0.0;
-
-      #if defined(VF_MPI) && !defined(CAB_RUBY)
-         this->startTime = PbMpi::Wtime();
-      #else
-         this->startTime = (double)clock();
-      #endif //VF_MPI 
-   }
-   /*==========================================================*/
-   void pause()
-   {
-      #if defined(VF_MPI) && !defined(CAB_RUBY)
-         this->duration += PbMpi::Wtime()-this->startTime;
-      #else
-         this->duration +=((double)clock()-this->startTime)/(double)CLOCKS_PER_SEC;
-      #endif //VF_MPI 
-   }
-   /*==========================================================*/
-   void unpause()
-   {
-      #if defined(VF_MPI) && !defined(CAB_RUBY)
-         this->startTime   = PbMpi::Wtime();
-      #else
-         this->startTime = (double)clock();
-      #endif //VF_MPI 
-   }
-   /*==========================================================*/
-   void stop()
-   {
-      #if defined(VF_MPI) && !defined(CAB_RUBY)
-         this->duration += PbMpi::Wtime()-this->startTime;
-      #else
-         this->duration +=((double)clock()-this->startTime)/(double)CLOCKS_PER_SEC;
-      #endif //VF_MPI 
-   }
-   /*==========================================================*/
-   double getTicks() const            
-   { 
-      #if defined(VF_MPI) && !defined(CAB_RUBY)
-         return PbMpi::Wtick();
-      #else
-         return double(1.0)/double(CLOCKS_PER_SEC);
-      #endif  //VF_MPI 
-   }
-
-protected:
-   std::string name;
-
-   double startTime;
-   double duration;
-	double deltaT;
-};
-
-/*=========================================================================*/
-//  UbTimer - Time Measuring                                              
-//                                                                         
-//
-//
-//This Class provides the base for ...
-//<BR><BR>
-//@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-//@version 1.0 - 16.08.2007
-// 
-#include <basics/utilities/UbSystem.h> //for definitons of system/OS type
-
-#ifdef UBSYSTEM_APPLE   //Apple hack
-   #include <mach/mach_time.h>  
-   #include <time.h>  
-   #include <stdio.h> 
-   inline void mach_absolute_difference(const uint64_t& end, const uint64_t& start, struct timespec *tp) 
-   {  
-         uint64_t difference = end - start;  
-         static mach_timebase_info_data_t info = {0,0};  
-   
-         if (info.denom == 0)  
-                 mach_timebase_info(&info);  
-   
-         uint64_t elapsednano = difference * (info.numer / info.denom);  
-   
-         tp->tv_sec = elapsednano * 1e-9;  
-         tp->tv_nsec = elapsednano - (tp->tv_sec * 1e9);  
-   } 
-#elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_AIX)
-   #include <ctime>
-   #include <unistd.h> // for sysconf
-   #include <pthread.h>
-#endif
-
-//example:
-//t=0  start 
-//t=1 
-//t=2  stop  -> return 2; getLapTime=2; getTotalTime 2; getLapTimes:  2
-//t=3 
-//t=4 
-//t=5  stop  -> return 3; getLapTime=3; getTotalTime 5; getLapTimes:  2,3
-//t=6  stop  -> return 1; getLapTime=1; getTotalTime 6; getLapTimes:  2,3,1
-//t=7  
-//t=8  start ->no consideration of time 7 and 8 
-//t=9  
-//t=10 stop  -> return 2; getLapTime=2; getTotalTime 8; getLapTimes:  2,3,1,2
-//t=11 resetAndStart timer wird zurueckgestellt und neu gestaret
-//t=12
-//t=13 
-//t=14 stop  -> return 3; getLapTime=3; getTotalTime 3; getLapTimes:  3
-
-class UbTimer
-{
-public:
-   UbTimer(const bool& storeLapTimes = false) 
-      :  name("unamed"), isMeasuring(false), storeLapTimes(storeLapTimes)
-       , startTime(0.0), totalTime(0.0), lapTime(0.0)
-   {
-
-   }
-   /*==========================================================*/
-   UbTimer(const std::string& name, const bool& storeLapTimes = false) 
-      :  name(name), isMeasuring(false), storeLapTimes(storeLapTimes)
-       , startTime(0.0), totalTime(0.0), lapTime(0.0)
-   {
-
-   }
-   /*==========================================================*/
-   virtual ~UbTimer() {}  
-   /*==========================================================*/
-   double              getLapTime() const               { return this->lapTime;  }
-   std::vector<double> getLapTimes() const              { return this->lapTimes; }
-   void                setName(const std::string& name) { this->name = name;     }
-   std::string         getName() const                  { return this->name;     }
-   bool                isRunning() const                { return isMeasuring;    }
-   bool                isStoringLapTimes() const        { return storeLapTimes;  }
-   /*==========================================================*/
-   void setStoreLapTimes(const bool& storeLapTimes) { this->storeLapTimes = storeLapTimes; }
-   /*==========================================================*/
-   void start()
-   {
-      this->isMeasuring = true;
-
-      #if defined(VF_MPI) && !defined(CAB_RUBY)
-          this->startTime = PbMpi::Wtime();
-      #elif defined(UBSYSTEM_APPLE)
-    	 this->startTime = mach_absolute_time();  
-      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_AIX)
-         timespec tp;
-         clock_gettime(CLOCK_REALTIME,&tp);
-         this->startTime = (double)(tp.tv_sec)*1.0e9 + (double)(tp.tv_nsec);
-      #else
-         this->startTime = (double)clock();
-      #endif //VF_MPI
-   }
-   /*==========================================================*/
-   void resetAndStart() { this->reset(); this->start(); }
-   /*==========================================================*/
-   //stop: - stops the calculation and returns the time elapsed since last start/stop
-   //      - timing continues
-   double stop()
-   {
-      //if start() was never activated before:
-      if(!isMeasuring) return 0.0; 
-      
-      #if defined(VF_MPI) && !defined(CAB_RUBY)
-         double actTime = PbMpi::Wtime();
-         this->lapTime  = actTime-this->startTime;
-      #elif defined(UBSYSTEM_APPLE)
-    	 double actTime = mach_absolute_time();  
-         timespec tp;  
-         mach_absolute_difference(actTime, this->startTime, &tp);
-         this->lapTime  =  tp.tv_sec + tp.tv_nsec*1e-9;
-	  #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_AIX)
-         timespec tp;
-         clock_gettime(CLOCK_REALTIME,&tp);
-         double actTime = (double)(tp.tv_sec)*1.0e9 + (double)(tp.tv_nsec);
-         this->lapTime  = (actTime-this->startTime)*1.0e-9;
-      #else
-         double actTime = (double)clock();
-         this->lapTime  = (actTime-this->startTime)/(double)CLOCKS_PER_SEC;
-      #endif //VF_MPI 
-      
-      this->startTime  = actTime;
-      this->totalTime += this->lapTime;
-      if(storeLapTimes) lapTimes.push_back(this->lapTime);
-
-      return lapTime;
-   }
-   /*==========================================================*/
-   void reset()
-   {
-      this->isMeasuring = false;
-      
-      this->startTime   = 0.0;
-      this->totalTime   = 0.0;
-      this->lapTime     = 0.0;
-
-      lapTimes.resize(0);
-   }
-   /*==========================================================*/
-   double getCurrentLapTime() const
-   {
-     //if start() was never activated before:
-      if(!isMeasuring) return 0.0; 
-      
-      #if defined(VF_MPI) && !defined(CAB_RUBY)
-         return PbMpi::Wtime() - this->startTime;
-      #elif defined(UBSYSTEM_APPLE)
-         timespec tp;  
-         mach_absolute_difference(mach_absolute_time(), this->startTime, &tp);
-         return tp.tv_sec + tp.tv_nsec*1e-9;
-      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_AIX)
-         timespec tp;
-         clock_gettime(CLOCK_REALTIME,&tp);
-         return ((double)(tp.tv_sec)*1.0e9 + (double)(tp.tv_nsec) - this->startTime)*1.0e-9;
-      #else
-         return ( (double)clock() - this->startTime ) / (double)CLOCKS_PER_SEC;
-      #endif //VF_MPI 
-      
-   }
-   /*==========================================================*/
-   double getTotalTime() const
-   {
-      return this->totalTime;
-   }
-   /*==========================================================*/
-   std::string toString()
-   {
-      std::stringstream text;
-      text<<*this;
-      return text.str();
-   }
-
-   //ueberladene Operatoren
-   /*==========================================================*/
-   friend inline std::ostream& operator << (std::ostream& os, const UbTimer& timer) 
-   {
-       os<<"UbTimer[totalTime="<<timer.totalTime<<"sec, lapTimes(";
-       for(std::size_t i=0; i<timer.lapTimes.size(); i++) os<<timer.lapTimes[i]<<",";
-       os<<")]";
-       return os;
-   }
-
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void SF_SERIALIZE(Archive & ar)
-   {
-      ar & name;
-      ar & isMeasuring;
-      ar & startTime;
-      ar & totalTime;
-      ar & lapTime;
-      ar & lapTimes;
-      ar & storeLapTimes;
-   }
-#endif //CAB_RCF
-
-protected:
-   std::string name;
-   bool        isMeasuring;
-   bool        storeLapTimes;
-
-   double      startTime;
-   double      totalTime;
-   double      lapTime;
-   
-   std::vector<double> lapTimes;
-};
-
-
-/*=========================================================================*/
-//  UbProgressTimer - Time Measuring                                              
-//                                                                         
-//
-//
-//UbProressTimer misst die Zeit von seiner Instantiierung bis zur Zerstörung
-//und gib die verstrichene Zeit auf "os" in [s] aus
-//example:
-// {
-//    UbProgressTimer timer;
-//    UbSystem::sleepS(10);
-// } //--> 10s
-//<BR><BR>
-//@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-//@version 1.0 - 10.03.2008
-// 
-class UbProgressTimer : public UbTimer
-{
-private:
-	UbProgressTimer(const UbProgressTimer& rhs);
-public:
-  explicit UbProgressTimer( std::ostream & os = std::cout )
-     : UbTimer(),os(os) 
-  {
-  	  this->start();
-  }
-  /*==========================================================*/
-  ~UbProgressTimer()
-  {
-  //  A) Throwing an exception from a destructor is a Bad Thing.
-  //  B) The progress_timer destructor does output which may throw.
-  //  C) A progress_timer is usually not critical to the application.
-  //  Therefore, wrap the I/O in a try block, catch and ignore all exceptions.
-    try
-    {
-      // use istream instead of ios_base to workaround GNU problem (Greg Chicares)
-      std::istream::fmtflags old_flags = os.setf( std::istream::fixed,
-                                                  std::istream::floatfield );
-      std::streamsize old_prec = os.precision( 2 );
-      os << stop() << " s" << std::endl;
-      os.flags( old_flags );
-      os.precision( old_prec );
-    }
-    catch (...) {} // eat any exceptions
-  } 
-
-private:
-  std::ostream & os;
-};
-
-
-#endif //UBTIMING_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBTIMING_H
+#define UBTIMING_H
+
+#include <string>
+#include <limits>
+#include <iostream>
+#include <sstream>
+#include <vector>
+#include <ctime>
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+#ifdef VF_MPI
+   #include <mpi.h>
+   #include <basics/parallel/PbMpi.h>
+#endif //VF_MPI
+
+/*=========================================================================*/
+//  UbTiming - Time Measuring                                              
+//                                                                         
+//
+//
+//This Class provides the base for ...
+//<BR><BR>
+//@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+//@author <A HREF="mailto:geller@cab.bau.tu-bs.de">S. Geller</A>
+//@version 1.1 - 14.02.06
+// 
+
+class UbTiming
+{
+public:
+	UbTiming()
+   {
+      this->duration		= 0.0;
+      this->deltaT		= 0.0;
+      this->startTime	= 0;
+      this->name        = "noname";
+   }
+   /*==========================================================*/
+   UbTiming(const std::string& name)
+   {
+      this->duration		= 0.0;
+      this->deltaT		= 0.0;
+      this->startTime	= 0;
+      this->name        = name;
+   }
+   /*==========================================================*/
+   virtual ~UbTiming() {}  
+   /*==========================================================*/
+   virtual void initTiming()
+   {
+      this->duration = 0.0;	
+   }
+   /*==========================================================*/
+   virtual void startTiming()
+   {
+      #if defined(VF_MPI) && !defined(CAB_RUBY)
+         this->startTime = PbMpi::Wtime();
+      #else
+         this->startTime = (double)clock();	
+      #endif //VF_MPI 
+   }
+   /*==========================================================*/
+   virtual void initAndStartTiming()
+   {
+      this->initTiming();
+      this->startTiming();
+   }
+   /*==========================================================*/
+   virtual void endTiming()
+   {
+      this->stopTiming();
+   }
+   /*==========================================================*/
+   virtual void stopTiming()
+   {
+      #if defined(VF_MPI) && !defined(CAB_RUBY)
+            this->deltaT   = PbMpi::Wtime()-this->startTime;
+      #else
+         this->deltaT   = ((double)clock()-this->startTime)/(double)CLOCKS_PER_SEC;
+      #endif //VF_MPI 
+
+      this->duration += this->deltaT;
+   }
+   /*==========================================================*/
+   virtual double getDuration() const
+   {
+      return this->duration;
+   }
+   /*==========================================================*/
+   virtual void setName(const std::string& name)
+   {
+      this->name = name;
+   }
+   /*==========================================================*/
+   virtual std::string getName() const
+   { 
+      return this->name; 
+   }
+   /*==========================================================*/
+   void start()
+   {
+      this->duration = 0.0;
+
+      #if defined(VF_MPI) && !defined(CAB_RUBY)
+         this->startTime = PbMpi::Wtime();
+      #else
+         this->startTime = (double)clock();
+      #endif //VF_MPI 
+   }
+   /*==========================================================*/
+   void pause()
+   {
+      #if defined(VF_MPI) && !defined(CAB_RUBY)
+         this->duration += PbMpi::Wtime()-this->startTime;
+      #else
+         this->duration +=((double)clock()-this->startTime)/(double)CLOCKS_PER_SEC;
+      #endif //VF_MPI 
+   }
+   /*==========================================================*/
+   void unpause()
+   {
+      #if defined(VF_MPI) && !defined(CAB_RUBY)
+         this->startTime   = PbMpi::Wtime();
+      #else
+         this->startTime = (double)clock();
+      #endif //VF_MPI 
+   }
+   /*==========================================================*/
+   void stop()
+   {
+      #if defined(VF_MPI) && !defined(CAB_RUBY)
+         this->duration += PbMpi::Wtime()-this->startTime;
+      #else
+         this->duration +=((double)clock()-this->startTime)/(double)CLOCKS_PER_SEC;
+      #endif //VF_MPI 
+   }
+   /*==========================================================*/
+   double getTicks() const            
+   { 
+      #if defined(VF_MPI) && !defined(CAB_RUBY)
+         return PbMpi::Wtick();
+      #else
+         return double(1.0)/double(CLOCKS_PER_SEC);
+      #endif  //VF_MPI 
+   }
+
+protected:
+   std::string name;
+
+   double startTime;
+   double duration;
+	double deltaT;
+};
+
+/*=========================================================================*/
+//  UbTimer - Time Measuring                                              
+//                                                                         
+//
+//
+//This Class provides the base for ...
+//<BR><BR>
+//@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+//@version 1.0 - 16.08.2007
+// 
+#include <basics/utilities/UbSystem.h> //for definitons of system/OS type
+
+#ifdef UBSYSTEM_APPLE   //Apple hack
+   #include <mach/mach_time.h>  
+   #include <time.h>  
+   #include <stdio.h> 
+   inline void mach_absolute_difference(const uint64_t& end, const uint64_t& start, struct timespec *tp) 
+   {  
+         uint64_t difference = end - start;  
+         static mach_timebase_info_data_t info = {0,0};  
+   
+         if (info.denom == 0)  
+                 mach_timebase_info(&info);  
+   
+         uint64_t elapsednano = difference * (info.numer / info.denom);  
+   
+         tp->tv_sec = elapsednano * 1e-9;  
+         tp->tv_nsec = elapsednano - (tp->tv_sec * 1e9);  
+   } 
+#elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_AIX)
+   #include <ctime>
+   #include <unistd.h> // for sysconf
+   #include <pthread.h>
+#endif
+
+//example:
+//t=0  start 
+//t=1 
+//t=2  stop  -> return 2; getLapTime=2; getTotalTime 2; getLapTimes:  2
+//t=3 
+//t=4 
+//t=5  stop  -> return 3; getLapTime=3; getTotalTime 5; getLapTimes:  2,3
+//t=6  stop  -> return 1; getLapTime=1; getTotalTime 6; getLapTimes:  2,3,1
+//t=7  
+//t=8  start ->no consideration of time 7 and 8 
+//t=9  
+//t=10 stop  -> return 2; getLapTime=2; getTotalTime 8; getLapTimes:  2,3,1,2
+//t=11 resetAndStart timer wird zurueckgestellt und neu gestaret
+//t=12
+//t=13 
+//t=14 stop  -> return 3; getLapTime=3; getTotalTime 3; getLapTimes:  3
+
+class UbTimer
+{
+public:
+   UbTimer(const bool& storeLapTimes = false) 
+      :  name("unamed"), isMeasuring(false), storeLapTimes(storeLapTimes)
+       , startTime(0.0), totalTime(0.0), lapTime(0.0)
+   {
+
+   }
+   /*==========================================================*/
+   UbTimer(const std::string& name, const bool& storeLapTimes = false) 
+      :  name(name), isMeasuring(false), storeLapTimes(storeLapTimes)
+       , startTime(0.0), totalTime(0.0), lapTime(0.0)
+   {
+
+   }
+   /*==========================================================*/
+   virtual ~UbTimer() {}  
+   /*==========================================================*/
+   double              getLapTime() const               { return this->lapTime;  }
+   std::vector<double> getLapTimes() const              { return this->lapTimes; }
+   void                setName(const std::string& name) { this->name = name;     }
+   std::string         getName() const                  { return this->name;     }
+   bool                isRunning() const                { return isMeasuring;    }
+   bool                isStoringLapTimes() const        { return storeLapTimes;  }
+   /*==========================================================*/
+   void setStoreLapTimes(const bool& storeLapTimes) { this->storeLapTimes = storeLapTimes; }
+   /*==========================================================*/
+   void start()
+   {
+      this->isMeasuring = true;
+
+      #if defined(VF_MPI) && !defined(CAB_RUBY)
+          this->startTime = PbMpi::Wtime();
+      #elif defined(UBSYSTEM_APPLE)
+    	 this->startTime = mach_absolute_time();  
+      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_AIX)
+         timespec tp;
+         clock_gettime(CLOCK_REALTIME,&tp);
+         this->startTime = (double)(tp.tv_sec)*1.0e9 + (double)(tp.tv_nsec);
+      #else
+         this->startTime = (double)clock();
+      #endif //VF_MPI
+   }
+   /*==========================================================*/
+   void resetAndStart() { this->reset(); this->start(); }
+   /*==========================================================*/
+   //stop: - stops the calculation and returns the time elapsed since last start/stop
+   //      - timing continues
+   double stop()
+   {
+      //if start() was never activated before:
+      if(!isMeasuring) return 0.0; 
+      
+      #if defined(VF_MPI) && !defined(CAB_RUBY)
+         double actTime = PbMpi::Wtime();
+         this->lapTime  = actTime-this->startTime;
+      #elif defined(UBSYSTEM_APPLE)
+    	 double actTime = mach_absolute_time();  
+         timespec tp;  
+         mach_absolute_difference(actTime, this->startTime, &tp);
+         this->lapTime  =  tp.tv_sec + tp.tv_nsec*1e-9;
+	  #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_AIX)
+         timespec tp;
+         clock_gettime(CLOCK_REALTIME,&tp);
+         double actTime = (double)(tp.tv_sec)*1.0e9 + (double)(tp.tv_nsec);
+         this->lapTime  = (actTime-this->startTime)*1.0e-9;
+      #else
+         double actTime = (double)clock();
+         this->lapTime  = (actTime-this->startTime)/(double)CLOCKS_PER_SEC;
+      #endif //VF_MPI 
+      
+      this->startTime  = actTime;
+      this->totalTime += this->lapTime;
+      if(storeLapTimes) lapTimes.push_back(this->lapTime);
+
+      return lapTime;
+   }
+   /*==========================================================*/
+   void reset()
+   {
+      this->isMeasuring = false;
+      
+      this->startTime   = 0.0;
+      this->totalTime   = 0.0;
+      this->lapTime     = 0.0;
+
+      lapTimes.resize(0);
+   }
+   /*==========================================================*/
+   double getCurrentLapTime() const
+   {
+     //if start() was never activated before:
+      if(!isMeasuring) return 0.0; 
+      
+      #if defined(VF_MPI) && !defined(CAB_RUBY)
+         return PbMpi::Wtime() - this->startTime;
+      #elif defined(UBSYSTEM_APPLE)
+         timespec tp;  
+         mach_absolute_difference(mach_absolute_time(), this->startTime, &tp);
+         return tp.tv_sec + tp.tv_nsec*1e-9;
+      #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_AIX)
+         timespec tp;
+         clock_gettime(CLOCK_REALTIME,&tp);
+         return ((double)(tp.tv_sec)*1.0e9 + (double)(tp.tv_nsec) - this->startTime)*1.0e-9;
+      #else
+         return ( (double)clock() - this->startTime ) / (double)CLOCKS_PER_SEC;
+      #endif //VF_MPI 
+      
+   }
+   /*==========================================================*/
+   double getTotalTime() const
+   {
+      return this->totalTime;
+   }
+   /*==========================================================*/
+   std::string toString()
+   {
+      std::stringstream text;
+      text<<*this;
+      return text.str();
+   }
+
+   //ueberladene Operatoren
+   /*==========================================================*/
+   friend inline std::ostream& operator << (std::ostream& os, const UbTimer& timer) 
+   {
+       os<<"UbTimer[totalTime="<<timer.totalTime<<"sec, lapTimes(";
+       for(std::size_t i=0; i<timer.lapTimes.size(); i++) os<<timer.lapTimes[i]<<",";
+       os<<")]";
+       return os;
+   }
+
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void SF_SERIALIZE(Archive & ar)
+   {
+      ar & name;
+      ar & isMeasuring;
+      ar & startTime;
+      ar & totalTime;
+      ar & lapTime;
+      ar & lapTimes;
+      ar & storeLapTimes;
+   }
+#endif //CAB_RCF
+
+protected:
+   std::string name;
+   bool        isMeasuring;
+   bool        storeLapTimes;
+
+   double      startTime;
+   double      totalTime;
+   double      lapTime;
+   
+   std::vector<double> lapTimes;
+};
+
+
+/*=========================================================================*/
+//  UbProgressTimer - Time Measuring                                              
+//                                                                         
+//
+//
+//UbProressTimer misst die Zeit von seiner Instantiierung bis zur Zerstörung
+//und gib die verstrichene Zeit auf "os" in [s] aus
+//example:
+// {
+//    UbProgressTimer timer;
+//    UbSystem::sleepS(10);
+// } //--> 10s
+//<BR><BR>
+//@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+//@version 1.0 - 10.03.2008
+// 
+class UbProgressTimer : public UbTimer
+{
+private:
+	UbProgressTimer(const UbProgressTimer& rhs);
+public:
+  explicit UbProgressTimer( std::ostream & os = std::cout )
+     : UbTimer(),os(os) 
+  {
+  	  this->start();
+  }
+  /*==========================================================*/
+  ~UbProgressTimer()
+  {
+  //  A) Throwing an exception from a destructor is a Bad Thing.
+  //  B) The progress_timer destructor does output which may throw.
+  //  C) A progress_timer is usually not critical to the application.
+  //  Therefore, wrap the I/O in a try block, catch and ignore all exceptions.
+    try
+    {
+      // use istream instead of ios_base to workaround GNU problem (Greg Chicares)
+      std::istream::fmtflags old_flags = os.setf( std::istream::fixed,
+                                                  std::istream::floatfield );
+      std::streamsize old_prec = os.precision( 2 );
+      os << stop() << " s" << std::endl;
+      os.flags( old_flags );
+      os.precision( old_prec );
+    }
+    catch (...) {} // eat any exceptions
+  } 
+
+private:
+  std::ostream & os;
+};
+
+
+#endif //UBTIMING_H
diff --git a/source/ThirdParty/Library/basics/utilities/UbTuple.cpp b/source/VirtualFluidsBasic/basics/utilities/UbTuple.cpp
similarity index 100%
rename from source/ThirdParty/Library/basics/utilities/UbTuple.cpp
rename to source/VirtualFluidsBasic/basics/utilities/UbTuple.cpp
diff --git a/source/ThirdParty/Library/basics/utilities/UbTuple.h b/source/VirtualFluidsBasic/basics/utilities/UbTuple.h
similarity index 96%
rename from source/ThirdParty/Library/basics/utilities/UbTuple.h
rename to source/VirtualFluidsBasic/basics/utilities/UbTuple.h
index 94132fcaf04137fd52f918458bb9be258efe79e7..3113317479185b303cb0fdf9943b3834f7a782ed 100644
--- a/source/ThirdParty/Library/basics/utilities/UbTuple.h
+++ b/source/VirtualFluidsBasic/basics/utilities/UbTuple.h
@@ -1,607 +1,607 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef UBTUPLE_H
-#define UBTUPLE_H
-
-#include <iostream>
-#include <string>
-#include <ostream>
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-/*=========================================================================*/
-/*  UbTuple                                                             */
-/*                                                                         */
-/**
-...
-<BR><BR>
-@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
-@version 1.0 - 23.10.06
-*/ 
-
-/*
-usage: ...
-////Advanced UbTuple
-//Bsp:
-//// create and use tuple with only one field
-//UbTuple<int,int,int,int,int> t1;
-//val<1>(t1) += 42;
-//std::cout << t1.v1() << std::endl;
-
-//// create and use duo
-//UbTuple<bool,int> t2;
-//std::cout << val<1>(t2) << ", ";
-//std::cout << t2.v1() << std::endl;
-
-//// create and use triple
-//UbTuple<bool,int,double> t3;
-//val<1>(t3) = true;  // new values via: val< pos >(triple) = ...
-//val<2>(t3) = 42;
-//val<3>(t3) = 0.2;
-//t3 = makeUbTuple(false, 23, 13.13);
-
-//std::cout << val<1>(t3) << ", ";
-//std::cout << val<2>(t3) << ", ";
-//std::cout << val<3>(t3) << std::endl;
-
-//// create and use quadruple
-//UbType<bool,int,float,double> t4(true,42,13,1.95583);
-//std::cout << val<4>(t4) << std::endl;        //<- option 2 (std)
-//std::cout << t4.v2().v2().v2() << std::endl; //<- option 2
-*/
-
-//typeop.h
-// primary template
-/**********************************
-* typeop1.hpp:
-**********************************/
-template <typename T>
-class UbTypeOp    // primary template
-{           
-public:
-   typedef T         ArgT;
-   typedef T         BareT;
-   typedef T const   ConstT;
-   typedef T &       RefT;
-   typedef T &       RefBareT;
-   typedef T const & RefConstT;
-};
-/**** end of typeop1.hpp ****/
-
-// partial specialization for const
-/**********************************
-* typeop2.hpp:
-**********************************/
-template <typename T>
-class UbTypeOp <T const>  // partial specialization for const types
-{
- public:
-   typedef T const   ArgT;
-   typedef T         BareT;
-   typedef T const   ConstT;
-   typedef T const & RefT;
-   typedef T &       RefBareT;
-   typedef T const & RefConstT;
-};
-/**** end of typeop2.hpp ****/
-
-// partial specialization for references
-/**********************************
-* typeop3.hpp:
-**********************************/
-template <typename T>
-class UbTypeOp <T&>        // partial specialization for references
-{
-public:
-   typedef T &                           ArgT;
-   typedef typename UbTypeOp<T>::BareT   BareT;
-   typedef T const                       ConstT;
-   typedef T &                           RefT;
-   typedef typename UbTypeOp<T>::BareT & RefBareT;
-   typedef T const &                     RefConstT;
-};
-/**** end of typeop3.hpp ****/
-
-// full specialization for void
-/**********************************
-* typeop4.hpp:
-**********************************/
-template<>
-class UbTypeOp <void>      // full specialization for void
-{
-public:
-   typedef void       ArgT;
-   typedef void       BareT;
-   typedef void const ConstT;
-   typedef void       RefT;
-   typedef void       RefBareT;
-   typedef void       RefConstT;
-};
-/**** end of typeop4.hpp ****/
-
-template <typename T1, typename T2>
-class  UbDuo;
-
-template <typename T1, typename T2>
-std::ostream& operator << (std::ostream& os, UbDuo<T1, T2> const& d1);
-
-//duo1.hpp
-template <typename T1, typename T2>
-class UbDuo 
-{
-public:
-   typedef T1 Type1;  // type of first field
-   typedef T2 Type2;  // type of second field
-   enum { N = 2 };    // number of fields
-
-public:
-   // constructors
-   UbDuo() : value1(), value2() {  }
-   UbDuo (T1 const & a, T2 const & b) : value1(a), value2(b)  {  }
-
-   // for implicit type conversion during construction
-   template <typename U1, typename U2>
-   UbDuo (UbDuo<U1,U2> const & d) : value1(d.v1()), value2(d.v2()) {  }
-
-   // for implicit type conversion during assignments
-   template <typename U1, typename U2>
-   UbDuo<T1, T2>& operator = (UbDuo<U1,U2> const & d) 
-   {
-      value1 = d.v1();//value1;
-      value2 = d.v2();//value2;
-      return *this;
-   }
-
-   // field access
-   T1& v1()             { return value1; }
-   T1 const& v1() const { return value1; }
-
-   T2& v2()             { return value2; }
-   T2 const& v2() const { return value2; }
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void serialize(Archive& ar, const unsigned int version)
-   {
-      ar & value1;
-      ar & value2;
-   }
-#endif //CAB_RCF
-
-private:
-   T1 value1;         // value of first field
-   T2 value2;         // value of second field
-};
-
-// comparison operators (allow mixed types):
-template <typename T1, typename T2,typename U1, typename U2>
-inline bool operator == (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2)
-{
-   return d1.v1()==d2.v1() && d1.v2()==d2.v2();
-}
-
-template <typename T1, typename T2,typename U1, typename U2>
-inline bool operator != (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2)
-{
-   return !(d1==d2);
-}
-
-template <typename T1, typename T2,typename U1, typename U2>
-inline bool operator < (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2)
-{
-   if     (d1.v1() <  d2.v1() ) return true;
-   else if(d1.v1() == d2.v1() ) return d1.v2() < d2.v2();
-
-   return false;
-}
-
-template <typename T1, typename T2>
-std::ostream& operator << (std::ostream& os, UbDuo<T1, T2> const& d1)
-{
-    os << d1.v1() << ", " << d1.v2();
-    return os;
-}
-
-// convenience function  for creation and initialization
-template <typename T1, typename T2> 
-inline UbDuo<T1,T2> makeUbDuo(T1 const & a, T2 const & b)
-{
-   return UbDuo<T1,T2>(a,b);
-}
-
-//duo2.hpp
-template <typename A, typename B, typename C>
-class UbDuo<A, UbDuo<B,C> > 
-{
-public:
-   typedef A          T1;           // type of first field
-   typedef UbDuo<B,C> T2;           // type of second field
-   enum { N = UbDuo<B,C>::N + 1 };  // number of fields
- 
-public:
-   // constructors
-   UbDuo() : value1(), value2() { }
-   UbDuo (T1 const & a, T2 const & b) : value1(a), value2(b) { }
-
-   // for implicit type conversion during construction
-   template <typename U1, typename U2>
-   UbDuo (UbDuo<U1,U2> const & d) : value1(d.v1()), value2(d.v2()) { }
-
-   // for implicit type conversion during assignments
-   template <typename U1, typename U2>
-   UbDuo<T1, T2>& operator = (UbDuo<U1,U2> const & d) 
-   { 
-      value1 = d.v1();//value1;     
-      value2 = d.v2();//value2;
-      return *this;
-   }
-
-   // field access
-   T1& v1()             { return value1; }
-   T1 const& v1() const { return value1; }
-
-   T2& v2()             { return value2; }
-   T2 const& v2() const { return value2; }
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void serialize(Archive & ar, const unsigned int version)
-   {
-      ar & value1;
-      ar & value2;
-   }
-#endif //CAB_RCF
-
-private:
-   T1 value1;         // value of first field
-   T2 value2;         // value of second field
-};
-
-//duo3.hpp
-// primary template for type of Nth field of (duo) T
-template <int N, typename T>
-class UbDuoT 
-{
-public:
-   typedef void ResultT;    // in general, the result type is void
-};
-
-// specialization for 1st field of a plain duo
-template <typename A, typename B>
-class UbDuoT<1, UbDuo<A,B> > 
-{
-public:
-   typedef A ResultT;
-};
-
-// specialization for 2nd field of a plain duo
-template <typename A, typename B>
-class UbDuoT<2, UbDuo<A,B> > 
-{
-public:
-   typedef B ResultT;
-};
-
-// specialization for Nth field of a recursive duo
-template <int N, typename A, typename B, typename C>
-class UbDuoT<N, UbDuo<A, UbDuo<B,C> > > 
-{
-public:
-   typedef typename UbDuoT<N-1, UbDuo<B,C> >::ResultT ResultT;
-};
-
-// specialization for 1st field of a recursive duo
-template <typename A, typename B, typename C>
-class UbDuoT<1, UbDuo<A, UbDuo<B,C> > > 
-{
-public:
-   typedef A ResultT;
-};
-
-// specialization for 2nd field of a recursive duo
-template <typename A, typename B, typename C>
-class UbDuoT<2, UbDuo<A, UbDuo<B,C> > > 
-{
-public:
-   typedef B ResultT;
-};
-
-//duo4.hpp
-// primary template for value of Nth field of (duo) T
-template <int N, typename T>
-class DuoValue 
-{
-public:
-   static void get(T&) {  }      // in general, we have no value
-   static void get(T const&) { }
-};
-
-// specialization for 1st field of a plain duo
-template <typename A, typename B>
-class DuoValue<1, UbDuo<A, B> > 
-{
-public:
-   static A& get(UbDuo<A, B> &d)             { return d.v1(); }
-   static A const& get(UbDuo<A, B> const &d) { return d.v1(); }
-};
-
-// specialization for 2nd field of a plain duo
-template <typename A, typename B>
-class DuoValue<2, UbDuo<A, B> > 
-{
-public:
-   static B& get(UbDuo<A, B> &d)             { return d.v2(); }
-   static B const& get(UbDuo<A, B> const &d) { return d.v2(); }
-};
-
-// specialization for Nth field of recursive duo
-template <int N, typename A, typename B, typename C>
-struct DuoValue<N, UbDuo<A, UbDuo<B,C> > >
-{
-   static typename UbTypeOp<typename UbDuoT<N-1, UbDuo<B,C> >::ResultT>::RefT  get(UbDuo<A, UbDuo<B,C> > &d)
-   { 
-      return DuoValue<N-1, UbDuo<B,C> >::get(d.v2()); 
-   }
-   static typename UbTypeOp<typename UbDuoT<N-1, UbDuo<B,C> >::ResultT>::RefConstT  get(UbDuo<A, UbDuo<B,C> > const &d)
-   { 
-      return DuoValue<N-1, UbDuo<B,C> >::get(d.v2()); 
-   }
-};
-
-// specialization for 1st field of recursive duo
-template <typename A, typename B, typename C>
-class DuoValue<1, UbDuo<A, UbDuo<B,C> > > 
-{
-public:
-   static A& get(UbDuo<A, UbDuo<B,C> > &d)             { return d.v1(); }
-   static A const& get(UbDuo<A, UbDuo<B,C> > const &d) { return d.v1(); }
-};
-
-// specialization for 2nd field of recursive duo
-template <typename A, typename B, typename C>
-class DuoValue<2, UbDuo<A, UbDuo<B,C> > > 
-{
-public:
-   static B& get(UbDuo<A, UbDuo<B,C> > &d)             { return d.v2().v1(); }
-   static B const& get(UbDuo<A, UbDuo<B,C> > const &d) { return d.v2().v1(); }
-};
-
-//duo5.hpp
-// return Nth value of variable duo
-template <int N, typename A, typename B> 
-inline typename UbTypeOp<typename UbDuoT<N, UbDuo<A, B> >::ResultT>::RefT val(UbDuo<A, B>& d)
-{
-   return DuoValue<N, UbDuo<A, B> >::get(d);
-}
-
-// return Nth value of constant duo
-template <int N, typename A, typename B> 
-inline typename UbTypeOp<typename UbDuoT<N, UbDuo<A, B> >::ResultT>::RefConstT val(UbDuo<A, B> const& d)
-{
-   return DuoValue<N, UbDuo<A, B> >::get(d);
-}
-
-//duo6.hpp
-// partial specialization for UbDuo<> with only one field
-template <typename A>
-struct UbDuo<A,void> 
-{
-public:
-   typedef A    T1;  // type of first field
-   typedef void T2;  // type of second field
-   enum { N = 1 };   // number of fields
-
-private:
-   T1 value1;        // value of first field
-
-public:
-   // constructors
-   UbDuo() : value1() { }
-   UbDuo (T1 const & a) : value1(a) { }
-
-   // field access
-   T1& v1()             { return value1; }
-   T1 const& v1() const { return value1; }
-
-   void v2() { }
-   void v2() const { }
-
-   #ifdef CAB_RCF
-      template<class Archive>
-      void serialize(Archive & ar, const unsigned int version)
-      {
-         ar & value1;
-      }
-   #endif
-};
-
-//tupel1.hpp
-// type that represents unused type parameters
-class UbNullT 
-{
-};
-
-// UbTuple<> in general derives from UbTuple<> with one more UbNullT
-template <typename P1,
-          typename P2 = UbNullT,
-          typename P3 = UbNullT,
-          typename P4 = UbNullT,
-          typename P5 = UbNullT,
-          typename P6 = UbNullT,
-          typename P7 = UbNullT,
-          typename P8 = UbNullT >
-class UbTuple : public UbDuo<P1, typename UbTuple<P2,P3,P4,P5,P6,P7,P8,UbNullT>::BaseT> 
-{
-public:
-   typedef UbDuo<P1, typename UbTuple<P2,P3,P4,P5,P6,P7,P8,UbNullT>::BaseT>  BaseT;
-
-   // constructor:
-   UbTuple() {}
-   UbTuple( typename UbTypeOp<P1>::RefConstT a1,
-            typename UbTypeOp<P2>::RefConstT a2,
-            typename UbTypeOp<P3>::RefConstT a3 = UbNullT(),
-            typename UbTypeOp<P4>::RefConstT a4 = UbNullT(),
-            typename UbTypeOp<P5>::RefConstT a5 = UbNullT(),
-            typename UbTypeOp<P6>::RefConstT a6 = UbNullT(),
-            typename UbTypeOp<P7>::RefConstT a7 = UbNullT(),
-            typename UbTypeOp<P8>::RefConstT a8 = UbNullT() )
-      : BaseT(a1, UbTuple<P2,P3,P4,P5,P6,P7,P8,UbNullT>(a2,a3,a4,a5,a6,a7,a8))
-   {
-   }
-
-   // for implicit type conversion during assignments
-   template <typename U1,typename U2, typename U3, typename U4, typename U5, typename U6, typename U7, typename U8 >
-   UbTuple<P1,P2,P3,P4,P5,P6,P7,P8>& operator = ( const UbTuple<U1,U2,U3,U4,U5,U6,U7,U8>& rhs)
-   {
-      this->BaseT::operator=( typename UbTuple<U1,U2,U3,U4,U5,U6,U7,U8>::BaseT(rhs) );
-      return *this;
-   }
-
-};
-
-// specialization to end deriving recursion
-template <typename P1, typename P2>
-class UbTuple<P1,P2,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT> : public UbDuo<P1,P2> {
-public:
-   typedef UbDuo<P1,P2> BaseT;
-   
-   // constructor:
-   UbTuple() {}
-   UbTuple( typename UbTypeOp<P1>::RefConstT a1,
-            typename UbTypeOp<P2>::RefConstT a2,
-            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
-            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
-            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
-            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
-            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
-            typename UbTypeOp<UbNullT>::RefConstT = UbNullT() )
-      : BaseT(a1, a2) 
-   {
-   }
-
-   // for implicit type conversion during assignments
-   template <typename U1,typename U2 >
-   UbTuple<P1,P2>& operator = ( const UbTuple<U1,U2>& rhs)
-   {
-      this->BaseT::operator=( typename UbTuple<U1,U2>::BaseT(rhs) );
-      return *this;
-   }
-
-};
-
-// specialization for singletons
-template <typename P1>
-class UbTuple<P1,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT> : public UbDuo<P1,void>
-{
-public:
-   typedef UbDuo<P1,void> BaseT;
-
-   // constructor:
-   UbTuple() {}
-   UbTuple( typename UbTypeOp<P1>::RefConstT a1,
-            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
-            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
-            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
-            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
-            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
-            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
-            typename UbTypeOp<UbNullT>::RefConstT = UbNullT() )
-      : BaseT(a1) 
-   {
-   }
-
-   // for implicit type conversion during assignments
-   template <typename U1 >
-   UbTuple<P1>& operator = ( const UbTuple<U1>& rhs)
-   {
-      this->v1() = rhs.v1();
-      return *this;
-   }
-
-};
-
-// convenience function for 1 argument
-template <typename T1> 
-inline UbTuple<T1> makeUbTuple(T1 const &a1)
-{
-   return UbTuple<T1>(a1);
-}
-
-// convenience function for 2 arguments
-template <typename T1, typename T2>
-inline UbTuple<T1,T2> makeUbTuple(T1 const &a1, T2 const &a2)
-{
-   return UbTuple<T1,T2>(a1,a2);
-}
-
-// convenience function for 3 arguments
-template <typename T1, typename T2, typename T3>
-inline UbTuple<T1,T2,T3> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3)
-{
-   return UbTuple<T1,T2,T3>(a1,a2,a3);
-}
-
-// convenience function for 4 arguments
-template <typename T1, typename T2, typename T3, typename T4>
-inline UbTuple<T1,T2,T3,T4> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4)
-{
-   return UbTuple<T1,T2,T3,T4>(a1,a2,a3,a4);
-}
-
-// convenience function for 5 arguments
-template <typename T1, typename T2, typename T3, typename T4, typename T5>
-inline UbTuple<T1,T2,T3,T4,T5> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4,T5 const &a5)
-{
-   return UbTuple<T1,T2,T3,T4,T5>(a1,a2,a3,a4,a5);
-}
-
-// convenience function for 6 arguments
-template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
-inline UbTuple<T1,T2,T3,T4,T5,T6> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4, T5 const &a5, T6 const &a6)
-{
-   return UbTuple<T1,T2,T3,T4,T5,T6>(a1,a2,a3,a4,a5,a6);
-}
-
-// convenience function for 7 arguments
-template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
-inline UbTuple<T1,T2,T3,T4,T5,T6,T7> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4, T5 const &a5, T6 const &a6, T7 const &a7)
-{
-   return UbTuple<T1,T2,T3,T4,T5,T6,T7>(a1,a2,a3,a4,a5,a6,a7);
-}
-
-// convenience function for 8 arguments
-template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
-inline UbTuple<T1,T2,T3,T4,T5,T6,T7,T8> makeUbTuple(T1 const &a1, T2 const &a2,T3 const &a3, T4 const &a4,T5 const &a5, T6 const &a6,T7 const &a7, T8 const &a8 )
-{
-   return UbTuple<T1,T2,T3,T4,T5,T6,T7,T8>(a1,a2,a3,a4,a5,a6,a7,a8);
-}
-
-//some typedefs
-typedef UbTuple<float,float>                               UbTupleFloat2;
-typedef UbTuple<float,float,float>                         UbTupleFloat3;
-typedef UbTuple<int,int>                                   UbTupleInt2;
-typedef UbTuple<int,int,int>                               UbTupleInt3;
-typedef UbTuple<int,int,int,int>                           UbTupleInt4;
-typedef UbTuple<int,int,int,int,int>                       UbTupleInt5;
-typedef UbTuple<int,int,int,int,int,int>                   UbTupleInt6;
-typedef UbTuple<int,int,int,int,int,int,int,int>           UbTupleInt8;
-typedef UbTuple<double,double>                             UbTupleDouble2;
-typedef UbTuple<double,double,double>                      UbTupleDouble3;
-typedef UbTuple<double,double,double,double>               UbTupleDouble4;
-typedef UbTuple<double,double,double,double,double,double> UbTupleDouble6;
-typedef UbTuple<std::string,double,double>                 UbTupleStringDouble2;
-typedef UbTuple<std::string,double,double,double>          UbTupleStringDouble3;
-typedef UbTuple<std::string,int,int,int>                   UbTupleStringInt3;
-typedef UbTuple<short,short,short,short>                   UbTupleShort4;
-typedef UbTuple<bool,bool,bool>                            UbTupleBool3;
-typedef UbTuple<int,double,double>                         UbTupleIntDouble2;
-typedef UbTuple<int, bool>                                 UbTupleIntBool;
-
-
-#endif //UBTUPLE_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef UBTUPLE_H
+#define UBTUPLE_H
+
+#include <iostream>
+#include <string>
+#include <ostream>
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+/*=========================================================================*/
+/*  UbTuple                                                             */
+/*                                                                         */
+/**
+...
+<BR><BR>
+@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+@version 1.0 - 23.10.06
+*/ 
+
+/*
+usage: ...
+////Advanced UbTuple
+//Bsp:
+//// create and use tuple with only one field
+//UbTuple<int,int,int,int,int> t1;
+//val<1>(t1) += 42;
+//std::cout << t1.v1() << std::endl;
+
+//// create and use duo
+//UbTuple<bool,int> t2;
+//std::cout << val<1>(t2) << ", ";
+//std::cout << t2.v1() << std::endl;
+
+//// create and use triple
+//UbTuple<bool,int,double> t3;
+//val<1>(t3) = true;  // new values via: val< pos >(triple) = ...
+//val<2>(t3) = 42;
+//val<3>(t3) = 0.2;
+//t3 = makeUbTuple(false, 23, 13.13);
+
+//std::cout << val<1>(t3) << ", ";
+//std::cout << val<2>(t3) << ", ";
+//std::cout << val<3>(t3) << std::endl;
+
+//// create and use quadruple
+//UbType<bool,int,float,double> t4(true,42,13,1.95583);
+//std::cout << val<4>(t4) << std::endl;        //<- option 2 (std)
+//std::cout << t4.v2().v2().v2() << std::endl; //<- option 2
+*/
+
+//typeop.h
+// primary template
+/**********************************
+* typeop1.hpp:
+**********************************/
+template <typename T>
+class UbTypeOp    // primary template
+{           
+public:
+   typedef T         ArgT;
+   typedef T         BareT;
+   typedef T const   ConstT;
+   typedef T &       RefT;
+   typedef T &       RefBareT;
+   typedef T const & RefConstT;
+};
+/**** end of typeop1.hpp ****/
+
+// partial specialization for const
+/**********************************
+* typeop2.hpp:
+**********************************/
+template <typename T>
+class UbTypeOp <T const>  // partial specialization for const types
+{
+ public:
+   typedef T const   ArgT;
+   typedef T         BareT;
+   typedef T const   ConstT;
+   typedef T const & RefT;
+   typedef T &       RefBareT;
+   typedef T const & RefConstT;
+};
+/**** end of typeop2.hpp ****/
+
+// partial specialization for references
+/**********************************
+* typeop3.hpp:
+**********************************/
+template <typename T>
+class UbTypeOp <T&>        // partial specialization for references
+{
+public:
+   typedef T &                           ArgT;
+   typedef typename UbTypeOp<T>::BareT   BareT;
+   typedef T const                       ConstT;
+   typedef T &                           RefT;
+   typedef typename UbTypeOp<T>::BareT & RefBareT;
+   typedef T const &                     RefConstT;
+};
+/**** end of typeop3.hpp ****/
+
+// full specialization for void
+/**********************************
+* typeop4.hpp:
+**********************************/
+template<>
+class UbTypeOp <void>      // full specialization for void
+{
+public:
+   typedef void       ArgT;
+   typedef void       BareT;
+   typedef void const ConstT;
+   typedef void       RefT;
+   typedef void       RefBareT;
+   typedef void       RefConstT;
+};
+/**** end of typeop4.hpp ****/
+
+template <typename T1, typename T2>
+class  UbDuo;
+
+template <typename T1, typename T2>
+std::ostream& operator << (std::ostream& os, UbDuo<T1, T2> const& d1);
+
+//duo1.hpp
+template <typename T1, typename T2>
+class UbDuo 
+{
+public:
+   typedef T1 Type1;  // type of first field
+   typedef T2 Type2;  // type of second field
+   enum { N = 2 };    // number of fields
+
+public:
+   // constructors
+   UbDuo() : value1(), value2() {  }
+   UbDuo (T1 const & a, T2 const & b) : value1(a), value2(b)  {  }
+
+   // for implicit type conversion during construction
+   template <typename U1, typename U2>
+   UbDuo (UbDuo<U1,U2> const & d) : value1(d.v1()), value2(d.v2()) {  }
+
+   // for implicit type conversion during assignments
+   template <typename U1, typename U2>
+   UbDuo<T1, T2>& operator = (UbDuo<U1,U2> const & d) 
+   {
+      value1 = d.v1();//value1;
+      value2 = d.v2();//value2;
+      return *this;
+   }
+
+   // field access
+   T1& v1()             { return value1; }
+   T1 const& v1() const { return value1; }
+
+   T2& v2()             { return value2; }
+   T2 const& v2() const { return value2; }
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void serialize(Archive& ar, const unsigned int version)
+   {
+      ar & value1;
+      ar & value2;
+   }
+#endif //CAB_RCF
+
+private:
+   T1 value1;         // value of first field
+   T2 value2;         // value of second field
+};
+
+// comparison operators (allow mixed types):
+template <typename T1, typename T2,typename U1, typename U2>
+inline bool operator == (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2)
+{
+   return d1.v1()==d2.v1() && d1.v2()==d2.v2();
+}
+
+template <typename T1, typename T2,typename U1, typename U2>
+inline bool operator != (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2)
+{
+   return !(d1==d2);
+}
+
+template <typename T1, typename T2,typename U1, typename U2>
+inline bool operator < (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2)
+{
+   if     (d1.v1() <  d2.v1() ) return true;
+   else if(d1.v1() == d2.v1() ) return d1.v2() < d2.v2();
+
+   return false;
+}
+
+template <typename T1, typename T2>
+std::ostream& operator << (std::ostream& os, UbDuo<T1, T2> const& d1)
+{
+    os << d1.v1() << ", " << d1.v2();
+    return os;
+}
+
+// convenience function  for creation and initialization
+template <typename T1, typename T2> 
+inline UbDuo<T1,T2> makeUbDuo(T1 const & a, T2 const & b)
+{
+   return UbDuo<T1,T2>(a,b);
+}
+
+//duo2.hpp
+template <typename A, typename B, typename C>
+class UbDuo<A, UbDuo<B,C> > 
+{
+public:
+   typedef A          T1;           // type of first field
+   typedef UbDuo<B,C> T2;           // type of second field
+   enum { N = UbDuo<B,C>::N + 1 };  // number of fields
+ 
+public:
+   // constructors
+   UbDuo() : value1(), value2() { }
+   UbDuo (T1 const & a, T2 const & b) : value1(a), value2(b) { }
+
+   // for implicit type conversion during construction
+   template <typename U1, typename U2>
+   UbDuo (UbDuo<U1,U2> const & d) : value1(d.v1()), value2(d.v2()) { }
+
+   // for implicit type conversion during assignments
+   template <typename U1, typename U2>
+   UbDuo<T1, T2>& operator = (UbDuo<U1,U2> const & d) 
+   { 
+      value1 = d.v1();//value1;     
+      value2 = d.v2();//value2;
+      return *this;
+   }
+
+   // field access
+   T1& v1()             { return value1; }
+   T1 const& v1() const { return value1; }
+
+   T2& v2()             { return value2; }
+   T2 const& v2() const { return value2; }
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void serialize(Archive & ar, const unsigned int version)
+   {
+      ar & value1;
+      ar & value2;
+   }
+#endif //CAB_RCF
+
+private:
+   T1 value1;         // value of first field
+   T2 value2;         // value of second field
+};
+
+//duo3.hpp
+// primary template for type of Nth field of (duo) T
+template <int N, typename T>
+class UbDuoT 
+{
+public:
+   typedef void ResultT;    // in general, the result type is void
+};
+
+// specialization for 1st field of a plain duo
+template <typename A, typename B>
+class UbDuoT<1, UbDuo<A,B> > 
+{
+public:
+   typedef A ResultT;
+};
+
+// specialization for 2nd field of a plain duo
+template <typename A, typename B>
+class UbDuoT<2, UbDuo<A,B> > 
+{
+public:
+   typedef B ResultT;
+};
+
+// specialization for Nth field of a recursive duo
+template <int N, typename A, typename B, typename C>
+class UbDuoT<N, UbDuo<A, UbDuo<B,C> > > 
+{
+public:
+   typedef typename UbDuoT<N-1, UbDuo<B,C> >::ResultT ResultT;
+};
+
+// specialization for 1st field of a recursive duo
+template <typename A, typename B, typename C>
+class UbDuoT<1, UbDuo<A, UbDuo<B,C> > > 
+{
+public:
+   typedef A ResultT;
+};
+
+// specialization for 2nd field of a recursive duo
+template <typename A, typename B, typename C>
+class UbDuoT<2, UbDuo<A, UbDuo<B,C> > > 
+{
+public:
+   typedef B ResultT;
+};
+
+//duo4.hpp
+// primary template for value of Nth field of (duo) T
+template <int N, typename T>
+class DuoValue 
+{
+public:
+   static void get(T&) {  }      // in general, we have no value
+   static void get(T const&) { }
+};
+
+// specialization for 1st field of a plain duo
+template <typename A, typename B>
+class DuoValue<1, UbDuo<A, B> > 
+{
+public:
+   static A& get(UbDuo<A, B> &d)             { return d.v1(); }
+   static A const& get(UbDuo<A, B> const &d) { return d.v1(); }
+};
+
+// specialization for 2nd field of a plain duo
+template <typename A, typename B>
+class DuoValue<2, UbDuo<A, B> > 
+{
+public:
+   static B& get(UbDuo<A, B> &d)             { return d.v2(); }
+   static B const& get(UbDuo<A, B> const &d) { return d.v2(); }
+};
+
+// specialization for Nth field of recursive duo
+template <int N, typename A, typename B, typename C>
+struct DuoValue<N, UbDuo<A, UbDuo<B,C> > >
+{
+   static typename UbTypeOp<typename UbDuoT<N-1, UbDuo<B,C> >::ResultT>::RefT  get(UbDuo<A, UbDuo<B,C> > &d)
+   { 
+      return DuoValue<N-1, UbDuo<B,C> >::get(d.v2()); 
+   }
+   static typename UbTypeOp<typename UbDuoT<N-1, UbDuo<B,C> >::ResultT>::RefConstT  get(UbDuo<A, UbDuo<B,C> > const &d)
+   { 
+      return DuoValue<N-1, UbDuo<B,C> >::get(d.v2()); 
+   }
+};
+
+// specialization for 1st field of recursive duo
+template <typename A, typename B, typename C>
+class DuoValue<1, UbDuo<A, UbDuo<B,C> > > 
+{
+public:
+   static A& get(UbDuo<A, UbDuo<B,C> > &d)             { return d.v1(); }
+   static A const& get(UbDuo<A, UbDuo<B,C> > const &d) { return d.v1(); }
+};
+
+// specialization for 2nd field of recursive duo
+template <typename A, typename B, typename C>
+class DuoValue<2, UbDuo<A, UbDuo<B,C> > > 
+{
+public:
+   static B& get(UbDuo<A, UbDuo<B,C> > &d)             { return d.v2().v1(); }
+   static B const& get(UbDuo<A, UbDuo<B,C> > const &d) { return d.v2().v1(); }
+};
+
+//duo5.hpp
+// return Nth value of variable duo
+template <int N, typename A, typename B> 
+inline typename UbTypeOp<typename UbDuoT<N, UbDuo<A, B> >::ResultT>::RefT val(UbDuo<A, B>& d)
+{
+   return DuoValue<N, UbDuo<A, B> >::get(d);
+}
+
+// return Nth value of constant duo
+template <int N, typename A, typename B> 
+inline typename UbTypeOp<typename UbDuoT<N, UbDuo<A, B> >::ResultT>::RefConstT val(UbDuo<A, B> const& d)
+{
+   return DuoValue<N, UbDuo<A, B> >::get(d);
+}
+
+//duo6.hpp
+// partial specialization for UbDuo<> with only one field
+template <typename A>
+struct UbDuo<A,void> 
+{
+public:
+   typedef A    T1;  // type of first field
+   typedef void T2;  // type of second field
+   enum { N = 1 };   // number of fields
+
+private:
+   T1 value1;        // value of first field
+
+public:
+   // constructors
+   UbDuo() : value1() { }
+   UbDuo (T1 const & a) : value1(a) { }
+
+   // field access
+   T1& v1()             { return value1; }
+   T1 const& v1() const { return value1; }
+
+   void v2() { }
+   void v2() const { }
+
+   #ifdef CAB_RCF
+      template<class Archive>
+      void serialize(Archive & ar, const unsigned int version)
+      {
+         ar & value1;
+      }
+   #endif
+};
+
+//tupel1.hpp
+// type that represents unused type parameters
+class UbNullT 
+{
+};
+
+// UbTuple<> in general derives from UbTuple<> with one more UbNullT
+template <typename P1,
+          typename P2 = UbNullT,
+          typename P3 = UbNullT,
+          typename P4 = UbNullT,
+          typename P5 = UbNullT,
+          typename P6 = UbNullT,
+          typename P7 = UbNullT,
+          typename P8 = UbNullT >
+class UbTuple : public UbDuo<P1, typename UbTuple<P2,P3,P4,P5,P6,P7,P8,UbNullT>::BaseT> 
+{
+public:
+   typedef UbDuo<P1, typename UbTuple<P2,P3,P4,P5,P6,P7,P8,UbNullT>::BaseT>  BaseT;
+
+   // constructor:
+   UbTuple() {}
+   UbTuple( typename UbTypeOp<P1>::RefConstT a1,
+            typename UbTypeOp<P2>::RefConstT a2,
+            typename UbTypeOp<P3>::RefConstT a3 = UbNullT(),
+            typename UbTypeOp<P4>::RefConstT a4 = UbNullT(),
+            typename UbTypeOp<P5>::RefConstT a5 = UbNullT(),
+            typename UbTypeOp<P6>::RefConstT a6 = UbNullT(),
+            typename UbTypeOp<P7>::RefConstT a7 = UbNullT(),
+            typename UbTypeOp<P8>::RefConstT a8 = UbNullT() )
+      : BaseT(a1, UbTuple<P2,P3,P4,P5,P6,P7,P8,UbNullT>(a2,a3,a4,a5,a6,a7,a8))
+   {
+   }
+
+   // for implicit type conversion during assignments
+   template <typename U1,typename U2, typename U3, typename U4, typename U5, typename U6, typename U7, typename U8 >
+   UbTuple<P1,P2,P3,P4,P5,P6,P7,P8>& operator = ( const UbTuple<U1,U2,U3,U4,U5,U6,U7,U8>& rhs)
+   {
+      this->BaseT::operator=( typename UbTuple<U1,U2,U3,U4,U5,U6,U7,U8>::BaseT(rhs) );
+      return *this;
+   }
+
+};
+
+// specialization to end deriving recursion
+template <typename P1, typename P2>
+class UbTuple<P1,P2,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT> : public UbDuo<P1,P2> {
+public:
+   typedef UbDuo<P1,P2> BaseT;
+   
+   // constructor:
+   UbTuple() {}
+   UbTuple( typename UbTypeOp<P1>::RefConstT a1,
+            typename UbTypeOp<P2>::RefConstT a2,
+            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
+            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
+            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
+            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
+            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
+            typename UbTypeOp<UbNullT>::RefConstT = UbNullT() )
+      : BaseT(a1, a2) 
+   {
+   }
+
+   // for implicit type conversion during assignments
+   template <typename U1,typename U2 >
+   UbTuple<P1,P2>& operator = ( const UbTuple<U1,U2>& rhs)
+   {
+      this->BaseT::operator=( typename UbTuple<U1,U2>::BaseT(rhs) );
+      return *this;
+   }
+
+};
+
+// specialization for singletons
+template <typename P1>
+class UbTuple<P1,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT> : public UbDuo<P1,void>
+{
+public:
+   typedef UbDuo<P1,void> BaseT;
+
+   // constructor:
+   UbTuple() {}
+   UbTuple( typename UbTypeOp<P1>::RefConstT a1,
+            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
+            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
+            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
+            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
+            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
+            typename UbTypeOp<UbNullT>::RefConstT = UbNullT(),
+            typename UbTypeOp<UbNullT>::RefConstT = UbNullT() )
+      : BaseT(a1) 
+   {
+   }
+
+   // for implicit type conversion during assignments
+   template <typename U1 >
+   UbTuple<P1>& operator = ( const UbTuple<U1>& rhs)
+   {
+      this->v1() = rhs.v1();
+      return *this;
+   }
+
+};
+
+// convenience function for 1 argument
+template <typename T1> 
+inline UbTuple<T1> makeUbTuple(T1 const &a1)
+{
+   return UbTuple<T1>(a1);
+}
+
+// convenience function for 2 arguments
+template <typename T1, typename T2>
+inline UbTuple<T1,T2> makeUbTuple(T1 const &a1, T2 const &a2)
+{
+   return UbTuple<T1,T2>(a1,a2);
+}
+
+// convenience function for 3 arguments
+template <typename T1, typename T2, typename T3>
+inline UbTuple<T1,T2,T3> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3)
+{
+   return UbTuple<T1,T2,T3>(a1,a2,a3);
+}
+
+// convenience function for 4 arguments
+template <typename T1, typename T2, typename T3, typename T4>
+inline UbTuple<T1,T2,T3,T4> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4)
+{
+   return UbTuple<T1,T2,T3,T4>(a1,a2,a3,a4);
+}
+
+// convenience function for 5 arguments
+template <typename T1, typename T2, typename T3, typename T4, typename T5>
+inline UbTuple<T1,T2,T3,T4,T5> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4,T5 const &a5)
+{
+   return UbTuple<T1,T2,T3,T4,T5>(a1,a2,a3,a4,a5);
+}
+
+// convenience function for 6 arguments
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
+inline UbTuple<T1,T2,T3,T4,T5,T6> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4, T5 const &a5, T6 const &a6)
+{
+   return UbTuple<T1,T2,T3,T4,T5,T6>(a1,a2,a3,a4,a5,a6);
+}
+
+// convenience function for 7 arguments
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
+inline UbTuple<T1,T2,T3,T4,T5,T6,T7> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4, T5 const &a5, T6 const &a6, T7 const &a7)
+{
+   return UbTuple<T1,T2,T3,T4,T5,T6,T7>(a1,a2,a3,a4,a5,a6,a7);
+}
+
+// convenience function for 8 arguments
+template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
+inline UbTuple<T1,T2,T3,T4,T5,T6,T7,T8> makeUbTuple(T1 const &a1, T2 const &a2,T3 const &a3, T4 const &a4,T5 const &a5, T6 const &a6,T7 const &a7, T8 const &a8 )
+{
+   return UbTuple<T1,T2,T3,T4,T5,T6,T7,T8>(a1,a2,a3,a4,a5,a6,a7,a8);
+}
+
+//some typedefs
+typedef UbTuple<float,float>                               UbTupleFloat2;
+typedef UbTuple<float,float,float>                         UbTupleFloat3;
+typedef UbTuple<int,int>                                   UbTupleInt2;
+typedef UbTuple<int,int,int>                               UbTupleInt3;
+typedef UbTuple<int,int,int,int>                           UbTupleInt4;
+typedef UbTuple<int,int,int,int,int>                       UbTupleInt5;
+typedef UbTuple<int,int,int,int,int,int>                   UbTupleInt6;
+typedef UbTuple<int,int,int,int,int,int,int,int>           UbTupleInt8;
+typedef UbTuple<double,double>                             UbTupleDouble2;
+typedef UbTuple<double,double,double>                      UbTupleDouble3;
+typedef UbTuple<double,double,double,double>               UbTupleDouble4;
+typedef UbTuple<double,double,double,double,double,double> UbTupleDouble6;
+typedef UbTuple<std::string,double,double>                 UbTupleStringDouble2;
+typedef UbTuple<std::string,double,double,double>          UbTupleStringDouble3;
+typedef UbTuple<std::string,int,int,int>                   UbTupleStringInt3;
+typedef UbTuple<short,short,short,short>                   UbTupleShort4;
+typedef UbTuple<bool,bool,bool>                            UbTupleBool3;
+typedef UbTuple<int,double,double>                         UbTupleIntDouble2;
+typedef UbTuple<int, bool>                                 UbTupleIntBool;
+
+
+#endif //UBTUPLE_H
diff --git a/source/ThirdParty/Library/basics/utilities/Vector3D.cpp b/source/VirtualFluidsBasic/basics/utilities/Vector3D.cpp
similarity index 100%
rename from source/ThirdParty/Library/basics/utilities/Vector3D.cpp
rename to source/VirtualFluidsBasic/basics/utilities/Vector3D.cpp
diff --git a/source/ThirdParty/Library/basics/utilities/Vector3D.h b/source/VirtualFluidsBasic/basics/utilities/Vector3D.h
similarity index 100%
rename from source/ThirdParty/Library/basics/utilities/Vector3D.h
rename to source/VirtualFluidsBasic/basics/utilities/Vector3D.h
diff --git a/source/VirtualFluidsBasic/basics/writer/CMakePackage.txt b/source/VirtualFluidsBasic/basics/writer/CMakePackage.txt
new file mode 100644
index 0000000000000000000000000000000000000000..6ef17942b856d69df194c11f63050e950564927b
--- /dev/null
+++ b/source/VirtualFluidsBasic/basics/writer/CMakePackage.txt
@@ -0,0 +1,3 @@
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
+
diff --git a/source/ThirdParty/Library/basics/writer/WbWriter.h b/source/VirtualFluidsBasic/basics/writer/WbWriter.h
similarity index 98%
rename from source/ThirdParty/Library/basics/writer/WbWriter.h
rename to source/VirtualFluidsBasic/basics/writer/WbWriter.h
index cad742f8e343b05fedca049453673cd25ca4df3a..be83c735cd058b6572c97e1add8b6faca096f325 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriter.h
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriter.h
@@ -1,176 +1,176 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef WBWRITER_H
-#define WBWRITER_H
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif
-
-
-#include <vector>
-#include <string>
-#include <fstream>
-#include <sstream>
-#include <iostream>
-#include <map>
-
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbSystem.h>
-#include <basics/utilities/UbTuple.h>
-#include <basics/utilities/UbPointerWrapper.h>
-#include <basics/utilities/UbAutoRun.hpp>
-#include <basics/objects/ObFactory.h>
-
-class WbWriter
-{
-public:
-   OBCREATOR_EXT(WbWriter)
-
-   //////////////////////////////////////////////////////////////////////////
-   virtual ~WbWriter() 
-   {
-
-   }
-
-   //////////////////////////////////////////////////////////////////////////
-   //rein virtuelle Methoden
-   virtual std::string getFileExtension() = 0;
-
-   //////////////////////////////////////////////////////////////////////////
-   //nodes
-   virtual std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
-   virtual std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
-   virtual std::string writeNodesWithNodeDataDouble(const std::string& filename,std::vector< UbTupleDouble3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
-
-   //////////////////////////////////////////////////////////////////////////
-   //lines
-   //     0 ---- 1
-   //nodenumbering must start with 0!
-   virtual std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
-   virtual std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
-
-   //////////////////////////////////////////////////////////////////////////
-   //triangles
-   //cell numbering:
-   //                     2
-   //                      
-   //                  0 === 1
-   //nodenumbering must start with 0!
-   virtual std::string writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
-   virtual std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
-
-   //////////////////////////////////////////////////////////////////////////
-   //quads
-   //cell numbering:
-   //                  3---2
-   //                  |   |
-   //                  0---1
-   //nodenumbering must start with 0!
-   virtual std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
-   virtual std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
-   virtual std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
-   virtual std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, 
-                                                     std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames,
-                                                     std::vector< std::vector< double > >& celldata                                                                                       ){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
-
-   //////////////////////////////////////////////////////////////////////////
-   //octs
-   //     7 ---- 6
-   //    /|     /|
-   //   4 +--- 5 |
-   //   | |    | |
-   //   | 3 ---+ 2
-   //   |/     |/
-   //   0 ---- 1
-   virtual std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
-   virtual std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
-   virtual std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
-
-private:
-
-};
-
-
-#ifdef CAB_RCF
-//serialize von singletons muss hier etwas anders erfolgen ;-)
-template<class Archive>
-inline bool serializeWbWriter(Archive &ar, WbWriter*& writer)
-{
-   std::string writerID;
-
-   if( ArchiveTools::isReading(ar) )
-   {                                                                  
-      ar & writerID;
-      if(writerID!="no_WbWriter") writer = ObFactory<WbWriter>::getInstance()->createObject(writerID);
-      else                        writer = NULL;
-   }                                                                  
-   else /* if (ar.isWrite())) if(Archive::is_saving())*/                                      
-   {                                                                   
-      if(writer) writerID = writer->getClassObjectTypeID(); 
-      else       writerID = "no_WbWriter";
-      ar & writerID;
-   } 
-   return true;
-}
-//////////////////
-template<class Archive, class STL_container>
-inline bool serializeWbWriter(Archive &ar, STL_container& writers)
-{
-   int       nofCounter;
-   std::string    writerID;
-   WbWriter* dummy;
-
-   if( ArchiveTools::isReading(ar) )
-   {                                                                  
-      ar & nofCounter;
-      for(int i=0; i<nofCounter; i++)
-      {
-         serializeWbWriter(ar, dummy);
-         writers.push_back(dummy);
-      }
-   }                                                                  
-   else                                 
-   {                                                                   
-      nofCounter = (int)writers.size();
-      ar & nofCounter;
-      typename STL_container::iterator pos;
-      for(pos=writers.begin(); pos!=writers.end(); ++pos)
-         serializeWbWriter(ar, *pos);
-   }                                                                   
-
-   return true;
-}
-//////////////////////////////////////////////////////////////////////////
-// Spezialisierung des UbPointerWrappers fuer WbWriter... 
-// da man bei singletons keine serializemethode einbauen kann...
-template< >
-class UbPointerWrapper< WbWriter > 
-{
-public:
-   UbPointerWrapper() : pointer(NULL) {}
-
-   UbPointerWrapper(WbWriter* pointer) : pointer(pointer) {}
-
-   WbWriter* get() { return pointer; }
-
-   template<class Archive>
-   void serialize(Archive& ar, const unsigned int version) 
-   {
-      serializeWbWriter(ar, pointer);
-   }
-
-private:
-   WbWriter* pointer;
-};
-
-
-#endif //CAB_RCF
-
-
-#endif //WBWRITER_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef WBWRITER_H
+#define WBWRITER_H
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif
+
+
+#include <vector>
+#include <string>
+#include <fstream>
+#include <sstream>
+#include <iostream>
+#include <map>
+
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbSystem.h>
+#include <basics/utilities/UbTuple.h>
+#include <basics/utilities/UbPointerWrapper.h>
+#include <basics/utilities/UbAutoRun.hpp>
+#include <basics/objects/ObFactory.h>
+
+class WbWriter
+{
+public:
+   OBCREATOR_EXT(WbWriter)
+
+   //////////////////////////////////////////////////////////////////////////
+   virtual ~WbWriter() 
+   {
+
+   }
+
+   //////////////////////////////////////////////////////////////////////////
+   //rein virtuelle Methoden
+   virtual std::string getFileExtension() = 0;
+
+   //////////////////////////////////////////////////////////////////////////
+   //nodes
+   virtual std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
+   virtual std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
+   virtual std::string writeNodesWithNodeDataDouble(const std::string& filename,std::vector< UbTupleDouble3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
+
+   //////////////////////////////////////////////////////////////////////////
+   //lines
+   //     0 ---- 1
+   //nodenumbering must start with 0!
+   virtual std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
+   virtual std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
+
+   //////////////////////////////////////////////////////////////////////////
+   //triangles
+   //cell numbering:
+   //                     2
+   //                      
+   //                  0 === 1
+   //nodenumbering must start with 0!
+   virtual std::string writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
+   virtual std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
+
+   //////////////////////////////////////////////////////////////////////////
+   //quads
+   //cell numbering:
+   //                  3---2
+   //                  |   |
+   //                  0---1
+   //nodenumbering must start with 0!
+   virtual std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
+   virtual std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
+   virtual std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
+   virtual std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, 
+                                                     std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames,
+                                                     std::vector< std::vector< double > >& celldata                                                                                       ){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
+
+   //////////////////////////////////////////////////////////////////////////
+   //octs
+   //     7 ---- 6
+   //    /|     /|
+   //   4 +--- 5 |
+   //   | |    | |
+   //   | 3 ---+ 2
+   //   |/     |/
+   //   0 ---- 1
+   virtual std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
+   virtual std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
+   virtual std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() );  }
+
+private:
+
+};
+
+
+#ifdef CAB_RCF
+//serialize von singletons muss hier etwas anders erfolgen ;-)
+template<class Archive>
+inline bool serializeWbWriter(Archive &ar, WbWriter*& writer)
+{
+   std::string writerID;
+
+   if( ArchiveTools::isReading(ar) )
+   {                                                                  
+      ar & writerID;
+      if(writerID!="no_WbWriter") writer = ObFactory<WbWriter>::getInstance()->createObject(writerID);
+      else                        writer = NULL;
+   }                                                                  
+   else /* if (ar.isWrite())) if(Archive::is_saving())*/                                      
+   {                                                                   
+      if(writer) writerID = writer->getClassObjectTypeID(); 
+      else       writerID = "no_WbWriter";
+      ar & writerID;
+   } 
+   return true;
+}
+//////////////////
+template<class Archive, class STL_container>
+inline bool serializeWbWriter(Archive &ar, STL_container& writers)
+{
+   int       nofCounter;
+   std::string    writerID;
+   WbWriter* dummy;
+
+   if( ArchiveTools::isReading(ar) )
+   {                                                                  
+      ar & nofCounter;
+      for(int i=0; i<nofCounter; i++)
+      {
+         serializeWbWriter(ar, dummy);
+         writers.push_back(dummy);
+      }
+   }                                                                  
+   else                                 
+   {                                                                   
+      nofCounter = (int)writers.size();
+      ar & nofCounter;
+      typename STL_container::iterator pos;
+      for(pos=writers.begin(); pos!=writers.end(); ++pos)
+         serializeWbWriter(ar, *pos);
+   }                                                                   
+
+   return true;
+}
+//////////////////////////////////////////////////////////////////////////
+// Spezialisierung des UbPointerWrappers fuer WbWriter... 
+// da man bei singletons keine serializemethode einbauen kann...
+template< >
+class UbPointerWrapper< WbWriter > 
+{
+public:
+   UbPointerWrapper() : pointer(NULL) {}
+
+   UbPointerWrapper(WbWriter* pointer) : pointer(pointer) {}
+
+   WbWriter* get() { return pointer; }
+
+   template<class Archive>
+   void serialize(Archive& ar, const unsigned int version) 
+   {
+      serializeWbWriter(ar, pointer);
+   }
+
+private:
+   WbWriter* pointer;
+};
+
+
+#endif //CAB_RCF
+
+
+#endif //WBWRITER_H
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterAvsASCII.cpp b/source/VirtualFluidsBasic/basics/writer/WbWriterAvsASCII.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/writer/WbWriterAvsASCII.cpp
rename to source/VirtualFluidsBasic/basics/writer/WbWriterAvsASCII.cpp
index 7a9616fd73b6ee250b1e11ac266d8bea77e478b2..b7e279e36f727c4696e76b131cff5eb12e87bcab 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterAvsASCII.cpp
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterAvsASCII.cpp
@@ -1,896 +1,896 @@
-#include <basics/writer/WbWriterAvsASCII.h>
-#include <basics/utilities/UbLogger.h>
-#include <cstring>
-
-using namespace std;
-
-std::string WbWriterAvsASCII::writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuads to "<<avsfilename<<" - start");
-
-   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+avsfilename);
-   }
-   char magic = (char)7;
-   int   idummy;
-   float fdummy;
-
-   int nofNodes = (int)nodes.size();
-   int nofCells = (int)cells.size();
-
-   int nofNodeData     = 0;
-   int nofCellData     = 0;
-   int nofModelData    = 0;
-   int cellType        = 3; //=quad
-   int nofNodesPerCell = 4; 
-
-   out.write((char*)&magic,sizeof(char));      
-   out.write((char*)&nofNodes,sizeof(int));    
-   out.write((char*)&nofCells,sizeof(int));    
-   out.write((char*)&nofNodeData,sizeof(int)); 
-   out.write((char*)&nofCellData,sizeof(int)); 
-   out.write((char*)&nofModelData,sizeof(int));
-
-   idummy = (int)nofCells*nofNodesPerCell;
-   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-   }
-   //knotennummern der einzelnen zellen
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-   }
-
-   //coords
-   //x1-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x2-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x3-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //out<<"\n";
-
-   out.close(); 
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuads to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsASCII::writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOcts to "<<avsfilename<<" - start");
-
-   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden "+avsfilename);
-   }
-
-   char magic = (char)7;
-   int   idummy;
-   float fdummy;
-
-   int nofNodes = (int)nodes.size();
-   int nofCells = (int)cells.size();
-
-   int nofNodeData     = 0;
-   int nofCellData     = 0;
-   int nofModelData    = 0;
-   int cellType        = 7; //=hex
-   int nofNodesPerCell = 8; 
-
-   out.write((char*)&magic,sizeof(char));      
-   out.write((char*)&nofNodes,sizeof(int));    
-   out.write((char*)&nofCells,sizeof(int));    
-   out.write((char*)&nofNodeData,sizeof(int)); 
-   out.write((char*)&nofCellData,sizeof(int)); 
-   out.write((char*)&nofModelData,sizeof(int));
-
-   idummy = (int)nofCells*nofNodesPerCell;
-   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-   }
-   //knotennummern der einzelnen zellen
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-   }
-
-   //coords
-   //x1-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x2-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x3-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //out<<"\n";
-
-   
-   out.close(); 
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOcts to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsASCII::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeData to "<<avsfilename<<" - start");
-
-   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"write UCD File "+avsfilename+" konnte nicht geschrieben werden");
-   }
-   char magic = (char)7;
-   int   idummy;
-   float fdummy;
-
-   int nofNodes = (int)nodes.size();
-   int nofCells = (int)cells.size();
-
-   int nofNodeData     = (int)datanames.size();
-   int nofCellData     = 0;
-   int nofModelData    = 0;
-   int cellType        = 3; //=quad
-   int nofNodesPerCell = 4; 
-
-   out.write((char*)&magic,sizeof(char));      
-   out.write((char*)&nofNodes,sizeof(int));    
-   out.write((char*)&nofCells,sizeof(int));    
-   out.write((char*)&nofNodeData,sizeof(int)); 
-   out.write((char*)&nofCellData,sizeof(int)); 
-   out.write((char*)&nofModelData,sizeof(int));
-
-   idummy = (int)nofCells*nofNodesPerCell;
-   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-   }
-   //knotennummern der einzelnen zellen
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-   }
-
-   //coords
-   //x1-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x2-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x3-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //out<<"\n";
-
-   //NODE DATA
-   char labels[1024];
-   char units[1024];
-   strcpy(labels, "");
-   strcpy(units, "");
-
-   for(int d=0; d<nofNodeData-1; ++d) 
-      { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
-   strcat(labels, datanames[nofNodeData-1].c_str()); 
-
-   for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit.");
-   strcat(units, "no_unit");
-
-   out.write((char*)&labels,sizeof(labels));
-   out.write((char*)&units,sizeof(units));
-
-   //nof and type of data
-   idummy = nofNodeData;
-   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
-
-   idummy = 1;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
-
-   //min and max of data
-   fdummy = 0.0;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
-   fdummy = 1.0;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   //daten ins file schreiben
-   for(int d=0; d<nofNodeData; ++d)
-      for(int n=0; n<(int)nodedata[d].size(); n++)
-      { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
-
-   fdummy = 1.;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   out.close(); 
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeData to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsASCII::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithCellData to "<<avsfilename<<" - start");
-
-   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File  "+avsfilename+" konnte nicht geschrieben werden");
-   }
-
-   char magic = (char)7;
-   int   idummy;
-   float fdummy;
-
-   int nofNodes = (int)nodes.size();
-   int nofCells = (int)cells.size();
-
-   int nofNodeData     = 0;
-   int nofCellData     = (int)datanames.size();
-   int nofModelData    = 0;
-   int cellType        = 3; //=quad
-   int nofNodesPerCell = 4; 
-
-   out.write((char*)&magic,sizeof(char));      
-   out.write((char*)&nofNodes,sizeof(int));    
-   out.write((char*)&nofCells,sizeof(int));    
-   out.write((char*)&nofNodeData,sizeof(int)); 
-   out.write((char*)&nofCellData,sizeof(int)); 
-   out.write((char*)&nofModelData,sizeof(int));
-
-   idummy = (int)nofCells*nofNodesPerCell;
-   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-   }
-   //knotennummern der einzelnen zellen
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-   }
-
-   //coords
-   //x1-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x2-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x3-coords
-   fdummy=0.0;
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //out<<"\n";
-
-   //CELL DATA
-   char labels[1024];
-   char units[1024];
-   strcpy(labels, "");
-   strcpy(units, "");
-
-   for(int d=0; d<nofCellData-1; ++d) { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
-   strcat(labels, datanames[nofCellData-1].c_str()); 
-
-   for(int d=0; d<nofCellData-1; ++d) strcat(units, "no_unit.");
-   strcat(units, "no_unit");
-
-   out.write((char*)&labels,sizeof(labels));
-   out.write((char*)&units,sizeof(units));
-
-   //nof and type of data
-   idummy = nofCellData;
-   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
-
-   idummy = 1;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
-
-   //min and max of data
-   fdummy = 0.0;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
-   fdummy = 1.0;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   //daten ins file schreiben
-   for(int d=0; d<nofCellData; ++d)
-      for(int n=0; n<(int)celldata[d].size(); n++)
-         { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
-
-   fdummy = 1.;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   out.close(); 
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithCellData to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsASCII::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, vector< vector< double > >& celldata)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - start");
-
-   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File  "+avsfilename+" konnte nicht geschrieben werden");
-   }
-
-   char magic = (char)7;
-   int   idummy;
-   float fdummy;
-
-   int nofNodes = (int)nodes.size();
-   int nofCells = (int)cells.size();
-
-   int nofNodeData     = (int)nodedatanames.size();
-   int nofCellData     = (int)celldatanames.size();
-   int nofModelData    = 0;
-   int cellType        = 3; //=quad
-   int nofNodesPerCell = 4; 
-
-   out.write((char*)&magic,sizeof(char));      
-   out.write((char*)&nofNodes,sizeof(int));    
-   out.write((char*)&nofCells,sizeof(int));    
-   out.write((char*)&nofNodeData,sizeof(int)); 
-   out.write((char*)&nofCellData,sizeof(int)); 
-   out.write((char*)&nofModelData,sizeof(int));
-
-   idummy = (int)nofCells*nofNodesPerCell;
-   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-   }
-   //knotennummern der einzelnen zellen
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-   }
-
-   //coords
-   //x1-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x2-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x3-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //out<<"\n";
-
-   //NODE DATA
-   char nodelabels[1024];
-   char nodeunits[1024];
-   strcpy(nodelabels, "");
-   strcpy(nodeunits, "");
-
-   for(int d=0; d<nofNodeData-1; ++d) { strcat(nodelabels, nodedatanames[d].c_str() ); strcat(nodelabels,"."); }
-   strcat(nodelabels, nodedatanames[nofNodeData-1].c_str()); 
-
-   for(int i=0;i<(nofNodeData-1);i++) strcat(nodeunits, "no_unit.");
-   strcat(nodeunits, "no_unit");
-
-   out.write((char*)&nodelabels,sizeof(nodelabels));
-   out.write((char*)&nodeunits,sizeof(nodeunits));
-
-   //nof and type of data
-   idummy = nofNodeData;
-   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
-
-   idummy = 1;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
-
-   //min and max of data
-   fdummy = 0.0;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
-   fdummy = 1.0;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   //daten ins file schreiben
-   for(int d=0; d<nofNodeData; ++d)
-      for(int n=0; n<(int)nodedata[d].size(); n++)
-      { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
-
-   fdummy = 1.;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   //CELL DATA
-   char celllabels[1024];
-   char cellunits[1024];
-   strcpy(celllabels, "");
-   strcpy(cellunits, "");
-
-   for(int d=0; d<nofCellData-1; ++d) { strcat(celllabels, celldatanames[d].c_str() ); strcat(celllabels,"."); }
-   strcat(celllabels, celldatanames[nofCellData-1].c_str()); 
-
-   for(int d=0; d<nofCellData-1; ++d) strcat(cellunits, "no_unit.");
-   strcat(cellunits, "no_unit");
-
-   out.write((char*)&celllabels,sizeof(celllabels));
-   out.write((char*)&cellunits,sizeof(cellunits));
-
-   //nof and type of data
-   idummy = nofCellData;
-   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
-
-   idummy = 1;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
-
-   //min and max of data
-   fdummy = 0.0;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
-   fdummy = 1.0;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   //daten ins file schreiben
-   for(int d=0; d<nofCellData; ++d)
-      for(int n=0; n<(int)celldata[d].size(); n++)
-      { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
-
-   fdummy = 1.;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   out.close(); 
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsASCII::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeLines to "<<avsfilename<<" - start");
-
-   ofstream out(avsfilename.c_str(),ios::out);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out);}
-      if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden");
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofLines = (int)lines.size(); 
-   
-   out<<"# UCD-File created by WbWriterAvsASCII\n";
-   out<<nofNodes<<" "<<nofLines<<" 0 0 0 "<<endl;
-
-   for(int n=0; n<nofNodes; n++)
-      out<<n+1<<" "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n";
-
-   for(int l=0; l<nofLines; l++)
-       out<<l+1<<" 2 line "<< val<1>(lines[l])+1 <<" "<< val<2>(lines[l])+1 <<" "<<endl;
-
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeLines to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsASCII::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTriangles to "<<avsfilename<<" - start");
-
-   ofstream out(avsfilename.c_str(),ios::out);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out);}
-      if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden "+avsfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofTrian = (int)triangles.size(); 
-
-   out<<"# UCD-File created by WbWriterAvsASCII\n";
-   out<<nofNodes<<" "<<nofTrian<<" 0 0 0 "<<endl;
-
-   for(int n=0; n<nofNodes; n++)
-   out<<n+1<<" "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n";
-
-   for(int l=0; l<nofTrian; l++)
-   out<<l+1<<" 2 tri "<< val<1>(triangles[l])+1 <<" "<< val<2>(triangles[l])+1 <<" "<< val<3>(triangles[l])+1 <<" "<<endl;
-
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTriangles to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsASCII::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTrianglesWithNodeData to "<<avsfilename<<" - end");
-
-   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden");
-   }
-   char magic = (char)7;
-   int   idummy;
-   float fdummy;
-
-   int nofNodes = (int)nodes.size();
-   int nofCells = (int)cells.size();
-
-   int nofNodeData     = (int)datanames.size();
-   int nofCellData     = 0;
-   int nofModelData    = 0;
-   int cellType        = 2; //triangle
-   int nofNodesPerCell = 3; 
-
-   out.write((char*)&magic,sizeof(char));      
-   out.write((char*)&nofNodes,sizeof(int));    
-   out.write((char*)&nofCells,sizeof(int));    
-   out.write((char*)&nofNodeData,sizeof(int)); 
-   out.write((char*)&nofCellData,sizeof(int)); 
-   out.write((char*)&nofModelData,sizeof(int));
-
-   idummy = (int)nofCells*nofNodesPerCell;
-   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-   }
-   //knotennummern der einzelnen zellen
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-   }
-
-   //coords
-   //x1-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x2-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x3-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //out<<"\n";
-
-   //NODE DATA
-   char labels[1024];
-   char units[1024];
-   strcpy(labels, "");
-   strcpy(units, "");
-
-   for(int d=0; d<nofNodeData-1; ++d) 
-   { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
-   strcat(labels, datanames[nofNodeData-1].c_str()); 
-
-   for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit.");
-   strcat(units, "no_unit");
-
-   out.write((char*)&labels,sizeof(labels));
-   out.write((char*)&units,sizeof(units));
-
-   //nof and type of data
-   idummy = nofNodeData;
-   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
-
-   idummy = 1;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
-
-   //min and max of data
-   fdummy = 0.0;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
-   fdummy = 1.0;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   //daten ins file schreiben
-   for(int d=0; d<nofNodeData; ++d)
-      for(int n=0; n<(int)nodedata[d].size(); n++)
-      { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
-
-      fdummy = 1.;
-      for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   out.close(); 
-   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTrianglesWithNodeData to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsASCII::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata)
-{
-    string avsfilename = filename+getFileExtension();
-    UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithCellData to "<<avsfilename<<" - start");
-
-    ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-    if(!out)
-    { 
-       out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-       string path = UbSystem::getPathFromString(avsfilename);
-       if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-       if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden "+avsfilename);
-    }
-
-    char magic = (char)7;
-    int   idummy;
-    float fdummy;
-
-    int nofNodes = (int)nodes.size();
-    int nofCells = (int)cells.size();
-
-    int nofNodeData     = 0;
-    int nofCellData     = (int)datanames.size();
-    int nofModelData    = 0;
-    int cellType        = 7; //=hex
-    int nofNodesPerCell = 8; 
-
-    out.write((char*)&magic,sizeof(char));      
-    out.write((char*)&nofNodes,sizeof(int));    
-    out.write((char*)&nofCells,sizeof(int));    
-    out.write((char*)&nofNodeData,sizeof(int)); 
-    out.write((char*)&nofCellData,sizeof(int)); 
-    out.write((char*)&nofModelData,sizeof(int));
-
-    idummy = (int)nofCells*nofNodesPerCell;
-    out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-    for(int c=0; c<nofCells; c++)
-    {
-       idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-       idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-       idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-       idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-    }
-    //knotennummern der einzelnen zellen
-    for(int c=0; c<nofCells; c++)
-    {
-       idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-    }
-
-    //coords
-    //x1-coords
-    for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-    //x2-coords
-    for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-    //x3-coords
-    for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-    //out<<"\n";
-
-    //CELL DATA
-    char labels[1024];
-    char units[1024];
-    strcpy(labels, "");
-    strcpy(units, "");
-
-    for(int d=0; d<nofCellData-1; ++d) { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
-    strcat(labels, datanames[nofCellData-1].c_str()); 
-
-    for(int d=0; d<nofCellData-1; ++d) strcat(units, "no_unit.");
-    strcat(units, "no_unit");
-
-    out.write((char*)&labels,sizeof(labels));
-    out.write((char*)&units,sizeof(units));
-
-    //nof and type of data
-    idummy = nofCellData;
-    out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
-
-    idummy = 1;
-    for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
-
-    //min and max of data
-    fdummy = 0.0;
-    for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
-    fdummy = 1.0;
-    for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-    //daten ins file schreiben
-    for(int d=0; d<nofCellData; ++d)
-    for(int n=0; n<(int)celldata[d].size(); n++)
-    { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
-
-    fdummy = 1.;
-    for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-    out.close(); 
-    UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithCellData to "<<avsfilename<<" - end");
-
-    return avsfilename;
- }
-/*===============================================================================*/
-std::string WbWriterAvsASCII::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata)
-{
-    string avsfilename = filename+getFileExtension();
-    UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithNodeData to "<<avsfilename<<" - start");
-
-    ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-    if(!out)
-    { 
-       out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-       string path = UbSystem::getPathFromString(avsfilename);
-       if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-       if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden "+avsfilename);
-    }
-
-    if((int)nodedata.size()==0) throw UbException(UB_EXARGS,"no nodedata!!!");
-    if(nodes.size()!=nodedata[0].size()) throw UbException(UB_EXARGS,"nodedata != nofNodes!!!");
-
-    char magic = (char)7;
-    int   idummy;
-    float fdummy;
-
-    int nofNodes = (int)nodes.size();
-    int nofCells = (int)cells.size();
-
-    int nofNodeData     = (int)datanames.size();
-    int nofCellData     = 0;
-    int nofModelData    = 0;
-    int cellType        = 7; //=hex
-    int nofNodesPerCell = 8; 
-
-    out.write((char*)&magic,sizeof(char));      
-    out.write((char*)&nofNodes,sizeof(int));    
-    out.write((char*)&nofCells,sizeof(int));    
-    out.write((char*)&nofNodeData,sizeof(int)); 
-    out.write((char*)&nofCellData,sizeof(int)); 
-    out.write((char*)&nofModelData,sizeof(int));
-
-    idummy = (int)nofCells*nofNodesPerCell;
-    out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-    for(int c=0; c<nofCells; c++)
-    {
-       idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-       idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-       idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-       idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-    }
-    //knotennummern der einzelnen zellen
-    for(int c=0; c<nofCells; c++)
-    {
-       idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-    }
-
-    //coords
-    //x1-coords
-    for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-    //x2-coords
-    for(int n=0; n<nofNodes; n++)
-       { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-    //x3-coords
-    for(int n=0; n<nofNodes; n++)
-       { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-
-    //NODE DATA
-    char labels[1024];
-    char units[1024];
-    strcpy(labels, "");
-    strcpy(units, "");
-
-    for(int d=0; d<nofNodeData-1; ++d) 
-    { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
-    strcat(labels, datanames[nofNodeData-1].c_str()); 
-
-    for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit.");
-    strcat(units, "no_unit");
-
-    out.write((char*)&labels,sizeof(labels));
-    out.write((char*)&units,sizeof(units));
-
-    //nof and type of data
-    idummy = nofNodeData;
-    out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
-
-    idummy = 1;
-    for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
-
-    //min and max of data
-    fdummy = 0.0;
-    for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
-    fdummy = 1.0;
-    for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-    //daten ins file schreiben
-    for(int d=0; d<nofNodeData; ++d)
-       for(int n=0; n<(int)nodedata[d].size(); n++)
-       { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
-
-    fdummy = 1.;
-    for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-    out.close(); 
-    UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithNodeData to "<<avsfilename<<" - end");
-
-    return avsfilename;
- }
+#include <basics/writer/WbWriterAvsASCII.h>
+#include <basics/utilities/UbLogger.h>
+#include <cstring>
+
+using namespace std;
+
+std::string WbWriterAvsASCII::writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuads to "<<avsfilename<<" - start");
+
+   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+avsfilename);
+   }
+   char magic = (char)7;
+   int   idummy;
+   float fdummy;
+
+   int nofNodes = (int)nodes.size();
+   int nofCells = (int)cells.size();
+
+   int nofNodeData     = 0;
+   int nofCellData     = 0;
+   int nofModelData    = 0;
+   int cellType        = 3; //=quad
+   int nofNodesPerCell = 4; 
+
+   out.write((char*)&magic,sizeof(char));      
+   out.write((char*)&nofNodes,sizeof(int));    
+   out.write((char*)&nofCells,sizeof(int));    
+   out.write((char*)&nofNodeData,sizeof(int)); 
+   out.write((char*)&nofCellData,sizeof(int)); 
+   out.write((char*)&nofModelData,sizeof(int));
+
+   idummy = (int)nofCells*nofNodesPerCell;
+   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+   }
+   //knotennummern der einzelnen zellen
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+   }
+
+   //coords
+   //x1-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x2-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x3-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //out<<"\n";
+
+   out.close(); 
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuads to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsASCII::writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOcts to "<<avsfilename<<" - start");
+
+   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden "+avsfilename);
+   }
+
+   char magic = (char)7;
+   int   idummy;
+   float fdummy;
+
+   int nofNodes = (int)nodes.size();
+   int nofCells = (int)cells.size();
+
+   int nofNodeData     = 0;
+   int nofCellData     = 0;
+   int nofModelData    = 0;
+   int cellType        = 7; //=hex
+   int nofNodesPerCell = 8; 
+
+   out.write((char*)&magic,sizeof(char));      
+   out.write((char*)&nofNodes,sizeof(int));    
+   out.write((char*)&nofCells,sizeof(int));    
+   out.write((char*)&nofNodeData,sizeof(int)); 
+   out.write((char*)&nofCellData,sizeof(int)); 
+   out.write((char*)&nofModelData,sizeof(int));
+
+   idummy = (int)nofCells*nofNodesPerCell;
+   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+   }
+   //knotennummern der einzelnen zellen
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+   }
+
+   //coords
+   //x1-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x2-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x3-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //out<<"\n";
+
+   
+   out.close(); 
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOcts to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsASCII::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeData to "<<avsfilename<<" - start");
+
+   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"write UCD File "+avsfilename+" konnte nicht geschrieben werden");
+   }
+   char magic = (char)7;
+   int   idummy;
+   float fdummy;
+
+   int nofNodes = (int)nodes.size();
+   int nofCells = (int)cells.size();
+
+   int nofNodeData     = (int)datanames.size();
+   int nofCellData     = 0;
+   int nofModelData    = 0;
+   int cellType        = 3; //=quad
+   int nofNodesPerCell = 4; 
+
+   out.write((char*)&magic,sizeof(char));      
+   out.write((char*)&nofNodes,sizeof(int));    
+   out.write((char*)&nofCells,sizeof(int));    
+   out.write((char*)&nofNodeData,sizeof(int)); 
+   out.write((char*)&nofCellData,sizeof(int)); 
+   out.write((char*)&nofModelData,sizeof(int));
+
+   idummy = (int)nofCells*nofNodesPerCell;
+   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+   }
+   //knotennummern der einzelnen zellen
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+   }
+
+   //coords
+   //x1-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x2-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x3-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //out<<"\n";
+
+   //NODE DATA
+   char labels[1024];
+   char units[1024];
+   strcpy(labels, "");
+   strcpy(units, "");
+
+   for(int d=0; d<nofNodeData-1; ++d) 
+      { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
+   strcat(labels, datanames[nofNodeData-1].c_str()); 
+
+   for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit.");
+   strcat(units, "no_unit");
+
+   out.write((char*)&labels,sizeof(labels));
+   out.write((char*)&units,sizeof(units));
+
+   //nof and type of data
+   idummy = nofNodeData;
+   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
+
+   idummy = 1;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
+
+   //min and max of data
+   fdummy = 0.0;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
+   fdummy = 1.0;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   //daten ins file schreiben
+   for(int d=0; d<nofNodeData; ++d)
+      for(int n=0; n<(int)nodedata[d].size(); n++)
+      { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
+
+   fdummy = 1.;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   out.close(); 
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeData to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsASCII::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithCellData to "<<avsfilename<<" - start");
+
+   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File  "+avsfilename+" konnte nicht geschrieben werden");
+   }
+
+   char magic = (char)7;
+   int   idummy;
+   float fdummy;
+
+   int nofNodes = (int)nodes.size();
+   int nofCells = (int)cells.size();
+
+   int nofNodeData     = 0;
+   int nofCellData     = (int)datanames.size();
+   int nofModelData    = 0;
+   int cellType        = 3; //=quad
+   int nofNodesPerCell = 4; 
+
+   out.write((char*)&magic,sizeof(char));      
+   out.write((char*)&nofNodes,sizeof(int));    
+   out.write((char*)&nofCells,sizeof(int));    
+   out.write((char*)&nofNodeData,sizeof(int)); 
+   out.write((char*)&nofCellData,sizeof(int)); 
+   out.write((char*)&nofModelData,sizeof(int));
+
+   idummy = (int)nofCells*nofNodesPerCell;
+   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+   }
+   //knotennummern der einzelnen zellen
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+   }
+
+   //coords
+   //x1-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x2-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x3-coords
+   fdummy=0.0;
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //out<<"\n";
+
+   //CELL DATA
+   char labels[1024];
+   char units[1024];
+   strcpy(labels, "");
+   strcpy(units, "");
+
+   for(int d=0; d<nofCellData-1; ++d) { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
+   strcat(labels, datanames[nofCellData-1].c_str()); 
+
+   for(int d=0; d<nofCellData-1; ++d) strcat(units, "no_unit.");
+   strcat(units, "no_unit");
+
+   out.write((char*)&labels,sizeof(labels));
+   out.write((char*)&units,sizeof(units));
+
+   //nof and type of data
+   idummy = nofCellData;
+   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
+
+   idummy = 1;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
+
+   //min and max of data
+   fdummy = 0.0;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
+   fdummy = 1.0;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   //daten ins file schreiben
+   for(int d=0; d<nofCellData; ++d)
+      for(int n=0; n<(int)celldata[d].size(); n++)
+         { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
+
+   fdummy = 1.;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   out.close(); 
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithCellData to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsASCII::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, vector< vector< double > >& celldata)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - start");
+
+   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File  "+avsfilename+" konnte nicht geschrieben werden");
+   }
+
+   char magic = (char)7;
+   int   idummy;
+   float fdummy;
+
+   int nofNodes = (int)nodes.size();
+   int nofCells = (int)cells.size();
+
+   int nofNodeData     = (int)nodedatanames.size();
+   int nofCellData     = (int)celldatanames.size();
+   int nofModelData    = 0;
+   int cellType        = 3; //=quad
+   int nofNodesPerCell = 4; 
+
+   out.write((char*)&magic,sizeof(char));      
+   out.write((char*)&nofNodes,sizeof(int));    
+   out.write((char*)&nofCells,sizeof(int));    
+   out.write((char*)&nofNodeData,sizeof(int)); 
+   out.write((char*)&nofCellData,sizeof(int)); 
+   out.write((char*)&nofModelData,sizeof(int));
+
+   idummy = (int)nofCells*nofNodesPerCell;
+   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+   }
+   //knotennummern der einzelnen zellen
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+   }
+
+   //coords
+   //x1-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x2-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x3-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //out<<"\n";
+
+   //NODE DATA
+   char nodelabels[1024];
+   char nodeunits[1024];
+   strcpy(nodelabels, "");
+   strcpy(nodeunits, "");
+
+   for(int d=0; d<nofNodeData-1; ++d) { strcat(nodelabels, nodedatanames[d].c_str() ); strcat(nodelabels,"."); }
+   strcat(nodelabels, nodedatanames[nofNodeData-1].c_str()); 
+
+   for(int i=0;i<(nofNodeData-1);i++) strcat(nodeunits, "no_unit.");
+   strcat(nodeunits, "no_unit");
+
+   out.write((char*)&nodelabels,sizeof(nodelabels));
+   out.write((char*)&nodeunits,sizeof(nodeunits));
+
+   //nof and type of data
+   idummy = nofNodeData;
+   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
+
+   idummy = 1;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
+
+   //min and max of data
+   fdummy = 0.0;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
+   fdummy = 1.0;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   //daten ins file schreiben
+   for(int d=0; d<nofNodeData; ++d)
+      for(int n=0; n<(int)nodedata[d].size(); n++)
+      { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
+
+   fdummy = 1.;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   //CELL DATA
+   char celllabels[1024];
+   char cellunits[1024];
+   strcpy(celllabels, "");
+   strcpy(cellunits, "");
+
+   for(int d=0; d<nofCellData-1; ++d) { strcat(celllabels, celldatanames[d].c_str() ); strcat(celllabels,"."); }
+   strcat(celllabels, celldatanames[nofCellData-1].c_str()); 
+
+   for(int d=0; d<nofCellData-1; ++d) strcat(cellunits, "no_unit.");
+   strcat(cellunits, "no_unit");
+
+   out.write((char*)&celllabels,sizeof(celllabels));
+   out.write((char*)&cellunits,sizeof(cellunits));
+
+   //nof and type of data
+   idummy = nofCellData;
+   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
+
+   idummy = 1;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
+
+   //min and max of data
+   fdummy = 0.0;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
+   fdummy = 1.0;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   //daten ins file schreiben
+   for(int d=0; d<nofCellData; ++d)
+      for(int n=0; n<(int)celldata[d].size(); n++)
+      { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
+
+   fdummy = 1.;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   out.close(); 
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsASCII::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeLines to "<<avsfilename<<" - start");
+
+   ofstream out(avsfilename.c_str(),ios::out);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out);}
+      if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden");
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofLines = (int)lines.size(); 
+   
+   out<<"# UCD-File created by WbWriterAvsASCII\n";
+   out<<nofNodes<<" "<<nofLines<<" 0 0 0 "<<endl;
+
+   for(int n=0; n<nofNodes; n++)
+      out<<n+1<<" "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n";
+
+   for(int l=0; l<nofLines; l++)
+       out<<l+1<<" 2 line "<< val<1>(lines[l])+1 <<" "<< val<2>(lines[l])+1 <<" "<<endl;
+
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeLines to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsASCII::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTriangles to "<<avsfilename<<" - start");
+
+   ofstream out(avsfilename.c_str(),ios::out);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out);}
+      if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden "+avsfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofTrian = (int)triangles.size(); 
+
+   out<<"# UCD-File created by WbWriterAvsASCII\n";
+   out<<nofNodes<<" "<<nofTrian<<" 0 0 0 "<<endl;
+
+   for(int n=0; n<nofNodes; n++)
+   out<<n+1<<" "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n";
+
+   for(int l=0; l<nofTrian; l++)
+   out<<l+1<<" 2 tri "<< val<1>(triangles[l])+1 <<" "<< val<2>(triangles[l])+1 <<" "<< val<3>(triangles[l])+1 <<" "<<endl;
+
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTriangles to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsASCII::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTrianglesWithNodeData to "<<avsfilename<<" - end");
+
+   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden");
+   }
+   char magic = (char)7;
+   int   idummy;
+   float fdummy;
+
+   int nofNodes = (int)nodes.size();
+   int nofCells = (int)cells.size();
+
+   int nofNodeData     = (int)datanames.size();
+   int nofCellData     = 0;
+   int nofModelData    = 0;
+   int cellType        = 2; //triangle
+   int nofNodesPerCell = 3; 
+
+   out.write((char*)&magic,sizeof(char));      
+   out.write((char*)&nofNodes,sizeof(int));    
+   out.write((char*)&nofCells,sizeof(int));    
+   out.write((char*)&nofNodeData,sizeof(int)); 
+   out.write((char*)&nofCellData,sizeof(int)); 
+   out.write((char*)&nofModelData,sizeof(int));
+
+   idummy = (int)nofCells*nofNodesPerCell;
+   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+   }
+   //knotennummern der einzelnen zellen
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+   }
+
+   //coords
+   //x1-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x2-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x3-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //out<<"\n";
+
+   //NODE DATA
+   char labels[1024];
+   char units[1024];
+   strcpy(labels, "");
+   strcpy(units, "");
+
+   for(int d=0; d<nofNodeData-1; ++d) 
+   { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
+   strcat(labels, datanames[nofNodeData-1].c_str()); 
+
+   for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit.");
+   strcat(units, "no_unit");
+
+   out.write((char*)&labels,sizeof(labels));
+   out.write((char*)&units,sizeof(units));
+
+   //nof and type of data
+   idummy = nofNodeData;
+   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
+
+   idummy = 1;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
+
+   //min and max of data
+   fdummy = 0.0;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
+   fdummy = 1.0;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   //daten ins file schreiben
+   for(int d=0; d<nofNodeData; ++d)
+      for(int n=0; n<(int)nodedata[d].size(); n++)
+      { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
+
+      fdummy = 1.;
+      for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   out.close(); 
+   UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTrianglesWithNodeData to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsASCII::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata)
+{
+    string avsfilename = filename+getFileExtension();
+    UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithCellData to "<<avsfilename<<" - start");
+
+    ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+    if(!out)
+    { 
+       out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+       string path = UbSystem::getPathFromString(avsfilename);
+       if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+       if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden "+avsfilename);
+    }
+
+    char magic = (char)7;
+    int   idummy;
+    float fdummy;
+
+    int nofNodes = (int)nodes.size();
+    int nofCells = (int)cells.size();
+
+    int nofNodeData     = 0;
+    int nofCellData     = (int)datanames.size();
+    int nofModelData    = 0;
+    int cellType        = 7; //=hex
+    int nofNodesPerCell = 8; 
+
+    out.write((char*)&magic,sizeof(char));      
+    out.write((char*)&nofNodes,sizeof(int));    
+    out.write((char*)&nofCells,sizeof(int));    
+    out.write((char*)&nofNodeData,sizeof(int)); 
+    out.write((char*)&nofCellData,sizeof(int)); 
+    out.write((char*)&nofModelData,sizeof(int));
+
+    idummy = (int)nofCells*nofNodesPerCell;
+    out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+    for(int c=0; c<nofCells; c++)
+    {
+       idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+       idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+       idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+       idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+    }
+    //knotennummern der einzelnen zellen
+    for(int c=0; c<nofCells; c++)
+    {
+       idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+    }
+
+    //coords
+    //x1-coords
+    for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+    //x2-coords
+    for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+    //x3-coords
+    for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+    //out<<"\n";
+
+    //CELL DATA
+    char labels[1024];
+    char units[1024];
+    strcpy(labels, "");
+    strcpy(units, "");
+
+    for(int d=0; d<nofCellData-1; ++d) { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
+    strcat(labels, datanames[nofCellData-1].c_str()); 
+
+    for(int d=0; d<nofCellData-1; ++d) strcat(units, "no_unit.");
+    strcat(units, "no_unit");
+
+    out.write((char*)&labels,sizeof(labels));
+    out.write((char*)&units,sizeof(units));
+
+    //nof and type of data
+    idummy = nofCellData;
+    out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
+
+    idummy = 1;
+    for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
+
+    //min and max of data
+    fdummy = 0.0;
+    for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
+    fdummy = 1.0;
+    for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+    //daten ins file schreiben
+    for(int d=0; d<nofCellData; ++d)
+    for(int n=0; n<(int)celldata[d].size(); n++)
+    { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
+
+    fdummy = 1.;
+    for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+    out.close(); 
+    UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithCellData to "<<avsfilename<<" - end");
+
+    return avsfilename;
+ }
+/*===============================================================================*/
+std::string WbWriterAvsASCII::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata)
+{
+    string avsfilename = filename+getFileExtension();
+    UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithNodeData to "<<avsfilename<<" - start");
+
+    ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+    if(!out)
+    { 
+       out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+       string path = UbSystem::getPathFromString(avsfilename);
+       if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+       if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden "+avsfilename);
+    }
+
+    if((int)nodedata.size()==0) throw UbException(UB_EXARGS,"no nodedata!!!");
+    if(nodes.size()!=nodedata[0].size()) throw UbException(UB_EXARGS,"nodedata != nofNodes!!!");
+
+    char magic = (char)7;
+    int   idummy;
+    float fdummy;
+
+    int nofNodes = (int)nodes.size();
+    int nofCells = (int)cells.size();
+
+    int nofNodeData     = (int)datanames.size();
+    int nofCellData     = 0;
+    int nofModelData    = 0;
+    int cellType        = 7; //=hex
+    int nofNodesPerCell = 8; 
+
+    out.write((char*)&magic,sizeof(char));      
+    out.write((char*)&nofNodes,sizeof(int));    
+    out.write((char*)&nofCells,sizeof(int));    
+    out.write((char*)&nofNodeData,sizeof(int)); 
+    out.write((char*)&nofCellData,sizeof(int)); 
+    out.write((char*)&nofModelData,sizeof(int));
+
+    idummy = (int)nofCells*nofNodesPerCell;
+    out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+    for(int c=0; c<nofCells; c++)
+    {
+       idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+       idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+       idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+       idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+    }
+    //knotennummern der einzelnen zellen
+    for(int c=0; c<nofCells; c++)
+    {
+       idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+    }
+
+    //coords
+    //x1-coords
+    for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+    //x2-coords
+    for(int n=0; n<nofNodes; n++)
+       { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+    //x3-coords
+    for(int n=0; n<nofNodes; n++)
+       { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+
+    //NODE DATA
+    char labels[1024];
+    char units[1024];
+    strcpy(labels, "");
+    strcpy(units, "");
+
+    for(int d=0; d<nofNodeData-1; ++d) 
+    { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
+    strcat(labels, datanames[nofNodeData-1].c_str()); 
+
+    for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit.");
+    strcat(units, "no_unit");
+
+    out.write((char*)&labels,sizeof(labels));
+    out.write((char*)&units,sizeof(units));
+
+    //nof and type of data
+    idummy = nofNodeData;
+    out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
+
+    idummy = 1;
+    for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
+
+    //min and max of data
+    fdummy = 0.0;
+    for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
+    fdummy = 1.0;
+    for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+    //daten ins file schreiben
+    for(int d=0; d<nofNodeData; ++d)
+       for(int n=0; n<(int)nodedata[d].size(); n++)
+       { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
+
+    fdummy = 1.;
+    for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+    out.close(); 
+    UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithNodeData to "<<avsfilename<<" - end");
+
+    return avsfilename;
+ }
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterAvsASCII.h b/source/VirtualFluidsBasic/basics/writer/WbWriterAvsASCII.h
similarity index 98%
rename from source/ThirdParty/Library/basics/writer/WbWriterAvsASCII.h
rename to source/VirtualFluidsBasic/basics/writer/WbWriterAvsASCII.h
index 5c65e1683d3de61a6322be303be76bdfd7f5a677..8f7f97a759fb4bf9bd414769dcfd7adfbe8858b6 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterAvsASCII.h
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterAvsASCII.h
@@ -1,76 +1,76 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef WBWRITERAVSASCII_H
-#define WBWRITERAVSASCII_H
-
-#include <basics/writer/WbWriter.h>
-      
-class WbWriterAvsASCII : public WbWriter
-{
-public:
-   OBCREATOR_EXT( WbWriterAvsASCII )
-
-   static WbWriterAvsASCII* getInstance()
-   {
-      static WbWriterAvsASCII instance;
-      return &instance;
-   }
-
-private:
-   WbWriterAvsASCII() : WbWriter() {}                            
-   WbWriterAvsASCII( const WbWriterAvsASCII& );                  //no copy allowed 
-   const WbWriterAvsASCII& operator=( const WbWriterAvsASCII& ); //no copy allowed
-
-public:
-   std::string getFileExtension() { return ".ascii.inp"; }
-   
-   ///////////////////virtual std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells) = 0;
-   ///////////////////////////////////////////////////////
-   //lines
-   //     0 ---- 1
-   //nodenumbering must start with 0!
-   std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines);
-
-   //////////////////////////////////////////////////////////////////////////
-   //triangles
-   //cell numbering:
-   //                    2
-   //                       
-   //                  0---1
-   //nodenumbering must start with 0!
-   std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTuple<int,int,int> >& triangles);
-   std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-
-   //////////////////////////////////////////////////////////////////////////
-   //quads
-   //cell numbering:
-   //                  3---2
-   //                  |   |
-   //                  0---1
-   //nodenumbering must start with 0!
-   std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells);
-   std::string writeQuadsWithNodeData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-   std::string writeQuadsWithCellData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
-   std::string writeQuadsWithNodeAndCellData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames, std::vector< std::vector< double > >& celldata);
-
-   //////////////////////////////////////////////////////////////////////////
-   //octs
-   //     7 ---- 6
-   //    /|     /|
-   //   4 +--- 5 |
-   //   | |    | |
-   //   | 3 ---+ 2
-   //   |/     |/
-   //   0 ---- 1
-   std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
-   std::string writeOctsWithCellData(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& celldata);
-   std::string writeOctsWithNodeData(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& nodedata);
-};
-
-UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterAvsASCII ,WbWriter>::getInstance()), CAB_WbWriterAvsASCII);
-
-#endif //WBWRITERAVSASCII_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef WBWRITERAVSASCII_H
+#define WBWRITERAVSASCII_H
+
+#include <basics/writer/WbWriter.h>
+      
+class WbWriterAvsASCII : public WbWriter
+{
+public:
+   OBCREATOR_EXT( WbWriterAvsASCII )
+
+   static WbWriterAvsASCII* getInstance()
+   {
+      static WbWriterAvsASCII instance;
+      return &instance;
+   }
+
+private:
+   WbWriterAvsASCII() : WbWriter() {}                            
+   WbWriterAvsASCII( const WbWriterAvsASCII& );                  //no copy allowed 
+   const WbWriterAvsASCII& operator=( const WbWriterAvsASCII& ); //no copy allowed
+
+public:
+   std::string getFileExtension() { return ".ascii.inp"; }
+   
+   ///////////////////virtual std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells) = 0;
+   ///////////////////////////////////////////////////////
+   //lines
+   //     0 ---- 1
+   //nodenumbering must start with 0!
+   std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines);
+
+   //////////////////////////////////////////////////////////////////////////
+   //triangles
+   //cell numbering:
+   //                    2
+   //                       
+   //                  0---1
+   //nodenumbering must start with 0!
+   std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTuple<int,int,int> >& triangles);
+   std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+
+   //////////////////////////////////////////////////////////////////////////
+   //quads
+   //cell numbering:
+   //                  3---2
+   //                  |   |
+   //                  0---1
+   //nodenumbering must start with 0!
+   std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells);
+   std::string writeQuadsWithNodeData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+   std::string writeQuadsWithCellData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
+   std::string writeQuadsWithNodeAndCellData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames, std::vector< std::vector< double > >& celldata);
+
+   //////////////////////////////////////////////////////////////////////////
+   //octs
+   //     7 ---- 6
+   //    /|     /|
+   //   4 +--- 5 |
+   //   | |    | |
+   //   | 3 ---+ 2
+   //   |/     |/
+   //   0 ---- 1
+   std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
+   std::string writeOctsWithCellData(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& celldata);
+   std::string writeOctsWithNodeData(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& nodedata);
+};
+
+UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterAvsASCII ,WbWriter>::getInstance()), CAB_WbWriterAvsASCII);
+
+#endif //WBWRITERAVSASCII_H
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterAvsBinary.cpp b/source/VirtualFluidsBasic/basics/writer/WbWriterAvsBinary.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/writer/WbWriterAvsBinary.cpp
rename to source/VirtualFluidsBasic/basics/writer/WbWriterAvsBinary.cpp
index 34d1d3415cf6ca738b0343b334a9d158d783012a..27b5a16b3f19662d3a9679b3f750bd403346970c 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterAvsBinary.cpp
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterAvsBinary.cpp
@@ -1,975 +1,975 @@
-#include <basics/writer/WbWriterAvsBinary.h>
-#include <basics/writer/WbWriterAvsASCII.h>
-#include <basics/utilities/UbLogger.h>
-#include <cstring>
-
-using namespace std;
-
-std::string WbWriterAvsBinary::writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeLines to "<<avsfilename<<" - start");
-
-   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary); }
-      if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden");
-   }
-
-   char magic = (char)7;
-   int   idummy;
-   float fdummy;
-
-   int nofNodes = (int)nodes.size();
-   int nofCells = (int)lines.size();
-
-   int nofNodeData     = 0;
-   int nofCellData     = 0;
-   int nofModelData    = 0;
-   int cellType        = 1; //line
-   int nofNodesPerCell = 2; 
-
-   out.write((char*)&magic,sizeof(char));      
-   out.write((char*)&nofNodes,sizeof(int));    
-   out.write((char*)&nofCells,sizeof(int));    
-   out.write((char*)&nofNodeData,sizeof(int)); 
-   out.write((char*)&nofCellData,sizeof(int)); 
-   out.write((char*)&nofModelData,sizeof(int));
-
-   idummy = (int)nofCells*nofNodesPerCell;
-   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-   }
-   //knotennummern der einzelnen zellen
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy = val<1>(lines[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<2>(lines[c])+1; out.write((char*)&idummy,sizeof(int)); 
-     
-   }
-
-   //coords
-   //x1-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x2-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x3-coords
-   fdummy=0.0;
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //out<<"\n";
-
-   out.close(); 
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeLines to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsBinary::writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTuple<int,int,int> >& triangles)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTriangles to "<<avsfilename<<" - start");
-
-   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden");
-   }
-
-   char magic = (char)7;
-   int   idummy;
-   float fdummy;
-
-   int nofNodes = (int)nodes.size();
-   int nofCells = (int)triangles.size();
-
-   int nofNodeData     = 0;
-   int nofCellData     = 0;
-   int nofModelData    = 0;
-   int cellType        = 2; //triangle
-   int nofNodesPerCell = 3; 
-
-   out.write((char*)&magic,sizeof(char));      
-   out.write((char*)&nofNodes,sizeof(int));    
-   out.write((char*)&nofCells,sizeof(int));    
-   out.write((char*)&nofNodeData,sizeof(int)); 
-   out.write((char*)&nofCellData,sizeof(int)); 
-   out.write((char*)&nofModelData,sizeof(int));
-
-   idummy = (int)nofCells*nofNodesPerCell;
-   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-   }
-   //knotennummern der einzelnen zellen
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy = val<1>(triangles[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<2>(triangles[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<3>(triangles[c])+1; out.write((char*)&idummy,sizeof(int)); 
-
-   }
-
-   //coords
-   //x1-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x2-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x3-coords
-   fdummy=0.0;
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //out<<"\n";
-
-   out.close(); 
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTriangles to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsBinary::writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuads to "<<avsfilename<<" - start");
-
-   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden");
-   }
-   char magic = (char)7;
-   int   idummy;
-   float fdummy;
-
-   int nofNodes = (int)nodes.size();
-   int nofCells = (int)cells.size();
-
-   int nofNodeData     = 0;
-   int nofCellData     = 0;
-   int nofModelData    = 0;
-   int cellType        = 3; //=quad
-   int nofNodesPerCell = 4; 
-
-   out.write((char*)&magic,sizeof(char));      
-   out.write((char*)&nofNodes,sizeof(int));    
-   out.write((char*)&nofCells,sizeof(int));    
-   out.write((char*)&nofNodeData,sizeof(int)); 
-   out.write((char*)&nofCellData,sizeof(int)); 
-   out.write((char*)&nofModelData,sizeof(int));
-
-   idummy = (int)nofCells*nofNodesPerCell;
-   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-   }
-   //knotennummern der einzelnen zellen
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-   }
-
-   //coords
-   //x1-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x2-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x3-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //out<<"\n";
-
-  
-   out.close(); 
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuads to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsBinary::writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOcts to "<<avsfilename<<" - start");
-
-   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden");
-   }
-
-   char magic = (char)7;
-   int   idummy;
-   float fdummy;
-
-   int nofNodes = (int)nodes.size();
-   int nofCells = (int)cells.size();
-
-   int nofNodeData     = 0;
-   int nofCellData     = 0;
-   int nofModelData    = 0;
-   int cellType        = 7; //=hex
-   int nofNodesPerCell = 8; 
-
-   out.write((char*)&magic,sizeof(char));      
-   out.write((char*)&nofNodes,sizeof(int));    
-   out.write((char*)&nofCells,sizeof(int));    
-   out.write((char*)&nofNodeData,sizeof(int)); 
-   out.write((char*)&nofCellData,sizeof(int)); 
-   out.write((char*)&nofModelData,sizeof(int));
-
-   idummy = (int)nofCells*nofNodesPerCell;
-   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-   }
-   //knotennummern der einzelnen zellen
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-   }
-
-   //coords
-   //x1-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x2-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x3-coords
-   for(int n=0; n<nofNodes; n++)
-   { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //out<<"\n";
-
-
-   out.close(); 
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOcts to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsBinary::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTrianglesWithNodeData to "<<avsfilename<<" - start");
-
-   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden");
-   }
-   char magic = (char)7;
-   int   idummy;
-   float fdummy;
-
-   int nofNodes = (int)nodes.size();
-   int nofCells = (int)cells.size();
-
-   int nofNodeData     = (int)datanames.size();
-   int nofCellData     = 0;
-   int nofModelData    = 0;
-   int cellType        = 2; //triangle
-   int nofNodesPerCell = 3; 
-
-   out.write((char*)&magic,sizeof(char));      
-   out.write((char*)&nofNodes,sizeof(int));    
-   out.write((char*)&nofCells,sizeof(int));    
-   out.write((char*)&nofNodeData,sizeof(int)); 
-   out.write((char*)&nofCellData,sizeof(int)); 
-   out.write((char*)&nofModelData,sizeof(int));
-
-   idummy = (int)nofCells*nofNodesPerCell;
-   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-   }
-   //knotennummern der einzelnen zellen
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-   }
-
-   //coords
-   //x1-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x2-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x3-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //out<<"\n";
-
-   //NODE DATA
-   char labels[1024];
-   char units[1024];
-   strcpy(labels, "");
-   strcpy(units, "");
-
-   for(int d=0; d<nofNodeData-1; ++d) 
-      { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
-   strcat(labels, datanames[nofNodeData-1].c_str()); 
-
-   for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit.");
-   strcat(units, "no_unit");
-
-   out.write((char*)&labels,sizeof(labels));
-   out.write((char*)&units,sizeof(units));
-
-   //nof and type of data
-   idummy = nofNodeData;
-   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
-
-   idummy = 1;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
-
-   //min and max of data
-   fdummy = 0.0;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
-   fdummy = 1.0;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   //daten ins file schreiben
-   for(int d=0; d<nofNodeData; ++d)
-      for(int n=0; n<(int)nodedata[d].size(); n++)
-      { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
-
-   fdummy = 1.;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   out.close(); 
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTrianglesWithNodeData to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsBinary::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeData to "<<avsfilename<<" - start");
-
-   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden");
-   }
-   char magic = (char)7;
-   int   idummy;
-   float fdummy;
-
-   int nofNodes = (int)nodes.size();
-   int nofCells = (int)cells.size();
-
-   int nofNodeData     = (int)datanames.size();
-   int nofCellData     = 0;
-   int nofModelData    = 0;
-   int cellType        = 3; //=quad
-   int nofNodesPerCell = 4; 
-
-   out.write((char*)&magic,sizeof(char));      
-   out.write((char*)&nofNodes,sizeof(int));    
-   out.write((char*)&nofCells,sizeof(int));    
-   out.write((char*)&nofNodeData,sizeof(int)); 
-   out.write((char*)&nofCellData,sizeof(int)); 
-   out.write((char*)&nofModelData,sizeof(int));
-
-   idummy = (int)nofCells*nofNodesPerCell;
-   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-   }
-   //knotennummern der einzelnen zellen
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-   }
-
-   //coords
-   //x1-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x2-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x3-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //out<<"\n";
-
-   //NODE DATA
-   char labels[1024];
-   char units[1024];
-   strcpy(labels, "");
-   strcpy(units, "");
-
-   for(int d=0; d<nofNodeData-1; ++d) 
-      { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
-   strcat(labels, datanames[nofNodeData-1].c_str()); 
-
-   for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit.");
-   strcat(units, "no_unit");
-
-   out.write((char*)&labels,sizeof(labels));
-   out.write((char*)&units,sizeof(units));
-
-   //nof and type of data
-   idummy = nofNodeData;
-   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
-
-   idummy = 1;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
-
-   //min and max of data
-   fdummy = 0.0;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
-   fdummy = 1.0;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   //daten ins file schreiben
-   for(int d=0; d<nofNodeData; ++d)
-      for(int n=0; n<(int)nodedata[d].size(); n++)
-      { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
-
-   fdummy = 1.;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   out.close(); 
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeData to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsBinary::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithCellData to "<<avsfilename<<" - start");
-
-   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden");
-   }
-
-   char magic = (char)7;
-   int   idummy;
-   float fdummy;
-
-   int nofNodes = (int)nodes.size();
-   int nofCells = (int)cells.size();
-
-   int nofNodeData     = 0;
-   int nofCellData     = (int)datanames.size();
-   int nofModelData    = 0;
-   int cellType        = 3; //=quad
-   int nofNodesPerCell = 4; 
-
-   out.write((char*)&magic,sizeof(char));      
-   out.write((char*)&nofNodes,sizeof(int));    
-   out.write((char*)&nofCells,sizeof(int));    
-   out.write((char*)&nofNodeData,sizeof(int)); 
-   out.write((char*)&nofCellData,sizeof(int)); 
-   out.write((char*)&nofModelData,sizeof(int));
-
-   idummy = (int)nofCells*nofNodesPerCell;
-   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-   }
-   //knotennummern der einzelnen zellen
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-   }
-
-   //coords
-   //x1-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x2-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x3-coords
-   fdummy=0.0;
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //out<<"\n";
-
-   //CELL DATA
-   char labels[1024];
-   char units[1024];
-   strcpy(labels, "");
-   strcpy(units, "");
-
-   for(int d=0; d<nofCellData-1; ++d) { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
-   strcat(labels, datanames[nofCellData-1].c_str()); 
-
-   for(int d=0; d<nofCellData-1; ++d) strcat(units, "no_unit.");
-   strcat(units, "no_unit");
-
-   out.write((char*)&labels,sizeof(labels));
-   out.write((char*)&units,sizeof(units));
-
-   //nof and type of data
-   idummy = nofCellData;
-   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
-
-   idummy = 1;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
-
-   //min and max of data
-   fdummy = 0.0;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
-   fdummy = 1.0;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   //daten ins file schreiben
-   for(int d=0; d<nofCellData; ++d)
-      for(int n=0; n<(int)celldata[d].size(); n++)
-         { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
-
-   fdummy = 1.;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   out.close(); 
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithCellData to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsBinary::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, vector< vector< double > >& celldata)
-{
-   string avsfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - start");
-
-   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-      string path = UbSystem::getPathFromString(avsfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden");
-   }
-
-   char magic = (char)7;
-   int   idummy;
-   float fdummy;
-
-   int nofNodes = (int)nodes.size();
-   int nofCells = (int)cells.size();
-
-   int nofNodeData     = (int)nodedatanames.size();
-   int nofCellData     = (int)celldatanames.size();
-   int nofModelData    = 0;
-   int cellType        = 3; //=quad
-   int nofNodesPerCell = 4; 
-
-   out.write((char*)&magic,sizeof(char));      
-   out.write((char*)&nofNodes,sizeof(int));    
-   out.write((char*)&nofCells,sizeof(int));    
-   out.write((char*)&nofNodeData,sizeof(int)); 
-   out.write((char*)&nofCellData,sizeof(int)); 
-   out.write((char*)&nofModelData,sizeof(int));
-
-   idummy = (int)nofCells*nofNodesPerCell;
-   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-   }
-   //knotennummern der einzelnen zellen
-   for(int c=0; c<nofCells; c++)
-   {
-      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-   }
-
-   //coords
-   //x1-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x2-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //x3-coords
-   for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-   //out<<"\n";
-
-   //NODE DATA
-   char nodelabels[1024];
-   char nodeunits[1024];
-   strcpy(nodelabels, "");
-   strcpy(nodeunits, "");
-
-   for(int d=0; d<nofNodeData-1; ++d) { strcat(nodelabels, nodedatanames[d].c_str() ); strcat(nodelabels,"."); }
-   strcat(nodelabels, nodedatanames[nofNodeData-1].c_str()); 
-
-   for(int i=0;i<(nofNodeData-1);i++) strcat(nodeunits, "no_unit.");
-   strcat(nodeunits, "no_unit");
-
-   out.write((char*)&nodelabels,sizeof(nodelabels));
-   out.write((char*)&nodeunits,sizeof(nodeunits));
-
-   //nof and type of data
-   idummy = nofNodeData;
-   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
-
-   idummy = 1;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
-
-   //min and max of data
-   fdummy = 0.0;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
-   fdummy = 1.0;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   //daten ins file schreiben
-   for(int d=0; d<nofNodeData; ++d)
-      for(int n=0; n<(int)nodedata[d].size(); n++)
-      { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
-
-   fdummy = 1.;
-   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   //CELL DATA
-   char celllabels[1024];
-   char cellunits[1024];
-   strcpy(celllabels, "");
-   strcpy(cellunits, "");
-
-   for(int d=0; d<nofCellData-1; ++d) { strcat(celllabels, celldatanames[d].c_str() ); strcat(celllabels,"."); }
-   strcat(celllabels, celldatanames[nofCellData-1].c_str()); 
-
-   for(int d=0; d<nofCellData-1; ++d) strcat(cellunits, "no_unit.");
-   strcat(cellunits, "no_unit");
-
-   out.write((char*)&celllabels,sizeof(celllabels));
-   out.write((char*)&cellunits,sizeof(cellunits));
-
-   //nof and type of data
-   idummy = nofCellData;
-   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
-
-   idummy = 1;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
-
-   //min and max of data
-   fdummy = 0.0;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
-   fdummy = 1.0;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   //daten ins file schreiben
-   for(int d=0; d<nofCellData; ++d)
-      for(int n=0; n<(int)celldata[d].size(); n++)
-      { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
-
-   fdummy = 1.;
-   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-   out.close(); 
-   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - end");
-
-   return avsfilename;
-}
-/*===============================================================================*/
-std::string WbWriterAvsBinary::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata)
-{
-    string avsfilename = filename+getFileExtension();
-    UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithCellData to "<<avsfilename<<" - start");
-
-    ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-    if(!out)
-    { 
-       out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-       string path = UbSystem::getPathFromString(avsfilename);
-       if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-       if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden");
-    }
-
-    char magic = (char)7;
-    int   idummy;
-    float fdummy;
-
-    int nofNodes = (int)nodes.size();
-    int nofCells = (int)cells.size();
-
-    int nofNodeData     = 0;
-    int nofCellData     = (int)datanames.size();
-    int nofModelData    = 0;
-    int cellType        = 7; //=hex
-    int nofNodesPerCell = 8; 
-
-    out.write((char*)&magic,sizeof(char));      
-    out.write((char*)&nofNodes,sizeof(int));    
-    out.write((char*)&nofCells,sizeof(int));    
-    out.write((char*)&nofNodeData,sizeof(int)); 
-    out.write((char*)&nofCellData,sizeof(int)); 
-    out.write((char*)&nofModelData,sizeof(int));
-
-    idummy = (int)nofCells*nofNodesPerCell;
-    out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-    for(int c=0; c<nofCells; c++)
-    {
-       idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-       idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-       idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-       idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-    }
-    //knotennummern der einzelnen zellen
-    for(int c=0; c<nofCells; c++)
-    {
-       idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-    }
-
-    //coords
-    //x1-coords
-    for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-    //x2-coords
-    for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-    //x3-coords
-    for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-    //out<<"\n";
-
-    //CELL DATA
-    char labels[1024];
-    char units[1024];
-    strcpy(labels, "");
-    strcpy(units, "");
-
-    for(int d=0; d<nofCellData-1; ++d) { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
-    strcat(labels, datanames[nofCellData-1].c_str()); 
-
-    for(int d=0; d<nofCellData-1; ++d) strcat(units, "no_unit.");
-    strcat(units, "no_unit");
-
-    out.write((char*)&labels,sizeof(labels));
-    out.write((char*)&units,sizeof(units));
-
-    //nof and type of data
-    idummy = nofCellData;
-    out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
-
-    idummy = 1;
-    for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
-
-    //min and max of data
-    fdummy = 0.0;
-    for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
-    fdummy = 1.0;
-    for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-    //daten ins file schreiben
-    for(int d=0; d<nofCellData; ++d)
-    for(int n=0; n<(int)celldata[d].size(); n++)
-    { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
-
-    fdummy = 1.;
-    for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-    out.close(); 
-    UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithCellData to "<<avsfilename<<" - end");
-
-    return avsfilename;
- }
-/*===============================================================================*/
-std::string WbWriterAvsBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata)
-{
-    string avsfilename = filename+getFileExtension();
-    UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithNodeData to "<<avsfilename<<" - start");
-
-    ofstream out(avsfilename.c_str(),ios::out|ios::binary);
-    if(!out)
-    { 
-       out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-       string path = UbSystem::getPathFromString(avsfilename);
-       if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
-       if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden");
-    }
-
-    if((int)nodedata.size()==0) throw UbException(UB_EXARGS,"no nodedata!!!");
-    if(nodes.size()!=nodedata[0].size()) throw UbException(UB_EXARGS,"nodedata != nofNodes!!!");
-
-    char magic = (char)7;
-    int   idummy;
-    float fdummy;
-
-    int nofNodes = (int)nodes.size();
-    int nofCells = (int)cells.size();
-
-    int nofNodeData     = (int)datanames.size();
-    int nofCellData     = 0;
-    int nofModelData    = 0;
-    int cellType        = 7; //=hex
-    int nofNodesPerCell = 8; 
-
-    out.write((char*)&magic,sizeof(char));      
-    out.write((char*)&nofNodes,sizeof(int));    
-    out.write((char*)&nofCells,sizeof(int));    
-    out.write((char*)&nofNodeData,sizeof(int)); 
-    out.write((char*)&nofCellData,sizeof(int)); 
-    out.write((char*)&nofModelData,sizeof(int));
-
-    idummy = (int)nofCells*nofNodesPerCell;
-    out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
-    for(int c=0; c<nofCells; c++)
-    {
-       idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
-       idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
-       idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
-       idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
-    }
-    //knotennummern der einzelnen zellen
-    for(int c=0; c<nofCells; c++)
-    {
-       idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-       idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
-    }
-
-    //coords
-    //x1-coords
-    for(int n=0; n<nofNodes; n++)
-      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-    //x2-coords
-    for(int n=0; n<nofNodes; n++)
-       { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-    //x3-coords
-    for(int n=0; n<nofNodes; n++)
-       { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
-
-    //NODE DATA
-    char labels[1024];
-    char units[1024];
-    strcpy(labels, "");
-    strcpy(units, "");
-
-    for(int d=0; d<nofNodeData-1; ++d) 
-    { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
-    strcat(labels, datanames[nofNodeData-1].c_str()); 
-
-    for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit.");
-    strcat(units, "no_unit");
-
-    out.write((char*)&labels,sizeof(labels));
-    out.write((char*)&units,sizeof(units));
-
-    //nof and type of data
-    idummy = nofNodeData;
-    out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
-
-    idummy = 1;
-    for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
-
-    //min and max of data
-    fdummy = 0.0;
-    for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
-    fdummy = 1.0;
-    for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-    //daten ins file schreiben
-    for(int d=0; d<nofNodeData; ++d)
-       for(int n=0; n<(int)nodedata[d].size(); n++)
-       { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
-
-    fdummy = 1.;
-    for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
-
-    out.close(); 
-    UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithNodeData to "<<avsfilename<<" - end");
-
-    return avsfilename;
- }
+#include <basics/writer/WbWriterAvsBinary.h>
+#include <basics/writer/WbWriterAvsASCII.h>
+#include <basics/utilities/UbLogger.h>
+#include <cstring>
+
+using namespace std;
+
+std::string WbWriterAvsBinary::writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeLines to "<<avsfilename<<" - start");
+
+   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary); }
+      if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden");
+   }
+
+   char magic = (char)7;
+   int   idummy;
+   float fdummy;
+
+   int nofNodes = (int)nodes.size();
+   int nofCells = (int)lines.size();
+
+   int nofNodeData     = 0;
+   int nofCellData     = 0;
+   int nofModelData    = 0;
+   int cellType        = 1; //line
+   int nofNodesPerCell = 2; 
+
+   out.write((char*)&magic,sizeof(char));      
+   out.write((char*)&nofNodes,sizeof(int));    
+   out.write((char*)&nofCells,sizeof(int));    
+   out.write((char*)&nofNodeData,sizeof(int)); 
+   out.write((char*)&nofCellData,sizeof(int)); 
+   out.write((char*)&nofModelData,sizeof(int));
+
+   idummy = (int)nofCells*nofNodesPerCell;
+   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+   }
+   //knotennummern der einzelnen zellen
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy = val<1>(lines[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<2>(lines[c])+1; out.write((char*)&idummy,sizeof(int)); 
+     
+   }
+
+   //coords
+   //x1-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x2-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x3-coords
+   fdummy=0.0;
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //out<<"\n";
+
+   out.close(); 
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeLines to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsBinary::writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTuple<int,int,int> >& triangles)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTriangles to "<<avsfilename<<" - start");
+
+   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden");
+   }
+
+   char magic = (char)7;
+   int   idummy;
+   float fdummy;
+
+   int nofNodes = (int)nodes.size();
+   int nofCells = (int)triangles.size();
+
+   int nofNodeData     = 0;
+   int nofCellData     = 0;
+   int nofModelData    = 0;
+   int cellType        = 2; //triangle
+   int nofNodesPerCell = 3; 
+
+   out.write((char*)&magic,sizeof(char));      
+   out.write((char*)&nofNodes,sizeof(int));    
+   out.write((char*)&nofCells,sizeof(int));    
+   out.write((char*)&nofNodeData,sizeof(int)); 
+   out.write((char*)&nofCellData,sizeof(int)); 
+   out.write((char*)&nofModelData,sizeof(int));
+
+   idummy = (int)nofCells*nofNodesPerCell;
+   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+   }
+   //knotennummern der einzelnen zellen
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy = val<1>(triangles[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<2>(triangles[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<3>(triangles[c])+1; out.write((char*)&idummy,sizeof(int)); 
+
+   }
+
+   //coords
+   //x1-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x2-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x3-coords
+   fdummy=0.0;
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //out<<"\n";
+
+   out.close(); 
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTriangles to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsBinary::writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuads to "<<avsfilename<<" - start");
+
+   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden");
+   }
+   char magic = (char)7;
+   int   idummy;
+   float fdummy;
+
+   int nofNodes = (int)nodes.size();
+   int nofCells = (int)cells.size();
+
+   int nofNodeData     = 0;
+   int nofCellData     = 0;
+   int nofModelData    = 0;
+   int cellType        = 3; //=quad
+   int nofNodesPerCell = 4; 
+
+   out.write((char*)&magic,sizeof(char));      
+   out.write((char*)&nofNodes,sizeof(int));    
+   out.write((char*)&nofCells,sizeof(int));    
+   out.write((char*)&nofNodeData,sizeof(int)); 
+   out.write((char*)&nofCellData,sizeof(int)); 
+   out.write((char*)&nofModelData,sizeof(int));
+
+   idummy = (int)nofCells*nofNodesPerCell;
+   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+   }
+   //knotennummern der einzelnen zellen
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+   }
+
+   //coords
+   //x1-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x2-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x3-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //out<<"\n";
+
+  
+   out.close(); 
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuads to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsBinary::writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOcts to "<<avsfilename<<" - start");
+
+   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden");
+   }
+
+   char magic = (char)7;
+   int   idummy;
+   float fdummy;
+
+   int nofNodes = (int)nodes.size();
+   int nofCells = (int)cells.size();
+
+   int nofNodeData     = 0;
+   int nofCellData     = 0;
+   int nofModelData    = 0;
+   int cellType        = 7; //=hex
+   int nofNodesPerCell = 8; 
+
+   out.write((char*)&magic,sizeof(char));      
+   out.write((char*)&nofNodes,sizeof(int));    
+   out.write((char*)&nofCells,sizeof(int));    
+   out.write((char*)&nofNodeData,sizeof(int)); 
+   out.write((char*)&nofCellData,sizeof(int)); 
+   out.write((char*)&nofModelData,sizeof(int));
+
+   idummy = (int)nofCells*nofNodesPerCell;
+   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+   }
+   //knotennummern der einzelnen zellen
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+   }
+
+   //coords
+   //x1-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x2-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x3-coords
+   for(int n=0; n<nofNodes; n++)
+   { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //out<<"\n";
+
+
+   out.close(); 
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOcts to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsBinary::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTrianglesWithNodeData to "<<avsfilename<<" - start");
+
+   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden");
+   }
+   char magic = (char)7;
+   int   idummy;
+   float fdummy;
+
+   int nofNodes = (int)nodes.size();
+   int nofCells = (int)cells.size();
+
+   int nofNodeData     = (int)datanames.size();
+   int nofCellData     = 0;
+   int nofModelData    = 0;
+   int cellType        = 2; //triangle
+   int nofNodesPerCell = 3; 
+
+   out.write((char*)&magic,sizeof(char));      
+   out.write((char*)&nofNodes,sizeof(int));    
+   out.write((char*)&nofCells,sizeof(int));    
+   out.write((char*)&nofNodeData,sizeof(int)); 
+   out.write((char*)&nofCellData,sizeof(int)); 
+   out.write((char*)&nofModelData,sizeof(int));
+
+   idummy = (int)nofCells*nofNodesPerCell;
+   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+   }
+   //knotennummern der einzelnen zellen
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+   }
+
+   //coords
+   //x1-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x2-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x3-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //out<<"\n";
+
+   //NODE DATA
+   char labels[1024];
+   char units[1024];
+   strcpy(labels, "");
+   strcpy(units, "");
+
+   for(int d=0; d<nofNodeData-1; ++d) 
+      { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
+   strcat(labels, datanames[nofNodeData-1].c_str()); 
+
+   for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit.");
+   strcat(units, "no_unit");
+
+   out.write((char*)&labels,sizeof(labels));
+   out.write((char*)&units,sizeof(units));
+
+   //nof and type of data
+   idummy = nofNodeData;
+   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
+
+   idummy = 1;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
+
+   //min and max of data
+   fdummy = 0.0;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
+   fdummy = 1.0;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   //daten ins file schreiben
+   for(int d=0; d<nofNodeData; ++d)
+      for(int n=0; n<(int)nodedata[d].size(); n++)
+      { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
+
+   fdummy = 1.;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   out.close(); 
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTrianglesWithNodeData to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsBinary::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeData to "<<avsfilename<<" - start");
+
+   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden");
+   }
+   char magic = (char)7;
+   int   idummy;
+   float fdummy;
+
+   int nofNodes = (int)nodes.size();
+   int nofCells = (int)cells.size();
+
+   int nofNodeData     = (int)datanames.size();
+   int nofCellData     = 0;
+   int nofModelData    = 0;
+   int cellType        = 3; //=quad
+   int nofNodesPerCell = 4; 
+
+   out.write((char*)&magic,sizeof(char));      
+   out.write((char*)&nofNodes,sizeof(int));    
+   out.write((char*)&nofCells,sizeof(int));    
+   out.write((char*)&nofNodeData,sizeof(int)); 
+   out.write((char*)&nofCellData,sizeof(int)); 
+   out.write((char*)&nofModelData,sizeof(int));
+
+   idummy = (int)nofCells*nofNodesPerCell;
+   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+   }
+   //knotennummern der einzelnen zellen
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+   }
+
+   //coords
+   //x1-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x2-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x3-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //out<<"\n";
+
+   //NODE DATA
+   char labels[1024];
+   char units[1024];
+   strcpy(labels, "");
+   strcpy(units, "");
+
+   for(int d=0; d<nofNodeData-1; ++d) 
+      { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
+   strcat(labels, datanames[nofNodeData-1].c_str()); 
+
+   for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit.");
+   strcat(units, "no_unit");
+
+   out.write((char*)&labels,sizeof(labels));
+   out.write((char*)&units,sizeof(units));
+
+   //nof and type of data
+   idummy = nofNodeData;
+   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
+
+   idummy = 1;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
+
+   //min and max of data
+   fdummy = 0.0;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
+   fdummy = 1.0;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   //daten ins file schreiben
+   for(int d=0; d<nofNodeData; ++d)
+      for(int n=0; n<(int)nodedata[d].size(); n++)
+      { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
+
+   fdummy = 1.;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   out.close(); 
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeData to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsBinary::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithCellData to "<<avsfilename<<" - start");
+
+   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden");
+   }
+
+   char magic = (char)7;
+   int   idummy;
+   float fdummy;
+
+   int nofNodes = (int)nodes.size();
+   int nofCells = (int)cells.size();
+
+   int nofNodeData     = 0;
+   int nofCellData     = (int)datanames.size();
+   int nofModelData    = 0;
+   int cellType        = 3; //=quad
+   int nofNodesPerCell = 4; 
+
+   out.write((char*)&magic,sizeof(char));      
+   out.write((char*)&nofNodes,sizeof(int));    
+   out.write((char*)&nofCells,sizeof(int));    
+   out.write((char*)&nofNodeData,sizeof(int)); 
+   out.write((char*)&nofCellData,sizeof(int)); 
+   out.write((char*)&nofModelData,sizeof(int));
+
+   idummy = (int)nofCells*nofNodesPerCell;
+   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+   }
+   //knotennummern der einzelnen zellen
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+   }
+
+   //coords
+   //x1-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x2-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x3-coords
+   fdummy=0.0;
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //out<<"\n";
+
+   //CELL DATA
+   char labels[1024];
+   char units[1024];
+   strcpy(labels, "");
+   strcpy(units, "");
+
+   for(int d=0; d<nofCellData-1; ++d) { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
+   strcat(labels, datanames[nofCellData-1].c_str()); 
+
+   for(int d=0; d<nofCellData-1; ++d) strcat(units, "no_unit.");
+   strcat(units, "no_unit");
+
+   out.write((char*)&labels,sizeof(labels));
+   out.write((char*)&units,sizeof(units));
+
+   //nof and type of data
+   idummy = nofCellData;
+   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
+
+   idummy = 1;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
+
+   //min and max of data
+   fdummy = 0.0;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
+   fdummy = 1.0;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   //daten ins file schreiben
+   for(int d=0; d<nofCellData; ++d)
+      for(int n=0; n<(int)celldata[d].size(); n++)
+         { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
+
+   fdummy = 1.;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   out.close(); 
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithCellData to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsBinary::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, vector< vector< double > >& celldata)
+{
+   string avsfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - start");
+
+   ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+      string path = UbSystem::getPathFromString(avsfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden");
+   }
+
+   char magic = (char)7;
+   int   idummy;
+   float fdummy;
+
+   int nofNodes = (int)nodes.size();
+   int nofCells = (int)cells.size();
+
+   int nofNodeData     = (int)nodedatanames.size();
+   int nofCellData     = (int)celldatanames.size();
+   int nofModelData    = 0;
+   int cellType        = 3; //=quad
+   int nofNodesPerCell = 4; 
+
+   out.write((char*)&magic,sizeof(char));      
+   out.write((char*)&nofNodes,sizeof(int));    
+   out.write((char*)&nofCells,sizeof(int));    
+   out.write((char*)&nofNodeData,sizeof(int)); 
+   out.write((char*)&nofCellData,sizeof(int)); 
+   out.write((char*)&nofModelData,sizeof(int));
+
+   idummy = (int)nofCells*nofNodesPerCell;
+   out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+      idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+      idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+      idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+   }
+   //knotennummern der einzelnen zellen
+   for(int c=0; c<nofCells; c++)
+   {
+      idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+      idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+   }
+
+   //coords
+   //x1-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x2-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //x3-coords
+   for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+   //out<<"\n";
+
+   //NODE DATA
+   char nodelabels[1024];
+   char nodeunits[1024];
+   strcpy(nodelabels, "");
+   strcpy(nodeunits, "");
+
+   for(int d=0; d<nofNodeData-1; ++d) { strcat(nodelabels, nodedatanames[d].c_str() ); strcat(nodelabels,"."); }
+   strcat(nodelabels, nodedatanames[nofNodeData-1].c_str()); 
+
+   for(int i=0;i<(nofNodeData-1);i++) strcat(nodeunits, "no_unit.");
+   strcat(nodeunits, "no_unit");
+
+   out.write((char*)&nodelabels,sizeof(nodelabels));
+   out.write((char*)&nodeunits,sizeof(nodeunits));
+
+   //nof and type of data
+   idummy = nofNodeData;
+   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
+
+   idummy = 1;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
+
+   //min and max of data
+   fdummy = 0.0;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
+   fdummy = 1.0;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   //daten ins file schreiben
+   for(int d=0; d<nofNodeData; ++d)
+      for(int n=0; n<(int)nodedata[d].size(); n++)
+      { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
+
+   fdummy = 1.;
+   for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   //CELL DATA
+   char celllabels[1024];
+   char cellunits[1024];
+   strcpy(celllabels, "");
+   strcpy(cellunits, "");
+
+   for(int d=0; d<nofCellData-1; ++d) { strcat(celllabels, celldatanames[d].c_str() ); strcat(celllabels,"."); }
+   strcat(celllabels, celldatanames[nofCellData-1].c_str()); 
+
+   for(int d=0; d<nofCellData-1; ++d) strcat(cellunits, "no_unit.");
+   strcat(cellunits, "no_unit");
+
+   out.write((char*)&celllabels,sizeof(celllabels));
+   out.write((char*)&cellunits,sizeof(cellunits));
+
+   //nof and type of data
+   idummy = nofCellData;
+   out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
+
+   idummy = 1;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
+
+   //min and max of data
+   fdummy = 0.0;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
+   fdummy = 1.0;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   //daten ins file schreiben
+   for(int d=0; d<nofCellData; ++d)
+      for(int n=0; n<(int)celldata[d].size(); n++)
+      { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
+
+   fdummy = 1.;
+   for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+   out.close(); 
+   UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - end");
+
+   return avsfilename;
+}
+/*===============================================================================*/
+std::string WbWriterAvsBinary::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata)
+{
+    string avsfilename = filename+getFileExtension();
+    UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithCellData to "<<avsfilename<<" - start");
+
+    ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+    if(!out)
+    { 
+       out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+       string path = UbSystem::getPathFromString(avsfilename);
+       if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+       if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden");
+    }
+
+    char magic = (char)7;
+    int   idummy;
+    float fdummy;
+
+    int nofNodes = (int)nodes.size();
+    int nofCells = (int)cells.size();
+
+    int nofNodeData     = 0;
+    int nofCellData     = (int)datanames.size();
+    int nofModelData    = 0;
+    int cellType        = 7; //=hex
+    int nofNodesPerCell = 8; 
+
+    out.write((char*)&magic,sizeof(char));      
+    out.write((char*)&nofNodes,sizeof(int));    
+    out.write((char*)&nofCells,sizeof(int));    
+    out.write((char*)&nofNodeData,sizeof(int)); 
+    out.write((char*)&nofCellData,sizeof(int)); 
+    out.write((char*)&nofModelData,sizeof(int));
+
+    idummy = (int)nofCells*nofNodesPerCell;
+    out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+    for(int c=0; c<nofCells; c++)
+    {
+       idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+       idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+       idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+       idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+    }
+    //knotennummern der einzelnen zellen
+    for(int c=0; c<nofCells; c++)
+    {
+       idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+    }
+
+    //coords
+    //x1-coords
+    for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+    //x2-coords
+    for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+    //x3-coords
+    for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+    //out<<"\n";
+
+    //CELL DATA
+    char labels[1024];
+    char units[1024];
+    strcpy(labels, "");
+    strcpy(units, "");
+
+    for(int d=0; d<nofCellData-1; ++d) { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
+    strcat(labels, datanames[nofCellData-1].c_str()); 
+
+    for(int d=0; d<nofCellData-1; ++d) strcat(units, "no_unit.");
+    strcat(units, "no_unit");
+
+    out.write((char*)&labels,sizeof(labels));
+    out.write((char*)&units,sizeof(units));
+
+    //nof and type of data
+    idummy = nofCellData;
+    out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
+
+    idummy = 1;
+    for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
+
+    //min and max of data
+    fdummy = 0.0;
+    for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
+    fdummy = 1.0;
+    for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+    //daten ins file schreiben
+    for(int d=0; d<nofCellData; ++d)
+    for(int n=0; n<(int)celldata[d].size(); n++)
+    { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
+
+    fdummy = 1.;
+    for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+    out.close(); 
+    UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithCellData to "<<avsfilename<<" - end");
+
+    return avsfilename;
+ }
+/*===============================================================================*/
+std::string WbWriterAvsBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata)
+{
+    string avsfilename = filename+getFileExtension();
+    UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithNodeData to "<<avsfilename<<" - start");
+
+    ofstream out(avsfilename.c_str(),ios::out|ios::binary);
+    if(!out)
+    { 
+       out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+       string path = UbSystem::getPathFromString(avsfilename);
+       if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);}
+       if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden");
+    }
+
+    if((int)nodedata.size()==0) throw UbException(UB_EXARGS,"no nodedata!!!");
+    if(nodes.size()!=nodedata[0].size()) throw UbException(UB_EXARGS,"nodedata != nofNodes!!!");
+
+    char magic = (char)7;
+    int   idummy;
+    float fdummy;
+
+    int nofNodes = (int)nodes.size();
+    int nofCells = (int)cells.size();
+
+    int nofNodeData     = (int)datanames.size();
+    int nofCellData     = 0;
+    int nofModelData    = 0;
+    int cellType        = 7; //=hex
+    int nofNodesPerCell = 8; 
+
+    out.write((char*)&magic,sizeof(char));      
+    out.write((char*)&nofNodes,sizeof(int));    
+    out.write((char*)&nofCells,sizeof(int));    
+    out.write((char*)&nofNodeData,sizeof(int)); 
+    out.write((char*)&nofCellData,sizeof(int)); 
+    out.write((char*)&nofModelData,sizeof(int));
+
+    idummy = (int)nofCells*nofNodesPerCell;
+    out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell)
+    for(int c=0; c<nofCells; c++)
+    {
+       idummy=c+1;             out.write((char*)&idummy,sizeof(int)); //cell id
+       idummy=1;               out.write((char*)&idummy,sizeof(int)); //mat
+       idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell
+       idummy=cellType;        out.write((char*)&idummy,sizeof(int)); //cell type 
+    }
+    //knotennummern der einzelnen zellen
+    for(int c=0; c<nofCells; c++)
+    {
+       idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+       idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); 
+    }
+
+    //coords
+    //x1-coords
+    for(int n=0; n<nofNodes; n++)
+      { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+    //x2-coords
+    for(int n=0; n<nofNodes; n++)
+       { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+    //x3-coords
+    for(int n=0; n<nofNodes; n++)
+       { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); }
+
+    //NODE DATA
+    char labels[1024];
+    char units[1024];
+    strcpy(labels, "");
+    strcpy(units, "");
+
+    for(int d=0; d<nofNodeData-1; ++d) 
+    { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); }
+    strcat(labels, datanames[nofNodeData-1].c_str()); 
+
+    for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit.");
+    strcat(units, "no_unit");
+
+    out.write((char*)&labels,sizeof(labels));
+    out.write((char*)&units,sizeof(units));
+
+    //nof and type of data
+    idummy = nofNodeData;
+    out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare)
+
+    idummy = 1;
+    for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert
+
+    //min and max of data
+    fdummy = 0.0;
+    for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp
+    fdummy = 1.0;
+    for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+    //daten ins file schreiben
+    for(int d=0; d<nofNodeData; ++d)
+       for(int n=0; n<(int)nodedata[d].size(); n++)
+       { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); }
+
+    fdummy = 1.;
+    for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp
+
+    out.close(); 
+    UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithNodeData to "<<avsfilename<<" - end");
+
+    return avsfilename;
+ }
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterAvsBinary.h b/source/VirtualFluidsBasic/basics/writer/WbWriterAvsBinary.h
similarity index 98%
rename from source/ThirdParty/Library/basics/writer/WbWriterAvsBinary.h
rename to source/VirtualFluidsBasic/basics/writer/WbWriterAvsBinary.h
index 39a5019e92568ea529aacb257253fc5274a4ae2e..2ba0e78420012314f2f286f83d12866ee534cee8 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterAvsBinary.h
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterAvsBinary.h
@@ -1,74 +1,74 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef WBWRITERAVSBINARY_H
-#define WBWRITERAVSBINARY_H
-
-#include <basics/writer/WbWriter.h>
-
-class WbWriterAvsBinary : public WbWriter
-{
-public:
-   OBCREATOR_EXT( WbWriterAvsBinary )
-
-   static WbWriterAvsBinary* getInstance()
-   {
-      static WbWriterAvsBinary instance;
-      return &instance;
-   }
-private:
-   WbWriterAvsBinary() : WbWriter() {}                             
-   WbWriterAvsBinary( const WbWriterAvsBinary& );                  //no copy allowed 
-   const WbWriterAvsBinary& operator=( const WbWriterAvsBinary& ); //no copy allowed
-
-public:
-   std::string getFileExtension() { return ".bin.inp"; }
-
-   //////////////////////////////////////////////////////////////////////////
-   //lines
-   //     0 ---- 1
-   //nodenumbering must start with 0!
-   std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines);
-
-   //////////////////////////////////////////////////////////////////////////
-   //triangles
-   //cell numbering:
-   //                    2
-   //                      
-   //                  0---1
-   //nodenumbering must start with 0!
-   std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTuple<int,int,int> >& triangles);
-   std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-   
-   //////////////////////////////////////////////////////////////////////////
-   //quads
-   //cell numbering:
-   //                  3---2
-   //                  |   |
-   //                  0---1
-   //nodenumbering must start with 0!
-   std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells);
-   std::string writeQuadsWithNodeData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-   std::string writeQuadsWithCellData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
-   std::string writeQuadsWithNodeAndCellData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames, std::vector< std::vector< double > >& celldata);
-
-   //////////////////////////////////////////////////////////////////////////
-   //octs
-   //     7 ---- 6
-   //    /|     /|
-   //   4 +--- 5 |
-   //   | |    | |
-   //   | 3 ---+ 2
-   //   |/     |/
-   //   0 ---- 1
-   std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
-   std::string writeOctsWithCellData(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& celldata);
-   std::string writeOctsWithNodeData(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& nodedata);
-};
-
-UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterAvsBinary ,WbWriter>::getInstance()), CAB_WbWriterAvsBinary);
-
-#endif //WBWRITERAVSBINARY_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef WBWRITERAVSBINARY_H
+#define WBWRITERAVSBINARY_H
+
+#include <basics/writer/WbWriter.h>
+
+class WbWriterAvsBinary : public WbWriter
+{
+public:
+   OBCREATOR_EXT( WbWriterAvsBinary )
+
+   static WbWriterAvsBinary* getInstance()
+   {
+      static WbWriterAvsBinary instance;
+      return &instance;
+   }
+private:
+   WbWriterAvsBinary() : WbWriter() {}                             
+   WbWriterAvsBinary( const WbWriterAvsBinary& );                  //no copy allowed 
+   const WbWriterAvsBinary& operator=( const WbWriterAvsBinary& ); //no copy allowed
+
+public:
+   std::string getFileExtension() { return ".bin.inp"; }
+
+   //////////////////////////////////////////////////////////////////////////
+   //lines
+   //     0 ---- 1
+   //nodenumbering must start with 0!
+   std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines);
+
+   //////////////////////////////////////////////////////////////////////////
+   //triangles
+   //cell numbering:
+   //                    2
+   //                      
+   //                  0---1
+   //nodenumbering must start with 0!
+   std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTuple<int,int,int> >& triangles);
+   std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+   
+   //////////////////////////////////////////////////////////////////////////
+   //quads
+   //cell numbering:
+   //                  3---2
+   //                  |   |
+   //                  0---1
+   //nodenumbering must start with 0!
+   std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells);
+   std::string writeQuadsWithNodeData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+   std::string writeQuadsWithCellData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
+   std::string writeQuadsWithNodeAndCellData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames, std::vector< std::vector< double > >& celldata);
+
+   //////////////////////////////////////////////////////////////////////////
+   //octs
+   //     7 ---- 6
+   //    /|     /|
+   //   4 +--- 5 |
+   //   | |    | |
+   //   | 3 ---+ 2
+   //   |/     |/
+   //   0 ---- 1
+   std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
+   std::string writeOctsWithCellData(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& celldata);
+   std::string writeOctsWithNodeData(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& nodedata);
+};
+
+UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterAvsBinary ,WbWriter>::getInstance()), CAB_WbWriterAvsBinary);
+
+#endif //WBWRITERAVSBINARY_H
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterBOBJ.cpp b/source/VirtualFluidsBasic/basics/writer/WbWriterBOBJ.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/writer/WbWriterBOBJ.cpp
rename to source/VirtualFluidsBasic/basics/writer/WbWriterBOBJ.cpp
index 20b1774de592e73bd0bb95d52cffeeacd1431345..fa88708b2de715471fb3f04c69ab6c3c2d2d45e1 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterBOBJ.cpp
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterBOBJ.cpp
@@ -1,79 +1,79 @@
-#ifdef CAB_ZLIB
-   #include <basics/writer/WbWriterBOBJ.h>
-   #include <basics/utilities/UbLogger.h>
-   #include <cstring>
-
-   #include <zlib.h>
-
-
-   using namespace std;
-   /*===============================================================================*/
-   std::string WbWriterBOBJ::writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles)
-   {
-      string bobjFilename=filename+getFileExtension();
-      UBLOG(logDEBUG1,"WbWriterBOBJ::writeTriangles to "<<bobjFilename<<" - start");
-
-      gzFile gzf = gzopen( bobjFilename.c_str(), "wb1" );
-      
-      size_t nofNodes     = nodes.size(); 
-      size_t nofTriangles = triangles.size(); 
-
-      //write to file
-      size_t numVerts;
-      //double v[3];
-      if(sizeof(numVerts)!=4) { throw UbException(UB_EXARGS,"danger..."); }
-      numVerts = nofNodes;
-      gzwrite(gzf, &numVerts, sizeof(numVerts));
-
-      for(size_t k=0; k<nofNodes; k++) {
-         float vertp = val<1>(nodes[k]);
-         gzwrite(gzf, &vertp, sizeof(vertp));
-         vertp       = val<2>(nodes[k]);
-         gzwrite(gzf, &vertp, sizeof(vertp));
-         vertp       = val<3>(nodes[k]);
-         gzwrite(gzf, &vertp, sizeof(vertp));
-      }
-
-      //NORMAL VECTOR
-      //double n[3];
-      gzwrite(gzf, &numVerts, sizeof(numVerts));
-      for(size_t k=0; k<nofNodes; k++) {
-         //poly->GetPointData()->GetNormals()->GetTuple(k, n);
-         float normp = 0.0;//n[0];
-         gzwrite(gzf, &normp, sizeof(normp));
-         normp = 0.0;//n[1];
-         gzwrite(gzf, &normp, sizeof(normp));
-         normp = 0.0;//n[2];
-         gzwrite(gzf, &normp, sizeof(normp));
-      }
-
-      //vtkIdType npts = 3;
-      //vtkIdType* pts;
-      size_t numTris = nofTriangles;
-      gzwrite(gzf, &numTris, sizeof(numTris));
-      for(size_t k=0; k<nofTriangles/*(size_t)poly->GetNumberOfPolys()*/; k++) {
-         //poly->GetPolys()->GetNextCell(npts, pts);
-         //int triIndex = *pts;
-         //gzwrite(gzf, &triIndex, sizeof(triIndex)); 
-         //triIndex = *(pts+1);
-         //gzwrite(gzf, &triIndex, sizeof(triIndex)); 
-         //triIndex = *(pts+2);
-         //gzwrite(gzf, &triIndex, sizeof(triIndex));
-         //poly->GetPolys()->GetNextCell(npts, pts);
-         int triIndex = val<1>(triangles[k]);//*pts;
-         gzwrite(gzf, &triIndex, sizeof(triIndex)); 
-         triIndex     = val<2>(triangles[k]);//*(pts+1);
-         gzwrite(gzf, &triIndex, sizeof(triIndex)); 
-         triIndex     = val<3>(triangles[k]);//*(pts+2);
-         gzwrite(gzf, &triIndex, sizeof(triIndex));
-      }
-
-      gzclose( gzf );
-
-      UBLOG(logDEBUG1,"WbWriterBOBJ::writeTriangles to "<<bobjFilename<<" - end");
-
-      return bobjFilename;
-   }
-   /*===============================================================================*/
-
-#endif //CAB_ZLIB
+#ifdef CAB_ZLIB
+   #include <basics/writer/WbWriterBOBJ.h>
+   #include <basics/utilities/UbLogger.h>
+   #include <cstring>
+
+   #include <zlib.h>
+
+
+   using namespace std;
+   /*===============================================================================*/
+   std::string WbWriterBOBJ::writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles)
+   {
+      string bobjFilename=filename+getFileExtension();
+      UBLOG(logDEBUG1,"WbWriterBOBJ::writeTriangles to "<<bobjFilename<<" - start");
+
+      gzFile gzf = gzopen( bobjFilename.c_str(), "wb1" );
+      
+      size_t nofNodes     = nodes.size(); 
+      size_t nofTriangles = triangles.size(); 
+
+      //write to file
+      size_t numVerts;
+      //double v[3];
+      if(sizeof(numVerts)!=4) { throw UbException(UB_EXARGS,"danger..."); }
+      numVerts = nofNodes;
+      gzwrite(gzf, &numVerts, sizeof(numVerts));
+
+      for(size_t k=0; k<nofNodes; k++) {
+         float vertp = val<1>(nodes[k]);
+         gzwrite(gzf, &vertp, sizeof(vertp));
+         vertp       = val<2>(nodes[k]);
+         gzwrite(gzf, &vertp, sizeof(vertp));
+         vertp       = val<3>(nodes[k]);
+         gzwrite(gzf, &vertp, sizeof(vertp));
+      }
+
+      //NORMAL VECTOR
+      //double n[3];
+      gzwrite(gzf, &numVerts, sizeof(numVerts));
+      for(size_t k=0; k<nofNodes; k++) {
+         //poly->GetPointData()->GetNormals()->GetTuple(k, n);
+         float normp = 0.0;//n[0];
+         gzwrite(gzf, &normp, sizeof(normp));
+         normp = 0.0;//n[1];
+         gzwrite(gzf, &normp, sizeof(normp));
+         normp = 0.0;//n[2];
+         gzwrite(gzf, &normp, sizeof(normp));
+      }
+
+      //vtkIdType npts = 3;
+      //vtkIdType* pts;
+      size_t numTris = nofTriangles;
+      gzwrite(gzf, &numTris, sizeof(numTris));
+      for(size_t k=0; k<nofTriangles/*(size_t)poly->GetNumberOfPolys()*/; k++) {
+         //poly->GetPolys()->GetNextCell(npts, pts);
+         //int triIndex = *pts;
+         //gzwrite(gzf, &triIndex, sizeof(triIndex)); 
+         //triIndex = *(pts+1);
+         //gzwrite(gzf, &triIndex, sizeof(triIndex)); 
+         //triIndex = *(pts+2);
+         //gzwrite(gzf, &triIndex, sizeof(triIndex));
+         //poly->GetPolys()->GetNextCell(npts, pts);
+         int triIndex = val<1>(triangles[k]);//*pts;
+         gzwrite(gzf, &triIndex, sizeof(triIndex)); 
+         triIndex     = val<2>(triangles[k]);//*(pts+1);
+         gzwrite(gzf, &triIndex, sizeof(triIndex)); 
+         triIndex     = val<3>(triangles[k]);//*(pts+2);
+         gzwrite(gzf, &triIndex, sizeof(triIndex));
+      }
+
+      gzclose( gzf );
+
+      UBLOG(logDEBUG1,"WbWriterBOBJ::writeTriangles to "<<bobjFilename<<" - end");
+
+      return bobjFilename;
+   }
+   /*===============================================================================*/
+
+#endif //CAB_ZLIB
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterBOBJ.h b/source/VirtualFluidsBasic/basics/writer/WbWriterBOBJ.h
similarity index 97%
rename from source/ThirdParty/Library/basics/writer/WbWriterBOBJ.h
rename to source/VirtualFluidsBasic/basics/writer/WbWriterBOBJ.h
index fec3454c3d4cbafb5d360c37f99a3a847f052dec..1d033c952ac2db021146a8e9ee20d9398ebae45e 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterBOBJ.h
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterBOBJ.h
@@ -1,40 +1,40 @@
-#ifdef CAB_ZLIB
-   #ifndef WBWRITERBOBJ_H
-   #define WBWRITERBOBJ_H
-
-   #include <string>
-   #include <basics/writer/WbWriter.h>
-
-   class WbWriterBOBJ  : public WbWriter
-   {
-   public:
-      OBCREATOR_EXT( WbWriterBOBJ )
-
-         static WbWriterBOBJ* getInstance()
-      {
-         static WbWriterBOBJ instance;
-         return &instance;
-      }
-   private:
-      WbWriterBOBJ() : WbWriter() 
-      {
-         if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char  type mismatch");
-         if(sizeof(int)          !=4) throw UbException(UB_EXARGS,"error int   type mismatch");
-         if(sizeof(float)        !=4) throw UbException(UB_EXARGS,"error float type mismatch");
-      }
-      WbWriterBOBJ( const WbWriterBOBJ& );                  //no copy allowed 
-      const WbWriterBOBJ& operator=( const WbWriterBOBJ& ); //no copy allowed
-
-      static std::string  pvdEndTag;
-
-   public:
-      std::string getFileExtension()  { return "BOBJ.gz"; }
-
-      std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles);
-   };
-
-   UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterBOBJ ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlASCII);
-
-   #endif //WBWRITERBOBJ_H
-
-#endif //CAB_ZLIB
+#ifdef CAB_ZLIB
+   #ifndef WBWRITERBOBJ_H
+   #define WBWRITERBOBJ_H
+
+   #include <string>
+   #include <basics/writer/WbWriter.h>
+
+   class WbWriterBOBJ  : public WbWriter
+   {
+   public:
+      OBCREATOR_EXT( WbWriterBOBJ )
+
+         static WbWriterBOBJ* getInstance()
+      {
+         static WbWriterBOBJ instance;
+         return &instance;
+      }
+   private:
+      WbWriterBOBJ() : WbWriter() 
+      {
+         if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char  type mismatch");
+         if(sizeof(int)          !=4) throw UbException(UB_EXARGS,"error int   type mismatch");
+         if(sizeof(float)        !=4) throw UbException(UB_EXARGS,"error float type mismatch");
+      }
+      WbWriterBOBJ( const WbWriterBOBJ& );                  //no copy allowed 
+      const WbWriterBOBJ& operator=( const WbWriterBOBJ& ); //no copy allowed
+
+      static std::string  pvdEndTag;
+
+   public:
+      std::string getFileExtension()  { return "BOBJ.gz"; }
+
+      std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles);
+   };
+
+   UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterBOBJ ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlASCII);
+
+   #endif //WBWRITERBOBJ_H
+
+#endif //CAB_ZLIB
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterSunflow.cpp b/source/VirtualFluidsBasic/basics/writer/WbWriterSunflow.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/writer/WbWriterSunflow.cpp
rename to source/VirtualFluidsBasic/basics/writer/WbWriterSunflow.cpp
index 4fa1a6381babc0837a2f3c65c576cfe76b75431c..6adbc274aec46f351b0d2cfc0f42340fcc6368ab 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterSunflow.cpp
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterSunflow.cpp
@@ -1,112 +1,112 @@
-#include <basics/writer/WbWriterSunflow.h>
-#include <basics/utilities/UbLogger.h>
-#include <cstring>
-
-using namespace std;
-
-/*===============================================================================*/
-std::string WbWriterSunflow::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles)
-{
-   string sunflowFilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterSunflow::writeTriangles to "<<sunflowFilename<<" - start");
-
-   std::ofstream out(sunflowFilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(sunflowFilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(sunflowFilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+sunflowFilename);
-   }
-
-   // General part
-
-   // Image details
-   out<<"image {"              <<endl;
-   out<<"   resolution 640 480"<<endl;
-   out<<"   aa 0 1"            <<endl;
-   out<<"   filter mitchell"   <<endl;
-   out<<"}"                    <<endl<<endl;
-
-   // Camera position
-   out<<"camera {"                 <<endl;
-   out<<"   type pinhole"          <<endl;
-   out<<"   eye    -0.25 -0.3 0.13"<<endl;
-   out<<"   target -0.1 0.1 0.13"  <<endl;
-   out<<"   up     0 0 1"          <<endl;
-   out<<"   fov    60"             <<endl;
-   out<<"   aspect 1.333333"       <<endl;
-   out<<"}"                        <<endl<<endl;
-
-   // Light
-   out<<"light {"                  <<endl;
-   out<<"   type ibl"              <<endl;
-   out<<"   image sky_small.hdr"   <<endl;
-   out<<"   center 0 -1 0"         <<endl;
-   out<<"   up 0 0 1"              <<endl;
-   out<<"   lock true"             <<endl;
-   out<<"   samples 200"           <<endl;
-   out<<"}"                        <<endl<<endl;
-
-   // Shaders
-   out<<"shader {"                 <<endl;
-   out<<"   name default-shader"   <<endl;
-   out<<"   type diffuse"          <<endl;
-   out<<"   diff 0.25 0.25 0.25"   <<endl;
-   out<<"}"                        <<endl<<endl;
-
-   out<<"shader {"                 <<endl;
-   out<<"   name Glass"            <<endl;
-   out<<"   type glass"            <<endl;
-   out<<"   eta 1.333"             <<endl;
-   out<<"   color 0.1 0.3 0.8"     <<endl;
-   out<<"}"                        <<endl<<endl;
-                                   
-   out<<"shader {"                 <<endl;
-   out<<"   name Mirror"           <<endl;
-   out<<"   type mirror"           <<endl;
-   out<<"   refl 0.7 0.7 0.7"      <<endl;
-   out<<"}"                        <<endl<<endl;
-
-   // Objects
-   // a) Ground plane
-   out<<"object {"                 <<endl;
-   out<<"   shader default-shader" <<endl;
-   out<<"   type plane"            <<endl;
-   out<<"   p 0 0 0"               <<endl;
-   out<<"   n 0 0 1"               <<endl;
-   out<<"}"                        <<endl<<endl;
-
-   // b) Mesh
-   out<<"object {"                 <<endl;
-   out<<"   shader Glass"          <<endl;
-   out<<"   transform {"           <<endl;
-   out<<"      rotatey 270.0"      <<endl;
-   out<<"   }"                     <<endl;
-   out<<"   type generic-mesh"     <<endl;
-   out<<"      name polySurfac"    <<endl<<endl;
-
-
-   // POINTS SECTION
-   int nofNodes = (int)nodes.size(); 
-   out<<"   points "<<nofNodes<<endl;
-   for(int n=0; n<nofNodes; n++)
-      out<<"      "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<endl;
-
-   // TRIANGLES SECTION
-   int nofTriangles= (int)triangles.size(); 
-   out<<"   triangles "<<nofTriangles<<endl;
-   for(int c=0; c<nofTriangles; c++)
-      out<<"      "<<val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<endl;
-
-   // FOOTER
-   out<<"   normals none" << endl;
-   out<<"   uvs none"     << endl;
-   out<<"}"               << endl;
-
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterSunflow::writeTriangles to "<<sunflowFilename<<" - end");
-
-   return sunflowFilename;
-}
-/*===============================================================================*/
+#include <basics/writer/WbWriterSunflow.h>
+#include <basics/utilities/UbLogger.h>
+#include <cstring>
+
+using namespace std;
+
+/*===============================================================================*/
+std::string WbWriterSunflow::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles)
+{
+   string sunflowFilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterSunflow::writeTriangles to "<<sunflowFilename<<" - start");
+
+   std::ofstream out(sunflowFilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(sunflowFilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(sunflowFilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+sunflowFilename);
+   }
+
+   // General part
+
+   // Image details
+   out<<"image {"              <<endl;
+   out<<"   resolution 640 480"<<endl;
+   out<<"   aa 0 1"            <<endl;
+   out<<"   filter mitchell"   <<endl;
+   out<<"}"                    <<endl<<endl;
+
+   // Camera position
+   out<<"camera {"                 <<endl;
+   out<<"   type pinhole"          <<endl;
+   out<<"   eye    -0.25 -0.3 0.13"<<endl;
+   out<<"   target -0.1 0.1 0.13"  <<endl;
+   out<<"   up     0 0 1"          <<endl;
+   out<<"   fov    60"             <<endl;
+   out<<"   aspect 1.333333"       <<endl;
+   out<<"}"                        <<endl<<endl;
+
+   // Light
+   out<<"light {"                  <<endl;
+   out<<"   type ibl"              <<endl;
+   out<<"   image sky_small.hdr"   <<endl;
+   out<<"   center 0 -1 0"         <<endl;
+   out<<"   up 0 0 1"              <<endl;
+   out<<"   lock true"             <<endl;
+   out<<"   samples 200"           <<endl;
+   out<<"}"                        <<endl<<endl;
+
+   // Shaders
+   out<<"shader {"                 <<endl;
+   out<<"   name default-shader"   <<endl;
+   out<<"   type diffuse"          <<endl;
+   out<<"   diff 0.25 0.25 0.25"   <<endl;
+   out<<"}"                        <<endl<<endl;
+
+   out<<"shader {"                 <<endl;
+   out<<"   name Glass"            <<endl;
+   out<<"   type glass"            <<endl;
+   out<<"   eta 1.333"             <<endl;
+   out<<"   color 0.1 0.3 0.8"     <<endl;
+   out<<"}"                        <<endl<<endl;
+                                   
+   out<<"shader {"                 <<endl;
+   out<<"   name Mirror"           <<endl;
+   out<<"   type mirror"           <<endl;
+   out<<"   refl 0.7 0.7 0.7"      <<endl;
+   out<<"}"                        <<endl<<endl;
+
+   // Objects
+   // a) Ground plane
+   out<<"object {"                 <<endl;
+   out<<"   shader default-shader" <<endl;
+   out<<"   type plane"            <<endl;
+   out<<"   p 0 0 0"               <<endl;
+   out<<"   n 0 0 1"               <<endl;
+   out<<"}"                        <<endl<<endl;
+
+   // b) Mesh
+   out<<"object {"                 <<endl;
+   out<<"   shader Glass"          <<endl;
+   out<<"   transform {"           <<endl;
+   out<<"      rotatey 270.0"      <<endl;
+   out<<"   }"                     <<endl;
+   out<<"   type generic-mesh"     <<endl;
+   out<<"      name polySurfac"    <<endl<<endl;
+
+
+   // POINTS SECTION
+   int nofNodes = (int)nodes.size(); 
+   out<<"   points "<<nofNodes<<endl;
+   for(int n=0; n<nofNodes; n++)
+      out<<"      "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<endl;
+
+   // TRIANGLES SECTION
+   int nofTriangles= (int)triangles.size(); 
+   out<<"   triangles "<<nofTriangles<<endl;
+   for(int c=0; c<nofTriangles; c++)
+      out<<"      "<<val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<endl;
+
+   // FOOTER
+   out<<"   normals none" << endl;
+   out<<"   uvs none"     << endl;
+   out<<"}"               << endl;
+
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterSunflow::writeTriangles to "<<sunflowFilename<<" - end");
+
+   return sunflowFilename;
+}
+/*===============================================================================*/
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterSunflow.h b/source/VirtualFluidsBasic/basics/writer/WbWriterSunflow.h
similarity index 97%
rename from source/ThirdParty/Library/basics/writer/WbWriterSunflow.h
rename to source/VirtualFluidsBasic/basics/writer/WbWriterSunflow.h
index 5681eac73dc63a24c703120bb58821312aab2090..a14461b0618557fbef2b2da4b95077b397568f78 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterSunflow.h
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterSunflow.h
@@ -1,38 +1,38 @@
-#ifndef WbWriterSunflow_H
-#define WbWriterSunflow_H
-
-#include <string>
-
-#include <basics/writer/WbWriter.h>
-
-class WbWriterSunflow  : public WbWriter
-{
-public:
-   OBCREATOR_EXT( WbWriterSunflow )
-
-   static WbWriterSunflow* getInstance()
-   {
-      static WbWriterSunflow instance;
-      return &instance;
-   }
-private:
-   WbWriterSunflow() : WbWriter() 
-   {
-      if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char  type mismatch");
-      if(sizeof(int)          !=4) throw UbException(UB_EXARGS,"error int   type mismatch");
-      if(sizeof(float)        !=4) throw UbException(UB_EXARGS,"error float type mismatch");
-   }
-   WbWriterSunflow( const WbWriterSunflow& );                  //no copy allowed 
-   const WbWriterSunflow& operator=( const WbWriterSunflow& ); //no copy allowed
-
-   static std::string  pvdEndTag;
-
-public:
-   std::string getFileExtension()  { return "ascii.sunflow"; }
-
-   std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles);
-};
-
-UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterSunflow ,WbWriter>::getInstance()), CAB_WbWriterSunflow);
-
-#endif //WbWriterSunflow_H
+#ifndef WbWriterSunflow_H
+#define WbWriterSunflow_H
+
+#include <string>
+
+#include <basics/writer/WbWriter.h>
+
+class WbWriterSunflow  : public WbWriter
+{
+public:
+   OBCREATOR_EXT( WbWriterSunflow )
+
+   static WbWriterSunflow* getInstance()
+   {
+      static WbWriterSunflow instance;
+      return &instance;
+   }
+private:
+   WbWriterSunflow() : WbWriter() 
+   {
+      if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char  type mismatch");
+      if(sizeof(int)          !=4) throw UbException(UB_EXARGS,"error int   type mismatch");
+      if(sizeof(float)        !=4) throw UbException(UB_EXARGS,"error float type mismatch");
+   }
+   WbWriterSunflow( const WbWriterSunflow& );                  //no copy allowed 
+   const WbWriterSunflow& operator=( const WbWriterSunflow& ); //no copy allowed
+
+   static std::string  pvdEndTag;
+
+public:
+   std::string getFileExtension()  { return "ascii.sunflow"; }
+
+   std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles);
+};
+
+UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterSunflow ,WbWriter>::getInstance()), CAB_WbWriterSunflow);
+
+#endif //WbWriterSunflow_H
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterTecPlotASCII.cpp b/source/VirtualFluidsBasic/basics/writer/WbWriterTecPlotASCII.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/writer/WbWriterTecPlotASCII.cpp
rename to source/VirtualFluidsBasic/basics/writer/WbWriterTecPlotASCII.cpp
index b2f83ef59c09e5d9b00b15b90c3d166042444f6a..5e2ef86b46b9a7c68a69c94166084b71973fd1f7 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterTecPlotASCII.cpp
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterTecPlotASCII.cpp
@@ -1,68 +1,68 @@
-#include <basics/writer/WbWriterTecPlotASCII.h>
-#include <basics/utilities/UbLogger.h>
-
-using namespace std;
-
-/*===============================================================================*/
-string WbWriterTecPlotASCII::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata)
-{
-   string tecplotfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterTecPlotASCII::writeOctsWithNodeData to "<<tecplotfilename<<" - start");
-
-   ofstream out(tecplotfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(tecplotfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(tecplotfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+tecplotfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   out<<"TITLE = VirtualFluids OctGrid from "<<UbSystem::getTimeStamp()<<endl;
-
-   out<<"VARIABLES = \"X\", \"Y\", \"Z\"";
-   for(size_t d=0; d<datanames.size(); d++)   
-      out<<", \""<<datanames[d]<<"\"";
-   out<<endl;
-
-   out<<"ZONE NODES="<<nofNodes<<", ELEMENTS="<<nofCells<<", DATAPACKING=POINT, ZONETYPE=FEBRICK"<<endl;
-   for(size_t n=0; n<nodes.size(); n++)   
-   {
-      UbTupleFloat3& coords = nodes[n];
-      out<<val<1>(coords)<<" "
-         <<val<2>(coords)<<" "
-         <<val<3>(coords);
-      for(size_t d=0; d<datanames.size(); d++)   
-         out<<" "<<nodedata[d][n];
-      out<<endl;
-   }
-
-   for(size_t c=0; c<cells.size(); c++)   
-   {
-      UbTupleInt8& cell = cells[c];
-      out<<val<1>(cell)<<" "
-         <<val<2>(cell)<<" "
-         <<val<3>(cell)<<" "
-         <<val<4>(cell)<<" "
-         <<val<5>(cell)<<" "
-         <<val<6>(cell)<<" "
-         <<val<7>(cell)<<" "
-         <<val<8>(cell)<<endl;
-   }
-
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterTecPlotASCII::writeOctsWithNodeData to "<<tecplotfilename<<" - end");
-
-   return tecplotfilename;
-}
-/*===============================================================================*/
-string WbWriterTecPlotASCII::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells)
-{
-   vector<string > datanames;
-   vector<vector<double > > nodedata;
-   return writeOctsWithNodeData(filename,nodes,cells,datanames,nodedata);
-}
-/*===============================================================================*/
+#include <basics/writer/WbWriterTecPlotASCII.h>
+#include <basics/utilities/UbLogger.h>
+
+using namespace std;
+
+/*===============================================================================*/
+string WbWriterTecPlotASCII::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata)
+{
+   string tecplotfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterTecPlotASCII::writeOctsWithNodeData to "<<tecplotfilename<<" - start");
+
+   ofstream out(tecplotfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(tecplotfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(tecplotfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+tecplotfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   out<<"TITLE = VirtualFluids OctGrid from "<<UbSystem::getTimeStamp()<<endl;
+
+   out<<"VARIABLES = \"X\", \"Y\", \"Z\"";
+   for(size_t d=0; d<datanames.size(); d++)   
+      out<<", \""<<datanames[d]<<"\"";
+   out<<endl;
+
+   out<<"ZONE NODES="<<nofNodes<<", ELEMENTS="<<nofCells<<", DATAPACKING=POINT, ZONETYPE=FEBRICK"<<endl;
+   for(size_t n=0; n<nodes.size(); n++)   
+   {
+      UbTupleFloat3& coords = nodes[n];
+      out<<val<1>(coords)<<" "
+         <<val<2>(coords)<<" "
+         <<val<3>(coords);
+      for(size_t d=0; d<datanames.size(); d++)   
+         out<<" "<<nodedata[d][n];
+      out<<endl;
+   }
+
+   for(size_t c=0; c<cells.size(); c++)   
+   {
+      UbTupleInt8& cell = cells[c];
+      out<<val<1>(cell)<<" "
+         <<val<2>(cell)<<" "
+         <<val<3>(cell)<<" "
+         <<val<4>(cell)<<" "
+         <<val<5>(cell)<<" "
+         <<val<6>(cell)<<" "
+         <<val<7>(cell)<<" "
+         <<val<8>(cell)<<endl;
+   }
+
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterTecPlotASCII::writeOctsWithNodeData to "<<tecplotfilename<<" - end");
+
+   return tecplotfilename;
+}
+/*===============================================================================*/
+string WbWriterTecPlotASCII::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells)
+{
+   vector<string > datanames;
+   vector<vector<double > > nodedata;
+   return writeOctsWithNodeData(filename,nodes,cells,datanames,nodedata);
+}
+/*===============================================================================*/
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterTecPlotASCII.h b/source/VirtualFluidsBasic/basics/writer/WbWriterTecPlotASCII.h
similarity index 98%
rename from source/ThirdParty/Library/basics/writer/WbWriterTecPlotASCII.h
rename to source/VirtualFluidsBasic/basics/writer/WbWriterTecPlotASCII.h
index ff50c9c928d3636c0a894a77c5e2d523fb88be86..01b067557a9d39ecfe706cb2f266aaaf75d3f016 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterTecPlotASCII.h
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterTecPlotASCII.h
@@ -1,95 +1,95 @@
-#ifndef WBWRITERTECPLOTASCII_H
-#define WBWRITERTECPLOTASCII_H
-
-#include <string>
-
-#include <basics/writer/WbWriter.h>
-
-class WbWriterTecPlotASCII  : public WbWriter
-{
-public:
-   #ifndef SWIG
-   OBCREATOR_EXT( WbWriterTecPlotASCII )
-   #endif
-
-   static WbWriterTecPlotASCII* getInstance()
-   {
-      static WbWriterTecPlotASCII instance;
-      return &instance;
-   }
-private:
-   WbWriterTecPlotASCII() : WbWriter() 
-   {
-      if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"machine error char  type mismatch");
-      if(sizeof(int)          !=4) throw UbException(UB_EXARGS,"machine error int   type mismatch");
-      if(sizeof(float)        !=4) throw UbException(UB_EXARGS,"machine error float type mismatch");
-   }
-
-   WbWriterTecPlotASCII( const WbWriterTecPlotASCII& );                  //no copy allowed 
-   const WbWriterTecPlotASCII& operator=( const WbWriterTecPlotASCII& ); //no copy allowed
-
-   static std::string  pvdEndTag;
-public:
-   std::string getFileExtension() { return ".ascii.dat";   }
-
-   //write a metafile 
-//    std::string writeCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups);
-//    std::string addFilesToCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups);
-//    std::string writeParallelFile(const std::string& filename,std::vector<std::string>& pieceSources, std::vector<std::string>& pointDataNames, std::vector<std::string>& cellDataNames);
-
-   //////////////////////////////////////////////////////////////////////////
-   //nodes
-//    std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes);
-//    std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
-
-   //////////////////////////////////////////////////////////////////////////
-   //lines
-   //     0 ---- 1
-   //nodenumbering must start with 0!
-//    std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines);
-//    std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-// 
-   //////////////////////////////////////////////////////////////////////////
-   //triangles
-   //                    2
-   //                     
-   //                  0---1
-   //nodenumbering must start with 0!
-//    std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles);
-//    std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
-
-   //////////////////////////////////////////////////////////////////////////
-   //2D
-   //cell numbering:
-   //                  3---2
-   //                  |   |
-   //                  0---1
-   //nodenumbering must start with 0!
-
-//    std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells);
-//    std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-//    std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
-//    std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, 
-//                                              std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames,
-//                                              std::vector< std::vector< double > >& celldata                                                                    );
-   
-   //////////////////////////////////////////////////////////////////////////
-   //octs
-   //     7 ---- 6
-   //    /|     /|
-   //   4 +--- 5 |
-   //   | |    | |
-   //   | 3 ---+ 2
-   //   |/     |/
-   //   0 ---- 1
-   std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
-   //std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata);
-   std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
-   
-};
-
-#ifndef SWIG
-UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterTecPlotASCII ,WbWriter>::getInstance()), CAB_WbWriterTecPlotASCII);
-#endif
-
-#endif //WBWRITERTECPLOTASCII_H
+#ifndef WBWRITERTECPLOTASCII_H
+#define WBWRITERTECPLOTASCII_H
+
+#include <string>
+
+#include <basics/writer/WbWriter.h>
+
+class WbWriterTecPlotASCII  : public WbWriter
+{
+public:
+   #ifndef SWIG
+   OBCREATOR_EXT( WbWriterTecPlotASCII )
+   #endif
+
+   static WbWriterTecPlotASCII* getInstance()
+   {
+      static WbWriterTecPlotASCII instance;
+      return &instance;
+   }
+private:
+   WbWriterTecPlotASCII() : WbWriter() 
+   {
+      if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"machine error char  type mismatch");
+      if(sizeof(int)          !=4) throw UbException(UB_EXARGS,"machine error int   type mismatch");
+      if(sizeof(float)        !=4) throw UbException(UB_EXARGS,"machine error float type mismatch");
+   }
+
+   WbWriterTecPlotASCII( const WbWriterTecPlotASCII& );                  //no copy allowed 
+   const WbWriterTecPlotASCII& operator=( const WbWriterTecPlotASCII& ); //no copy allowed
+
+   static std::string  pvdEndTag;
+public:
+   std::string getFileExtension() { return ".ascii.dat";   }
+
+   //write a metafile 
+//    std::string writeCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups);
+//    std::string addFilesToCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups);
+//    std::string writeParallelFile(const std::string& filename,std::vector<std::string>& pieceSources, std::vector<std::string>& pointDataNames, std::vector<std::string>& cellDataNames);
+
+   //////////////////////////////////////////////////////////////////////////
+   //nodes
+//    std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes);
+//    std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
+
+   //////////////////////////////////////////////////////////////////////////
+   //lines
+   //     0 ---- 1
+   //nodenumbering must start with 0!
+//    std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines);
+//    std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+// 
+   //////////////////////////////////////////////////////////////////////////
+   //triangles
+   //                    2
+   //                     
+   //                  0---1
+   //nodenumbering must start with 0!
+//    std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles);
+//    std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
+
+   //////////////////////////////////////////////////////////////////////////
+   //2D
+   //cell numbering:
+   //                  3---2
+   //                  |   |
+   //                  0---1
+   //nodenumbering must start with 0!
+
+//    std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells);
+//    std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+//    std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
+//    std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, 
+//                                              std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames,
+//                                              std::vector< std::vector< double > >& celldata                                                                    );
+   
+   //////////////////////////////////////////////////////////////////////////
+   //octs
+   //     7 ---- 6
+   //    /|     /|
+   //   4 +--- 5 |
+   //   | |    | |
+   //   | 3 ---+ 2
+   //   |/     |/
+   //   0 ---- 1
+   std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
+   //std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata);
+   std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
+   
+};
+
+#ifndef SWIG
+UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterTecPlotASCII ,WbWriter>::getInstance()), CAB_WbWriterTecPlotASCII);
+#endif
+
+#endif //WBWRITERTECPLOTASCII_H
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterVtkASCII.cpp b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkASCII.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/writer/WbWriterVtkASCII.cpp
rename to source/VirtualFluidsBasic/basics/writer/WbWriterVtkASCII.cpp
index 0356f38fa155525ac929c81a7117acba2ffbd0bc..e88bbf3b4d8983e016d047e60ec7277ce8fb08ef 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterVtkASCII.cpp
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkASCII.cpp
@@ -1,601 +1,601 @@
-#include <basics/writer/WbWriterVtkASCII.h>
-#include <basics/utilities/UbLogger.h>
-#include <cstring>
-
-using namespace std;
-
-std::string WbWriterVtkASCII::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuads to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VtkASCII FILE
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"GeoFile"<<"\n";
-   out<<"ASCII"<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
-   
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n";
-   for(int c=0; c<(int)cells.size(); c++)
-      out<<"4 "
-         << val<1>(cells[c]) <<" "
-         << val<2>(cells[c]) <<" "
-         << val<4>(cells[c]) <<" "
-         << val<3>(cells[c]) <<" \n";
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<nofCells<<"\n";
-   for(int i=0; i<nofCells; i++) out<<"8"<<endl;
-   out<<endl;
-
-   out.close();
-
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuads to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkASCII::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
- 
-   //write geo
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VtkASCII FILE
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"GeoFile"<<"\n";
-   out<<"ASCII"<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
-
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n";
-   for(int c=0; c<(int)cells.size(); c++)
-      out<<"4 "
-      << val<1>(cells[c]) <<" "
-      << val<2>(cells[c]) <<" "
-      << val<4>(cells[c]) <<" "
-      << val<3>(cells[c]) <<" \n";
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<nofCells<<"\n";
-   for(int i=0; i<nofCells; i++) out<<"8"<<endl;
-   out<<endl;
-
-   //write data section
-   out<<"POINT_DATA "<<nofNodes<<"\n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
-      for(int d=0; d<(int)nodedata[s].size(); d++)
-         out<<nodedata[s][d]<<"\n";
-      
-      out<<endl;
-   }
-
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkASCII::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithCellData to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   //write geo
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VtkASCII FILE
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"GeoFile"<<"\n";
-   out<<"ASCII"<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
-
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n";
-   for(int c=0; c<(int)cells.size(); c++)
-      out<<"4 "
-      << val<1>(cells[c]) <<" "
-      << val<2>(cells[c]) <<" "
-      << val<4>(cells[c]) <<" "
-      << val<3>(cells[c]) <<" \n";
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<nofCells<<"\n";
-   for(int i=0; i<nofCells; i++) out<<"8"<<endl;
-   out<<endl;
-
-   //write data section
-   out<<"CELL_DATA "<<nofCells<<"\n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
-      for(int d=0; d<(int)celldata[s].size(); d++)
-         out<<celldata[s][d]<<"\n";
-
-      out<<endl;
-   }
-
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithCellData to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkASCII::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, 
-                                                            vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames,
-                                                            vector< vector< double > >& celldata                                                                       )
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   //write geo
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VtkASCII FILE
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"GeoFile"<<"\n";
-   out<<"ASCII"<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
-
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n";
-   for(int c=0; c<(int)cells.size(); c++)
-      out<<"4 "
-         << val<1>(cells[c]) <<" "
-         << val<2>(cells[c]) <<" "
-         << val<4>(cells[c]) <<" "
-         << val<3>(cells[c]) <<" \n";
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<nofCells<<"\n";
-   for(int i=0; i<nofCells; i++) out<<"8"<<endl;
-   out<<endl;
-
-   //write node data section
-   out<<"POINT_DATA "<<nofNodes<<"\n";
-   for(int s=0; s<(int)nodedatanames.size(); ++s)
-   {
-      out<<"SCALARS "<<nodedatanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
-      for(int d=0; d<(int)nodedata[s].size(); d++)
-         out<<nodedata[s][d]<<"\n";
-
-      out<<endl;
-   }
-
-   //write cell data section
-   out<<"CELL_DATA "<<nofCells<<"\n";
-   for(int s=0; s<(int)celldatanames.size(); ++s)
-   {
-      out<<"SCALARS "<<celldatanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
-      for(int d=0; d<(int)celldata[s].size(); d++)
-         out<<celldata[s][d]<<"\n";
-
-      out<<endl;
-   }
-
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkASCII::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines) 
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeLines to "<<vtkfilename<<" - start");
-   
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofLines = (int)lines.size(); 
-   
-   //VtkASCII FILE
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"GeoFile"<<"\n";
-   out<<"ASCII"<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-   {
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n";
-   }
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofLines<<" "<<3*nofLines<<"\n";
-   int nr = 0;
-   for(int l=0; l<nofLines; l++)
-   {
-      int el = nr+1;	
-      out<<"2 "<< val<1>(lines[l]) <<" "<< val<2>(lines[l]) <<" "<<endl;
-      nr=el+1;
-   }
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<nofLines<<"\n";
-   for(int l=0; l<nofLines; l++) out<<"3"<<endl;
-   out<<endl;
-
-   out.close();
-   
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeLines to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkASCII::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTriangles to "<<vtkfilename<<" - start");
-   
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes     = (int)nodes.size(); 
-   int nofTriangles = (int)triangles.size(); 
-
-   //VtkASCII FILE
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"GeoFile"<<"\n";
-   out<<"ASCII"<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-   {
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n";
-   }
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofTriangles<<" "<<4*nofTriangles<<"\n";
-   int nr = 0;
-   for(int t=0; t<nofTriangles; t++)
-   {
-      int el = nr+1;	
-      out<<"3 "<< val<1>(triangles[t]) <<" "<< val<2>(triangles[t]) <<" "<< val<3>(triangles[t]) <<" "<<endl;
-      nr=el+1;
-   }
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<nofTriangles<<"\n";
-   for(int l=0; l<nofTriangles; l++) out<<"5"<<endl;
-   out<<endl;
-
-   out.close();
-
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTriangles to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkASCII::writeTrianglesWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt3 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - start");
-   
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   //write geo
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VtkASCII FILE
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"GeoFile"<<"\n";
-   out<<"ASCII"<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
-
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofCells<<" "<<4*nofCells<<"\n";
-   for(int c=0; c<(int)cells.size(); c++)
-      out<<"3 "<< val<1>(cells[c]) <<" "<< val<2>(cells[c]) <<" "<< val<3>(cells[c]) <<" \n";
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<nofCells<<"\n";
-   for(int i=0; i<nofCells; i++) out<<"5"<<endl;
-   out<<endl;
-
-   //write data section
-   out<<"POINT_DATA "<<nofNodes<<"\n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
-      for(int d=0; d<(int)nodedata[s].size(); d++)
-         out<<nodedata[s][d]<<"\n";
-
-      out<<endl;
-   }
-
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkASCII::writeOctsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithCellData to "<<vtkfilename<<" - start");
-   
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   //write geo
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VtkASCII FILE
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"GeoFile"<<"\n";
-   out<<"ASCII"<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
-
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofCells<<" "<<9*nofCells<<"\n";
-   for(int c=0; c<(int)cells.size(); c++)
-   {   out<<"8 "
-         << val<1>(cells[c]) <<" "
-         << val<2>(cells[c]) <<" "
-         << val<4>(cells[c]) <<" "
-         << val<3>(cells[c]) <<" "
-         << val<5>(cells[c]) <<" "
-         << val<6>(cells[c]) <<" "
-         << val<8>(cells[c]) <<" "
-         << val<7>(cells[c]) <<" \n";
-   }
-
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<nofCells<<"\n";
-   for(int i=0; i<nofCells; i++) out<<"11 "<<endl;
-   out<<endl;
-
-   //write data section
-   out<<"CELL_DATA "<<nofCells<<"\n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
-      for(int d=0; d<(int)celldata[s].size(); d++)
-         out<<celldata[s][d]<<"\n";
-
-      out<<endl;
-   }
-
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithCellData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkASCII::writeOctsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithNodeData to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   //write geo
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VtkASCII FILE
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"GeoFile"<<"\n";
-   out<<"ASCII"<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
-
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofCells<<" "<<9*nofCells<<"\n";
-   for(int c=0; c<(int)cells.size(); c++)
-   {   out<<"8 "
-         << val<1>(cells[c]) <<" "
-         << val<2>(cells[c]) <<" "
-         << val<4>(cells[c]) <<" "
-         << val<3>(cells[c]) <<" "
-         << val<5>(cells[c]) <<" "
-         << val<6>(cells[c]) <<" "
-         << val<8>(cells[c]) <<" "
-         << val<7>(cells[c]) <<" \n";
-   }
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<nofCells<<"\n";
-   for(int i=0; i<nofCells; i++) out<<"11"<<endl;
-   out<<endl;
-
-   //write data section
-   out<<"POINT_DATA "<<nofNodes<<"\n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
-      for(int d=0; d<(int)nodedata[s].size(); d++)
-         out<<nodedata[s][d]<<"\n";
-
-      out<<endl;
-   }
-
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithNodeData to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkASCII::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOcts to "<<vtkfilename<<" - start");
-   
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VtkASCII FILE
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"GeoFile"<<"\n";
-   out<<"ASCII"<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
-
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofCells<<" "<<9*nofCells<<"\n";
-   for(int c=0; c<(int)cells.size(); c++)
-      out<<"8 "
-      << val<1>(cells[c]) <<" "
-      << val<2>(cells[c]) <<" "
-      << val<4>(cells[c]) <<" "
-      << val<3>(cells[c]) <<" "
-      << val<5>(cells[c]) <<" "
-      << val<6>(cells[c]) <<" "
-      << val<8>(cells[c]) <<" "
-      << val<7>(cells[c]) <<" \n";
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<nofCells<<"\n";
-   for(int i=0; i<nofCells; i++) out<<"11"<<endl;
-   out<<endl;
-
-   out.close();
-
-   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOcts to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
+#include <basics/writer/WbWriterVtkASCII.h>
+#include <basics/utilities/UbLogger.h>
+#include <cstring>
+
+using namespace std;
+
+std::string WbWriterVtkASCII::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuads to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VtkASCII FILE
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"GeoFile"<<"\n";
+   out<<"ASCII"<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
+   
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n";
+   for(int c=0; c<(int)cells.size(); c++)
+      out<<"4 "
+         << val<1>(cells[c]) <<" "
+         << val<2>(cells[c]) <<" "
+         << val<4>(cells[c]) <<" "
+         << val<3>(cells[c]) <<" \n";
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<nofCells<<"\n";
+   for(int i=0; i<nofCells; i++) out<<"8"<<endl;
+   out<<endl;
+
+   out.close();
+
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuads to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkASCII::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+ 
+   //write geo
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VtkASCII FILE
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"GeoFile"<<"\n";
+   out<<"ASCII"<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
+
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n";
+   for(int c=0; c<(int)cells.size(); c++)
+      out<<"4 "
+      << val<1>(cells[c]) <<" "
+      << val<2>(cells[c]) <<" "
+      << val<4>(cells[c]) <<" "
+      << val<3>(cells[c]) <<" \n";
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<nofCells<<"\n";
+   for(int i=0; i<nofCells; i++) out<<"8"<<endl;
+   out<<endl;
+
+   //write data section
+   out<<"POINT_DATA "<<nofNodes<<"\n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
+      for(int d=0; d<(int)nodedata[s].size(); d++)
+         out<<nodedata[s][d]<<"\n";
+      
+      out<<endl;
+   }
+
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkASCII::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithCellData to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   //write geo
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VtkASCII FILE
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"GeoFile"<<"\n";
+   out<<"ASCII"<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
+
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n";
+   for(int c=0; c<(int)cells.size(); c++)
+      out<<"4 "
+      << val<1>(cells[c]) <<" "
+      << val<2>(cells[c]) <<" "
+      << val<4>(cells[c]) <<" "
+      << val<3>(cells[c]) <<" \n";
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<nofCells<<"\n";
+   for(int i=0; i<nofCells; i++) out<<"8"<<endl;
+   out<<endl;
+
+   //write data section
+   out<<"CELL_DATA "<<nofCells<<"\n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
+      for(int d=0; d<(int)celldata[s].size(); d++)
+         out<<celldata[s][d]<<"\n";
+
+      out<<endl;
+   }
+
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithCellData to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkASCII::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, 
+                                                            vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames,
+                                                            vector< vector< double > >& celldata                                                                       )
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   //write geo
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VtkASCII FILE
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"GeoFile"<<"\n";
+   out<<"ASCII"<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
+
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n";
+   for(int c=0; c<(int)cells.size(); c++)
+      out<<"4 "
+         << val<1>(cells[c]) <<" "
+         << val<2>(cells[c]) <<" "
+         << val<4>(cells[c]) <<" "
+         << val<3>(cells[c]) <<" \n";
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<nofCells<<"\n";
+   for(int i=0; i<nofCells; i++) out<<"8"<<endl;
+   out<<endl;
+
+   //write node data section
+   out<<"POINT_DATA "<<nofNodes<<"\n";
+   for(int s=0; s<(int)nodedatanames.size(); ++s)
+   {
+      out<<"SCALARS "<<nodedatanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
+      for(int d=0; d<(int)nodedata[s].size(); d++)
+         out<<nodedata[s][d]<<"\n";
+
+      out<<endl;
+   }
+
+   //write cell data section
+   out<<"CELL_DATA "<<nofCells<<"\n";
+   for(int s=0; s<(int)celldatanames.size(); ++s)
+   {
+      out<<"SCALARS "<<celldatanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
+      for(int d=0; d<(int)celldata[s].size(); d++)
+         out<<celldata[s][d]<<"\n";
+
+      out<<endl;
+   }
+
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkASCII::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines) 
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeLines to "<<vtkfilename<<" - start");
+   
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofLines = (int)lines.size(); 
+   
+   //VtkASCII FILE
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"GeoFile"<<"\n";
+   out<<"ASCII"<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+   {
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n";
+   }
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofLines<<" "<<3*nofLines<<"\n";
+   int nr = 0;
+   for(int l=0; l<nofLines; l++)
+   {
+      int el = nr+1;	
+      out<<"2 "<< val<1>(lines[l]) <<" "<< val<2>(lines[l]) <<" "<<endl;
+      nr=el+1;
+   }
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<nofLines<<"\n";
+   for(int l=0; l<nofLines; l++) out<<"3"<<endl;
+   out<<endl;
+
+   out.close();
+   
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeLines to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkASCII::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTriangles to "<<vtkfilename<<" - start");
+   
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes     = (int)nodes.size(); 
+   int nofTriangles = (int)triangles.size(); 
+
+   //VtkASCII FILE
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"GeoFile"<<"\n";
+   out<<"ASCII"<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+   {
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n";
+   }
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofTriangles<<" "<<4*nofTriangles<<"\n";
+   int nr = 0;
+   for(int t=0; t<nofTriangles; t++)
+   {
+      int el = nr+1;	
+      out<<"3 "<< val<1>(triangles[t]) <<" "<< val<2>(triangles[t]) <<" "<< val<3>(triangles[t]) <<" "<<endl;
+      nr=el+1;
+   }
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<nofTriangles<<"\n";
+   for(int l=0; l<nofTriangles; l++) out<<"5"<<endl;
+   out<<endl;
+
+   out.close();
+
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTriangles to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkASCII::writeTrianglesWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt3 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - start");
+   
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   //write geo
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VtkASCII FILE
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"GeoFile"<<"\n";
+   out<<"ASCII"<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
+
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofCells<<" "<<4*nofCells<<"\n";
+   for(int c=0; c<(int)cells.size(); c++)
+      out<<"3 "<< val<1>(cells[c]) <<" "<< val<2>(cells[c]) <<" "<< val<3>(cells[c]) <<" \n";
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<nofCells<<"\n";
+   for(int i=0; i<nofCells; i++) out<<"5"<<endl;
+   out<<endl;
+
+   //write data section
+   out<<"POINT_DATA "<<nofNodes<<"\n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
+      for(int d=0; d<(int)nodedata[s].size(); d++)
+         out<<nodedata[s][d]<<"\n";
+
+      out<<endl;
+   }
+
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkASCII::writeOctsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithCellData to "<<vtkfilename<<" - start");
+   
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   //write geo
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VtkASCII FILE
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"GeoFile"<<"\n";
+   out<<"ASCII"<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
+
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofCells<<" "<<9*nofCells<<"\n";
+   for(int c=0; c<(int)cells.size(); c++)
+   {   out<<"8 "
+         << val<1>(cells[c]) <<" "
+         << val<2>(cells[c]) <<" "
+         << val<4>(cells[c]) <<" "
+         << val<3>(cells[c]) <<" "
+         << val<5>(cells[c]) <<" "
+         << val<6>(cells[c]) <<" "
+         << val<8>(cells[c]) <<" "
+         << val<7>(cells[c]) <<" \n";
+   }
+
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<nofCells<<"\n";
+   for(int i=0; i<nofCells; i++) out<<"11 "<<endl;
+   out<<endl;
+
+   //write data section
+   out<<"CELL_DATA "<<nofCells<<"\n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
+      for(int d=0; d<(int)celldata[s].size(); d++)
+         out<<celldata[s][d]<<"\n";
+
+      out<<endl;
+   }
+
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithCellData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkASCII::writeOctsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithNodeData to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   //write geo
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VtkASCII FILE
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"GeoFile"<<"\n";
+   out<<"ASCII"<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
+
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofCells<<" "<<9*nofCells<<"\n";
+   for(int c=0; c<(int)cells.size(); c++)
+   {   out<<"8 "
+         << val<1>(cells[c]) <<" "
+         << val<2>(cells[c]) <<" "
+         << val<4>(cells[c]) <<" "
+         << val<3>(cells[c]) <<" "
+         << val<5>(cells[c]) <<" "
+         << val<6>(cells[c]) <<" "
+         << val<8>(cells[c]) <<" "
+         << val<7>(cells[c]) <<" \n";
+   }
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<nofCells<<"\n";
+   for(int i=0; i<nofCells; i++) out<<"11"<<endl;
+   out<<endl;
+
+   //write data section
+   out<<"POINT_DATA "<<nofNodes<<"\n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
+      for(int d=0; d<(int)nodedata[s].size(); d++)
+         out<<nodedata[s][d]<<"\n";
+
+      out<<endl;
+   }
+
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithNodeData to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkASCII::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOcts to "<<vtkfilename<<" - start");
+   
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VtkASCII FILE
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"GeoFile"<<"\n";
+   out<<"ASCII"<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n";
+
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofCells<<" "<<9*nofCells<<"\n";
+   for(int c=0; c<(int)cells.size(); c++)
+      out<<"8 "
+      << val<1>(cells[c]) <<" "
+      << val<2>(cells[c]) <<" "
+      << val<4>(cells[c]) <<" "
+      << val<3>(cells[c]) <<" "
+      << val<5>(cells[c]) <<" "
+      << val<6>(cells[c]) <<" "
+      << val<8>(cells[c]) <<" "
+      << val<7>(cells[c]) <<" \n";
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<nofCells<<"\n";
+   for(int i=0; i<nofCells; i++) out<<"11"<<endl;
+   out<<endl;
+
+   out.close();
+
+   UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOcts to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterVtkASCII.h b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkASCII.h
similarity index 98%
rename from source/ThirdParty/Library/basics/writer/WbWriterVtkASCII.h
rename to source/VirtualFluidsBasic/basics/writer/WbWriterVtkASCII.h
index 914ab2cab9a37ace767e9fd389c79401d12c5a8a..aaa1f563cd252fd95691a0e6039f7cadeabc9e58 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterVtkASCII.h
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkASCII.h
@@ -1,78 +1,78 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef WBWRITERVTKASCII_H
-#define WBWRITERVTKASCII_H
-
-#include <basics/writer/WbWriter.h>
-
-class WbWriterVtkASCII : public WbWriter
-{
-public:
-   OBCREATOR_EXT( WbWriterVtkASCII )
-
-   static WbWriterVtkASCII* getInstance()
-   {
-      static WbWriterVtkASCII instance;
-      return &instance;
-   }
-private:
-   WbWriterVtkASCII() : WbWriter() {}                            
-   WbWriterVtkASCII( const WbWriterVtkASCII& );                  //no copy allowed 
-   const WbWriterVtkASCII& operator=( const WbWriterVtkASCII& ); //no copy allowed
-
-public:
-   std::string getFileExtension()  { return ".ascii.vtk"; }
-
-   //////////////////////////////////////////////////////////////////////////
-   //lines
-   //     0 ---- 1
-   //nodenumbering must start with 0!
-   std::string writeLines(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines);
-
-   //////////////////////////////////////////////////////////////////////////
-   //triangles
-   //cell numbering:
-   //                    2
-   //                     
-   //                  0---1
-   //nodenumbering must start with 0!
-   std::string writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells);
-   std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-
-   //////////////////////////////////////////////////////////////////////////
-   //2D
-   //cell numbering:
-   //                  3---2
-   //                  |   |
-   //                  0---1
-   //nodenumbering must start with 0!
-   std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells);
-   std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-   std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
-   std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, 
-                                             std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames,
-                                             std::vector< std::vector< double > >& celldata                                                                       );
-   
-   //////////////////////////////////////////////////////////////////////////
-   //octs
-   //     7 ---- 6
-   //    /|     /|
-   //   4 +--- 5 |
-   //   | |    | |
-   //   | 3 ---+ 2
-   //   |/     |/
-   //   0 ---- 1
-   std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
-   std::string writeOctsBinary(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
-   std::string writeOctsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata);
-   std::string writeOctsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
-
-};
-
-UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkASCII,WbWriter>::getInstance()), CAB_WbWriterVtkASCII);
-
-#endif //WBWRITERVTKASCII_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef WBWRITERVTKASCII_H
+#define WBWRITERVTKASCII_H
+
+#include <basics/writer/WbWriter.h>
+
+class WbWriterVtkASCII : public WbWriter
+{
+public:
+   OBCREATOR_EXT( WbWriterVtkASCII )
+
+   static WbWriterVtkASCII* getInstance()
+   {
+      static WbWriterVtkASCII instance;
+      return &instance;
+   }
+private:
+   WbWriterVtkASCII() : WbWriter() {}                            
+   WbWriterVtkASCII( const WbWriterVtkASCII& );                  //no copy allowed 
+   const WbWriterVtkASCII& operator=( const WbWriterVtkASCII& ); //no copy allowed
+
+public:
+   std::string getFileExtension()  { return ".ascii.vtk"; }
+
+   //////////////////////////////////////////////////////////////////////////
+   //lines
+   //     0 ---- 1
+   //nodenumbering must start with 0!
+   std::string writeLines(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines);
+
+   //////////////////////////////////////////////////////////////////////////
+   //triangles
+   //cell numbering:
+   //                    2
+   //                     
+   //                  0---1
+   //nodenumbering must start with 0!
+   std::string writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells);
+   std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+
+   //////////////////////////////////////////////////////////////////////////
+   //2D
+   //cell numbering:
+   //                  3---2
+   //                  |   |
+   //                  0---1
+   //nodenumbering must start with 0!
+   std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells);
+   std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+   std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
+   std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, 
+                                             std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames,
+                                             std::vector< std::vector< double > >& celldata                                                                       );
+   
+   //////////////////////////////////////////////////////////////////////////
+   //octs
+   //     7 ---- 6
+   //    /|     /|
+   //   4 +--- 5 |
+   //   | |    | |
+   //   | 3 ---+ 2
+   //   |/     |/
+   //   0 ---- 1
+   std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
+   std::string writeOctsBinary(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
+   std::string writeOctsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata);
+   std::string writeOctsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
+
+};
+
+UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkASCII,WbWriter>::getInstance()), CAB_WbWriterVtkASCII);
+
+#endif //WBWRITERVTKASCII_H
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterVtkBinary.cpp b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkBinary.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/writer/WbWriterVtkBinary.cpp
rename to source/VirtualFluidsBasic/basics/writer/WbWriterVtkBinary.cpp
index f766fa402236f3fa47a218a54e3187fb3b3a9fb0..8925a9b0381c2884d4f1929b18e94f8badbf5580 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterVtkBinary.cpp
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkBinary.cpp
@@ -1,747 +1,747 @@
-#include <basics/writer/WbWriterVtkBinary.h>
-#include <basics/writer/WbWriterVtkASCII.h>
-#include <basics/utilities/UbLogger.h>
-#include <cstring>
-
-using namespace std;
-
-std::string WbWriterVtkBinary::writeLines(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines)
-{
-   return WbWriterVtkASCII::getInstance()->writeLines(filename,nodes,lines);
-}
-/*===============================================================================*/
-std::string WbWriterVtkBinary::writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells)
-{
-   return WbWriterVtkASCII::getInstance()->writeTriangles(filename,nodes,cells);
-}
-/*===============================================================================*/
-std::string WbWriterVtkBinary::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata)
-{
-   return WbWriterVtkASCII::getInstance()->writeTrianglesWithNodeData(filename,nodes,cells,datanames,nodedata);
-}
-/*===============================================================================*/
-std::string WbWriterVtkBinary::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells)
-{
-   string vtkfilename = filename + getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuads to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   //HEADER-SECTION
-   //WRITE BIGENDIAN VtkBinary FILE
-   bool swapByte = UbSystem::isLittleEndian();
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"D3Q19MasterNodeGrid"<<"\n";
-   out<<""<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-   {
-      float x1 = (float)val<1>(nodes[n]); 
-      float x2 = (float)val<2>(nodes[n]); 
-      float x3 = (float)val<3>(nodes[n]); 
-
-      if(swapByte)
-      {
-         UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float));
-         UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float));
-         UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float));
-      }
-
-      out.write((char*)&x1,sizeof(float));
-      out.write((char*)&x2,sizeof(float));
-      out.write((char*)&x3,sizeof(float));
-   }
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n";
-
-   int nodesPerCellDummy = 4;  //nofNodesPerCell         
-   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int));
-   for(int c=0; c<(int)cells.size(); c++)
-   {
-      int SW = val<1>(cells[c]); 
-      int SE = val<2>(cells[c]); 
-      int NE = val<3>(cells[c]);
-      int NW = val<4>(cells[c]);
-      if(swapByte)
-      {
-         UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int));
-      }
-
-      out.write((char*)&nodesPerCellDummy,sizeof(int));
-      out.write((char*)&SW,sizeof(int));
-      out.write((char*)&SE,sizeof(int));
-      out.write((char*)&NW,sizeof(int));
-      out.write((char*)&NE,sizeof(int));
-   }
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<(int)cells.size()<<"\n";
-   int celltype = 8;
-   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int));
-   for(int c=0; c<nofCells; c++)
-      out.write((char*)&celltype,sizeof(int));
-
-   out<<endl;
-   out.close();
-
-   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuads to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkBinary::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
-{
-   string vtkfilename = filename + getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   //WRITE BIGENDIAN VtkBinary FILE
-   bool swapByte = UbSystem::isLittleEndian();
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"D3Q19MasterNodeGrid"<<"\n";
-   out<<""<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-   {
-      float x1 = (float)val<1>(nodes[n]); 
-      float x2 = (float)val<2>(nodes[n]); 
-      float x3 = (float)val<3>(nodes[n]); 
-
-      if(swapByte)
-      {
-         UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float));
-         UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float));
-         UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float));
-      }
-
-      out.write((char*)&x1,sizeof(float));
-      out.write((char*)&x2,sizeof(float));
-      out.write((char*)&x3,sizeof(float));
-   }
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n";
-
-   int nodesPerCellDummy = 4;  //nofNodesPerCell         
-   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int));
-   for(int c=0; c<(int)cells.size(); c++)
-   {
-      int SW = val<1>(cells[c]); 
-      int SE = val<2>(cells[c]); 
-      int NE = val<3>(cells[c]);
-      int NW = val<4>(cells[c]);
-      if(swapByte)
-      {
-         UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int));
-      }
-
-      out.write((char*)&nodesPerCellDummy,sizeof(int));
-      out.write((char*)&SW,sizeof(int));
-      out.write((char*)&SE,sizeof(int));
-      out.write((char*)&NW,sizeof(int));
-      out.write((char*)&NE,sizeof(int));
-   }
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<(int)cells.size()<<"\n";
-   int celltype = 8;
-   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int));
-   for(int c=0; c<nofCells; c++)
-      out.write((char*)&celltype,sizeof(int));
-
-   out<<endl;
-
-   //DATA SECTION
-   //write data section
-   out<<"POINT_DATA "<<nofNodes<<"\n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      if((int)nodedata[s].size() != nofNodes) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes");
-      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
-      for(int d=0; d<(int)nodedata[s].size(); d++)
-      { 
-         float dummy = (float)nodedata[s][d]; 
-         if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); 
-         out.write((const char*)&dummy,sizeof(float));
-      }
-      out<<endl;
-   }
-   out.close();
-
-   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkBinary::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
-{
-   //HEADER-SECTION
-   string vtkfilename = filename + getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithCellData to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   //WRITE BIGENDIAN VtkBinary FILE
-   bool swapByte = UbSystem::isLittleEndian();
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"D3Q19MasterNodeGrid"<<"\n";
-   out<<""<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-   {
-      float x1 = (float)val<1>(nodes[n]); 
-      float x2 = (float)val<2>(nodes[n]); 
-      float x3 = (float)val<3>(nodes[n]); 
-
-      if(swapByte)
-      {
-         UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float));
-         UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float));
-         UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float));
-      }
-
-      out.write((char*)&x1,sizeof(float));
-      out.write((char*)&x2,sizeof(float));
-      out.write((char*)&x3,sizeof(float));
-   }
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n";
-
-   int nodesPerCellDummy = 4;  //nofNodesPerCell         
-   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int));
-   for(int c=0; c<(int)cells.size(); c++)
-   {
-      int SW = val<1>(cells[c]); 
-      int SE = val<2>(cells[c]); 
-      int NE = val<3>(cells[c]);
-      int NW = val<4>(cells[c]);
-      if(swapByte)
-      {
-         UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int));
-      }
-
-      out.write((char*)&nodesPerCellDummy,sizeof(int));
-      out.write((char*)&SW,sizeof(int));
-      out.write((char*)&SE,sizeof(int));
-      out.write((char*)&NW,sizeof(int));
-      out.write((char*)&NE,sizeof(int));
-   }
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<(int)cells.size()<<"\n";
-   int celltype = 8;
-   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int));
-   for(int c=0; c<nofCells; c++)
-      out.write((char*)&celltype,sizeof(int));
-
-   out<<endl;
-
-   //DATA SECTION
-   //write data section
-   out<<"CELL_DATA "<<nofCells<<"\n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      if((int)celldata[s].size() != nofCells) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes");
-      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
-      for(int d=0; d<(int)celldata[s].size(); d++)
-      { 
-         float dummy = (float)celldata[s][d]; 
-         if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); 
-         out.write((const char*)&dummy,sizeof(float));
-      }
-      out<<endl;
-   }
-   out.close();
-
-   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithCellData to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkBinary::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, 
-                                                             vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames,
-                                                             vector< vector< double > >& celldata                                                                    )
-{
-   string vtkfilename = filename + getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   //HEADER-SECTION
-   //WRITE BIGENDIAN VtkBinary FILE
-   bool swapByte = UbSystem::isLittleEndian();
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"D3Q19MasterNodeGrid"<<"\n";
-   out<<""<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-   {
-      float x1 = (float)val<1>(nodes[n]); 
-      float x2 = (float)val<2>(nodes[n]); 
-      float x3 = (float)val<3>(nodes[n]);  
-
-      if(swapByte)
-      {
-         UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float));
-         UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float));
-         UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float));
-      }
-
-      out.write((char*)&x1,sizeof(float));
-      out.write((char*)&x2,sizeof(float));
-      out.write((char*)&x3,sizeof(float));
-   }
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n";
-
-   int nodesPerCellDummy = 4;  //nofNodesPerCell         
-   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int));
-   for(int c=0; c<(int)cells.size(); c++)
-   {
-      int SW = val<1>(cells[c]); 
-      int SE = val<2>(cells[c]); 
-      int NE = val<3>(cells[c]);
-      int NW = val<4>(cells[c]);
-      if(swapByte)
-      {
-         UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int));
-      }
-
-      out.write((char*)&nodesPerCellDummy,sizeof(int));
-      out.write((char*)&SW,sizeof(int));
-      out.write((char*)&SE,sizeof(int));
-      out.write((char*)&NW,sizeof(int));
-      out.write((char*)&NE,sizeof(int));
-   }
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<(int)cells.size()<<"\n";
-   int celltype = 8;
-   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int));
-   for(int c=0; c<nofCells; c++)
-      out.write((char*)&celltype,sizeof(int));
-
-   out<<endl;
-
-   //NODE DATA SECTION
-   //write data section
-   out<<"POINT_DATA "<<nofNodes<<"\n";
-   for(int s=0; s<(int)nodedatanames.size(); ++s)
-   {
-      if((int)nodedata[s].size() != nofNodes) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes");
-      out<<"SCALARS "<<nodedatanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
-      for(int d=0; d<(int)nodedata[s].size(); d++)
-      { 
-         float dummy = (float)nodedata[s][d]; 
-         if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); 
-         out.write((const char*)&dummy,sizeof(float));
-      }
-      out<<endl;
-   }
-   
-   //CELL DATA SECTION
-   //write data section
-   out<<"CELL_DATA "<<nofCells<<"\n";
-   for(int s=0; s<(int)celldatanames.size(); ++s)
-   {
-      if((int)celldata[s].size() != nofCells) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes");
-      out<<"SCALARS "<<celldatanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
-      for(int d=0; d<(int)celldata[s].size(); d++)
-      { 
-         float dummy = (float)celldata[s][d]; 
-         if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); 
-         out.write((const char*)&dummy,sizeof(float));
-      }
-      out<<endl;
-   }
-
-   out.close();
-
-   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkBinary::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata)
-{
-   string vtkfilename = filename + getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithCellData to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   //HEADER-SECTION
-   //WRITE BIGENDIAN VtkBinary FILE
-   bool swapByte = UbSystem::isLittleEndian();
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"D3Q19MasterNodeGrid"<<"\n";
-   out<<""<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-   {
-      float x1 = (float)val<1>(nodes[n]); 
-      float x2 = (float)val<2>(nodes[n]); 
-      float x3 = (float)val<3>(nodes[n]);
-
-      if(swapByte)
-      {
-         UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float));
-         UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float));
-         UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float));
-      }
-
-      out.write((char*)&x1,sizeof(float));
-      out.write((char*)&x2,sizeof(float));
-      out.write((char*)&x3,sizeof(float));
-   }
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofCells<<" "<<nofCells*9<<"\n";
-
-   int nodesPerCellDummy = 8;  //nofNodesPerCell         
-   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int));
-   for(int c=0; c<(int)cells.size(); c++)
-   {
-      int BSW = val<1>(cells[c]);  int TSW = val<5>(cells[c]);
-      int BSE = val<2>(cells[c]);  int TSE = val<6>(cells[c]);
-      int BNW = val<3>(cells[c]);  int TNW = val<7>(cells[c]);
-      int BNE = val<4>(cells[c]);  int TNE = val<8>(cells[c]);
-      if(swapByte)
-      {
-         UbSystem::swapByteOrder((unsigned char*)&BSW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&BSE,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&BNW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&BNE,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&TSW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&TSE,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&TNW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&TNE,sizeof(int));
-      }
-
-      out.write((char*)&nodesPerCellDummy,sizeof(int));
-      out.write((char*)&BSW,sizeof(int));
-      out.write((char*)&BSE,sizeof(int));
-      out.write((char*)&BNE,sizeof(int));
-      out.write((char*)&BNW,sizeof(int));
-      out.write((char*)&TSW,sizeof(int));
-      out.write((char*)&TSE,sizeof(int));
-      out.write((char*)&TNE,sizeof(int));
-      out.write((char*)&TNW,sizeof(int));
-   }
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<(int)cells.size()<<"\n";
-   int celltype = 11;
-   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int));
-   for(int c=0; c<nofCells; c++)
-      out.write((char*)&celltype,sizeof(int));
-
-   out<<endl;
-
-   //CELL DATA SECTION
-   //write data section
-   out<<"CELL_DATA "<<nofCells<<"\n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      if((int)celldata[s].size() != nofCells) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes");
-      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
-      for(int d=0; d<(int)celldata[s].size(); d++)
-      { 
-         float dummy = (float)celldata[s][d]; 
-         if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); 
-         out.write((const char*)&dummy,sizeof(float));
-      }
-      out<<endl;
-   }
-   out.close();
-
-   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithCellData to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata)
-{
-   //HEADER-SECTION
-   string vtkfilename = filename + getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithNodeData to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   //WRITE BIGENDIAN VtkBinary FILE
-   bool swapByte = UbSystem::isLittleEndian();
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"D3Q19MasterNodeGrid"<<"\n";
-   out<<""<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-   {
-      float x1 = val<1>(nodes[n]); 
-      float x2 = val<2>(nodes[n]); 
-      float x3 = val<3>(nodes[n]); 
-
-      if(swapByte)
-      {
-         UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float));
-         UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float));
-         UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float));
-      }
-
-      out.write((char*)&x1,sizeof(float));
-      out.write((char*)&x2,sizeof(float));
-      out.write((char*)&x3,sizeof(float));
-   }
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofCells<<" "<<nofCells*9<<"\n";
-
-   int nodesPerCellDummy = 8;  //nofNodesPerCell         
-   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int));
-   for(int c=0; c<(int)cells.size(); c++)
-   {
-      int BSW = val<1>(cells[c]);  int TSW = val<5>(cells[c]);
-      int BSE = val<2>(cells[c]);  int TSE = val<6>(cells[c]);
-      int BNW = val<3>(cells[c]);  int TNW = val<7>(cells[c]);
-      int BNE = val<4>(cells[c]);  int TNE = val<8>(cells[c]);
-      if(swapByte)
-      {
-         UbSystem::swapByteOrder((unsigned char*)&BSW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&BSE,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&BNW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&BNE,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&TSW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&TSE,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&TNW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&TNE,sizeof(int));
-      }
-
-      out.write((char*)&nodesPerCellDummy,sizeof(int));
-      out.write((char*)&BSW,sizeof(int));
-      out.write((char*)&BSE,sizeof(int));
-      out.write((char*)&BNE,sizeof(int));
-      out.write((char*)&BNW,sizeof(int));
-      out.write((char*)&TSW,sizeof(int));
-      out.write((char*)&TSE,sizeof(int));
-      out.write((char*)&TNE,sizeof(int));
-      out.write((char*)&TNW,sizeof(int));
-   }
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<(int)cells.size()<<"\n";
-   int celltype = 11;
-   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int));
-   for(int c=0; c<nofCells; c++)
-      out.write((char*)&celltype,sizeof(int));
-
-   out<<endl;
-
-   //NODE DATA SECTION
-   //write data section
-   out<<"POINT_DATA "<<nofNodes<<"\n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      if((int)nodedata[s].size() != nofNodes) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes");
-      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
-      for(int d=0; d<(int)nodedata[s].size(); d++)
-      { 
-         float dummy = (float)nodedata[s][d]; 
-         if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); 
-         out.write((const char*)&dummy,sizeof(float));
-      }
-      out<<endl;
-   }
-
-   out.close();
-
-   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithNodeData to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkBinary::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells)
-{
-   string vtkfilename = filename + getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOcts to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   //HEADER-SECTION
-   //WRITE BIGENDIAN VtkBinary FILE
-   bool swapByte = UbSystem::isLittleEndian();
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   out<<"# vtk DataFile Version 4.0"<<"\n";
-   out<<"D3Q19MasterNodeGrid"<<"\n";
-   out<<""<<"\n";
-
-   //POINTS SECTION
-   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
-   out<<"POINTS "<<nofNodes<<" float"<<"\n";
-   for(int n=0; n<nofNodes; n++)
-   {
-      float x1 = val<1>(nodes[n]); 
-      float x2 = val<2>(nodes[n]); 
-      float x3 = val<3>(nodes[n]); 
-
-      if(swapByte)
-      {
-         UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float));
-         UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float));
-         UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float));
-      }
-
-      out.write((char*)&x1,sizeof(float));
-      out.write((char*)&x2,sizeof(float));
-      out.write((char*)&x3,sizeof(float));
-   }
-   out<<"\n";
-
-   //CELLS SECTION
-   out<<"CELLS "<<nofCells<<" "<<nofCells*9<<"\n";
-
-   int nodesPerCellDummy = 8;  //nofNodesPerCell         
-   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int));
-   for(int c=0; c<(int)cells.size(); c++)
-   {
-      int BSW = val<1>(cells[c]);  int TSW = val<5>(cells[c]);
-      int BSE = val<2>(cells[c]);  int TSE = val<6>(cells[c]);
-      int BNW = val<3>(cells[c]);  int TNW = val<7>(cells[c]);
-      int BNE = val<4>(cells[c]);  int TNE = val<8>(cells[c]);
-      if(swapByte)
-      {
-         UbSystem::swapByteOrder((unsigned char*)&BSW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&BSE,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&BNW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&BNE,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&TSW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&TSE,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&TNW,sizeof(int));
-         UbSystem::swapByteOrder((unsigned char*)&TNE,sizeof(int));
-      }
-
-       out.write((char*)&nodesPerCellDummy,sizeof(int));
-       out.write((char*)&BSW,sizeof(int));
-       out.write((char*)&BSE,sizeof(int));
-       out.write((char*)&BNE,sizeof(int));
-       out.write((char*)&BNW,sizeof(int));
-       out.write((char*)&TSW,sizeof(int));
-       out.write((char*)&TSE,sizeof(int));
-       out.write((char*)&TNE,sizeof(int));
-       out.write((char*)&TNW,sizeof(int));
-   }
-   out<<"\n";
-
-   out<<"CELL_TYPES "<<(int)cells.size()<<"\n";
-   int celltype = 11;
-   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int));
-   for(int c=0; c<nofCells; c++)
-      out.write((char*)&celltype,sizeof(int));
-
-   out<<endl;
-   out.close();
-
-   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOcts to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
-
+#include <basics/writer/WbWriterVtkBinary.h>
+#include <basics/writer/WbWriterVtkASCII.h>
+#include <basics/utilities/UbLogger.h>
+#include <cstring>
+
+using namespace std;
+
+std::string WbWriterVtkBinary::writeLines(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines)
+{
+   return WbWriterVtkASCII::getInstance()->writeLines(filename,nodes,lines);
+}
+/*===============================================================================*/
+std::string WbWriterVtkBinary::writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells)
+{
+   return WbWriterVtkASCII::getInstance()->writeTriangles(filename,nodes,cells);
+}
+/*===============================================================================*/
+std::string WbWriterVtkBinary::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata)
+{
+   return WbWriterVtkASCII::getInstance()->writeTrianglesWithNodeData(filename,nodes,cells,datanames,nodedata);
+}
+/*===============================================================================*/
+std::string WbWriterVtkBinary::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells)
+{
+   string vtkfilename = filename + getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuads to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   //HEADER-SECTION
+   //WRITE BIGENDIAN VtkBinary FILE
+   bool swapByte = UbSystem::isLittleEndian();
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"D3Q19MasterNodeGrid"<<"\n";
+   out<<""<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+   {
+      float x1 = (float)val<1>(nodes[n]); 
+      float x2 = (float)val<2>(nodes[n]); 
+      float x3 = (float)val<3>(nodes[n]); 
+
+      if(swapByte)
+      {
+         UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float));
+         UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float));
+         UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float));
+      }
+
+      out.write((char*)&x1,sizeof(float));
+      out.write((char*)&x2,sizeof(float));
+      out.write((char*)&x3,sizeof(float));
+   }
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n";
+
+   int nodesPerCellDummy = 4;  //nofNodesPerCell         
+   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int));
+   for(int c=0; c<(int)cells.size(); c++)
+   {
+      int SW = val<1>(cells[c]); 
+      int SE = val<2>(cells[c]); 
+      int NE = val<3>(cells[c]);
+      int NW = val<4>(cells[c]);
+      if(swapByte)
+      {
+         UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int));
+      }
+
+      out.write((char*)&nodesPerCellDummy,sizeof(int));
+      out.write((char*)&SW,sizeof(int));
+      out.write((char*)&SE,sizeof(int));
+      out.write((char*)&NW,sizeof(int));
+      out.write((char*)&NE,sizeof(int));
+   }
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<(int)cells.size()<<"\n";
+   int celltype = 8;
+   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int));
+   for(int c=0; c<nofCells; c++)
+      out.write((char*)&celltype,sizeof(int));
+
+   out<<endl;
+   out.close();
+
+   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuads to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkBinary::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
+{
+   string vtkfilename = filename + getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   //WRITE BIGENDIAN VtkBinary FILE
+   bool swapByte = UbSystem::isLittleEndian();
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"D3Q19MasterNodeGrid"<<"\n";
+   out<<""<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+   {
+      float x1 = (float)val<1>(nodes[n]); 
+      float x2 = (float)val<2>(nodes[n]); 
+      float x3 = (float)val<3>(nodes[n]); 
+
+      if(swapByte)
+      {
+         UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float));
+         UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float));
+         UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float));
+      }
+
+      out.write((char*)&x1,sizeof(float));
+      out.write((char*)&x2,sizeof(float));
+      out.write((char*)&x3,sizeof(float));
+   }
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n";
+
+   int nodesPerCellDummy = 4;  //nofNodesPerCell         
+   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int));
+   for(int c=0; c<(int)cells.size(); c++)
+   {
+      int SW = val<1>(cells[c]); 
+      int SE = val<2>(cells[c]); 
+      int NE = val<3>(cells[c]);
+      int NW = val<4>(cells[c]);
+      if(swapByte)
+      {
+         UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int));
+      }
+
+      out.write((char*)&nodesPerCellDummy,sizeof(int));
+      out.write((char*)&SW,sizeof(int));
+      out.write((char*)&SE,sizeof(int));
+      out.write((char*)&NW,sizeof(int));
+      out.write((char*)&NE,sizeof(int));
+   }
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<(int)cells.size()<<"\n";
+   int celltype = 8;
+   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int));
+   for(int c=0; c<nofCells; c++)
+      out.write((char*)&celltype,sizeof(int));
+
+   out<<endl;
+
+   //DATA SECTION
+   //write data section
+   out<<"POINT_DATA "<<nofNodes<<"\n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      if((int)nodedata[s].size() != nofNodes) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes");
+      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
+      for(int d=0; d<(int)nodedata[s].size(); d++)
+      { 
+         float dummy = (float)nodedata[s][d]; 
+         if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); 
+         out.write((const char*)&dummy,sizeof(float));
+      }
+      out<<endl;
+   }
+   out.close();
+
+   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkBinary::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
+{
+   //HEADER-SECTION
+   string vtkfilename = filename + getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithCellData to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   //WRITE BIGENDIAN VtkBinary FILE
+   bool swapByte = UbSystem::isLittleEndian();
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"D3Q19MasterNodeGrid"<<"\n";
+   out<<""<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+   {
+      float x1 = (float)val<1>(nodes[n]); 
+      float x2 = (float)val<2>(nodes[n]); 
+      float x3 = (float)val<3>(nodes[n]); 
+
+      if(swapByte)
+      {
+         UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float));
+         UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float));
+         UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float));
+      }
+
+      out.write((char*)&x1,sizeof(float));
+      out.write((char*)&x2,sizeof(float));
+      out.write((char*)&x3,sizeof(float));
+   }
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n";
+
+   int nodesPerCellDummy = 4;  //nofNodesPerCell         
+   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int));
+   for(int c=0; c<(int)cells.size(); c++)
+   {
+      int SW = val<1>(cells[c]); 
+      int SE = val<2>(cells[c]); 
+      int NE = val<3>(cells[c]);
+      int NW = val<4>(cells[c]);
+      if(swapByte)
+      {
+         UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int));
+      }
+
+      out.write((char*)&nodesPerCellDummy,sizeof(int));
+      out.write((char*)&SW,sizeof(int));
+      out.write((char*)&SE,sizeof(int));
+      out.write((char*)&NW,sizeof(int));
+      out.write((char*)&NE,sizeof(int));
+   }
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<(int)cells.size()<<"\n";
+   int celltype = 8;
+   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int));
+   for(int c=0; c<nofCells; c++)
+      out.write((char*)&celltype,sizeof(int));
+
+   out<<endl;
+
+   //DATA SECTION
+   //write data section
+   out<<"CELL_DATA "<<nofCells<<"\n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      if((int)celldata[s].size() != nofCells) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes");
+      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
+      for(int d=0; d<(int)celldata[s].size(); d++)
+      { 
+         float dummy = (float)celldata[s][d]; 
+         if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); 
+         out.write((const char*)&dummy,sizeof(float));
+      }
+      out<<endl;
+   }
+   out.close();
+
+   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithCellData to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkBinary::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, 
+                                                             vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames,
+                                                             vector< vector< double > >& celldata                                                                    )
+{
+   string vtkfilename = filename + getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   //HEADER-SECTION
+   //WRITE BIGENDIAN VtkBinary FILE
+   bool swapByte = UbSystem::isLittleEndian();
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"D3Q19MasterNodeGrid"<<"\n";
+   out<<""<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+   {
+      float x1 = (float)val<1>(nodes[n]); 
+      float x2 = (float)val<2>(nodes[n]); 
+      float x3 = (float)val<3>(nodes[n]);  
+
+      if(swapByte)
+      {
+         UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float));
+         UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float));
+         UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float));
+      }
+
+      out.write((char*)&x1,sizeof(float));
+      out.write((char*)&x2,sizeof(float));
+      out.write((char*)&x3,sizeof(float));
+   }
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n";
+
+   int nodesPerCellDummy = 4;  //nofNodesPerCell         
+   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int));
+   for(int c=0; c<(int)cells.size(); c++)
+   {
+      int SW = val<1>(cells[c]); 
+      int SE = val<2>(cells[c]); 
+      int NE = val<3>(cells[c]);
+      int NW = val<4>(cells[c]);
+      if(swapByte)
+      {
+         UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int));
+      }
+
+      out.write((char*)&nodesPerCellDummy,sizeof(int));
+      out.write((char*)&SW,sizeof(int));
+      out.write((char*)&SE,sizeof(int));
+      out.write((char*)&NW,sizeof(int));
+      out.write((char*)&NE,sizeof(int));
+   }
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<(int)cells.size()<<"\n";
+   int celltype = 8;
+   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int));
+   for(int c=0; c<nofCells; c++)
+      out.write((char*)&celltype,sizeof(int));
+
+   out<<endl;
+
+   //NODE DATA SECTION
+   //write data section
+   out<<"POINT_DATA "<<nofNodes<<"\n";
+   for(int s=0; s<(int)nodedatanames.size(); ++s)
+   {
+      if((int)nodedata[s].size() != nofNodes) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes");
+      out<<"SCALARS "<<nodedatanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
+      for(int d=0; d<(int)nodedata[s].size(); d++)
+      { 
+         float dummy = (float)nodedata[s][d]; 
+         if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); 
+         out.write((const char*)&dummy,sizeof(float));
+      }
+      out<<endl;
+   }
+   
+   //CELL DATA SECTION
+   //write data section
+   out<<"CELL_DATA "<<nofCells<<"\n";
+   for(int s=0; s<(int)celldatanames.size(); ++s)
+   {
+      if((int)celldata[s].size() != nofCells) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes");
+      out<<"SCALARS "<<celldatanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
+      for(int d=0; d<(int)celldata[s].size(); d++)
+      { 
+         float dummy = (float)celldata[s][d]; 
+         if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); 
+         out.write((const char*)&dummy,sizeof(float));
+      }
+      out<<endl;
+   }
+
+   out.close();
+
+   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkBinary::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata)
+{
+   string vtkfilename = filename + getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithCellData to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   //HEADER-SECTION
+   //WRITE BIGENDIAN VtkBinary FILE
+   bool swapByte = UbSystem::isLittleEndian();
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"D3Q19MasterNodeGrid"<<"\n";
+   out<<""<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+   {
+      float x1 = (float)val<1>(nodes[n]); 
+      float x2 = (float)val<2>(nodes[n]); 
+      float x3 = (float)val<3>(nodes[n]);
+
+      if(swapByte)
+      {
+         UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float));
+         UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float));
+         UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float));
+      }
+
+      out.write((char*)&x1,sizeof(float));
+      out.write((char*)&x2,sizeof(float));
+      out.write((char*)&x3,sizeof(float));
+   }
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofCells<<" "<<nofCells*9<<"\n";
+
+   int nodesPerCellDummy = 8;  //nofNodesPerCell         
+   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int));
+   for(int c=0; c<(int)cells.size(); c++)
+   {
+      int BSW = val<1>(cells[c]);  int TSW = val<5>(cells[c]);
+      int BSE = val<2>(cells[c]);  int TSE = val<6>(cells[c]);
+      int BNW = val<3>(cells[c]);  int TNW = val<7>(cells[c]);
+      int BNE = val<4>(cells[c]);  int TNE = val<8>(cells[c]);
+      if(swapByte)
+      {
+         UbSystem::swapByteOrder((unsigned char*)&BSW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&BSE,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&BNW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&BNE,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&TSW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&TSE,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&TNW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&TNE,sizeof(int));
+      }
+
+      out.write((char*)&nodesPerCellDummy,sizeof(int));
+      out.write((char*)&BSW,sizeof(int));
+      out.write((char*)&BSE,sizeof(int));
+      out.write((char*)&BNE,sizeof(int));
+      out.write((char*)&BNW,sizeof(int));
+      out.write((char*)&TSW,sizeof(int));
+      out.write((char*)&TSE,sizeof(int));
+      out.write((char*)&TNE,sizeof(int));
+      out.write((char*)&TNW,sizeof(int));
+   }
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<(int)cells.size()<<"\n";
+   int celltype = 11;
+   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int));
+   for(int c=0; c<nofCells; c++)
+      out.write((char*)&celltype,sizeof(int));
+
+   out<<endl;
+
+   //CELL DATA SECTION
+   //write data section
+   out<<"CELL_DATA "<<nofCells<<"\n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      if((int)celldata[s].size() != nofCells) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes");
+      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
+      for(int d=0; d<(int)celldata[s].size(); d++)
+      { 
+         float dummy = (float)celldata[s][d]; 
+         if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); 
+         out.write((const char*)&dummy,sizeof(float));
+      }
+      out<<endl;
+   }
+   out.close();
+
+   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithCellData to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata)
+{
+   //HEADER-SECTION
+   string vtkfilename = filename + getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithNodeData to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   //WRITE BIGENDIAN VtkBinary FILE
+   bool swapByte = UbSystem::isLittleEndian();
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"D3Q19MasterNodeGrid"<<"\n";
+   out<<""<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+   {
+      float x1 = val<1>(nodes[n]); 
+      float x2 = val<2>(nodes[n]); 
+      float x3 = val<3>(nodes[n]); 
+
+      if(swapByte)
+      {
+         UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float));
+         UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float));
+         UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float));
+      }
+
+      out.write((char*)&x1,sizeof(float));
+      out.write((char*)&x2,sizeof(float));
+      out.write((char*)&x3,sizeof(float));
+   }
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofCells<<" "<<nofCells*9<<"\n";
+
+   int nodesPerCellDummy = 8;  //nofNodesPerCell         
+   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int));
+   for(int c=0; c<(int)cells.size(); c++)
+   {
+      int BSW = val<1>(cells[c]);  int TSW = val<5>(cells[c]);
+      int BSE = val<2>(cells[c]);  int TSE = val<6>(cells[c]);
+      int BNW = val<3>(cells[c]);  int TNW = val<7>(cells[c]);
+      int BNE = val<4>(cells[c]);  int TNE = val<8>(cells[c]);
+      if(swapByte)
+      {
+         UbSystem::swapByteOrder((unsigned char*)&BSW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&BSE,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&BNW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&BNE,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&TSW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&TSE,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&TNW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&TNE,sizeof(int));
+      }
+
+      out.write((char*)&nodesPerCellDummy,sizeof(int));
+      out.write((char*)&BSW,sizeof(int));
+      out.write((char*)&BSE,sizeof(int));
+      out.write((char*)&BNE,sizeof(int));
+      out.write((char*)&BNW,sizeof(int));
+      out.write((char*)&TSW,sizeof(int));
+      out.write((char*)&TSE,sizeof(int));
+      out.write((char*)&TNE,sizeof(int));
+      out.write((char*)&TNW,sizeof(int));
+   }
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<(int)cells.size()<<"\n";
+   int celltype = 11;
+   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int));
+   for(int c=0; c<nofCells; c++)
+      out.write((char*)&celltype,sizeof(int));
+
+   out<<endl;
+
+   //NODE DATA SECTION
+   //write data section
+   out<<"POINT_DATA "<<nofNodes<<"\n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      if((int)nodedata[s].size() != nofNodes) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes");
+      out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n";
+      for(int d=0; d<(int)nodedata[s].size(); d++)
+      { 
+         float dummy = (float)nodedata[s][d]; 
+         if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); 
+         out.write((const char*)&dummy,sizeof(float));
+      }
+      out<<endl;
+   }
+
+   out.close();
+
+   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithNodeData to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkBinary::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells)
+{
+   string vtkfilename = filename + getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOcts to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   //HEADER-SECTION
+   //WRITE BIGENDIAN VtkBinary FILE
+   bool swapByte = UbSystem::isLittleEndian();
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   out<<"# vtk DataFile Version 4.0"<<"\n";
+   out<<"D3Q19MasterNodeGrid"<<"\n";
+   out<<""<<"\n";
+
+   //POINTS SECTION
+   out<<"DATASET UNSTRUCTURED_GRID"<<"\n";
+   out<<"POINTS "<<nofNodes<<" float"<<"\n";
+   for(int n=0; n<nofNodes; n++)
+   {
+      float x1 = val<1>(nodes[n]); 
+      float x2 = val<2>(nodes[n]); 
+      float x3 = val<3>(nodes[n]); 
+
+      if(swapByte)
+      {
+         UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float));
+         UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float));
+         UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float));
+      }
+
+      out.write((char*)&x1,sizeof(float));
+      out.write((char*)&x2,sizeof(float));
+      out.write((char*)&x3,sizeof(float));
+   }
+   out<<"\n";
+
+   //CELLS SECTION
+   out<<"CELLS "<<nofCells<<" "<<nofCells*9<<"\n";
+
+   int nodesPerCellDummy = 8;  //nofNodesPerCell         
+   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int));
+   for(int c=0; c<(int)cells.size(); c++)
+   {
+      int BSW = val<1>(cells[c]);  int TSW = val<5>(cells[c]);
+      int BSE = val<2>(cells[c]);  int TSE = val<6>(cells[c]);
+      int BNW = val<3>(cells[c]);  int TNW = val<7>(cells[c]);
+      int BNE = val<4>(cells[c]);  int TNE = val<8>(cells[c]);
+      if(swapByte)
+      {
+         UbSystem::swapByteOrder((unsigned char*)&BSW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&BSE,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&BNW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&BNE,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&TSW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&TSE,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&TNW,sizeof(int));
+         UbSystem::swapByteOrder((unsigned char*)&TNE,sizeof(int));
+      }
+
+       out.write((char*)&nodesPerCellDummy,sizeof(int));
+       out.write((char*)&BSW,sizeof(int));
+       out.write((char*)&BSE,sizeof(int));
+       out.write((char*)&BNE,sizeof(int));
+       out.write((char*)&BNW,sizeof(int));
+       out.write((char*)&TSW,sizeof(int));
+       out.write((char*)&TSE,sizeof(int));
+       out.write((char*)&TNE,sizeof(int));
+       out.write((char*)&TNW,sizeof(int));
+   }
+   out<<"\n";
+
+   out<<"CELL_TYPES "<<(int)cells.size()<<"\n";
+   int celltype = 11;
+   if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int));
+   for(int c=0; c<nofCells; c++)
+      out.write((char*)&celltype,sizeof(int));
+
+   out<<endl;
+   out.close();
+
+   UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOcts to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
+
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterVtkBinary.h b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkBinary.h
similarity index 98%
rename from source/ThirdParty/Library/basics/writer/WbWriterVtkBinary.h
rename to source/VirtualFluidsBasic/basics/writer/WbWriterVtkBinary.h
index dca3567d3505e0bea3c549ab601cb478c0bb17ed..c67666c2cc5d688f4901ee02c7741b056e55ac33 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterVtkBinary.h
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkBinary.h
@@ -1,77 +1,77 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef WBWRITERVTKBINARY_H
-#define WBWRITERVTKBINARY_H
-
-#include <basics/writer/WbWriter.h>
-
-class WbWriterVtkBinary : public WbWriter
-{
-public:
-   OBCREATOR_EXT( WbWriterVtkBinary )
-
-   static WbWriterVtkBinary* getInstance()
-   {
-      static WbWriterVtkBinary instance;
-      return &instance;
-   }
-private:
-   WbWriterVtkBinary() : WbWriter() {}                             
-   WbWriterVtkBinary( const WbWriterVtkBinary& );                  //no copy allowed 
-   const WbWriterVtkBinary& operator=( const WbWriterVtkBinary& ); //no copy allowed
-
-public:
-   std::string getFileExtension() { return ".bin.vtk"; }
-
-   //////////////////////////////////////////////////////////////////////////
-   //lines
-   //     0 ---- 1
-   //nodenumbering must start with 0!
-   std::string writeLines(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines);
-
-   //////////////////////////////////////////////////////////////////////////
-   //triangles
-   //cell numbering:
-   //                    2
-   //                     
-   //                  0---1
-   //nodenumbering must start with 0!
-   std::string writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells);
-   std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-
-   //////////////////////////////////////////////////////////////////////////
-   //2D
-   //cell numbering:
-   //                  3---2
-   //                  |   |
-   //                  0---1
-   //nodenumbering must start with 0!
-   std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells);
-   std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-   std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
-   std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, 
-                                             std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames,
-                                             std::vector< std::vector< double > >& celldata                                                                    );
-   
-   //////////////////////////////////////////////////////////////////////////
-   //octs
-   //     7 ---- 6
-   //    /|     /|
-   //   4 +--- 5 |
-   //   | |    | |
-   //   | 3 ---+ 2
-   //   |/     |/
-   //   0 ---- 1
-   std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
-   std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata);
-   std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
-
-};
-
-UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkBinary ,WbWriter>::getInstance()), CAB_WbWriterVtkBinary);
-
-#endif //WBWRITERVTKBINARY_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef WBWRITERVTKBINARY_H
+#define WBWRITERVTKBINARY_H
+
+#include <basics/writer/WbWriter.h>
+
+class WbWriterVtkBinary : public WbWriter
+{
+public:
+   OBCREATOR_EXT( WbWriterVtkBinary )
+
+   static WbWriterVtkBinary* getInstance()
+   {
+      static WbWriterVtkBinary instance;
+      return &instance;
+   }
+private:
+   WbWriterVtkBinary() : WbWriter() {}                             
+   WbWriterVtkBinary( const WbWriterVtkBinary& );                  //no copy allowed 
+   const WbWriterVtkBinary& operator=( const WbWriterVtkBinary& ); //no copy allowed
+
+public:
+   std::string getFileExtension() { return ".bin.vtk"; }
+
+   //////////////////////////////////////////////////////////////////////////
+   //lines
+   //     0 ---- 1
+   //nodenumbering must start with 0!
+   std::string writeLines(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines);
+
+   //////////////////////////////////////////////////////////////////////////
+   //triangles
+   //cell numbering:
+   //                    2
+   //                     
+   //                  0---1
+   //nodenumbering must start with 0!
+   std::string writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells);
+   std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+
+   //////////////////////////////////////////////////////////////////////////
+   //2D
+   //cell numbering:
+   //                  3---2
+   //                  |   |
+   //                  0---1
+   //nodenumbering must start with 0!
+   std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells);
+   std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+   std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
+   std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, 
+                                             std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames,
+                                             std::vector< std::vector< double > >& celldata                                                                    );
+   
+   //////////////////////////////////////////////////////////////////////////
+   //octs
+   //     7 ---- 6
+   //    /|     /|
+   //   4 +--- 5 |
+   //   | |    | |
+   //   | 3 ---+ 2
+   //   |/     |/
+   //   0 ---- 1
+   std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
+   std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata);
+   std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
+
+};
+
+UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkBinary ,WbWriter>::getInstance()), CAB_WbWriterVtkBinary);
+
+#endif //WBWRITERVTKBINARY_H
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.cpp b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkXmlASCII.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.cpp
rename to source/VirtualFluidsBasic/basics/writer/WbWriterVtkXmlASCII.cpp
index 51a52f5811c60f9a8463f5881837c105d0b09cb7..3cdff4b114877fe6df8bb76645300d0aa8f94a70 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.cpp
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkXmlASCII.cpp
@@ -1,1189 +1,1189 @@
-#include <basics/writer/WbWriterVtkXmlASCII.h>
-#include <basics/utilities/UbLogger.h>
-#include <cstring>
-#include <limits>
-
-using namespace std;
-
-/*===============================================================================*/
-std::string WbWriterVtkXmlASCII::pvdEndTag ="   </Collection>\n</VTKFile>";
-/*===============================================================================*/
-std::string WbWriterVtkXmlASCII::writeCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timeStep, const bool& sepGroups)
-{
-   std::string vtkfilename=filename+".pvd";
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   std::string endian;
-   if(UbSystem::isLittleEndian()) endian = "LittleEndian";
-   else                           endian = "BigEndian";
-   out<<"<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\""<<endian<<"\" >\n";
-   out<<"   <Collection>"<<endl;
-   
-   int group = 0, part=0;
-   for(std::size_t i=0; i<filenames.size(); i++)
-   {
-      out<<"       <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<part<<"\" file=\""<<filenames[i]<<"\"/>\n";
-      if(sepGroups) group++;
-      else          part++;
-   }
-   out<<pvdEndTag;
-   out.close();
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkXmlASCII::addFilesToCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timeStep, const bool& sepGroups)
-{
-   std::string vtkfilename=filename;
-   std::fstream test(vtkfilename.c_str(), ios::in);
-   if(!test)
-   {
-      test.clear();
-      vtkfilename += ".pvd";
-      test.open(vtkfilename.c_str(), ios::in);
-      if(!test) return this->writeCollection(filename,filenames,timeStep,sepGroups);
-   }
-
-   std::fstream out(vtkfilename.c_str(), ios::in | ios::out);
-   out.seekp(-(int)pvdEndTag.size()-1, ios_base::end);
-
-   int group = 0;
-   for(std::size_t i=0; i<filenames.size(); i++)
-   {
-      out<<"       <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<i<<"\" file=\""<<filenames[i]<<"\"/>\n";
-      if(sepGroups) group++;
-   }
-   out<<pvdEndTag;
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkXmlASCII::writeParallelFile(const string& filename,vector<string>& pieceSources, vector<string>& pointDataNames, vector<string>& cellDataNames)
-{
-   string vtkfilename=filename+".pvtu";
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeParallelFile to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   //VTK FILE
-   out<<"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
-   out<<"  <PUnstructuredGrid GhostLevel=\"0\">\n";
-   out<<"    <PPoints>\n"; 
-   out<<"      <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n";
-   out<<"    </PPoints>\n";
-   out<<"    <PPointData>\n";
-   for(size_t s=0; s<pointDataNames.size(); s++)
-      out<< "      <PDataArray type=\"Float32\" Name=\""<< pointDataNames[s] <<"\"/>\n";
-   out<<"    </PPointData>\n";
-   if (cellDataNames.size() > 0)
-   {
-      out<<"    <PCellData>\n";
-      for(size_t s=0; s<cellDataNames.size(); s++)
-         out<< "      <PDataArray type=\"Float32\" Name=\""<< cellDataNames[s] <<"\"/>\n";
-      out<<"    </PCellData>\n";
-   }
-
-   for(size_t s=0; s<pieceSources.size(); s++)
-      out<<"    <Piece Source=\""<<pieceSources[s]<<"\"/>\n";
-   out<<"  </PUnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeParallelFile to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkXmlASCII::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuads to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VTK FILE
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
-
-   //POINTS SECTION
-   out<<"      <Points>\n"; 
-   out<<"         <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
-
-   out<<"\n";
-   out<<"         </DataArray>\n";
-   out<<"      </Points>\n";
-
-   //CELLS SECTION
-   out<<"      <Cells>\n";
-   out<<"         <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
-
-   for(int c=0; c<nofCells; c++)
-      out<< val<1>(cells[c]) <<" "
-         << val<2>(cells[c]) <<" "
-         << val<4>(cells[c]) <<" "
-         << val<3>(cells[c]) <<"   ";
-   out<<"\n";
-   out<<"      </DataArray>\n";
-   out<<"         <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
-   for(int c=1; c<nofCells+1; c++)
-      out<<c*4<<" " ;
-
-   out<<"\n";
-   out<<"         </DataArray>\n";
-
-   out<<"      <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n";
-
-   for(int c=0; c<nofCells; c++)
-      out<<"8 ";
-   out<<"\n";
-   out<<"      </DataArray>\n";
-   out<<"      </Cells>\n";
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuads to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkXmlASCII::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VTK FILE
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"         </Points>\n";
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofCells; c++)
-      out<< val<1>(cells[c]) <<" "
-         << val<2>(cells[c]) <<" "
-         << val<4>(cells[c]) <<" "
-         << val<3>(cells[c]) <<"   ";
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
-   for(int c=1; c<nofCells+1; c++)
-      out<<c*4<<" " ;
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofCells; c++)
-      out<<"8 ";
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"         </Cells>\n";
-
-   //write data section
-   out<<"         <PointData Scalars=\"Scalars\"> \n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      out<< "           <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n";
-
-      for(int d=0; d<(int)nodedata[s].size(); d++)
-         out<<nodedata[s][d]<<" ";
-
-      out<<"\n          </DataArray>\n";
-    }
-   out<<"         </PointData>\n";
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - end");
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkXmlASCII::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithCellData to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VTK FILE
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"         </Points>\n";
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofCells; c++)
-      out<< val<1>(cells[c]) <<" "
-         << val<2>(cells[c]) <<" "
-         << val<4>(cells[c]) <<" "
-         << val<3>(cells[c]) <<"   ";
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
-   for(int c=1; c<nofCells+1; c++)
-      out<<c*4<<" " ;
-
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofCells; c++)
-      out<<"8 ";
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"         </Cells>\n";
-
-   //write data section
-   out<<"         <CellData Scalars=\"Scalars\"> \n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      out<< "           <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n";
-
-      for(int d=0; d<(int)celldata[s].size(); d++)
-         out<<celldata[s][d]<<" ";
-
-      out<<"\n          </DataArray>\n";
-   }
-   out<<"         </CellData>\n";
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-
-   out.close();
-
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithCellData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-string WbWriterVtkXmlASCII::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, 
-                                                          vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames,
-                                                          vector< vector< double > >& celldata                                                                       )
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VTK FILE
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"         </Points>\n";
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofCells; c++)
-      out<< val<1>(cells[c]) <<" "
-         << val<2>(cells[c]) <<" "
-         << val<4>(cells[c]) <<" "
-         << val<3>(cells[c]) <<"   ";
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
-   for(int c=1; c<nofCells+1; c++)
-      out<<c*4<<" " ;
-
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofCells; c++)
-      out<<"8 ";
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"         </Cells>\n";
-   
-   //write PointData section
-   out<<"         <PointData Scalars=\"PScalars\"> \n";
-   for(int s=0; s<(int)nodedatanames.size(); ++s)
-   {
-      out<< "           <DataArray type=\"Float32\" Name=\""<< nodedatanames[s] <<"\" format=\"ascii\"> \n";
-
-      for(int d=0; d<(int)nodedata[s].size(); d++)
-         out<<nodedata[s][d]<<" ";
-
-      out<<"\n          </DataArray>\n";
-   }
-   out<<"         </PointData>\n";
-
-   //write celldata section
-   out<<"         <CellData Scalars=\"CScalars\"> \n";
-   for(int s=0; s<(int)celldatanames.size(); ++s)
-   {
-      out<< "           <DataArray type=\"Float32\" Name=\""<< celldatanames[s] <<"\" format=\"ascii\"> \n";
-
-      for(int d=0; d<(int)celldata[s].size(); d++)
-         out<<celldata[s][d]<<" ";
-
-      out<<"\n          </DataArray>\n";
-   }
-   out<<"         </CellData>\n";
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkXmlASCII::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines) 
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofLines = (int)lines.size(); 
-
-   //VTK FILE
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofLines<<"\">   \n";
-
-   //POINTS SECTION
-   out<<"      <Points>\n"; 
-   out<<"         <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
-
-   out<<"\n";
-   out<<"         </DataArray>\n";
-   out<<"      </Points>\n";
-
-   //CELLS SECTION
-   out<<"      <Cells>\n";
-   out<<"         <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
-
-   for(int c=0; c<nofLines; c++)
-      out<< val<1>(lines[c]) <<" "<< val<2>(lines[c])<<"  ";
-   out<<"\n";
-   out<<"      </DataArray>\n";
-   out<<"         <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
-   for(int c=1; c<=nofLines; c++)
-      out<<c*2<<" " ;
-
-   out<<"\n";
-   out<<"         </DataArray>\n";
-
-   out<<"      <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n";
-
-   for(int c=0; c<nofLines; c++)
-      out<<"3 ";
-   out<<"\n";
-   out<<"      </DataArray>\n";
-   out<<"      </Cells>\n";
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkXmlASCII::writeLinesWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLinesWithNodeData to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofLines = (int)lines.size(); 
-
-   //VTK FILE
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofLines<<"\">   \n";
-
-   //POINTS SECTION
-   out<<"      <Points>\n"; 
-   out<<"         <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
-
-   out<<"\n";
-   out<<"         </DataArray>\n";
-   out<<"      </Points>\n";
-
-   //CELLS SECTION
-   out<<"      <Cells>\n";
-   out<<"         <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
-
-   for(int c=0; c<nofLines; c++)
-      out<< val<1>(lines[c]) <<" "<< val<2>(lines[c])<<"  ";
-   out<<"\n";
-   out<<"      </DataArray>\n";
-   out<<"         <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
-   for(int c=1; c<=nofLines; c++)
-      out<<c*2<<" " ;
-
-   out<<"\n";
-   out<<"         </DataArray>\n";
-
-   out<<"      <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n";
-
-   for(int c=0; c<nofLines; c++)
-      out<<"3 ";
-   out<<"\n";
-   out<<"      </DataArray>\n";
-   out<<"      </Cells>\n";
-
-   //write data section
-   out<<"         <PointData Scalars=\"Scalars\"> \n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      out<< "           <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n";
-
-      for(int d=0; d<(int)nodedata[s].size(); d++)
-         out<<nodedata[s][d]<<" ";
-
-      out<<"\n          </DataArray>\n";
-   }
-   out<<"         </PointData>\n";
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLinesWithNodeData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkXmlASCII::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTriangles to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofTriangles= (int)triangles.size(); 
-
-   //VTK FILE
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofTriangles<<"\">   \n";
-
-   //POINTS SECTION
-   out<<"      <Points>\n"; 
-   out<<"         <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
-
-   out<<"\n";
-   out<<"         </DataArray>\n";
-   out<<"      </Points>\n";
-
-   //CELLS SECTION
-   out<<"      <Cells>\n";
-   out<<"         <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
-
-   for(int c=0; c<nofTriangles; c++)
-      out<< val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<"  ";
-   out<<"\n";
-   out<<"      </DataArray>\n";
-   out<<"         <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
-   for(int c=1; c<nofTriangles+1; c++)
-      out<<c*3<<" " ;
-
-   out<<"\n";
-   out<<"         </DataArray>\n";
-
-   out<<"      <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n";
-
-   for(int c=0; c<nofTriangles; c++)
-      out<<"5 ";
-   out<<"\n";
-   out<<"      </DataArray>\n";
-   out<<"      </Cells>\n";
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTriangles to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkXmlASCII::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VTK FILE
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"         </Points>\n";
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofCells; c++)
-      out<< val<1>(cells[c]) <<" "<< val<2>(cells[c]) <<" "<< val<3>(cells[c]) <<"   ";
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
-   for(int c=1; c<nofCells+1; c++)
-      out<<c*3<<" " ;
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofCells; c++)
-      out<<"5 ";
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"         </Cells>\n";
-
-   //write data section
-   out<<"         <PointData Scalars=\"Scalars\"> \n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      out<< "           <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n";
-
-      for(int d=0; d<(int)nodedata[s].size(); d++)
-         out<<nodedata[s][d]<<" ";
-
-      out<<"\n          </DataArray>\n";
-   }
-   out<<"         </PointData>\n";
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkXmlASCII::writeOctsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithCellData to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VTK FILE
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"         </Points>\n";
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofCells; c++)
-      out<< val<1>(cells[c]) <<" "
-         << val<2>(cells[c]) <<" "
-         << val<4>(cells[c]) <<" "
-         << val<3>(cells[c]) <<" "
-         << val<5>(cells[c]) <<" "
-         << val<6>(cells[c]) <<" "
-         << val<8>(cells[c]) <<" "
-         << val<7>(cells[c]) <<"  ";
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
-   for(int c=1; c<nofCells+1; c++)
-      out<<c*8<<" " ;
-
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofCells; c++)
-      out<<"11 ";
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"         </Cells>\n";
-   
-
-   //write data section
-   out<<"         <CellData Scalars=\"Scalars\"> \n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      out<< "           <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n";
-
-      for(int d=0; d<(int)celldata[s].size(); d++)
-         out<<celldata[s][d]<<" ";
-
-      out<<"\n          </DataArray>\n";
-   }
-   out<<"         </CellData>\n";
-
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithCellData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkXmlASCII::writeOctsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithNodeData to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VTK FILE
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
-   for(int n=0; n<nofNodes; n++)
-      out<<val<1>(nodes[n])<<" "<<val<2>(nodes[n])<<" "<<val<3>(nodes[n])<<" ";
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"         </Points>\n";
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofCells; c++)
-      out<< val<1>(cells[c]) <<" "
-         << val<2>(cells[c]) <<" "
-         << val<4>(cells[c]) <<" "
-         << val<3>(cells[c]) <<" "
-         << val<5>(cells[c]) <<" "
-         << val<6>(cells[c]) <<" "
-         << val<8>(cells[c]) <<" "
-         << val<7>(cells[c]) <<"  ";
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
-   for(int c=1; c<nofCells+1; c++)
-      out<<c*8<<" " ;
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofCells; c++)
-      out<<"11 ";
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"         </Cells>\n";
-
-   //write PointData section
-   out<<"         <PointData Scalars=\"PScalars\"> \n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      out<< "           <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\">";
-
-      for(int d=0; d<(int)nodedata[s].size(); d++)
-      {
-         //out<<base64_encode((unsigned char*)(&nodedata[s][d]),sizeof(float));
-         //out.write((char*)&nodedata[s][d],sizeof(float));
-         out<<nodedata[s][d]<<" ";
-      }
-      out<<"</DataArray>\n";
-   }
-   out<<"         </PointData>\n";
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithNodeData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkXmlASCII::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOcts to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   //VTK FILE
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"         </Points>\n";
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofCells; c++)
-      out<< val<1>(cells[c]) <<" "
-         << val<2>(cells[c]) <<" "
-         << val<4>(cells[c]) <<" "
-         << val<3>(cells[c]) <<" "
-         << val<5>(cells[c]) <<" "
-         << val<6>(cells[c]) <<" "
-         << val<8>(cells[c]) <<" "
-         << val<7>(cells[c]) <<"   ";
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
-   for(int c=1; c<nofCells+1; c++)
-      out<<c*8<<" " ;
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofCells; c++)
-      out<<"11 ";
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"         </Cells>\n";
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOcts to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-std::string WbWriterVtkXmlASCII::writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-
-   //VTK FILE
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofNodes<<"\">   \n";
-
-   //POINTS SECTION
-   out<<"      <Points>\n"; 
-   out<<"         <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
-
-   out<<"\n";
-   out<<"         </DataArray>\n";
-   out<<"      </Points>\n";
-
-   //CELLS SECTION
-   out<<"      <Cells>\n";
-   out<<"         <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
-   for(int n=0; n<nofNodes; n++)
-      out<< n << "  ";
-   out<<"\n";
-
-   out<<"      </DataArray>\n";
-   out<<"         <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
-   for(int n=1; n<=nofNodes; n++)
-      out << n << " ";
-
-   out<<"\n";
-   out<<"         </DataArray>\n";
-
-   out<<"      <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n";
-
-   for(int n=0; n<nofNodes; n++)
-      out<<"1 ";
-   out<<"\n";
-   out<<"      </DataArray>\n";
-   out<<"      </Cells>\n";
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-std::string WbWriterVtkXmlASCII::writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeNodesWithNodeData to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-
-   //VTK FILE
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofNodes<<"\">   \n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"         </Points>\n";
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofNodes; c++)
-      out << c <<"   ";
-   out<<"\n";
-
-   out<<"            </DataArray>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
-   for(int c=1; c<nofNodes+1; c++)
-      out<<c<<" " ;
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
-   for(int c=0; c<nofNodes; c++)
-      out<<"1 ";
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"         </Cells>\n";
-
-   //write data section
-   out<<"         <PointData Scalars=\"Scalars\"> \n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      out<< "           <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n";
-
-      for(int d=0; d<(int)nodedata[s].size(); d++)
-         out<<nodedata[s][d]<<" ";
-
-      out<<"\n          </DataArray>\n";
-   }
-   out<<"         </PointData>\n";
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeNodesWithNodeData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-
-//////////////////////////////////////////////////////////////////////////
-std::string WbWriterVtkXmlASCII::writeNodesWithNodeDataDouble(const std::string& filename,std::vector< UbTupleDouble3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata)
-{
-   string vtkfilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeNodesWithNodeData to "<<vtkfilename<<" - start");
-
-   std::ofstream out(vtkfilename.c_str());
-   out.precision (std::numeric_limits<double>::digits10 + 1);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-
-   //VTK FILE
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofNodes<<"\">   \n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
-   for(int n=0; n<nofNodes; n++)
-      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-   out<<"         </Points>\n";
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
-
-   for(int c=0; c<nofNodes; c++)
-      out << c <<"   ";
-   out<<"\n";
-
-   out<<"            </DataArray>\n";
-   out<<"            <DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\">\n              ";
-   for(int c=1; c<nofNodes+1; c++)
-      out<<c<<" " ;
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
-   for(int c=0; c<nofNodes; c++)
-      out<<"1 ";
-
-   out<<"\n";
-   out<<"            </DataArray>\n";
-
-   out<<"         </Cells>\n";
-
-   //write data section
-   out<<"         <PointData Scalars=\"Scalars\"> \n";
-   for(int s=0; s<(int)datanames.size(); ++s)
-   {
-      out<< "           <DataArray type=\"Float64\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n";
-
-      for(int d=0; d<(int)nodedata[s].size(); d++)
-         out<<nodedata[s][d]<<" ";
-
-      out<<"\n          </DataArray>\n";
-   }
-   out<<"         </PointData>\n";
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeNodesWithNodeData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
+#include <basics/writer/WbWriterVtkXmlASCII.h>
+#include <basics/utilities/UbLogger.h>
+#include <cstring>
+#include <limits>
+
+using namespace std;
+
+/*===============================================================================*/
+std::string WbWriterVtkXmlASCII::pvdEndTag ="   </Collection>\n</VTKFile>";
+/*===============================================================================*/
+std::string WbWriterVtkXmlASCII::writeCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timeStep, const bool& sepGroups)
+{
+   std::string vtkfilename=filename+".pvd";
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   std::string endian;
+   if(UbSystem::isLittleEndian()) endian = "LittleEndian";
+   else                           endian = "BigEndian";
+   out<<"<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\""<<endian<<"\" >\n";
+   out<<"   <Collection>"<<endl;
+   
+   int group = 0, part=0;
+   for(std::size_t i=0; i<filenames.size(); i++)
+   {
+      out<<"       <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<part<<"\" file=\""<<filenames[i]<<"\"/>\n";
+      if(sepGroups) group++;
+      else          part++;
+   }
+   out<<pvdEndTag;
+   out.close();
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkXmlASCII::addFilesToCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timeStep, const bool& sepGroups)
+{
+   std::string vtkfilename=filename;
+   std::fstream test(vtkfilename.c_str(), ios::in);
+   if(!test)
+   {
+      test.clear();
+      vtkfilename += ".pvd";
+      test.open(vtkfilename.c_str(), ios::in);
+      if(!test) return this->writeCollection(filename,filenames,timeStep,sepGroups);
+   }
+
+   std::fstream out(vtkfilename.c_str(), ios::in | ios::out);
+   out.seekp(-(int)pvdEndTag.size()-1, ios_base::end);
+
+   int group = 0;
+   for(std::size_t i=0; i<filenames.size(); i++)
+   {
+      out<<"       <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<i<<"\" file=\""<<filenames[i]<<"\"/>\n";
+      if(sepGroups) group++;
+   }
+   out<<pvdEndTag;
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkXmlASCII::writeParallelFile(const string& filename,vector<string>& pieceSources, vector<string>& pointDataNames, vector<string>& cellDataNames)
+{
+   string vtkfilename=filename+".pvtu";
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeParallelFile to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   //VTK FILE
+   out<<"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
+   out<<"  <PUnstructuredGrid GhostLevel=\"0\">\n";
+   out<<"    <PPoints>\n"; 
+   out<<"      <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n";
+   out<<"    </PPoints>\n";
+   out<<"    <PPointData>\n";
+   for(size_t s=0; s<pointDataNames.size(); s++)
+      out<< "      <PDataArray type=\"Float32\" Name=\""<< pointDataNames[s] <<"\"/>\n";
+   out<<"    </PPointData>\n";
+   if (cellDataNames.size() > 0)
+   {
+      out<<"    <PCellData>\n";
+      for(size_t s=0; s<cellDataNames.size(); s++)
+         out<< "      <PDataArray type=\"Float32\" Name=\""<< cellDataNames[s] <<"\"/>\n";
+      out<<"    </PCellData>\n";
+   }
+
+   for(size_t s=0; s<pieceSources.size(); s++)
+      out<<"    <Piece Source=\""<<pieceSources[s]<<"\"/>\n";
+   out<<"  </PUnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeParallelFile to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkXmlASCII::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuads to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VTK FILE
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
+
+   //POINTS SECTION
+   out<<"      <Points>\n"; 
+   out<<"         <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
+
+   out<<"\n";
+   out<<"         </DataArray>\n";
+   out<<"      </Points>\n";
+
+   //CELLS SECTION
+   out<<"      <Cells>\n";
+   out<<"         <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
+
+   for(int c=0; c<nofCells; c++)
+      out<< val<1>(cells[c]) <<" "
+         << val<2>(cells[c]) <<" "
+         << val<4>(cells[c]) <<" "
+         << val<3>(cells[c]) <<"   ";
+   out<<"\n";
+   out<<"      </DataArray>\n";
+   out<<"         <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
+   for(int c=1; c<nofCells+1; c++)
+      out<<c*4<<" " ;
+
+   out<<"\n";
+   out<<"         </DataArray>\n";
+
+   out<<"      <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n";
+
+   for(int c=0; c<nofCells; c++)
+      out<<"8 ";
+   out<<"\n";
+   out<<"      </DataArray>\n";
+   out<<"      </Cells>\n";
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuads to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkXmlASCII::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VTK FILE
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"         </Points>\n";
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofCells; c++)
+      out<< val<1>(cells[c]) <<" "
+         << val<2>(cells[c]) <<" "
+         << val<4>(cells[c]) <<" "
+         << val<3>(cells[c]) <<"   ";
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
+   for(int c=1; c<nofCells+1; c++)
+      out<<c*4<<" " ;
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofCells; c++)
+      out<<"8 ";
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"         </Cells>\n";
+
+   //write data section
+   out<<"         <PointData Scalars=\"Scalars\"> \n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      out<< "           <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n";
+
+      for(int d=0; d<(int)nodedata[s].size(); d++)
+         out<<nodedata[s][d]<<" ";
+
+      out<<"\n          </DataArray>\n";
+    }
+   out<<"         </PointData>\n";
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - end");
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkXmlASCII::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithCellData to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VTK FILE
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"         </Points>\n";
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofCells; c++)
+      out<< val<1>(cells[c]) <<" "
+         << val<2>(cells[c]) <<" "
+         << val<4>(cells[c]) <<" "
+         << val<3>(cells[c]) <<"   ";
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
+   for(int c=1; c<nofCells+1; c++)
+      out<<c*4<<" " ;
+
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofCells; c++)
+      out<<"8 ";
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"         </Cells>\n";
+
+   //write data section
+   out<<"         <CellData Scalars=\"Scalars\"> \n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      out<< "           <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n";
+
+      for(int d=0; d<(int)celldata[s].size(); d++)
+         out<<celldata[s][d]<<" ";
+
+      out<<"\n          </DataArray>\n";
+   }
+   out<<"         </CellData>\n";
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+
+   out.close();
+
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithCellData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+string WbWriterVtkXmlASCII::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, 
+                                                          vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames,
+                                                          vector< vector< double > >& celldata                                                                       )
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VTK FILE
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"         </Points>\n";
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofCells; c++)
+      out<< val<1>(cells[c]) <<" "
+         << val<2>(cells[c]) <<" "
+         << val<4>(cells[c]) <<" "
+         << val<3>(cells[c]) <<"   ";
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
+   for(int c=1; c<nofCells+1; c++)
+      out<<c*4<<" " ;
+
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofCells; c++)
+      out<<"8 ";
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"         </Cells>\n";
+   
+   //write PointData section
+   out<<"         <PointData Scalars=\"PScalars\"> \n";
+   for(int s=0; s<(int)nodedatanames.size(); ++s)
+   {
+      out<< "           <DataArray type=\"Float32\" Name=\""<< nodedatanames[s] <<"\" format=\"ascii\"> \n";
+
+      for(int d=0; d<(int)nodedata[s].size(); d++)
+         out<<nodedata[s][d]<<" ";
+
+      out<<"\n          </DataArray>\n";
+   }
+   out<<"         </PointData>\n";
+
+   //write celldata section
+   out<<"         <CellData Scalars=\"CScalars\"> \n";
+   for(int s=0; s<(int)celldatanames.size(); ++s)
+   {
+      out<< "           <DataArray type=\"Float32\" Name=\""<< celldatanames[s] <<"\" format=\"ascii\"> \n";
+
+      for(int d=0; d<(int)celldata[s].size(); d++)
+         out<<celldata[s][d]<<" ";
+
+      out<<"\n          </DataArray>\n";
+   }
+   out<<"         </CellData>\n";
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkXmlASCII::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines) 
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofLines = (int)lines.size(); 
+
+   //VTK FILE
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofLines<<"\">   \n";
+
+   //POINTS SECTION
+   out<<"      <Points>\n"; 
+   out<<"         <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
+
+   out<<"\n";
+   out<<"         </DataArray>\n";
+   out<<"      </Points>\n";
+
+   //CELLS SECTION
+   out<<"      <Cells>\n";
+   out<<"         <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
+
+   for(int c=0; c<nofLines; c++)
+      out<< val<1>(lines[c]) <<" "<< val<2>(lines[c])<<"  ";
+   out<<"\n";
+   out<<"      </DataArray>\n";
+   out<<"         <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
+   for(int c=1; c<=nofLines; c++)
+      out<<c*2<<" " ;
+
+   out<<"\n";
+   out<<"         </DataArray>\n";
+
+   out<<"      <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n";
+
+   for(int c=0; c<nofLines; c++)
+      out<<"3 ";
+   out<<"\n";
+   out<<"      </DataArray>\n";
+   out<<"      </Cells>\n";
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkXmlASCII::writeLinesWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLinesWithNodeData to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofLines = (int)lines.size(); 
+
+   //VTK FILE
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofLines<<"\">   \n";
+
+   //POINTS SECTION
+   out<<"      <Points>\n"; 
+   out<<"         <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
+
+   out<<"\n";
+   out<<"         </DataArray>\n";
+   out<<"      </Points>\n";
+
+   //CELLS SECTION
+   out<<"      <Cells>\n";
+   out<<"         <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
+
+   for(int c=0; c<nofLines; c++)
+      out<< val<1>(lines[c]) <<" "<< val<2>(lines[c])<<"  ";
+   out<<"\n";
+   out<<"      </DataArray>\n";
+   out<<"         <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
+   for(int c=1; c<=nofLines; c++)
+      out<<c*2<<" " ;
+
+   out<<"\n";
+   out<<"         </DataArray>\n";
+
+   out<<"      <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n";
+
+   for(int c=0; c<nofLines; c++)
+      out<<"3 ";
+   out<<"\n";
+   out<<"      </DataArray>\n";
+   out<<"      </Cells>\n";
+
+   //write data section
+   out<<"         <PointData Scalars=\"Scalars\"> \n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      out<< "           <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n";
+
+      for(int d=0; d<(int)nodedata[s].size(); d++)
+         out<<nodedata[s][d]<<" ";
+
+      out<<"\n          </DataArray>\n";
+   }
+   out<<"         </PointData>\n";
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLinesWithNodeData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkXmlASCII::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTriangles to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofTriangles= (int)triangles.size(); 
+
+   //VTK FILE
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofTriangles<<"\">   \n";
+
+   //POINTS SECTION
+   out<<"      <Points>\n"; 
+   out<<"         <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
+
+   out<<"\n";
+   out<<"         </DataArray>\n";
+   out<<"      </Points>\n";
+
+   //CELLS SECTION
+   out<<"      <Cells>\n";
+   out<<"         <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
+
+   for(int c=0; c<nofTriangles; c++)
+      out<< val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<"  ";
+   out<<"\n";
+   out<<"      </DataArray>\n";
+   out<<"         <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
+   for(int c=1; c<nofTriangles+1; c++)
+      out<<c*3<<" " ;
+
+   out<<"\n";
+   out<<"         </DataArray>\n";
+
+   out<<"      <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n";
+
+   for(int c=0; c<nofTriangles; c++)
+      out<<"5 ";
+   out<<"\n";
+   out<<"      </DataArray>\n";
+   out<<"      </Cells>\n";
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTriangles to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkXmlASCII::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VTK FILE
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"         </Points>\n";
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofCells; c++)
+      out<< val<1>(cells[c]) <<" "<< val<2>(cells[c]) <<" "<< val<3>(cells[c]) <<"   ";
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
+   for(int c=1; c<nofCells+1; c++)
+      out<<c*3<<" " ;
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofCells; c++)
+      out<<"5 ";
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"         </Cells>\n";
+
+   //write data section
+   out<<"         <PointData Scalars=\"Scalars\"> \n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      out<< "           <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n";
+
+      for(int d=0; d<(int)nodedata[s].size(); d++)
+         out<<nodedata[s][d]<<" ";
+
+      out<<"\n          </DataArray>\n";
+   }
+   out<<"         </PointData>\n";
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkXmlASCII::writeOctsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithCellData to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VTK FILE
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"         </Points>\n";
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofCells; c++)
+      out<< val<1>(cells[c]) <<" "
+         << val<2>(cells[c]) <<" "
+         << val<4>(cells[c]) <<" "
+         << val<3>(cells[c]) <<" "
+         << val<5>(cells[c]) <<" "
+         << val<6>(cells[c]) <<" "
+         << val<8>(cells[c]) <<" "
+         << val<7>(cells[c]) <<"  ";
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
+   for(int c=1; c<nofCells+1; c++)
+      out<<c*8<<" " ;
+
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofCells; c++)
+      out<<"11 ";
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"         </Cells>\n";
+   
+
+   //write data section
+   out<<"         <CellData Scalars=\"Scalars\"> \n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      out<< "           <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n";
+
+      for(int d=0; d<(int)celldata[s].size(); d++)
+         out<<celldata[s][d]<<" ";
+
+      out<<"\n          </DataArray>\n";
+   }
+   out<<"         </CellData>\n";
+
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithCellData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkXmlASCII::writeOctsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithNodeData to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VTK FILE
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
+   for(int n=0; n<nofNodes; n++)
+      out<<val<1>(nodes[n])<<" "<<val<2>(nodes[n])<<" "<<val<3>(nodes[n])<<" ";
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"         </Points>\n";
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofCells; c++)
+      out<< val<1>(cells[c]) <<" "
+         << val<2>(cells[c]) <<" "
+         << val<4>(cells[c]) <<" "
+         << val<3>(cells[c]) <<" "
+         << val<5>(cells[c]) <<" "
+         << val<6>(cells[c]) <<" "
+         << val<8>(cells[c]) <<" "
+         << val<7>(cells[c]) <<"  ";
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
+   for(int c=1; c<nofCells+1; c++)
+      out<<c*8<<" " ;
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofCells; c++)
+      out<<"11 ";
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"         </Cells>\n";
+
+   //write PointData section
+   out<<"         <PointData Scalars=\"PScalars\"> \n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      out<< "           <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\">";
+
+      for(int d=0; d<(int)nodedata[s].size(); d++)
+      {
+         //out<<base64_encode((unsigned char*)(&nodedata[s][d]),sizeof(float));
+         //out.write((char*)&nodedata[s][d],sizeof(float));
+         out<<nodedata[s][d]<<" ";
+      }
+      out<<"</DataArray>\n";
+   }
+   out<<"         </PointData>\n";
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithNodeData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkXmlASCII::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOcts to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   //VTK FILE
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofCells<<"\">   \n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"         </Points>\n";
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofCells; c++)
+      out<< val<1>(cells[c]) <<" "
+         << val<2>(cells[c]) <<" "
+         << val<4>(cells[c]) <<" "
+         << val<3>(cells[c]) <<" "
+         << val<5>(cells[c]) <<" "
+         << val<6>(cells[c]) <<" "
+         << val<8>(cells[c]) <<" "
+         << val<7>(cells[c]) <<"   ";
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
+   for(int c=1; c<nofCells+1; c++)
+      out<<c*8<<" " ;
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofCells; c++)
+      out<<"11 ";
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"         </Cells>\n";
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOcts to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+std::string WbWriterVtkXmlASCII::writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+
+   //VTK FILE
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofNodes<<"\">   \n";
+
+   //POINTS SECTION
+   out<<"      <Points>\n"; 
+   out<<"         <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
+
+   out<<"\n";
+   out<<"         </DataArray>\n";
+   out<<"      </Points>\n";
+
+   //CELLS SECTION
+   out<<"      <Cells>\n";
+   out<<"         <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
+   for(int n=0; n<nofNodes; n++)
+      out<< n << "  ";
+   out<<"\n";
+
+   out<<"      </DataArray>\n";
+   out<<"         <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
+   for(int n=1; n<=nofNodes; n++)
+      out << n << " ";
+
+   out<<"\n";
+   out<<"         </DataArray>\n";
+
+   out<<"      <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n";
+
+   for(int n=0; n<nofNodes; n++)
+      out<<"1 ";
+   out<<"\n";
+   out<<"      </DataArray>\n";
+   out<<"      </Cells>\n";
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+std::string WbWriterVtkXmlASCII::writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeNodesWithNodeData to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+
+   //VTK FILE
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofNodes<<"\">   \n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"         </Points>\n";
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofNodes; c++)
+      out << c <<"   ";
+   out<<"\n";
+
+   out<<"            </DataArray>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n              ";
+   for(int c=1; c<nofNodes+1; c++)
+      out<<c<<" " ;
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
+   for(int c=0; c<nofNodes; c++)
+      out<<"1 ";
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"         </Cells>\n";
+
+   //write data section
+   out<<"         <PointData Scalars=\"Scalars\"> \n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      out<< "           <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n";
+
+      for(int d=0; d<(int)nodedata[s].size(); d++)
+         out<<nodedata[s][d]<<" ";
+
+      out<<"\n          </DataArray>\n";
+   }
+   out<<"         </PointData>\n";
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeNodesWithNodeData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+
+//////////////////////////////////////////////////////////////////////////
+std::string WbWriterVtkXmlASCII::writeNodesWithNodeDataDouble(const std::string& filename,std::vector< UbTupleDouble3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata)
+{
+   string vtkfilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeNodesWithNodeData to "<<vtkfilename<<" - start");
+
+   std::ofstream out(vtkfilename.c_str());
+   out.precision (std::numeric_limits<double>::digits10 + 1);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+
+   //VTK FILE
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\"	NumberOfCells=\""<<nofNodes<<"\">   \n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\">\n               ";
+   for(int n=0; n<nofNodes; n++)
+      out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<"   ";
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+   out<<"         </Points>\n";
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n              ";
+
+   for(int c=0; c<nofNodes; c++)
+      out << c <<"   ";
+   out<<"\n";
+
+   out<<"            </DataArray>\n";
+   out<<"            <DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\">\n              ";
+   for(int c=1; c<nofNodes+1; c++)
+      out<<c<<" " ;
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n              ";
+   for(int c=0; c<nofNodes; c++)
+      out<<"1 ";
+
+   out<<"\n";
+   out<<"            </DataArray>\n";
+
+   out<<"         </Cells>\n";
+
+   //write data section
+   out<<"         <PointData Scalars=\"Scalars\"> \n";
+   for(int s=0; s<(int)datanames.size(); ++s)
+   {
+      out<< "           <DataArray type=\"Float64\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n";
+
+      for(int d=0; d<(int)nodedata[s].size(); d++)
+         out<<nodedata[s][d]<<" ";
+
+      out<<"\n          </DataArray>\n";
+   }
+   out<<"         </PointData>\n";
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeNodesWithNodeData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.h b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkXmlASCII.h
similarity index 98%
rename from source/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.h
rename to source/VirtualFluidsBasic/basics/writer/WbWriterVtkXmlASCII.h
index ece441015af0df1e538e1d29bff43136c93ccd9c..248131a01c1739de5c3c02ee5b9e2f71a1f79059 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.h
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkXmlASCII.h
@@ -1,94 +1,94 @@
-#ifndef WBWRITERVTKXMLASCII_H
-#define WBWRITERVTKXMLASCII_H
-
-#include <string>
-
-#include <basics/writer/WbWriter.h>
-
-class WbWriterVtkXmlASCII  : public WbWriter
-{
-public:
-   OBCREATOR_EXT( WbWriterVtkXmlASCII )
-
-   static WbWriterVtkXmlASCII* getInstance()
-   {
-      static WbWriterVtkXmlASCII instance;
-      return &instance;
-   }
-private:
-   WbWriterVtkXmlASCII() : WbWriter() 
-   {
-      if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char  type mismatch");
-      if(sizeof(int)          !=4) throw UbException(UB_EXARGS,"error int   type mismatch");
-      if(sizeof(float)        !=4) throw UbException(UB_EXARGS,"error float type mismatch");
-   }
-   WbWriterVtkXmlASCII( const WbWriterVtkXmlASCII& );                  //no copy allowed 
-   const WbWriterVtkXmlASCII& operator=( const WbWriterVtkXmlASCII& ); //no copy allowed
-
-   static std::string  pvdEndTag;
-
-public:
-   std::string getFileExtension()  { return ".ascii.vtu"; }
-
-   //write a metafile 
-   std::string writeCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timesteps, const bool& sepGroups);//std::vector<double>& groups, std::vector<double>& parts);
-   std::string addFilesToCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups);
-   std::string writeParallelFile(const std::string& filename,std::vector<std::string>& pieceSources, std::vector<std::string>& pointDataNames, std::vector<std::string>& cellDataNames);
-
-   //////////////////////////////////////////////////////////////////////////
-   //nodes
-   std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes);
-   std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
-   std::string writeNodesWithNodeDataDouble(const std::string& filename,std::vector< UbTupleDouble3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
-
-   //////////////////////////////////////////////////////////////////////////
-   //lines
-   //     0 ---- 1
-   //nodenumbering must start with 0!
-   std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines);
-   std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-
-   //////////////////////////////////////////////////////////////////////////
-   //triangles
-   //                    2
-   //                     
-   //                  0---1
-   //nodenumbering must start with 0!
-   std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles);
-   std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-
-   //////////////////////////////////////////////////////////////////////////
-   //2D
-   //cell numbering:
-   //                  3---2
-   //                  |   |
-   //                  0---1
-   //nodenumbering must start with 0!
-
-   std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells);
-   std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-   std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
-   std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, 
-                                             std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames,
-                                             std::vector< std::vector< double > >& celldata                                                                       );
-   
-   //////////////////////////////////////////////////////////////////////////
-   //octs
-   //     7 ---- 6
-   //    /|     /|
-   //   4 +--- 5 |
-   //   | |    | |
-   //   | 3 ---+ 2
-   //   |/     |/
-   //   0 ---- 1
-   std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
-   std::string writeOctsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
-   std::string writeOctsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-
-private:
-
-};
-
-UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkXmlASCII ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlASCII);
-
-#endif //WBWRITERVTKXMLASCII_H
+#ifndef WBWRITERVTKXMLASCII_H
+#define WBWRITERVTKXMLASCII_H
+
+#include <string>
+
+#include <basics/writer/WbWriter.h>
+
+class WbWriterVtkXmlASCII  : public WbWriter
+{
+public:
+   OBCREATOR_EXT( WbWriterVtkXmlASCII )
+
+   static WbWriterVtkXmlASCII* getInstance()
+   {
+      static WbWriterVtkXmlASCII instance;
+      return &instance;
+   }
+private:
+   WbWriterVtkXmlASCII() : WbWriter() 
+   {
+      if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char  type mismatch");
+      if(sizeof(int)          !=4) throw UbException(UB_EXARGS,"error int   type mismatch");
+      if(sizeof(float)        !=4) throw UbException(UB_EXARGS,"error float type mismatch");
+   }
+   WbWriterVtkXmlASCII( const WbWriterVtkXmlASCII& );                  //no copy allowed 
+   const WbWriterVtkXmlASCII& operator=( const WbWriterVtkXmlASCII& ); //no copy allowed
+
+   static std::string  pvdEndTag;
+
+public:
+   std::string getFileExtension()  { return ".ascii.vtu"; }
+
+   //write a metafile 
+   std::string writeCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timesteps, const bool& sepGroups);//std::vector<double>& groups, std::vector<double>& parts);
+   std::string addFilesToCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups);
+   std::string writeParallelFile(const std::string& filename,std::vector<std::string>& pieceSources, std::vector<std::string>& pointDataNames, std::vector<std::string>& cellDataNames);
+
+   //////////////////////////////////////////////////////////////////////////
+   //nodes
+   std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes);
+   std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
+   std::string writeNodesWithNodeDataDouble(const std::string& filename,std::vector< UbTupleDouble3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
+
+   //////////////////////////////////////////////////////////////////////////
+   //lines
+   //     0 ---- 1
+   //nodenumbering must start with 0!
+   std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines);
+   std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+
+   //////////////////////////////////////////////////////////////////////////
+   //triangles
+   //                    2
+   //                     
+   //                  0---1
+   //nodenumbering must start with 0!
+   std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles);
+   std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+
+   //////////////////////////////////////////////////////////////////////////
+   //2D
+   //cell numbering:
+   //                  3---2
+   //                  |   |
+   //                  0---1
+   //nodenumbering must start with 0!
+
+   std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells);
+   std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+   std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
+   std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, 
+                                             std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames,
+                                             std::vector< std::vector< double > >& celldata                                                                       );
+   
+   //////////////////////////////////////////////////////////////////////////
+   //octs
+   //     7 ---- 6
+   //    /|     /|
+   //   4 +--- 5 |
+   //   | |    | |
+   //   | 3 ---+ 2
+   //   |/     |/
+   //   0 ---- 1
+   std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
+   std::string writeOctsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
+   std::string writeOctsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+
+private:
+
+};
+
+UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkXmlASCII ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlASCII);
+
+#endif //WBWRITERVTKXMLASCII_H
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterVtkXmlBinary.cpp b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkXmlBinary.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/writer/WbWriterVtkXmlBinary.cpp
rename to source/VirtualFluidsBasic/basics/writer/WbWriterVtkXmlBinary.cpp
index 8d3d9dbf790dee6b6eca2eeb78135fcf877961f3..397b231dbff229d9aaa12bb0d9c5b477de8cbc58 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterVtkXmlBinary.cpp
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkXmlBinary.cpp
@@ -1,1582 +1,1582 @@
-#include <basics/writer/WbWriterVtkXmlBinary.h>
-#include <basics/writer/WbWriterVtkXmlASCII.h>
-#include <basics/utilities/UbLogger.h>
-#include <cstring>
-
-using namespace std;
-
-/*===============================================================================*/
-string WbWriterVtkXmlBinary::pvdEndTag ="   </Collection>\n</VTKFile>";
-/*===============================================================================*/
-string WbWriterVtkXmlBinary::writeCollection(const string& filename, const vector<string>& filenames, const double& timeStep, const bool& sepGroups)
-{
-   string vtkfilename=filename+".pvd";
-   ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   string endian;
-   if(UbSystem::isLittleEndian()) endian = "LittleEndian";
-   else                           endian = "BigEndian";
-   out<<"<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\""<<endian<<"\" >"<<endl;
-   out<<"   <Collection>"<<endl;
-   
-   int group = 0, part=0;
-   for(size_t i=0; i<filenames.size(); i++)
-   {
-      out<<"       <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<part<<"\" file=\""<<filenames[i]<<"\"/>"<<endl;
-      if(sepGroups) group++;
-      else          part++;
-   }
-   out<<pvdEndTag;
-   out.close();
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-string WbWriterVtkXmlBinary::addFilesToCollection(const string& filename, const vector<string>& filenames, const double& timeStep, const bool& sepGroups)
-{
-   string vtkfilename=filename;
-   fstream test(vtkfilename.c_str(), ios::in);
-   if(!test)
-   {
-      test.clear();
-      vtkfilename += ".pvd";
-      test.open(vtkfilename.c_str(), ios::in);
-      if(!test) return this->writeCollection(filename,filenames,timeStep,sepGroups);
-   }
- 
-   fstream out(vtkfilename.c_str(), ios::in | ios::out);
-   out.seekp(-(int)pvdEndTag.size()-1, ios_base::end);
-
-   int group = 0;
-   for(size_t i=0; i<filenames.size(); i++)
-   {
-      out<<"       <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<i<<"\" file=\""<<filenames[i]<<"\"/>"<<endl;
-      if(sepGroups) group++;
-   }
-   out<<pvdEndTag;
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-string WbWriterVtkXmlBinary::writeParallelFile(const string& filename,vector<string>& pieceSources, vector<string>& pointDataNames, vector<string>& cellDataNames)
-{
-   string vtkfilename=filename+".pvtu";
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeParallelFile to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   //VTK FILE
-   out<<"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">"<<"\n";
-   out<<"  <PUnstructuredGrid GhostLevel=\"0\">"<<"\n";
-   out<<"    <PPoints>\n"; 
-   out<<"      <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n";
-   out<<"    </PPoints>\n";
-   out<<"    <PPointData>\n";
-   for(size_t s=0; s<pointDataNames.size(); s++)
-      out<< "      <PDataArray type=\"Float32\" Name=\""<< pointDataNames[s] <<"\"/>\n";
-   out<<"    </PPointData>\n";
-   if (cellDataNames.size() > 0)
-   {
-      out<<"    <PCellData>\n";
-      for(size_t s=0; s<cellDataNames.size(); s++)
-         out<< "      <PDataArray type=\"Float32\" Name=\""<< cellDataNames[s] <<"\"/>\n";
-      out<<"    </PCellData>\n";
-   }
-
-   for(size_t s=0; s<pieceSources.size(); s++)
-      out<<"    <Piece Source=\""<<pieceSources[s]<<"\"/>\n";
-   out<<"  </PUnstructuredGrid>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeParallelFile to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-string WbWriterVtkXmlBinary::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines)
-{
-   string vtkfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLines to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)lines.size(); 
-
-   int bytesPerByteVal      = 4; //==sizeof(int)
-   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
-   int bytesCellConnectivty = 2 /*nodes per line */ * nofCells * sizeof(int  );
-   int bytesCellOffsets     = 1 /*offset per line */ * nofCells * sizeof(int  );
-   int bytesCellTypes       = 1 /*type of line */ * nofCells * sizeof(unsigned char);
-
-   int offset = 0;
-   //VTK FILE
-   out<<"<?xml version=\"1.0\"?>\n";
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
-   out<<"         </Points>\n";
-   offset += (bytesPerByteVal + bytesPoints);
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellConnectivty); 
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellOffsets);
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
-   offset += (bytesPerByteVal + bytesCellTypes);
-   out<<"         </Cells>\n";
-
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-
-   // AppendedData SECTION
-   out<<"   <AppendedData encoding=\"raw\">\n";
-   out<<"_";
-
-   //POINTS SECTION
-   out.write((char*)&bytesPoints,bytesPerByteVal);
-   for(int n=0; n<nofNodes; n++)
-   {
-      out.write((char*)&val<1>(nodes[n]),sizeof(float));
-      out.write((char*)&val<2>(nodes[n]),sizeof(float));
-      out.write((char*)&val<3>(nodes[n]),sizeof(float));
-   }
-
-   //CELLS SECTION
-   //cellConnectivity
-   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
-   for(int c=0; c<nofCells; c++) 
-   {
-      out.write( (char*)&val<1>(lines[c]), sizeof(int) );
-      out.write( (char*)&val<2>(lines[c]), sizeof(int) );
-      
-   }
-
-   //cellOffsets
-   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
-   int itmp;
-   for(int c=1; c<=nofCells; c++)
-   {
-      itmp = 2 * c;    
-      out.write( (char*)&itmp, sizeof(int) );
-   }
-
-   //cellTypes
-   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
-   unsigned char vtkCellType = 3;
-   for(int c=0; c<nofCells; c++)
-   {
-      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
-   }
-   out<<"\n</AppendedData>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLines to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-std::string WbWriterVtkXmlBinary::writeLinesWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata)
-{
-   string vtkfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLinesWithNodeData to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)lines.size(); 
-
-   int bytesPerByteVal      = 4; //==sizeof(int)
-   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
-   int bytesCellConnectivty = 2 /*nodes per line  */ * nofCells * sizeof(int  );
-   int bytesCellOffsets     = 1 /*offset per line */ * nofCells * sizeof(int  );
-   int bytesCellTypes       = 1 /*type of line    */ * nofCells * sizeof(unsigned char);
-   int bytesScalarData      = 1 /*scalar          */ * nofNodes * sizeof(float); 
-
-   int offset = 0;
-   //VTK FILE
-   out<<"<?xml version=\"1.0\"?>\n";
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
-   out<<"         </Points>\n";
-   offset += (bytesPerByteVal + bytesPoints);
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellConnectivty); 
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellOffsets);
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
-   offset += (bytesPerByteVal + bytesCellTypes);
-   out<<"         </Cells>\n";
-
-   //DATA SECTION
-   out<<"         <PointData>\n";
-   for(size_t s=0; s<datanames.size(); ++s)
-   {
-      out<< "            <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
-      offset += (bytesPerByteVal + bytesScalarData);
-   }
-   out<<"         </PointData>\n";
-
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-
-   // AppendedData SECTION
-   out<<"   <AppendedData encoding=\"raw\">\n";
-   out<<"_";
-
-   //POINTS SECTION
-   out.write((char*)&bytesPoints,bytesPerByteVal);
-   for(int n=0; n<nofNodes; n++)
-   {
-      out.write((char*)&val<1>(nodes[n]),sizeof(float));
-      out.write((char*)&val<2>(nodes[n]),sizeof(float));
-      out.write((char*)&val<3>(nodes[n]),sizeof(float));
-   }
-
-   //CELLS SECTION
-   //cellConnectivity
-   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
-   for(int c=0; c<nofCells; c++) 
-   {
-      out.write( (char*)&val<1>(lines[c]), sizeof(int) );
-      out.write( (char*)&val<2>(lines[c]), sizeof(int) );
-   }
-
-   //cellOffsets
-   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
-   int itmp;
-   for(int c=1; c<=nofCells; c++)
-   {
-      itmp = 3 * c;    
-      out.write( (char*)&itmp, sizeof(int) );
-   }
-
-   //cellTypes
-   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
-   unsigned char vtkCellType = 5;
-   for(int c=0; c<nofCells; c++)
-   {
-      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
-   }
-
-   //DATA SECTION
-   //scalarData
-   for(size_t s=0; s<datanames.size(); ++s)
-   {
-      out.write((char*)&bytesScalarData,bytesPerByteVal);
-      for(size_t d=0; d<nodedata[s].size(); ++d)
-      {
-         //loake kopie machen, da in nodedata "doubles" sind
-         float tmp = (float)nodedata[s][d];
-         out.write((char*)&tmp,sizeof(float));
-      }
-   }
-   out<<"\n</AppendedData>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLinesWithNodeData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-
-}
-/*===============================================================================*/
-string WbWriterVtkXmlBinary::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles)
-{
-   string vtkfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTriangles to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)triangles.size(); 
-
-   int bytesPerByteVal      = 4; //==sizeof(int)
-   int bytesPoints          = 3 /*x1/x2/x3 - coord    */ * nofNodes * sizeof(float);
-   int bytesCellConnectivty = 3 /*nodes per triangle  */ * nofCells * sizeof(int  );
-   int bytesCellOffsets     = 1 /*offset per triangle */ * nofCells * sizeof(int  );
-   int bytesCellTypes       = 1 /*type of triangle    */ * nofCells * sizeof(unsigned char);
-
-   int offset = 0;
-   //VTK FILE
-   out<<"<?xml version=\"1.0\"?>\n";
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
-   out<<"         </Points>\n";
-   offset += (bytesPerByteVal + bytesPoints);
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellConnectivty); 
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellOffsets);
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
-   offset += (bytesPerByteVal + bytesCellTypes);
-   out<<"         </Cells>\n";
-
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-
-   // AppendedData SECTION
-   out<<"   <AppendedData encoding=\"raw\">\n";
-   out<<"_";
-
-   //POINTS SECTION
-   out.write((char*)&bytesPoints,bytesPerByteVal);
-   for(int n=0; n<nofNodes; n++)
-   {
-      out.write((char*)&val<1>(nodes[n]),sizeof(float));
-      out.write((char*)&val<2>(nodes[n]),sizeof(float));
-      out.write((char*)&val<3>(nodes[n]),sizeof(float));
-   }
-
-   //CELLS SECTION
-   //cellConnectivity
-   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
-   for(int c=0; c<nofCells; c++) 
-   {
-      out.write( (char*)&val<1>(triangles[c]), sizeof(int) );
-      out.write( (char*)&val<2>(triangles[c]), sizeof(int) );
-      out.write( (char*)&val<3>(triangles[c]), sizeof(int) );
-   }
-
-   //cellOffsets
-   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
-   int itmp;
-   for(int c=1; c<=nofCells; c++)
-   {
-      itmp = 3 * c;    
-      out.write( (char*)&itmp, sizeof(int) );
-   }
-
-   //cellTypes
-   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
-   unsigned char vtkCellType = 5;
-   for(int c=0; c<nofCells; c++)
-   {
-      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
-   }
-
-   out<<"\n</AppendedData>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out<<flush;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTriangles to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-string WbWriterVtkXmlBinary::writeTrianglesWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt3 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
-{
-   string vtkfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTrianglesWithNodeData to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   int bytesPerByteVal      = 4; //==sizeof(int)
-   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
-   int bytesCellConnectivty = 3 /*nodes per tri   */ * nofCells * sizeof(int  );
-   int bytesCellOffsets     = 1 /*offset per tri  */ * nofCells * sizeof(int  );
-   int bytesCellTypes       = 1 /*type of tri     */ * nofCells * sizeof(unsigned char);
-   int bytesScalarData      = 1 /*scalar          */ * nofNodes * sizeof(float); 
-   
-   int offset = 0;
-   //VTK FILE
-   out<<"<?xml version=\"1.0\"?>\n";
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
-   out<<"         </Points>\n";
-   offset += (bytesPerByteVal + bytesPoints);
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellConnectivty); 
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellOffsets);
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
-   offset += (bytesPerByteVal + bytesCellTypes);
-   out<<"         </Cells>\n";
-
-   //DATA SECTION
-   out<<"         <PointData>\n";
-   for(size_t s=0; s<datanames.size(); ++s)
-   {
-      out<< "            <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
-      offset += (bytesPerByteVal + bytesScalarData);
-   }
-   out<<"         </PointData>\n";
-
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-
-   // AppendedData SECTION
-   out<<"   <AppendedData encoding=\"raw\">\n";
-   out<<"_";
-
-   //POINTS SECTION
-   out.write((char*)&bytesPoints,bytesPerByteVal);
-   for(int n=0; n<nofNodes; n++)
-   {
-      out.write((char*)&val<1>(nodes[n]),sizeof(float));
-      out.write((char*)&val<2>(nodes[n]),sizeof(float));
-      out.write((char*)&val<3>(nodes[n]),sizeof(float));
-   }
-
-   //CELLS SECTION
-   //cellConnectivity
-   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
-   for(int c=0; c<nofCells; c++) 
-   {
-      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
-   }
-
-   //cellOffsets
-   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
-   int itmp;
-   for(int c=1; c<=nofCells; c++)
-   {
-      itmp = 3 * c;    
-      out.write( (char*)&itmp, sizeof(int) );
-   }
-
-   //cellTypes
-   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
-   unsigned char vtkCellType = 5;
-   for(int c=0; c<nofCells; c++)
-   {
-      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
-   }
-
-   //DATA SECTION
-   //scalarData
-   for(size_t s=0; s<datanames.size(); ++s)
-   {
-      out.write((char*)&bytesScalarData,bytesPerByteVal);
-      for(size_t d=0; d<nodedata[s].size(); ++d)
-      {
-         //loake kopie machen, da in nodedata "doubles" sind
-         float tmp = (float)nodedata[s][d];
-         out.write((char*)&tmp,sizeof(float));
-      }
-   }
-   out<<"\n</AppendedData>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTrianglesWithNodeData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-string WbWriterVtkXmlBinary::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells)
-{
-   string vtkfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuads to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   int bytesPerByteVal      = 4; //==sizeof(int)
-   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
-   int bytesCellConnectivty = 4 /*nodes per quad  */ * nofCells * sizeof(int  );
-   int bytesCellOffsets     = 1 /*offset per quad */ * nofCells * sizeof(int  );
-   int bytesCellTypes       = 1 /*type of quad    */ * nofCells * sizeof(unsigned char);
-  
-   int offset = 0;
-   //VTK FILE
-   out<<"<?xml version=\"1.0\"?>\n";
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
-   out<<"         </Points>\n";
-   offset += (bytesPerByteVal + bytesPoints);
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellConnectivty); 
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellOffsets);
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
-   offset += (bytesPerByteVal + bytesCellTypes);
-   out<<"         </Cells>\n";
-
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-
-   // AppendedData SECTION
-   out<<"   <AppendedData encoding=\"raw\">\n";
-   out<<"_";
-
-   //POINTS SECTION
-   out.write((char*)&bytesPoints,bytesPerByteVal);
-   for(int n=0; n<nofNodes; n++)
-   {
-      out.write((char*)&val<1>(nodes[n]),sizeof(float));
-      out.write((char*)&val<2>(nodes[n]),sizeof(float));
-      out.write((char*)&val<3>(nodes[n]),sizeof(float));
-   }
-
-   //CELLS SECTION
-   //cellConnectivity
-   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
-   for(int c=0; c<nofCells; c++) 
-   {
-      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<4>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
-   }
-
-   //cellOffsets
-   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
-   int itmp;
-   for(int c=1; c<=nofCells; c++)
-   {
-      itmp = 4 * c;    
-      out.write( (char*)&itmp, sizeof(int) );
-   }
-
-   //cellTypes
-   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
-   unsigned char vtkCellType = 8;
-   for(int c=0; c<nofCells; c++)
-   {
-      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
-   }
-   out<<"\n</AppendedData>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out<<flush;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuads to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-string WbWriterVtkXmlBinary::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
-{
-   string vtkfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   int bytesPerByteVal      = 4; //==sizeof(int)
-   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
-   int bytesCellConnectivty = 4 /*nodes per quad  */ * nofCells * sizeof(int  );
-   int bytesCellOffsets     = 1 /*offset per quad */ * nofCells * sizeof(int  );
-   int bytesCellTypes       = 1 /*type of quad    */ * nofCells * sizeof(unsigned char);
-   int bytesScalarData      = 1 /*scalar          */ * nofNodes * sizeof(float); 
-
-   int offset = 0;
-   //VTK FILE
-   out<<"<?xml version=\"1.0\"?>\n";
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
-   out<<"         </Points>\n";
-   offset += (bytesPerByteVal + bytesPoints);
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellConnectivty); 
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellOffsets);
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
-   offset += (bytesPerByteVal + bytesCellTypes);
-   out<<"         </Cells>\n";
-
-   //DATA SECTION
-   out<<"         <PointData>\n";
-   for(size_t s=0; s<datanames.size(); ++s)
-   {
-      out<< "            <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
-      offset += (bytesPerByteVal + bytesScalarData);
-   }
-   out<<"         </PointData>\n";
-
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-
-   // AppendedData SECTION
-   out<<"   <AppendedData encoding=\"raw\">\n";
-   out<<"_";
-
-   //POINTS SECTION
-   out.write((char*)&bytesPoints,bytesPerByteVal);
-   for(int n=0; n<nofNodes; n++)
-   {
-      out.write((char*)&val<1>(nodes[n]),sizeof(float));
-      out.write((char*)&val<2>(nodes[n]),sizeof(float));
-      out.write((char*)&val<3>(nodes[n]),sizeof(float));
-   }
-
-   //CELLS SECTION
-   //cellConnectivity
-   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
-   for(int c=0; c<nofCells; c++) 
-   {
-      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<4>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
-   }
-
-   //cellOffsets
-   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
-   int itmp;
-   for(int c=1; c<=nofCells; c++)
-   {
-      itmp = 4 * c;    
-      out.write( (char*)&itmp, sizeof(int) );
-   }
-
-   //cellTypes
-   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
-   unsigned char vtkCellType = 8;
-   for(int c=0; c<nofCells; c++)
-   {
-      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
-   }
-
-   //DATA SECTION
-   //scalarData
-   for(size_t s=0; s<datanames.size(); ++s)
-   {
-      out.write((char*)&bytesScalarData,bytesPerByteVal);
-      for(size_t d=0; d<nodedata[s].size(); ++d)
-      {
-         //loake kopie machen, da in nodedata "doubles" sind
-         float tmp = (float)nodedata[s][d];
-         out.write((char*)&tmp,sizeof(float));
-      }
-   }
-   out<<"\n</AppendedData>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-string WbWriterVtkXmlBinary::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
-{
-   string vtkfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithCellData to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   int bytesPerByteVal      = 4; //==sizeof(int)
-   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
-   int bytesCellConnectivty = 4 /*nodes per quad  */ * nofCells * sizeof(int  );
-   int bytesCellOffsets     = 1 /*offset per quad */ * nofCells * sizeof(int  );
-   int bytesCellTypes       = 1 /*type of quad    */ * nofCells * sizeof(unsigned char);
-   int bytesScalarData      = 1 /*scalar          */ * nofCells * sizeof(float); 
-
-   int offset = 0;
-   //VTK FILE
-   out<<"<?xml version=\"1.0\"?>\n";
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
-   out<<"         </Points>\n";
-   offset += (bytesPerByteVal + bytesPoints);
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellConnectivty); 
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellOffsets);
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
-   offset += (bytesPerByteVal + bytesCellTypes);
-   out<<"         </Cells>\n";
-
-   //DATA SECTION
-   out<<"         <CellData>\n";
-   for(size_t s=0; s<datanames.size(); ++s)
-   {
-      out<< "            <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
-      offset += (bytesPerByteVal + bytesScalarData);
-   }
-   out<<"         </CellData>\n";
-
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-
-   // AppendedData SECTION
-   out<<"   <AppendedData encoding=\"raw\">\n";
-   out<<"_";
-
-   //POINTS SECTION
-   out.write((char*)&bytesPoints,bytesPerByteVal);
-   for(int n=0; n<nofNodes; n++)
-   {
-      out.write((char*)&val<1>(nodes[n]),sizeof(float));
-      out.write((char*)&val<2>(nodes[n]),sizeof(float));
-      out.write((char*)&val<3>(nodes[n]),sizeof(float));
-   }
-
-   //CELLS SECTION
-   //cellConnectivity
-   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
-   for(int c=0; c<nofCells; c++) 
-   {
-      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<4>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
-   }
-
-   //cellOffsets
-   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
-   int itmp;
-   for(int c=1; c<=nofCells; c++)
-   {
-      itmp = 4 * c;    
-      out.write( (char*)&itmp, sizeof(int) );
-   }
-
-   //cellTypes
-   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
-   unsigned char vtkCellType = 8;
-   for(int c=0; c<nofCells; c++)
-   {
-      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
-   }
-
-   //DATA SECTION
-   //scalarData
-   for(size_t s=0; s<datanames.size(); ++s)
-   {
-      out.write((char*)&bytesScalarData,bytesPerByteVal);
-      for(size_t d=0; d<celldata[s].size(); ++d)
-      {
-         //loake kopie machen, da in celldata "doubles" sind
-         float tmp = (float)celldata[s][d];
-         out.write((char*)&tmp,sizeof(float));
-      }
-   }
-
-   out<<"\n</AppendedData>\n";
-
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithCellData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-string WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, 
-                                                                vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames,
-                                                                vector< vector< double > >& celldata                                                                    )
-{
-   string vtkfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   int bytesPerByteVal      = 4; //==sizeof(int)
-   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
-   int bytesCellConnectivty = 4 /*nodes per quad  */ * nofCells * sizeof(int  );
-   int bytesCellOffsets     = 1 /*offset per quad */ * nofCells * sizeof(int  );
-   int bytesCellTypes       = 1 /*type of quad    */ * nofCells * sizeof(unsigned char);
-   int bytesScalarDataPoint = 1 /*scalar          */ * nofNodes * sizeof(float); 
-   int bytesScalarDataCell  = 1 /*scalar          */ * nofCells * sizeof(float); 
-
-   int offset = 0;
-   //VTK FILE
-   out<<"<?xml version=\"1.0\"?>\n";
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
-   out<<"         </Points>\n";
-   offset += (bytesPerByteVal + bytesPoints);
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellConnectivty); 
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellOffsets);
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
-   offset += (bytesPerByteVal + bytesCellTypes);
-   out<<"         </Cells>\n";
-
-   // Point DATA SECTION
-   out<<"         <PointData>\n";
-   for(size_t s=0; s<nodedatanames.size(); ++s)
-   {
-      out<< "            <DataArray type=\"Float32\" Name=\""<< nodedatanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
-      offset += (bytesPerByteVal + bytesScalarDataPoint);
-   }
-   out<<"         </PointData>\n";
-
-
-   // Cell DATA SECTION
-   out<<"         <CellData>\n";
-   for(size_t s=0; s<celldatanames.size(); ++s)
-   {
-      out<< "            <DataArray type=\"Float32\" Name=\""<< celldatanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
-      offset += (bytesPerByteVal + bytesScalarDataCell);
-   }
-   out<<"         </CellData>\n";
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-
-   // AppendedData SECTION
-   out<<"   <AppendedData encoding=\"raw\">\n";
-   out<<"_";
-
-   //POINTS SECTION
-   out.write((char*)&bytesPoints,bytesPerByteVal);
-   for(int n=0; n<nofNodes; n++)
-   {
-      out.write((char*)&val<1>(nodes[n]),sizeof(float));
-      out.write((char*)&val<2>(nodes[n]),sizeof(float));
-      out.write((char*)&val<3>(nodes[n]),sizeof(float));
-   }
-
-   //CELLS SECTION
-   //cellConnectivity
-   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
-   for(int c=0; c<nofCells; c++) 
-   {
-      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<4>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
-   }
-
-   //cellOffsets
-   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
-   int itmp;
-   for(int c=1; c<=nofCells; c++)
-   {
-      itmp = 4 * c;    
-      out.write( (char*)&itmp, sizeof(int) );
-   }
-
-   //cellTypes
-   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
-   unsigned char vtkCellType = 8;
-   for(int c=0; c<nofCells; c++)
-   {
-      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
-   }
-
-   //Point DATA SECTION
-   //scalarData
-   for(size_t s=0; s<nodedatanames.size(); ++s)
-   {
-      out.write((char*)&bytesScalarDataPoint,bytesPerByteVal);
-      for(size_t d=0; d<nodedata[s].size(); ++d)
-      {
-         //loake kopie machen, da in nodedata "doubles" sind
-         float tmp = (float)nodedata[s][d];
-         out.write((char*)&tmp,sizeof(float));
-      }
-   }
-   //Cell DATA SECTION
-   //scalarData
-   for(size_t s=0; s<celldatanames.size(); ++s)
-   {
-      out.write((char*)&bytesScalarDataCell,bytesPerByteVal);
-      for(size_t d=0; d<celldata[s].size(); ++d)
-      {
-         //loake kopie machen, da in celldata "doubles" sind
-         float tmp = (float)celldata[s][d];
-         out.write((char*)&tmp,sizeof(float));
-      }
-   }
-   out<<"\n</AppendedData>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-string WbWriterVtkXmlBinary::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata)
-{
-   string vtkfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithCellData to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   int bytesPerByteVal      = 4; //==sizeof(int)
-   int bytesPoints          = 3 /*x1/x2/x3      */ * nofNodes * sizeof(float);
-   int bytesCellConnectivty = 8 /*nodes per oct */ * nofCells * sizeof(int  );
-   int bytesCellOffsets     = 1 /*offset per oct*/ * nofCells * sizeof(int  );
-   int bytesCellTypes       = 1 /*type of oct   */ * nofCells * sizeof(unsigned char);
-   int bytesScalarData      = 1 /*scalar        */ * nofCells * sizeof(float); 
-
-   int offset = 0;
-   //VTK FILE
-   out<<"<?xml version=\"1.0\"?>\n";
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
-   out<<"         </Points>\n";
-   offset += (bytesPerByteVal + bytesPoints);
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellConnectivty); 
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellOffsets);
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
-   offset += (bytesPerByteVal + bytesCellTypes);
-   out<<"         </Cells>\n";
-
-   //DATA SECTION
-   out<<"         <CellData>\n";
-   for(size_t s=0; s<datanames.size(); ++s)
-   {
-      out<< "            <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
-      offset += (bytesPerByteVal + bytesScalarData);
-   }
-   out<<"         </CellData>\n";
-
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-
-   // AppendedData SECTION
-   out<<"   <AppendedData encoding=\"raw\">\n";
-   out<<"_";
-
-   //POINTS SECTION
-   out.write((char*)&bytesPoints,bytesPerByteVal);
-   for(int n=0; n<nofNodes; n++)
-   {
-      out.write((char*)&val<1>(nodes[n]),sizeof(float));
-      out.write((char*)&val<2>(nodes[n]),sizeof(float));
-      out.write((char*)&val<3>(nodes[n]),sizeof(float));
-   }
-
-   //CELLS SECTION
-   //cellConnectivity
-   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
-   for(int c=0; c<nofCells; c++) 
-   {
-      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<4>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<5>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<6>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<8>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<7>(cells[c]), sizeof(int) );
-   }
-
-   //cellOffsets
-   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
-   int itmp;
-   for(int c=1; c<=nofCells; c++)
-   {
-      itmp = 8 * c;    
-      out.write( (char*)&itmp, sizeof(int) );
-   }
-
-   //cellTypes
-   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
-   unsigned char vtkCellType = 11;
-   for(int c=0; c<nofCells; c++)
-   {
-      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
-   }
-
-   //DATA SECTION
-   //scalarData
-   for(size_t s=0; s<datanames.size(); ++s)
-   {
-      out.write((char*)&bytesScalarData,bytesPerByteVal);
-      for(size_t d=0; d<celldata[s].size(); ++d)
-      {
-         //loake kopie machen, da in celldata "doubles" sind
-         float tmp = (float)celldata[s][d];
-         out.write((char*)&tmp,sizeof(float));
-      }
-   }
-   out<<"\n</AppendedData>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithCellData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-string WbWriterVtkXmlBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata)
-{
-   string vtkfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithNodeData to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   int bytesPerByteVal      = 4; //==sizeof(int)
-   int bytesPoints          = 3 /*x1/x2/x3      */ * nofNodes * sizeof(float);
-   int bytesCellConnectivty = 8 /*nodes per oct */ * nofCells * sizeof(int  );
-   int bytesCellOffsets     = 1 /*offset per oct*/ * nofCells * sizeof(int  );
-   int bytesCellTypes       = 1 /*type of oct   */ * nofCells * sizeof(unsigned char);
-   int bytesScalarData      = 1 /*scalar        */ * nofNodes * sizeof(float); 
-
-   int offset = 0;
-   //VTK FILE
-   out<<"<?xml version=\"1.0\"?>\n";
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
-   out<<"         </Points>\n";
-   offset += (bytesPerByteVal + bytesPoints);
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellConnectivty); 
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellOffsets);
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
-   offset += (bytesPerByteVal + bytesCellTypes);
-   out<<"         </Cells>\n";
-
-   //DATA SECTION
-   out<<"         <PointData>\n";
-   for(size_t s=0; s<datanames.size(); ++s)
-   {
-      out<< "            <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
-      offset += (bytesPerByteVal + bytesScalarData);
-   }
-   out<<"         </PointData>\n";
-
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-
-   // AppendedData SECTION
-   out<<"   <AppendedData encoding=\"raw\">\n";
-   out<<"_";
-
-   //POINTS SECTION
-   out.write((char*)&bytesPoints,bytesPerByteVal);
-   for(int n=0; n<nofNodes; n++)
-   {
-      out.write((char*)&val<1>(nodes[n]),sizeof(float));
-      out.write((char*)&val<2>(nodes[n]),sizeof(float));
-      out.write((char*)&val<3>(nodes[n]),sizeof(float));
-   }
-
-   //CELLS SECTION
-   //cellConnectivity
-   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
-   for(int c=0; c<nofCells; c++) 
-   {
-      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<4>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<5>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<6>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<8>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<7>(cells[c]), sizeof(int) );
-   }
-
-   //cellOffsets
-   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
-   int itmp;
-   for(int c=1; c<=nofCells; c++)
-   {
-      itmp = 8 * c;    
-      out.write( (char*)&itmp, sizeof(int) );
-   }
-
-   //cellTypes
-   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
-   unsigned char vtkCellType = 11;
-   for(int c=0; c<nofCells; c++)
-   {
-      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
-   }
-
-   //DATA SECTION
-   //scalarData
-   for(size_t s=0; s<datanames.size(); ++s)
-   {
-      out.write((char*)&bytesScalarData,bytesPerByteVal);
-      for(size_t d=0; d<nodedata[s].size(); ++d)
-      {
-         //loake kopie machen, da in nodedata "doubles" sind
-         float tmp = (float)nodedata[s][d];
-         out.write((char*)&tmp,sizeof(float));
-      }
-   }
-   out<<"\n</AppendedData>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithNodeData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-/*===============================================================================*/
-string WbWriterVtkXmlBinary::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells)
-{
-   string vtkfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOcts to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-   int nofCells = (int)cells.size(); 
-
-   int bytesPerByteVal      = 4; //==sizeof(int)
-   int bytesPoints          = 3 /*x1/x2/x3      */ * nofNodes * sizeof(float);
-   int bytesCellConnectivty = 8 /*nodes per oct */ * nofCells * sizeof(int  );
-   int bytesCellOffsets     = 1 /*offset per oct*/ * nofCells * sizeof(int  );
-   int bytesCellTypes       = 1 /*type of oct   */ * nofCells * sizeof(unsigned char);
-   //int bytesScalarData      = 1 /*scalar        */ * nofNodes * sizeof(float); 
-
-   int offset = 0;
-   //VTK FILE
-   out<<"<?xml version=\"1.0\"?>\n";
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
-   out<<"         </Points>\n";
-   offset += (bytesPerByteVal + bytesPoints);
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellConnectivty); 
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellOffsets);
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
-   offset += (bytesPerByteVal + bytesCellTypes);
-   out<<"         </Cells>\n";
-
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-
-   // AppendedData SECTION
-   out<<"   <AppendedData encoding=\"raw\">\n";
-   out<<"_";
-
-   //POINTS SECTION
-   out.write((char*)&bytesPoints,bytesPerByteVal);
-   for(int n=0; n<nofNodes; n++)
-   {
-      out.write((char*)&val<1>(nodes[n]),sizeof(float));
-      out.write((char*)&val<2>(nodes[n]),sizeof(float));
-      out.write((char*)&val<3>(nodes[n]),sizeof(float));
-   }
-
-   //CELLS SECTION
-   //cellConnectivity
-   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
-   for(int c=0; c<nofCells; c++) 
-   {
-      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<4>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<5>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<6>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<8>(cells[c]), sizeof(int) );
-      out.write( (char*)&val<7>(cells[c]), sizeof(int) );
-   }
-
-   //cellOffsets
-   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
-   int itmp;
-   for(int c=1; c<=nofCells; c++)
-   {
-      itmp = 8 * c;    
-      out.write( (char*)&itmp, sizeof(int) );
-   }
-
-   //cellTypes
-   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
-   unsigned char vtkCellType = 11;
-   for(int c=0; c<nofCells; c++)
-   {
-      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
-   }
-   out<<"\n</AppendedData>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOcts to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-std::string WbWriterVtkXmlBinary::writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes)
-{
-   string vtkfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodes to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-
-   int bytesPerByteVal      = 4; //==sizeof(int)
-   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
-   int bytesCellConnectivty = 1 /*nodes per cell  */ * nofNodes * sizeof(int  );
-   int bytesCellOffsets     = 1 /*offset per cell */ * nofNodes * sizeof(int  );
-   int bytesCellTypes       = 1 /*type of line    */ * nofNodes * sizeof(unsigned char);
-
-   int offset = 0;
-   //VTK FILE
-   out<<"<?xml version=\"1.0\"?>\n";
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofNodes<<"\">\n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
-   out<<"         </Points>\n";
-   offset += (bytesPerByteVal + bytesPoints);
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellConnectivty); 
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellOffsets);
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
-   offset += (bytesPerByteVal + bytesCellTypes);
-   out<<"         </Cells>\n";
-
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-
-   // AppendedData SECTION
-   out<<"   <AppendedData encoding=\"raw\">\n";
-   out<<"_";
-
-   //POINTS SECTION
-   out.write((char*)&bytesPoints,bytesPerByteVal);
-   for(int n=0; n<nofNodes; n++)
-   {
-      out.write((char*)&val<1>(nodes[n]),sizeof(float));
-      out.write((char*)&val<2>(nodes[n]),sizeof(float));
-      out.write((char*)&val<3>(nodes[n]),sizeof(float));
-   }
-
-   //CELLS SECTION
-   //cellConnectivity
-   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
-   for(int c=0; c<nofNodes; c++) 
-      out.write( (char*)&c, sizeof(int) );
-
-   //cellOffsets
-   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
-   for(int c=1; c<=nofNodes; c++)
-      out.write( (char*)&c, sizeof(int) );
-
-   //cellTypes
-   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
-   unsigned char vtkCellType = 1;
-   for(int c=0; c<nofNodes; c++)
-      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
-
-   out<<"\n</AppendedData>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodes to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-}
-std::string WbWriterVtkXmlBinary::writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata)
-{
-   string vtkfilename = filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodesWithNodeData to "<<vtkfilename<<" - start");
-
-   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(vtkfilename);
-      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
-   }
-
-   int nofNodes = (int)nodes.size(); 
-
-   int bytesPerByteVal      = 4; //==sizeof(int)
-   int bytesPoints          = 3 /*x1/x2/x3       */ * nofNodes * sizeof(float);
-   int bytesCellConnectivty = 1 /*nodes per cell */ * nofNodes * sizeof(int  );
-   int bytesCellOffsets     = 1 /*offset per cell*/ * nofNodes * sizeof(int  );
-   int bytesCellTypes       = 1 /*type of oct    */ * nofNodes * sizeof(unsigned char);
-   int bytesScalarData      = 1 /*scalar         */ * nofNodes * sizeof(float); 
-
-   int offset = 0;
-   //VTK FILE
-   out<<"<?xml version=\"1.0\"?>\n";
-   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
-   out<<"   <UnstructuredGrid>"<<"\n";
-   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofNodes<<"\">\n";
-
-   //POINTS SECTION
-   out<<"         <Points>\n"; 
-   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
-   out<<"         </Points>\n";
-   offset += (bytesPerByteVal + bytesPoints);
-
-   //CELLS SECTION
-   out<<"         <Cells>\n";
-   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellConnectivty); 
-   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
-   offset += (bytesPerByteVal + bytesCellOffsets);
-   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
-   offset += (bytesPerByteVal + bytesCellTypes);
-   out<<"         </Cells>\n";
-
-   //DATA SECTION
-   out<<"         <PointData>\n";
-   for(size_t s=0; s<datanames.size(); ++s)
-   {
-      out<< "            <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
-      offset += (bytesPerByteVal + bytesScalarData);
-   }
-   out<<"         </PointData>\n";
-
-   out<<"      </Piece>\n";
-   out<<"   </UnstructuredGrid>\n";
-
-   // AppendedData SECTION
-   out<<"   <AppendedData encoding=\"raw\">\n";
-   out<<"_";
-
-   //POINTS SECTION
-   out.write((char*)&bytesPoints,bytesPerByteVal);
-   for(int n=0; n<nofNodes; n++)
-   {
-      out.write((char*)&val<1>(nodes[n]),sizeof(float));
-      out.write((char*)&val<2>(nodes[n]),sizeof(float));
-      out.write((char*)&val<3>(nodes[n]),sizeof(float));
-   }
-
-   //CELLS SECTION
-   //cellConnectivity
-   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
-   for(int c=0; c<nofNodes; c++) 
-      out.write( (char*)&c, sizeof(int) );
-
-   //cellOffsets
-   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
-   for(int c=1; c<=nofNodes; c++)
-      out.write( (char*)&c, sizeof(int) );
-
-   //cellTypes
-   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
-   unsigned char vtkCellType = 1;
-   for(int c=0; c<nofNodes; c++)
-      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
-   
-   //DATA SECTION
-   //scalarData
-   for(size_t s=0; s<datanames.size(); ++s)
-   {
-      out.write((char*)&bytesScalarData,bytesPerByteVal);
-      for(size_t d=0; d<nodedata[s].size(); ++d)
-      {
-         //loake kopie machen, da in nodedata "doubles" sind
-         float tmp = (float)nodedata[s][d];
-         out.write((char*)&tmp,sizeof(float));
-      }
-   }
-   out<<"\n</AppendedData>\n";
-   out<<"</VTKFile>";
-   out<<endl;
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodesWithNodeData to "<<vtkfilename<<" - end");
-
-   return vtkfilename;
-
-}
+#include <basics/writer/WbWriterVtkXmlBinary.h>
+#include <basics/writer/WbWriterVtkXmlASCII.h>
+#include <basics/utilities/UbLogger.h>
+#include <cstring>
+
+using namespace std;
+
+/*===============================================================================*/
+string WbWriterVtkXmlBinary::pvdEndTag ="   </Collection>\n</VTKFile>";
+/*===============================================================================*/
+string WbWriterVtkXmlBinary::writeCollection(const string& filename, const vector<string>& filenames, const double& timeStep, const bool& sepGroups)
+{
+   string vtkfilename=filename+".pvd";
+   ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   string endian;
+   if(UbSystem::isLittleEndian()) endian = "LittleEndian";
+   else                           endian = "BigEndian";
+   out<<"<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\""<<endian<<"\" >"<<endl;
+   out<<"   <Collection>"<<endl;
+   
+   int group = 0, part=0;
+   for(size_t i=0; i<filenames.size(); i++)
+   {
+      out<<"       <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<part<<"\" file=\""<<filenames[i]<<"\"/>"<<endl;
+      if(sepGroups) group++;
+      else          part++;
+   }
+   out<<pvdEndTag;
+   out.close();
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+string WbWriterVtkXmlBinary::addFilesToCollection(const string& filename, const vector<string>& filenames, const double& timeStep, const bool& sepGroups)
+{
+   string vtkfilename=filename;
+   fstream test(vtkfilename.c_str(), ios::in);
+   if(!test)
+   {
+      test.clear();
+      vtkfilename += ".pvd";
+      test.open(vtkfilename.c_str(), ios::in);
+      if(!test) return this->writeCollection(filename,filenames,timeStep,sepGroups);
+   }
+ 
+   fstream out(vtkfilename.c_str(), ios::in | ios::out);
+   out.seekp(-(int)pvdEndTag.size()-1, ios_base::end);
+
+   int group = 0;
+   for(size_t i=0; i<filenames.size(); i++)
+   {
+      out<<"       <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<i<<"\" file=\""<<filenames[i]<<"\"/>"<<endl;
+      if(sepGroups) group++;
+   }
+   out<<pvdEndTag;
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+string WbWriterVtkXmlBinary::writeParallelFile(const string& filename,vector<string>& pieceSources, vector<string>& pointDataNames, vector<string>& cellDataNames)
+{
+   string vtkfilename=filename+".pvtu";
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeParallelFile to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   //VTK FILE
+   out<<"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">"<<"\n";
+   out<<"  <PUnstructuredGrid GhostLevel=\"0\">"<<"\n";
+   out<<"    <PPoints>\n"; 
+   out<<"      <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n";
+   out<<"    </PPoints>\n";
+   out<<"    <PPointData>\n";
+   for(size_t s=0; s<pointDataNames.size(); s++)
+      out<< "      <PDataArray type=\"Float32\" Name=\""<< pointDataNames[s] <<"\"/>\n";
+   out<<"    </PPointData>\n";
+   if (cellDataNames.size() > 0)
+   {
+      out<<"    <PCellData>\n";
+      for(size_t s=0; s<cellDataNames.size(); s++)
+         out<< "      <PDataArray type=\"Float32\" Name=\""<< cellDataNames[s] <<"\"/>\n";
+      out<<"    </PCellData>\n";
+   }
+
+   for(size_t s=0; s<pieceSources.size(); s++)
+      out<<"    <Piece Source=\""<<pieceSources[s]<<"\"/>\n";
+   out<<"  </PUnstructuredGrid>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeParallelFile to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+string WbWriterVtkXmlBinary::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines)
+{
+   string vtkfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLines to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)lines.size(); 
+
+   int bytesPerByteVal      = 4; //==sizeof(int)
+   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
+   int bytesCellConnectivty = 2 /*nodes per line */ * nofCells * sizeof(int  );
+   int bytesCellOffsets     = 1 /*offset per line */ * nofCells * sizeof(int  );
+   int bytesCellTypes       = 1 /*type of line */ * nofCells * sizeof(unsigned char);
+
+   int offset = 0;
+   //VTK FILE
+   out<<"<?xml version=\"1.0\"?>\n";
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
+   out<<"         </Points>\n";
+   offset += (bytesPerByteVal + bytesPoints);
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellConnectivty); 
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellOffsets);
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
+   offset += (bytesPerByteVal + bytesCellTypes);
+   out<<"         </Cells>\n";
+
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+
+   // AppendedData SECTION
+   out<<"   <AppendedData encoding=\"raw\">\n";
+   out<<"_";
+
+   //POINTS SECTION
+   out.write((char*)&bytesPoints,bytesPerByteVal);
+   for(int n=0; n<nofNodes; n++)
+   {
+      out.write((char*)&val<1>(nodes[n]),sizeof(float));
+      out.write((char*)&val<2>(nodes[n]),sizeof(float));
+      out.write((char*)&val<3>(nodes[n]),sizeof(float));
+   }
+
+   //CELLS SECTION
+   //cellConnectivity
+   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
+   for(int c=0; c<nofCells; c++) 
+   {
+      out.write( (char*)&val<1>(lines[c]), sizeof(int) );
+      out.write( (char*)&val<2>(lines[c]), sizeof(int) );
+      
+   }
+
+   //cellOffsets
+   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
+   int itmp;
+   for(int c=1; c<=nofCells; c++)
+   {
+      itmp = 2 * c;    
+      out.write( (char*)&itmp, sizeof(int) );
+   }
+
+   //cellTypes
+   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
+   unsigned char vtkCellType = 3;
+   for(int c=0; c<nofCells; c++)
+   {
+      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
+   }
+   out<<"\n</AppendedData>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLines to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+std::string WbWriterVtkXmlBinary::writeLinesWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata)
+{
+   string vtkfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLinesWithNodeData to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)lines.size(); 
+
+   int bytesPerByteVal      = 4; //==sizeof(int)
+   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
+   int bytesCellConnectivty = 2 /*nodes per line  */ * nofCells * sizeof(int  );
+   int bytesCellOffsets     = 1 /*offset per line */ * nofCells * sizeof(int  );
+   int bytesCellTypes       = 1 /*type of line    */ * nofCells * sizeof(unsigned char);
+   int bytesScalarData      = 1 /*scalar          */ * nofNodes * sizeof(float); 
+
+   int offset = 0;
+   //VTK FILE
+   out<<"<?xml version=\"1.0\"?>\n";
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
+   out<<"         </Points>\n";
+   offset += (bytesPerByteVal + bytesPoints);
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellConnectivty); 
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellOffsets);
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
+   offset += (bytesPerByteVal + bytesCellTypes);
+   out<<"         </Cells>\n";
+
+   //DATA SECTION
+   out<<"         <PointData>\n";
+   for(size_t s=0; s<datanames.size(); ++s)
+   {
+      out<< "            <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
+      offset += (bytesPerByteVal + bytesScalarData);
+   }
+   out<<"         </PointData>\n";
+
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+
+   // AppendedData SECTION
+   out<<"   <AppendedData encoding=\"raw\">\n";
+   out<<"_";
+
+   //POINTS SECTION
+   out.write((char*)&bytesPoints,bytesPerByteVal);
+   for(int n=0; n<nofNodes; n++)
+   {
+      out.write((char*)&val<1>(nodes[n]),sizeof(float));
+      out.write((char*)&val<2>(nodes[n]),sizeof(float));
+      out.write((char*)&val<3>(nodes[n]),sizeof(float));
+   }
+
+   //CELLS SECTION
+   //cellConnectivity
+   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
+   for(int c=0; c<nofCells; c++) 
+   {
+      out.write( (char*)&val<1>(lines[c]), sizeof(int) );
+      out.write( (char*)&val<2>(lines[c]), sizeof(int) );
+   }
+
+   //cellOffsets
+   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
+   int itmp;
+   for(int c=1; c<=nofCells; c++)
+   {
+      itmp = 3 * c;    
+      out.write( (char*)&itmp, sizeof(int) );
+   }
+
+   //cellTypes
+   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
+   unsigned char vtkCellType = 5;
+   for(int c=0; c<nofCells; c++)
+   {
+      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
+   }
+
+   //DATA SECTION
+   //scalarData
+   for(size_t s=0; s<datanames.size(); ++s)
+   {
+      out.write((char*)&bytesScalarData,bytesPerByteVal);
+      for(size_t d=0; d<nodedata[s].size(); ++d)
+      {
+         //loake kopie machen, da in nodedata "doubles" sind
+         float tmp = (float)nodedata[s][d];
+         out.write((char*)&tmp,sizeof(float));
+      }
+   }
+   out<<"\n</AppendedData>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLinesWithNodeData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+
+}
+/*===============================================================================*/
+string WbWriterVtkXmlBinary::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles)
+{
+   string vtkfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTriangles to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)triangles.size(); 
+
+   int bytesPerByteVal      = 4; //==sizeof(int)
+   int bytesPoints          = 3 /*x1/x2/x3 - coord    */ * nofNodes * sizeof(float);
+   int bytesCellConnectivty = 3 /*nodes per triangle  */ * nofCells * sizeof(int  );
+   int bytesCellOffsets     = 1 /*offset per triangle */ * nofCells * sizeof(int  );
+   int bytesCellTypes       = 1 /*type of triangle    */ * nofCells * sizeof(unsigned char);
+
+   int offset = 0;
+   //VTK FILE
+   out<<"<?xml version=\"1.0\"?>\n";
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
+   out<<"         </Points>\n";
+   offset += (bytesPerByteVal + bytesPoints);
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellConnectivty); 
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellOffsets);
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
+   offset += (bytesPerByteVal + bytesCellTypes);
+   out<<"         </Cells>\n";
+
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+
+   // AppendedData SECTION
+   out<<"   <AppendedData encoding=\"raw\">\n";
+   out<<"_";
+
+   //POINTS SECTION
+   out.write((char*)&bytesPoints,bytesPerByteVal);
+   for(int n=0; n<nofNodes; n++)
+   {
+      out.write((char*)&val<1>(nodes[n]),sizeof(float));
+      out.write((char*)&val<2>(nodes[n]),sizeof(float));
+      out.write((char*)&val<3>(nodes[n]),sizeof(float));
+   }
+
+   //CELLS SECTION
+   //cellConnectivity
+   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
+   for(int c=0; c<nofCells; c++) 
+   {
+      out.write( (char*)&val<1>(triangles[c]), sizeof(int) );
+      out.write( (char*)&val<2>(triangles[c]), sizeof(int) );
+      out.write( (char*)&val<3>(triangles[c]), sizeof(int) );
+   }
+
+   //cellOffsets
+   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
+   int itmp;
+   for(int c=1; c<=nofCells; c++)
+   {
+      itmp = 3 * c;    
+      out.write( (char*)&itmp, sizeof(int) );
+   }
+
+   //cellTypes
+   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
+   unsigned char vtkCellType = 5;
+   for(int c=0; c<nofCells; c++)
+   {
+      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
+   }
+
+   out<<"\n</AppendedData>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out<<flush;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTriangles to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+string WbWriterVtkXmlBinary::writeTrianglesWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt3 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
+{
+   string vtkfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTrianglesWithNodeData to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   int bytesPerByteVal      = 4; //==sizeof(int)
+   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
+   int bytesCellConnectivty = 3 /*nodes per tri   */ * nofCells * sizeof(int  );
+   int bytesCellOffsets     = 1 /*offset per tri  */ * nofCells * sizeof(int  );
+   int bytesCellTypes       = 1 /*type of tri     */ * nofCells * sizeof(unsigned char);
+   int bytesScalarData      = 1 /*scalar          */ * nofNodes * sizeof(float); 
+   
+   int offset = 0;
+   //VTK FILE
+   out<<"<?xml version=\"1.0\"?>\n";
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
+   out<<"         </Points>\n";
+   offset += (bytesPerByteVal + bytesPoints);
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellConnectivty); 
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellOffsets);
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
+   offset += (bytesPerByteVal + bytesCellTypes);
+   out<<"         </Cells>\n";
+
+   //DATA SECTION
+   out<<"         <PointData>\n";
+   for(size_t s=0; s<datanames.size(); ++s)
+   {
+      out<< "            <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
+      offset += (bytesPerByteVal + bytesScalarData);
+   }
+   out<<"         </PointData>\n";
+
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+
+   // AppendedData SECTION
+   out<<"   <AppendedData encoding=\"raw\">\n";
+   out<<"_";
+
+   //POINTS SECTION
+   out.write((char*)&bytesPoints,bytesPerByteVal);
+   for(int n=0; n<nofNodes; n++)
+   {
+      out.write((char*)&val<1>(nodes[n]),sizeof(float));
+      out.write((char*)&val<2>(nodes[n]),sizeof(float));
+      out.write((char*)&val<3>(nodes[n]),sizeof(float));
+   }
+
+   //CELLS SECTION
+   //cellConnectivity
+   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
+   for(int c=0; c<nofCells; c++) 
+   {
+      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
+   }
+
+   //cellOffsets
+   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
+   int itmp;
+   for(int c=1; c<=nofCells; c++)
+   {
+      itmp = 3 * c;    
+      out.write( (char*)&itmp, sizeof(int) );
+   }
+
+   //cellTypes
+   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
+   unsigned char vtkCellType = 5;
+   for(int c=0; c<nofCells; c++)
+   {
+      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
+   }
+
+   //DATA SECTION
+   //scalarData
+   for(size_t s=0; s<datanames.size(); ++s)
+   {
+      out.write((char*)&bytesScalarData,bytesPerByteVal);
+      for(size_t d=0; d<nodedata[s].size(); ++d)
+      {
+         //loake kopie machen, da in nodedata "doubles" sind
+         float tmp = (float)nodedata[s][d];
+         out.write((char*)&tmp,sizeof(float));
+      }
+   }
+   out<<"\n</AppendedData>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTrianglesWithNodeData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+string WbWriterVtkXmlBinary::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells)
+{
+   string vtkfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuads to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   int bytesPerByteVal      = 4; //==sizeof(int)
+   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
+   int bytesCellConnectivty = 4 /*nodes per quad  */ * nofCells * sizeof(int  );
+   int bytesCellOffsets     = 1 /*offset per quad */ * nofCells * sizeof(int  );
+   int bytesCellTypes       = 1 /*type of quad    */ * nofCells * sizeof(unsigned char);
+  
+   int offset = 0;
+   //VTK FILE
+   out<<"<?xml version=\"1.0\"?>\n";
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
+   out<<"         </Points>\n";
+   offset += (bytesPerByteVal + bytesPoints);
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellConnectivty); 
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellOffsets);
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
+   offset += (bytesPerByteVal + bytesCellTypes);
+   out<<"         </Cells>\n";
+
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+
+   // AppendedData SECTION
+   out<<"   <AppendedData encoding=\"raw\">\n";
+   out<<"_";
+
+   //POINTS SECTION
+   out.write((char*)&bytesPoints,bytesPerByteVal);
+   for(int n=0; n<nofNodes; n++)
+   {
+      out.write((char*)&val<1>(nodes[n]),sizeof(float));
+      out.write((char*)&val<2>(nodes[n]),sizeof(float));
+      out.write((char*)&val<3>(nodes[n]),sizeof(float));
+   }
+
+   //CELLS SECTION
+   //cellConnectivity
+   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
+   for(int c=0; c<nofCells; c++) 
+   {
+      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<4>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
+   }
+
+   //cellOffsets
+   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
+   int itmp;
+   for(int c=1; c<=nofCells; c++)
+   {
+      itmp = 4 * c;    
+      out.write( (char*)&itmp, sizeof(int) );
+   }
+
+   //cellTypes
+   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
+   unsigned char vtkCellType = 8;
+   for(int c=0; c<nofCells; c++)
+   {
+      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
+   }
+   out<<"\n</AppendedData>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out<<flush;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuads to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+string WbWriterVtkXmlBinary::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata)
+{
+   string vtkfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   int bytesPerByteVal      = 4; //==sizeof(int)
+   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
+   int bytesCellConnectivty = 4 /*nodes per quad  */ * nofCells * sizeof(int  );
+   int bytesCellOffsets     = 1 /*offset per quad */ * nofCells * sizeof(int  );
+   int bytesCellTypes       = 1 /*type of quad    */ * nofCells * sizeof(unsigned char);
+   int bytesScalarData      = 1 /*scalar          */ * nofNodes * sizeof(float); 
+
+   int offset = 0;
+   //VTK FILE
+   out<<"<?xml version=\"1.0\"?>\n";
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
+   out<<"         </Points>\n";
+   offset += (bytesPerByteVal + bytesPoints);
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellConnectivty); 
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellOffsets);
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
+   offset += (bytesPerByteVal + bytesCellTypes);
+   out<<"         </Cells>\n";
+
+   //DATA SECTION
+   out<<"         <PointData>\n";
+   for(size_t s=0; s<datanames.size(); ++s)
+   {
+      out<< "            <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
+      offset += (bytesPerByteVal + bytesScalarData);
+   }
+   out<<"         </PointData>\n";
+
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+
+   // AppendedData SECTION
+   out<<"   <AppendedData encoding=\"raw\">\n";
+   out<<"_";
+
+   //POINTS SECTION
+   out.write((char*)&bytesPoints,bytesPerByteVal);
+   for(int n=0; n<nofNodes; n++)
+   {
+      out.write((char*)&val<1>(nodes[n]),sizeof(float));
+      out.write((char*)&val<2>(nodes[n]),sizeof(float));
+      out.write((char*)&val<3>(nodes[n]),sizeof(float));
+   }
+
+   //CELLS SECTION
+   //cellConnectivity
+   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
+   for(int c=0; c<nofCells; c++) 
+   {
+      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<4>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
+   }
+
+   //cellOffsets
+   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
+   int itmp;
+   for(int c=1; c<=nofCells; c++)
+   {
+      itmp = 4 * c;    
+      out.write( (char*)&itmp, sizeof(int) );
+   }
+
+   //cellTypes
+   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
+   unsigned char vtkCellType = 8;
+   for(int c=0; c<nofCells; c++)
+   {
+      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
+   }
+
+   //DATA SECTION
+   //scalarData
+   for(size_t s=0; s<datanames.size(); ++s)
+   {
+      out.write((char*)&bytesScalarData,bytesPerByteVal);
+      for(size_t d=0; d<nodedata[s].size(); ++d)
+      {
+         //loake kopie machen, da in nodedata "doubles" sind
+         float tmp = (float)nodedata[s][d];
+         out.write((char*)&tmp,sizeof(float));
+      }
+   }
+   out<<"\n</AppendedData>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+string WbWriterVtkXmlBinary::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata)
+{
+   string vtkfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithCellData to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   int bytesPerByteVal      = 4; //==sizeof(int)
+   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
+   int bytesCellConnectivty = 4 /*nodes per quad  */ * nofCells * sizeof(int  );
+   int bytesCellOffsets     = 1 /*offset per quad */ * nofCells * sizeof(int  );
+   int bytesCellTypes       = 1 /*type of quad    */ * nofCells * sizeof(unsigned char);
+   int bytesScalarData      = 1 /*scalar          */ * nofCells * sizeof(float); 
+
+   int offset = 0;
+   //VTK FILE
+   out<<"<?xml version=\"1.0\"?>\n";
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
+   out<<"         </Points>\n";
+   offset += (bytesPerByteVal + bytesPoints);
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellConnectivty); 
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellOffsets);
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
+   offset += (bytesPerByteVal + bytesCellTypes);
+   out<<"         </Cells>\n";
+
+   //DATA SECTION
+   out<<"         <CellData>\n";
+   for(size_t s=0; s<datanames.size(); ++s)
+   {
+      out<< "            <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
+      offset += (bytesPerByteVal + bytesScalarData);
+   }
+   out<<"         </CellData>\n";
+
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+
+   // AppendedData SECTION
+   out<<"   <AppendedData encoding=\"raw\">\n";
+   out<<"_";
+
+   //POINTS SECTION
+   out.write((char*)&bytesPoints,bytesPerByteVal);
+   for(int n=0; n<nofNodes; n++)
+   {
+      out.write((char*)&val<1>(nodes[n]),sizeof(float));
+      out.write((char*)&val<2>(nodes[n]),sizeof(float));
+      out.write((char*)&val<3>(nodes[n]),sizeof(float));
+   }
+
+   //CELLS SECTION
+   //cellConnectivity
+   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
+   for(int c=0; c<nofCells; c++) 
+   {
+      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<4>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
+   }
+
+   //cellOffsets
+   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
+   int itmp;
+   for(int c=1; c<=nofCells; c++)
+   {
+      itmp = 4 * c;    
+      out.write( (char*)&itmp, sizeof(int) );
+   }
+
+   //cellTypes
+   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
+   unsigned char vtkCellType = 8;
+   for(int c=0; c<nofCells; c++)
+   {
+      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
+   }
+
+   //DATA SECTION
+   //scalarData
+   for(size_t s=0; s<datanames.size(); ++s)
+   {
+      out.write((char*)&bytesScalarData,bytesPerByteVal);
+      for(size_t d=0; d<celldata[s].size(); ++d)
+      {
+         //loake kopie machen, da in celldata "doubles" sind
+         float tmp = (float)celldata[s][d];
+         out.write((char*)&tmp,sizeof(float));
+      }
+   }
+
+   out<<"\n</AppendedData>\n";
+
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithCellData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+string WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, 
+                                                                vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames,
+                                                                vector< vector< double > >& celldata                                                                    )
+{
+   string vtkfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   int bytesPerByteVal      = 4; //==sizeof(int)
+   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
+   int bytesCellConnectivty = 4 /*nodes per quad  */ * nofCells * sizeof(int  );
+   int bytesCellOffsets     = 1 /*offset per quad */ * nofCells * sizeof(int  );
+   int bytesCellTypes       = 1 /*type of quad    */ * nofCells * sizeof(unsigned char);
+   int bytesScalarDataPoint = 1 /*scalar          */ * nofNodes * sizeof(float); 
+   int bytesScalarDataCell  = 1 /*scalar          */ * nofCells * sizeof(float); 
+
+   int offset = 0;
+   //VTK FILE
+   out<<"<?xml version=\"1.0\"?>\n";
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
+   out<<"         </Points>\n";
+   offset += (bytesPerByteVal + bytesPoints);
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellConnectivty); 
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellOffsets);
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
+   offset += (bytesPerByteVal + bytesCellTypes);
+   out<<"         </Cells>\n";
+
+   // Point DATA SECTION
+   out<<"         <PointData>\n";
+   for(size_t s=0; s<nodedatanames.size(); ++s)
+   {
+      out<< "            <DataArray type=\"Float32\" Name=\""<< nodedatanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
+      offset += (bytesPerByteVal + bytesScalarDataPoint);
+   }
+   out<<"         </PointData>\n";
+
+
+   // Cell DATA SECTION
+   out<<"         <CellData>\n";
+   for(size_t s=0; s<celldatanames.size(); ++s)
+   {
+      out<< "            <DataArray type=\"Float32\" Name=\""<< celldatanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
+      offset += (bytesPerByteVal + bytesScalarDataCell);
+   }
+   out<<"         </CellData>\n";
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+
+   // AppendedData SECTION
+   out<<"   <AppendedData encoding=\"raw\">\n";
+   out<<"_";
+
+   //POINTS SECTION
+   out.write((char*)&bytesPoints,bytesPerByteVal);
+   for(int n=0; n<nofNodes; n++)
+   {
+      out.write((char*)&val<1>(nodes[n]),sizeof(float));
+      out.write((char*)&val<2>(nodes[n]),sizeof(float));
+      out.write((char*)&val<3>(nodes[n]),sizeof(float));
+   }
+
+   //CELLS SECTION
+   //cellConnectivity
+   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
+   for(int c=0; c<nofCells; c++) 
+   {
+      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<4>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
+   }
+
+   //cellOffsets
+   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
+   int itmp;
+   for(int c=1; c<=nofCells; c++)
+   {
+      itmp = 4 * c;    
+      out.write( (char*)&itmp, sizeof(int) );
+   }
+
+   //cellTypes
+   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
+   unsigned char vtkCellType = 8;
+   for(int c=0; c<nofCells; c++)
+   {
+      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
+   }
+
+   //Point DATA SECTION
+   //scalarData
+   for(size_t s=0; s<nodedatanames.size(); ++s)
+   {
+      out.write((char*)&bytesScalarDataPoint,bytesPerByteVal);
+      for(size_t d=0; d<nodedata[s].size(); ++d)
+      {
+         //loake kopie machen, da in nodedata "doubles" sind
+         float tmp = (float)nodedata[s][d];
+         out.write((char*)&tmp,sizeof(float));
+      }
+   }
+   //Cell DATA SECTION
+   //scalarData
+   for(size_t s=0; s<celldatanames.size(); ++s)
+   {
+      out.write((char*)&bytesScalarDataCell,bytesPerByteVal);
+      for(size_t d=0; d<celldata[s].size(); ++d)
+      {
+         //loake kopie machen, da in celldata "doubles" sind
+         float tmp = (float)celldata[s][d];
+         out.write((char*)&tmp,sizeof(float));
+      }
+   }
+   out<<"\n</AppendedData>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+string WbWriterVtkXmlBinary::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata)
+{
+   string vtkfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithCellData to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   int bytesPerByteVal      = 4; //==sizeof(int)
+   int bytesPoints          = 3 /*x1/x2/x3      */ * nofNodes * sizeof(float);
+   int bytesCellConnectivty = 8 /*nodes per oct */ * nofCells * sizeof(int  );
+   int bytesCellOffsets     = 1 /*offset per oct*/ * nofCells * sizeof(int  );
+   int bytesCellTypes       = 1 /*type of oct   */ * nofCells * sizeof(unsigned char);
+   int bytesScalarData      = 1 /*scalar        */ * nofCells * sizeof(float); 
+
+   int offset = 0;
+   //VTK FILE
+   out<<"<?xml version=\"1.0\"?>\n";
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
+   out<<"         </Points>\n";
+   offset += (bytesPerByteVal + bytesPoints);
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellConnectivty); 
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellOffsets);
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
+   offset += (bytesPerByteVal + bytesCellTypes);
+   out<<"         </Cells>\n";
+
+   //DATA SECTION
+   out<<"         <CellData>\n";
+   for(size_t s=0; s<datanames.size(); ++s)
+   {
+      out<< "            <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
+      offset += (bytesPerByteVal + bytesScalarData);
+   }
+   out<<"         </CellData>\n";
+
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+
+   // AppendedData SECTION
+   out<<"   <AppendedData encoding=\"raw\">\n";
+   out<<"_";
+
+   //POINTS SECTION
+   out.write((char*)&bytesPoints,bytesPerByteVal);
+   for(int n=0; n<nofNodes; n++)
+   {
+      out.write((char*)&val<1>(nodes[n]),sizeof(float));
+      out.write((char*)&val<2>(nodes[n]),sizeof(float));
+      out.write((char*)&val<3>(nodes[n]),sizeof(float));
+   }
+
+   //CELLS SECTION
+   //cellConnectivity
+   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
+   for(int c=0; c<nofCells; c++) 
+   {
+      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<4>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<5>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<6>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<8>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<7>(cells[c]), sizeof(int) );
+   }
+
+   //cellOffsets
+   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
+   int itmp;
+   for(int c=1; c<=nofCells; c++)
+   {
+      itmp = 8 * c;    
+      out.write( (char*)&itmp, sizeof(int) );
+   }
+
+   //cellTypes
+   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
+   unsigned char vtkCellType = 11;
+   for(int c=0; c<nofCells; c++)
+   {
+      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
+   }
+
+   //DATA SECTION
+   //scalarData
+   for(size_t s=0; s<datanames.size(); ++s)
+   {
+      out.write((char*)&bytesScalarData,bytesPerByteVal);
+      for(size_t d=0; d<celldata[s].size(); ++d)
+      {
+         //loake kopie machen, da in celldata "doubles" sind
+         float tmp = (float)celldata[s][d];
+         out.write((char*)&tmp,sizeof(float));
+      }
+   }
+   out<<"\n</AppendedData>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithCellData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+string WbWriterVtkXmlBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata)
+{
+   string vtkfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithNodeData to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   int bytesPerByteVal      = 4; //==sizeof(int)
+   int bytesPoints          = 3 /*x1/x2/x3      */ * nofNodes * sizeof(float);
+   int bytesCellConnectivty = 8 /*nodes per oct */ * nofCells * sizeof(int  );
+   int bytesCellOffsets     = 1 /*offset per oct*/ * nofCells * sizeof(int  );
+   int bytesCellTypes       = 1 /*type of oct   */ * nofCells * sizeof(unsigned char);
+   int bytesScalarData      = 1 /*scalar        */ * nofNodes * sizeof(float); 
+
+   int offset = 0;
+   //VTK FILE
+   out<<"<?xml version=\"1.0\"?>\n";
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
+   out<<"         </Points>\n";
+   offset += (bytesPerByteVal + bytesPoints);
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellConnectivty); 
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellOffsets);
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
+   offset += (bytesPerByteVal + bytesCellTypes);
+   out<<"         </Cells>\n";
+
+   //DATA SECTION
+   out<<"         <PointData>\n";
+   for(size_t s=0; s<datanames.size(); ++s)
+   {
+      out<< "            <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
+      offset += (bytesPerByteVal + bytesScalarData);
+   }
+   out<<"         </PointData>\n";
+
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+
+   // AppendedData SECTION
+   out<<"   <AppendedData encoding=\"raw\">\n";
+   out<<"_";
+
+   //POINTS SECTION
+   out.write((char*)&bytesPoints,bytesPerByteVal);
+   for(int n=0; n<nofNodes; n++)
+   {
+      out.write((char*)&val<1>(nodes[n]),sizeof(float));
+      out.write((char*)&val<2>(nodes[n]),sizeof(float));
+      out.write((char*)&val<3>(nodes[n]),sizeof(float));
+   }
+
+   //CELLS SECTION
+   //cellConnectivity
+   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
+   for(int c=0; c<nofCells; c++) 
+   {
+      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<4>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<5>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<6>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<8>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<7>(cells[c]), sizeof(int) );
+   }
+
+   //cellOffsets
+   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
+   int itmp;
+   for(int c=1; c<=nofCells; c++)
+   {
+      itmp = 8 * c;    
+      out.write( (char*)&itmp, sizeof(int) );
+   }
+
+   //cellTypes
+   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
+   unsigned char vtkCellType = 11;
+   for(int c=0; c<nofCells; c++)
+   {
+      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
+   }
+
+   //DATA SECTION
+   //scalarData
+   for(size_t s=0; s<datanames.size(); ++s)
+   {
+      out.write((char*)&bytesScalarData,bytesPerByteVal);
+      for(size_t d=0; d<nodedata[s].size(); ++d)
+      {
+         //loake kopie machen, da in nodedata "doubles" sind
+         float tmp = (float)nodedata[s][d];
+         out.write((char*)&tmp,sizeof(float));
+      }
+   }
+   out<<"\n</AppendedData>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithNodeData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+/*===============================================================================*/
+string WbWriterVtkXmlBinary::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells)
+{
+   string vtkfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOcts to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+   int nofCells = (int)cells.size(); 
+
+   int bytesPerByteVal      = 4; //==sizeof(int)
+   int bytesPoints          = 3 /*x1/x2/x3      */ * nofNodes * sizeof(float);
+   int bytesCellConnectivty = 8 /*nodes per oct */ * nofCells * sizeof(int  );
+   int bytesCellOffsets     = 1 /*offset per oct*/ * nofCells * sizeof(int  );
+   int bytesCellTypes       = 1 /*type of oct   */ * nofCells * sizeof(unsigned char);
+   //int bytesScalarData      = 1 /*scalar        */ * nofNodes * sizeof(float); 
+
+   int offset = 0;
+   //VTK FILE
+   out<<"<?xml version=\"1.0\"?>\n";
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
+   out<<"         </Points>\n";
+   offset += (bytesPerByteVal + bytesPoints);
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellConnectivty); 
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellOffsets);
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
+   offset += (bytesPerByteVal + bytesCellTypes);
+   out<<"         </Cells>\n";
+
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+
+   // AppendedData SECTION
+   out<<"   <AppendedData encoding=\"raw\">\n";
+   out<<"_";
+
+   //POINTS SECTION
+   out.write((char*)&bytesPoints,bytesPerByteVal);
+   for(int n=0; n<nofNodes; n++)
+   {
+      out.write((char*)&val<1>(nodes[n]),sizeof(float));
+      out.write((char*)&val<2>(nodes[n]),sizeof(float));
+      out.write((char*)&val<3>(nodes[n]),sizeof(float));
+   }
+
+   //CELLS SECTION
+   //cellConnectivity
+   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
+   for(int c=0; c<nofCells; c++) 
+   {
+      out.write( (char*)&val<1>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<2>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<4>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<3>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<5>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<6>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<8>(cells[c]), sizeof(int) );
+      out.write( (char*)&val<7>(cells[c]), sizeof(int) );
+   }
+
+   //cellOffsets
+   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
+   int itmp;
+   for(int c=1; c<=nofCells; c++)
+   {
+      itmp = 8 * c;    
+      out.write( (char*)&itmp, sizeof(int) );
+   }
+
+   //cellTypes
+   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
+   unsigned char vtkCellType = 11;
+   for(int c=0; c<nofCells; c++)
+   {
+      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
+   }
+   out<<"\n</AppendedData>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOcts to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+std::string WbWriterVtkXmlBinary::writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes)
+{
+   string vtkfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodes to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+
+   int bytesPerByteVal      = 4; //==sizeof(int)
+   int bytesPoints          = 3 /*x1/x2/x3        */ * nofNodes * sizeof(float);
+   int bytesCellConnectivty = 1 /*nodes per cell  */ * nofNodes * sizeof(int  );
+   int bytesCellOffsets     = 1 /*offset per cell */ * nofNodes * sizeof(int  );
+   int bytesCellTypes       = 1 /*type of line    */ * nofNodes * sizeof(unsigned char);
+
+   int offset = 0;
+   //VTK FILE
+   out<<"<?xml version=\"1.0\"?>\n";
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofNodes<<"\">\n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
+   out<<"         </Points>\n";
+   offset += (bytesPerByteVal + bytesPoints);
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellConnectivty); 
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellOffsets);
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
+   offset += (bytesPerByteVal + bytesCellTypes);
+   out<<"         </Cells>\n";
+
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+
+   // AppendedData SECTION
+   out<<"   <AppendedData encoding=\"raw\">\n";
+   out<<"_";
+
+   //POINTS SECTION
+   out.write((char*)&bytesPoints,bytesPerByteVal);
+   for(int n=0; n<nofNodes; n++)
+   {
+      out.write((char*)&val<1>(nodes[n]),sizeof(float));
+      out.write((char*)&val<2>(nodes[n]),sizeof(float));
+      out.write((char*)&val<3>(nodes[n]),sizeof(float));
+   }
+
+   //CELLS SECTION
+   //cellConnectivity
+   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
+   for(int c=0; c<nofNodes; c++) 
+      out.write( (char*)&c, sizeof(int) );
+
+   //cellOffsets
+   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
+   for(int c=1; c<=nofNodes; c++)
+      out.write( (char*)&c, sizeof(int) );
+
+   //cellTypes
+   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
+   unsigned char vtkCellType = 1;
+   for(int c=0; c<nofNodes; c++)
+      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
+
+   out<<"\n</AppendedData>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodes to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+}
+std::string WbWriterVtkXmlBinary::writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata)
+{
+   string vtkfilename = filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodesWithNodeData to "<<vtkfilename<<" - start");
+
+   ofstream out(vtkfilename.c_str(),ios::out | ios::binary);
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(vtkfilename);
+      if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename);
+   }
+
+   int nofNodes = (int)nodes.size(); 
+
+   int bytesPerByteVal      = 4; //==sizeof(int)
+   int bytesPoints          = 3 /*x1/x2/x3       */ * nofNodes * sizeof(float);
+   int bytesCellConnectivty = 1 /*nodes per cell */ * nofNodes * sizeof(int  );
+   int bytesCellOffsets     = 1 /*offset per cell*/ * nofNodes * sizeof(int  );
+   int bytesCellTypes       = 1 /*type of oct    */ * nofNodes * sizeof(unsigned char);
+   int bytesScalarData      = 1 /*scalar         */ * nofNodes * sizeof(float); 
+
+   int offset = 0;
+   //VTK FILE
+   out<<"<?xml version=\"1.0\"?>\n";
+   out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n";
+   out<<"   <UnstructuredGrid>"<<"\n";
+   out<<"      <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofNodes<<"\">\n";
+
+   //POINTS SECTION
+   out<<"         <Points>\n"; 
+   out<<"            <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\"  />\n";
+   out<<"         </Points>\n";
+   offset += (bytesPerByteVal + bytesPoints);
+
+   //CELLS SECTION
+   out<<"         <Cells>\n";
+   out<<"            <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellConnectivty); 
+   out<<"            <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n";
+   offset += (bytesPerByteVal + bytesCellOffsets);
+   out<<"            <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n ";
+   offset += (bytesPerByteVal + bytesCellTypes);
+   out<<"         </Cells>\n";
+
+   //DATA SECTION
+   out<<"         <PointData>\n";
+   for(size_t s=0; s<datanames.size(); ++s)
+   {
+      out<< "            <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n";
+      offset += (bytesPerByteVal + bytesScalarData);
+   }
+   out<<"         </PointData>\n";
+
+   out<<"      </Piece>\n";
+   out<<"   </UnstructuredGrid>\n";
+
+   // AppendedData SECTION
+   out<<"   <AppendedData encoding=\"raw\">\n";
+   out<<"_";
+
+   //POINTS SECTION
+   out.write((char*)&bytesPoints,bytesPerByteVal);
+   for(int n=0; n<nofNodes; n++)
+   {
+      out.write((char*)&val<1>(nodes[n]),sizeof(float));
+      out.write((char*)&val<2>(nodes[n]),sizeof(float));
+      out.write((char*)&val<3>(nodes[n]),sizeof(float));
+   }
+
+   //CELLS SECTION
+   //cellConnectivity
+   out.write( (char*)&bytesCellConnectivty, bytesPerByteVal );  
+   for(int c=0; c<nofNodes; c++) 
+      out.write( (char*)&c, sizeof(int) );
+
+   //cellOffsets
+   out.write( (char*)&bytesCellOffsets, bytesPerByteVal );
+   for(int c=1; c<=nofNodes; c++)
+      out.write( (char*)&c, sizeof(int) );
+
+   //cellTypes
+   out.write( (char*)&bytesCellTypes, bytesPerByteVal );
+   unsigned char vtkCellType = 1;
+   for(int c=0; c<nofNodes; c++)
+      out.write( (char*)&vtkCellType, sizeof(unsigned char) );
+   
+   //DATA SECTION
+   //scalarData
+   for(size_t s=0; s<datanames.size(); ++s)
+   {
+      out.write((char*)&bytesScalarData,bytesPerByteVal);
+      for(size_t d=0; d<nodedata[s].size(); ++d)
+      {
+         //loake kopie machen, da in nodedata "doubles" sind
+         float tmp = (float)nodedata[s][d];
+         out.write((char*)&tmp,sizeof(float));
+      }
+   }
+   out<<"\n</AppendedData>\n";
+   out<<"</VTKFile>";
+   out<<endl;
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodesWithNodeData to "<<vtkfilename<<" - end");
+
+   return vtkfilename;
+
+}
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterVtkXmlBinary.h b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkXmlBinary.h
similarity index 98%
rename from source/ThirdParty/Library/basics/writer/WbWriterVtkXmlBinary.h
rename to source/VirtualFluidsBasic/basics/writer/WbWriterVtkXmlBinary.h
index bf4c93e422e3cc796c32622762db0bc633ebee3b..716cc6c79051f7faaf9f3507c9c972d87d2272c2 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterVtkXmlBinary.h
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterVtkXmlBinary.h
@@ -1,97 +1,97 @@
-#ifndef WBWRITERVTKXMLBINARY_H
-#define WBWRITERVTKXMLBINARY_H
-
-#include <string>
-
-#include <basics/writer/WbWriter.h>
-
-class WbWriterVtkXmlBinary  : public WbWriter
-{
-public:
-#ifndef SWIG
-   OBCREATOR_EXT( WbWriterVtkXmlBinary )
-#endif
-
-   static WbWriterVtkXmlBinary* getInstance()
-   {
-      static WbWriterVtkXmlBinary instance;
-      return &instance;
-   }
-private:
-   WbWriterVtkXmlBinary() : WbWriter() 
-   {
-      if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"machine error char  type mismatch");
-      if(sizeof(int)          !=4) throw UbException(UB_EXARGS,"machine error int   type mismatch");
-      if(sizeof(float)        !=4) throw UbException(UB_EXARGS,"machine error float type mismatch");
-   }
-
-   WbWriterVtkXmlBinary( const WbWriterVtkXmlBinary& );                  //no copy allowed 
-   const WbWriterVtkXmlBinary& operator=( const WbWriterVtkXmlBinary& ); //no copy allowed
-
-   static std::string  pvdEndTag;
-public:
-   std::string getFileExtension() { return ".bin.vtu";   }
-
-   //write a metafile 
-   std::string writeCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups);
-   std::string addFilesToCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups);
-   std::string writeParallelFile(const std::string& filename,std::vector<std::string>& pieceSources, std::vector<std::string>& pointDataNames, std::vector<std::string>& cellDataNames);
-
-   //////////////////////////////////////////////////////////////////////////
-   //nodes
-   std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes);
-   std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
-
-   //////////////////////////////////////////////////////////////////////////
-   //lines
-   //     0 ---- 1
-   //nodenumbering must start with 0!
-   std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines);
-   std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-
-   //////////////////////////////////////////////////////////////////////////
-   //triangles
-   //                    2
-   //                     
-   //                  0---1
-   //nodenumbering must start with 0!
-   std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles);
-   std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
-
-   //////////////////////////////////////////////////////////////////////////
-   //2D
-   //cell numbering:
-   //                  3---2
-   //                  |   |
-   //                  0---1
-   //nodenumbering must start with 0!
-
-   std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells);
-   std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
-   std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
-   std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, 
-                                             std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames,
-                                             std::vector< std::vector< double > >& celldata                                                                    );
-   
-   //////////////////////////////////////////////////////////////////////////
-   //octs
-   //     7 ---- 6
-   //    /|     /|
-   //   4 +--- 5 |
-   //   | |    | |
-   //   | 3 ---+ 2
-   //   |/     |/
-   //   0 ---- 1
-   std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
-   std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata);
-   std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
-   
-private:
-
-};
-
-#ifndef SWIG
-UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkXmlBinary ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlBinary);
-#endif
-
-#endif //WBWRITERVTKXMLBINARY_H
+#ifndef WBWRITERVTKXMLBINARY_H
+#define WBWRITERVTKXMLBINARY_H
+
+#include <string>
+
+#include <basics/writer/WbWriter.h>
+
+class WbWriterVtkXmlBinary  : public WbWriter
+{
+public:
+#ifndef SWIG
+   OBCREATOR_EXT( WbWriterVtkXmlBinary )
+#endif
+
+   static WbWriterVtkXmlBinary* getInstance()
+   {
+      static WbWriterVtkXmlBinary instance;
+      return &instance;
+   }
+private:
+   WbWriterVtkXmlBinary() : WbWriter() 
+   {
+      if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"machine error char  type mismatch");
+      if(sizeof(int)          !=4) throw UbException(UB_EXARGS,"machine error int   type mismatch");
+      if(sizeof(float)        !=4) throw UbException(UB_EXARGS,"machine error float type mismatch");
+   }
+
+   WbWriterVtkXmlBinary( const WbWriterVtkXmlBinary& );                  //no copy allowed 
+   const WbWriterVtkXmlBinary& operator=( const WbWriterVtkXmlBinary& ); //no copy allowed
+
+   static std::string  pvdEndTag;
+public:
+   std::string getFileExtension() { return ".bin.vtu";   }
+
+   //write a metafile 
+   std::string writeCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups);
+   std::string addFilesToCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups);
+   std::string writeParallelFile(const std::string& filename,std::vector<std::string>& pieceSources, std::vector<std::string>& pointDataNames, std::vector<std::string>& cellDataNames);
+
+   //////////////////////////////////////////////////////////////////////////
+   //nodes
+   std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes);
+   std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
+
+   //////////////////////////////////////////////////////////////////////////
+   //lines
+   //     0 ---- 1
+   //nodenumbering must start with 0!
+   std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines);
+   std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+
+   //////////////////////////////////////////////////////////////////////////
+   //triangles
+   //                    2
+   //                     
+   //                  0---1
+   //nodenumbering must start with 0!
+   std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles);
+   std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
+
+   //////////////////////////////////////////////////////////////////////////
+   //2D
+   //cell numbering:
+   //                  3---2
+   //                  |   |
+   //                  0---1
+   //nodenumbering must start with 0!
+
+   std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells);
+   std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata);
+   std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata);
+   std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, 
+                                             std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames,
+                                             std::vector< std::vector< double > >& celldata                                                                    );
+   
+   //////////////////////////////////////////////////////////////////////////
+   //octs
+   //     7 ---- 6
+   //    /|     /|
+   //   4 +--- 5 |
+   //   | |    | |
+   //   | 3 ---+ 2
+   //   |/     |/
+   //   0 ---- 1
+   std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells);
+   std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata);
+   std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata);
+   
+private:
+
+};
+
+#ifndef SWIG
+UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkXmlBinary ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlBinary);
+#endif
+
+#endif //WBWRITERVTKXMLBINARY_H
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterX3D.cpp b/source/VirtualFluidsBasic/basics/writer/WbWriterX3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/basics/writer/WbWriterX3D.cpp
rename to source/VirtualFluidsBasic/basics/writer/WbWriterX3D.cpp
index 68eee613779233c44dbb0cf6c501c564a0bfdab2..14d1b3741695e17f5c3608e275b676ea6e739491 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterX3D.cpp
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterX3D.cpp
@@ -1,152 +1,152 @@
-#include <basics/writer/WbWriterX3D.h>
-#include <basics/utilities/UbLogger.h>
-
-using namespace std;
-
-/*===============================================================================*/
-std::string WbWriterX3D::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles)
-{
-   string X3DFilename=filename+getFileExtension();
-   UBLOG(logDEBUG1,"WbWriterX3D::writeTriangles to "<<X3DFilename<<" - start");
-
-   std::ofstream out(X3DFilename.c_str());
-   if(!out)
-   { 
-      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
-      string path = UbSystem::getPathFromString(X3DFilename);
-      if(path.size()>0){UbSystem::makeDirectory(path);out.open(X3DFilename.c_str());}
-      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+X3DFilename);
-   }
-
-   // General part
-
-   //Root Element
-   out<<"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"																																 	   <<endl;
-   out<<"<!DOCTYPE X3D PUBLIC \"ISO//Web3D//DTD X3D 3.1//EN\"   \"http://www.web3d.org/specifications/x3d-3.1.dtd\">"																	   <<endl;
-   out<<"<X3D profile='Interchange' version='3.1' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation=' http://www.web3d.org/specifications/x3d-3.1.xsd '>"<<endl<<endl;
-
-   //Head
-   out<<"<head>"										 <<endl;
-   out<<"<meta content='Simple X3D Writer for blender'/>"<<endl;
-   out<<"</head>"										 <<endl<<endl;
-
-	//Scene, Shape beginn 
-   out<<"<Scene>"            <<endl;
-   out<<"<Shape>"            <<endl;
-
-	//IndexedFaceSet => Polylinien der Dreiecke
-	out<<"<IndexedFaceSet  coordIndex=\""<<endl;
-
-	// TRIANGLES Ponits SECTION
-	int nofTriangles= (int)triangles.size(); 
-	//out<<"   triangles "<<nofTriangles<<endl;
-	for(int c=0; c<nofTriangles; c++)
-		out<<"      "<<val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<" -1"<<endl;
-	out<<"\">"            <<endl;
-    
-	//Coordinates
-	out<<"<Coordinate  point=\""    <<endl;
-
-	// Coordinates SECTION
-	int nofNodes = (int)nodes.size(); 
-	//out<<"   points "<<nofNodes<<endl;
-	for(int n=0; n<nofNodes; n++)
-		out<<"      "<< val<1>(nodes[n]) <<", "<< val<2>(nodes[n]) <<", "<< val<3>(nodes[n])<<", "<<endl;
-   out<<"\"/>"            <<endl;
-
-	//Footer
-	out<<"</IndexedFaceSet>"<< endl;
-	out<<"</Shape>"			<< endl;
-	out<<"</Scene>"         << endl;
-	out<<"</X3D>"           << endl;
-   
-
-   //// Image details
-   //out<<"image {"              <<endl;
-   //out<<"   resolution 640 480"<<endl;
-   //out<<"   aa 0 1"            <<endl;
-   //out<<"   filter mitchell"   <<endl;
-   //out<<"}"                    <<endl<<endl;
-
-   //// Camera position
-   //out<<"camera {"                 <<endl;
-   //out<<"   type pinhole"          <<endl;
-   //out<<"   eye    -0.25 -0.3 0.13"<<endl;
-   //out<<"   target -0.1 0.1 0.13"  <<endl;
-   //out<<"   up     0 0 1"          <<endl;
-   //out<<"   fov    60"             <<endl;
-   //out<<"   aspect 1.333333"       <<endl;
-   //out<<"}"                        <<endl<<endl;
-
-   //// Light
-   //out<<"light {"                  <<endl;
-   //out<<"   type ibl"              <<endl;
-   //out<<"   image sky_small.hdr"   <<endl;
-   //out<<"   center 0 -1 0"         <<endl;
-   //out<<"   up 0 0 1"              <<endl;
-   //out<<"   lock true"             <<endl;
-   //out<<"   samples 200"           <<endl;
-   //out<<"}"                        <<endl<<endl;
-
-   //// Shaders
-   //out<<"shader {"                 <<endl;
-   //out<<"   name default-shader"   <<endl;
-   //out<<"   type diffuse"          <<endl;
-   //out<<"   diff 0.25 0.25 0.25"   <<endl;
-   //out<<"}"                        <<endl<<endl;
-
-   //out<<"shader {"                 <<endl;
-   //out<<"   name Glass"            <<endl;
-   //out<<"   type glass"            <<endl;
-   //out<<"   eta 1.333"             <<endl;
-   //out<<"   color 0.1 0.3 0.8"     <<endl;
-   //out<<"}"                        <<endl<<endl;
-   //                                
-   //out<<"shader {"                 <<endl;
-   //out<<"   name Mirror"           <<endl;
-   //out<<"   type mirror"           <<endl;
-   //out<<"   refl 0.7 0.7 0.7"      <<endl;
-   //out<<"}"                        <<endl<<endl;
-
-   //// Objects
-   //// a) Ground plane
-   //out<<"object {"                 <<endl;
-   //out<<"   shader default-shader" <<endl;
-   //out<<"   type plane"            <<endl;
-   //out<<"   p 0 0 0"               <<endl;
-   //out<<"   n 0 0 1"               <<endl;
-   //out<<"}"                        <<endl<<endl;
-
-   //// b) Mesh
-   //out<<"object {"                 <<endl;
-   //out<<"   shader Glass"          <<endl;
-   //out<<"   transform {"           <<endl;
-   //out<<"      rotatey 270.0"      <<endl;
-   //out<<"   }"                     <<endl;
-   //out<<"   type generic-mesh"     <<endl;
-   //out<<"      name polySurfac"    <<endl<<endl;
-
-
-   //// POINTS SECTION
-   //int nofNodes = (int)nodes.size(); 
-   //out<<"   points "<<nofNodes<<endl;
-   //for(int n=0; n<nofNodes; n++)
-   //   out<<"      "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<endl;
-
-   //// TRIANGLES SECTION
-   //int nofTriangles= (int)triangles.size(); 
-   //out<<"   triangles "<<nofTriangles<<endl;
-   //for(int c=0; c<nofTriangles; c++)
-   //   out<<"      "<<val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<endl;
-
-   //// FOOTER
-   //out<<"   normals none" << endl;
-   //out<<"   uvs none"     << endl;
-   //out<<"}"               << endl;
-
-   out.close();
-   UBLOG(logDEBUG1,"WbWriterX3D::writeTriangles to "<<X3DFilename<<" - end");
-
-   return X3DFilename;
-}
-/*===============================================================================*/
+#include <basics/writer/WbWriterX3D.h>
+#include <basics/utilities/UbLogger.h>
+
+using namespace std;
+
+/*===============================================================================*/
+std::string WbWriterX3D::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles)
+{
+   string X3DFilename=filename+getFileExtension();
+   UBLOG(logDEBUG1,"WbWriterX3D::writeTriangles to "<<X3DFilename<<" - start");
+
+   std::ofstream out(X3DFilename.c_str());
+   if(!out)
+   { 
+      out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!!
+      string path = UbSystem::getPathFromString(X3DFilename);
+      if(path.size()>0){UbSystem::makeDirectory(path);out.open(X3DFilename.c_str());}
+      if(!out) throw UbException(UB_EXARGS,"couldn't open file "+X3DFilename);
+   }
+
+   // General part
+
+   //Root Element
+   out<<"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"																																 	   <<endl;
+   out<<"<!DOCTYPE X3D PUBLIC \"ISO//Web3D//DTD X3D 3.1//EN\"   \"http://www.web3d.org/specifications/x3d-3.1.dtd\">"																	   <<endl;
+   out<<"<X3D profile='Interchange' version='3.1' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation=' http://www.web3d.org/specifications/x3d-3.1.xsd '>"<<endl<<endl;
+
+   //Head
+   out<<"<head>"										 <<endl;
+   out<<"<meta content='Simple X3D Writer for blender'/>"<<endl;
+   out<<"</head>"										 <<endl<<endl;
+
+	//Scene, Shape beginn 
+   out<<"<Scene>"            <<endl;
+   out<<"<Shape>"            <<endl;
+
+	//IndexedFaceSet => Polylinien der Dreiecke
+	out<<"<IndexedFaceSet  coordIndex=\""<<endl;
+
+	// TRIANGLES Ponits SECTION
+	int nofTriangles= (int)triangles.size(); 
+	//out<<"   triangles "<<nofTriangles<<endl;
+	for(int c=0; c<nofTriangles; c++)
+		out<<"      "<<val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<" -1"<<endl;
+	out<<"\">"            <<endl;
+    
+	//Coordinates
+	out<<"<Coordinate  point=\""    <<endl;
+
+	// Coordinates SECTION
+	int nofNodes = (int)nodes.size(); 
+	//out<<"   points "<<nofNodes<<endl;
+	for(int n=0; n<nofNodes; n++)
+		out<<"      "<< val<1>(nodes[n]) <<", "<< val<2>(nodes[n]) <<", "<< val<3>(nodes[n])<<", "<<endl;
+   out<<"\"/>"            <<endl;
+
+	//Footer
+	out<<"</IndexedFaceSet>"<< endl;
+	out<<"</Shape>"			<< endl;
+	out<<"</Scene>"         << endl;
+	out<<"</X3D>"           << endl;
+   
+
+   //// Image details
+   //out<<"image {"              <<endl;
+   //out<<"   resolution 640 480"<<endl;
+   //out<<"   aa 0 1"            <<endl;
+   //out<<"   filter mitchell"   <<endl;
+   //out<<"}"                    <<endl<<endl;
+
+   //// Camera position
+   //out<<"camera {"                 <<endl;
+   //out<<"   type pinhole"          <<endl;
+   //out<<"   eye    -0.25 -0.3 0.13"<<endl;
+   //out<<"   target -0.1 0.1 0.13"  <<endl;
+   //out<<"   up     0 0 1"          <<endl;
+   //out<<"   fov    60"             <<endl;
+   //out<<"   aspect 1.333333"       <<endl;
+   //out<<"}"                        <<endl<<endl;
+
+   //// Light
+   //out<<"light {"                  <<endl;
+   //out<<"   type ibl"              <<endl;
+   //out<<"   image sky_small.hdr"   <<endl;
+   //out<<"   center 0 -1 0"         <<endl;
+   //out<<"   up 0 0 1"              <<endl;
+   //out<<"   lock true"             <<endl;
+   //out<<"   samples 200"           <<endl;
+   //out<<"}"                        <<endl<<endl;
+
+   //// Shaders
+   //out<<"shader {"                 <<endl;
+   //out<<"   name default-shader"   <<endl;
+   //out<<"   type diffuse"          <<endl;
+   //out<<"   diff 0.25 0.25 0.25"   <<endl;
+   //out<<"}"                        <<endl<<endl;
+
+   //out<<"shader {"                 <<endl;
+   //out<<"   name Glass"            <<endl;
+   //out<<"   type glass"            <<endl;
+   //out<<"   eta 1.333"             <<endl;
+   //out<<"   color 0.1 0.3 0.8"     <<endl;
+   //out<<"}"                        <<endl<<endl;
+   //                                
+   //out<<"shader {"                 <<endl;
+   //out<<"   name Mirror"           <<endl;
+   //out<<"   type mirror"           <<endl;
+   //out<<"   refl 0.7 0.7 0.7"      <<endl;
+   //out<<"}"                        <<endl<<endl;
+
+   //// Objects
+   //// a) Ground plane
+   //out<<"object {"                 <<endl;
+   //out<<"   shader default-shader" <<endl;
+   //out<<"   type plane"            <<endl;
+   //out<<"   p 0 0 0"               <<endl;
+   //out<<"   n 0 0 1"               <<endl;
+   //out<<"}"                        <<endl<<endl;
+
+   //// b) Mesh
+   //out<<"object {"                 <<endl;
+   //out<<"   shader Glass"          <<endl;
+   //out<<"   transform {"           <<endl;
+   //out<<"      rotatey 270.0"      <<endl;
+   //out<<"   }"                     <<endl;
+   //out<<"   type generic-mesh"     <<endl;
+   //out<<"      name polySurfac"    <<endl<<endl;
+
+
+   //// POINTS SECTION
+   //int nofNodes = (int)nodes.size(); 
+   //out<<"   points "<<nofNodes<<endl;
+   //for(int n=0; n<nofNodes; n++)
+   //   out<<"      "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<endl;
+
+   //// TRIANGLES SECTION
+   //int nofTriangles= (int)triangles.size(); 
+   //out<<"   triangles "<<nofTriangles<<endl;
+   //for(int c=0; c<nofTriangles; c++)
+   //   out<<"      "<<val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<endl;
+
+   //// FOOTER
+   //out<<"   normals none" << endl;
+   //out<<"   uvs none"     << endl;
+   //out<<"}"               << endl;
+
+   out.close();
+   UBLOG(logDEBUG1,"WbWriterX3D::writeTriangles to "<<X3DFilename<<" - end");
+
+   return X3DFilename;
+}
+/*===============================================================================*/
diff --git a/source/ThirdParty/Library/basics/writer/WbWriterX3D.h b/source/VirtualFluidsBasic/basics/writer/WbWriterX3D.h
similarity index 96%
rename from source/ThirdParty/Library/basics/writer/WbWriterX3D.h
rename to source/VirtualFluidsBasic/basics/writer/WbWriterX3D.h
index b9c708c1215bb897d6ff58e5e30367b4b54505ae..6bb503f1c71fbd462a0f36e07e0a270051c48e29 100644
--- a/source/ThirdParty/Library/basics/writer/WbWriterX3D.h
+++ b/source/VirtualFluidsBasic/basics/writer/WbWriterX3D.h
@@ -1,38 +1,38 @@
-#ifndef WBWRITERX3D_H
-#define WBWRITERX3D_H
-
-#include <string>
-
-#include <basics/writer/WbWriter.h>
-
-class WbWriterX3D  : public WbWriter
-{
-public:
-   OBCREATOR_EXT( WbWriterX3D )
-
-   static WbWriterX3D* getInstance()
-   {
-      static WbWriterX3D instance;
-      return &instance;
-   }
-private:
-   WbWriterX3D() : WbWriter() 
-   {
-      if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char  type mismatch");
-      if(sizeof(int)          !=4) throw UbException(UB_EXARGS,"error int   type mismatch");
-      if(sizeof(float)        !=4) throw UbException(UB_EXARGS,"error float type mismatch");
-   }
-   WbWriterX3D( const WbWriterX3D& );                  //no copy allowed 
-   const WbWriterX3D& operator=( const WbWriterX3D& ); //no copy allowed
-
-   static std::string  pvdEndTag;
-
-public:
-   std::string getFileExtension()  { return "ascii.X3D"; }
-
-   std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles);
-};
-
-UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterX3D ,WbWriter>::getInstance()), CAB_WbWriterX3D);
-
-#endif //WBWRITERX3D_H
+#ifndef WBWRITERX3D_H
+#define WBWRITERX3D_H
+
+#include <string>
+
+#include <basics/writer/WbWriter.h>
+
+class WbWriterX3D  : public WbWriter
+{
+public:
+   OBCREATOR_EXT( WbWriterX3D )
+
+   static WbWriterX3D* getInstance()
+   {
+      static WbWriterX3D instance;
+      return &instance;
+   }
+private:
+   WbWriterX3D() : WbWriter() 
+   {
+      if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char  type mismatch");
+      if(sizeof(int)          !=4) throw UbException(UB_EXARGS,"error int   type mismatch");
+      if(sizeof(float)        !=4) throw UbException(UB_EXARGS,"error float type mismatch");
+   }
+   WbWriterX3D( const WbWriterX3D& );                  //no copy allowed 
+   const WbWriterX3D& operator=( const WbWriterX3D& ); //no copy allowed
+
+   static std::string  pvdEndTag;
+
+public:
+   std::string getFileExtension()  { return "ascii.X3D"; }
+
+   std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles);
+};
+
+UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterX3D ,WbWriter>::getInstance()), CAB_WbWriterX3D);
+
+#endif //WBWRITERX3D_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/CMakePackage.txt b/source/VirtualFluidsBasic/numerics/geometry3d/CMakePackage.txt
similarity index 99%
rename from source/ThirdParty/Library/numerics/geometry3d/CMakePackage.txt
rename to source/VirtualFluidsBasic/numerics/geometry3d/CMakePackage.txt
index de1dc5a88225180b8e40c6cf46f4a6fbb102778f..e3e3f9a387b022a62ecc0d63c3ef0210313e906d 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/CMakePackage.txt
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/CMakePackage.txt
@@ -1,2 +1,2 @@
-GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
 COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
\ No newline at end of file
diff --git a/source/ThirdParty/Library/numerics/geometry3d/CoordinateTransformation3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/CoordinateTransformation3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/CoordinateTransformation3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/CoordinateTransformation3D.cpp
index 0d20dadd41c1c4ad2f93eea2f8ddc7dc3fb5de67..ba219df7783bad16901e7f3f5d01ce9913550795 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/CoordinateTransformation3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/CoordinateTransformation3D.cpp
@@ -1,254 +1,254 @@
-#include <numerics/geometry3d/CoordinateTransformation3D.h>
-#include <basics/utilities/UbMath.h>
-
-using namespace std;
-
-CoordinateTransformation3D::CoordinateTransformation3D()
-{
-   this->setTransformationValues(0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0);
-}
-/*======================================================*/
-CoordinateTransformation3D::CoordinateTransformation3D(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3, const double& alpha, const double& beta, const double& gamma) 
-{
-   this->setTransformationValues(originX1, originX2, originX3, dx1, dx2, dx3, alpha, beta, gamma);
-}
-/*======================================================*/
-CoordinateTransformation3D::CoordinateTransformation3D(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3) 
-{
-   this->setTransformationValues(originX1, originX2, originX3, dx1, dx2, dx3, 0.0, 0.0, 0.0);
-}
-/*======================================================*/
-CoordinateTransformation3D::CoordinateTransformation3D(CoordinateTransformation3D* transformation)
-{
-   this->setTransformationValues(transformation->Tx1 , transformation->Tx2 , transformation->Tx3 , transformation->Sx1 , transformation->Sx2 , transformation->Sx3, transformation->alpha, transformation->beta, transformation->gamma);
-}
-/*======================================================*/
-// void CoordinateTransformation3D::init()
-// {
-//    this->Tx1   = 0.0;      this->Tx2   = 0.0;	this->Tx3   = 0.0;
-//    this->Sx1   = 1.0;      this->Sx2   = 1.0;	this->Sx3   = 1.0;
-//    this->alpha = 0.0;		this->beta = 0.0;		this->gamma = 0.0;
-// 
-//    this->toX1factorX1   = 1.0; this->toX1factorX2   = 0.0; this->toX1factorX3   = 0.0;
-//    this->toX2factorX1   = 0.0; this->toX2factorX2   = 1.0; this->toX2factorX3   = 0.0;
-//    this->toX3factorX1   = 0.0; this->toX3factorX2   = 0.0; this->toX3factorX3   = 1.0;
-//    this->toX1delta      = 0.0; this->toX2delta      = 0.0; this->toX3delta      = 0.0;
-//    this->fromX1factorX1 = 1.0; this->fromX1factorX2 = 0.0; this->fromX1factorX3 = 0.0;
-//    this->fromX2factorX1 = 0.0; this->fromX2factorX2 = 1.0; this->fromX2factorX3 = 0.0;
-//    this->fromX3factorX1 = 0.0; this->fromX3factorX2 = 0.0; this->fromX3factorX3 = 1.0;
-//    
-//    this->active         = false;
-//    this->transformation = false;
-// }
-/*======================================================*/
-
-/**====  Set transformation values
-@param a     transformed coordinate system x0 (in global coordinates)
-@param b     transformed coordinate system y0 (in global coordinates)
-@param c     transformed coordinate system z0 (in global coordinates)
-@param dx1    x coordinate scaling       (dx_transformed/dx_global)
-@param dx2    y coordinate scaling       (dy_transformed/dy_global)
-@param dx3    z coordinate scaling       (dz_transformed/dz_global)
-@param alpha rotation around z angle    (positive FROM global TO transformed coordinate system)
-@param beta  rotation around y angle            
-@param gamma rotation around x angle            
-@exception IllegalArgumentException if one of the scale values is between -1.0E-8 and 1.0E-8
-**/
-
-void CoordinateTransformation3D::setTransformationValues(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3, const double& alpha, const double& beta, const double& gamma)
-{
-   if(UbMath::zero(dx1) || UbMath::zero(dx2) || UbMath::zero(dx3))
-      throw UbException(UB_EXARGS,"error: at least one delta==0.0");
-   
-   this->Tx1   = originX1; this->Tx2  = originX2; this->Tx3   = originX3;
-   this->Sx1   = dx1;	   this->Sx2  = dx2;	     this->Sx3   = dx3;
-   this->alpha = alpha;	   this->beta = beta;     this->gamma = gamma;
-
-   double ra   = UbMath::PI*alpha/180.0;
-   double cosA = cos(ra);
-   double sinA = sin(ra);
-   double rb   = UbMath::PI*beta/180.0;
-   double cosB = cos(rb);
-   double sinB = sin(rb);
-   double rg   = UbMath::PI*gamma/180.0;
-   double cosG = cos(rg);
-   double sinG = sin(rg);
-
-   //Matrix-Werte von T_invers  (indizes: 12 = spalte 1 zeile 2)
-   double divisor = (Sx1*Sx2*Sx3);
-   
-   this->toX1factorX1 = +cosB*cosA*Sx2*Sx3/divisor;
-   this->toX1factorX2 = -cosB*sinA*Sx1*Sx3/divisor;
-   this->toX1factorX3 = +sinB*Sx1*Sx2/divisor;
-   this->toX1delta    = (-Tx3*Sx1*Sx2*sinB       
-                         +Tx2*Sx1*Sx3*sinA*cosB  
-                         -Tx1*Sx2*Sx3*cosB*cosA)/divisor;
-   
-   this->toX2factorX1 = Sx2*Sx3*(sinG*sinB*cosA+cosG*sinA)/divisor;
-   this->toX2factorX2 = Sx1*Sx3*(-sinG*sinB*sinA+cosG*cosA)/divisor;
-   this->toX2factorX3 = -Sx1*Sx2*cosB*sinG/divisor;
-   this->toX2delta    = (-Tx2*Sx1*Sx3*cosG*cosA
-                         +Tx3*Sx1*Sx2*sinG*cosB
-                         +Tx2*Sx1*Sx3*sinG*sinA*sinB
-                         -Tx1*Sx2*Sx3*cosG*sinA
-                         -Tx1*Sx2*Sx3*sinB*sinG*cosA   )/divisor;
-   
-
-   this->toX3factorX1 = Sx2*Sx3*(-cosG*sinB*cosA+sinG*sinA)/divisor;
-   this->toX3factorX2 = Sx1*Sx3*(sinB*cosG*sinA+sinG*cosA)/divisor;
-   this->toX3factorX3 = Sx1*Sx2*cosB*cosG/divisor;
-   this->toX3delta    = (-Tx2*Sx1*Sx3*sinG*cosA
-                         -Tx3*Sx1*Sx2*cosG*cosB
-                         -Tx2*Sx1*Sx3*cosG*sinA*sinB
-                         -Tx1*Sx2*Sx3*sinG*sinA
-                         +Tx1*Sx2*Sx3*sinB*cosG*cosA  )/divisor;
-                        
-   //Matrix-Werte von T_invers  (indizes: 12 = spalte 1 zeile 2)
-   this->fromX1factorX1 =  cosB*cosA*Sx1;
-   this->fromX1factorX2 =  (sinG*sinB*cosA+cosG*sinA)*Sx1;
-   this->fromX1factorX3 =  (-cosG*sinB*cosA+sinG*sinA)*Sx1;
-   this->fromX1delta    =  Tx1;
-
-   this->fromX2factorX1 =  -cosB*sinA*Sx2;
-   this->fromX2factorX2 =  -(sinG*sinB*sinA-cosG*cosA)*Sx2;
-   this->fromX2factorX3 =  (cosG*sinB*sinA+sinG*cosA)*Sx2;
-   this->fromX2delta    =  Tx2;
-   
-   this->fromX3factorX1 =  sinB*Sx3;
-   this->fromX3factorX2 =  -sinG*cosB*Sx3;
-   this->fromX3factorX3 =  cosG*cosB*Sx3;
-   this->fromX3delta    =  Tx3;
-
-   this->active         =  true;
-   
-   this->transformation =  true;
-}
-/*======================================================*/
-/**
-Set transformation active state (if this IS a transformation)
-@param active true to be active, false otherwise
-**/
-void CoordinateTransformation3D::setActive(const bool& active)
-{
-   if(this->active == active) return;
-   if(this->transformation)   this->active = active;
-}
-/*======================================================*/
-/**
-Transform FROM global coordinates TO transformed coordinates.
-@param x1  the global x coordinate
-@param x2  the global y coordinate
-@param x3  the global z coordinate
-**/
-double CoordinateTransformation3D::transformForwardToX1Coordinate(const double& x1, const double& x2, const double& x3) const
-{
-   if(this->active) return this->toX1factorX1*x1 + this->toX1factorX2*x2 + this->toX1factorX3*x3 + this->toX1delta;
-   else             return x1;
-}
-/*======================================================*/
-double CoordinateTransformation3D::transformForwardToX2Coordinate(const double& x1, const double& x2, const double& x3) const
-{
-   if(this->active) return this->toX2factorX1*x1 + this->toX2factorX2*x2 + this->toX2factorX3*x3 + this->toX2delta;
-   else             return x2;
-}
-/*======================================================*/
-double CoordinateTransformation3D::transformForwardToX3Coordinate(const double& x1, const double& x2, const double& x3) const
-{
-   if(this->active) return this->toX3factorX1*x1 + this->toX3factorX2*x2 + this->toX3factorX3*x3 + this->toX3delta;
-   else             return x3;
-}
-/*======================================================*/
-/**
-Transform FROM global coordinates TO transformed coordinates (ignoring rotation).
-@param x1  the global x coordinate
-**/
-double CoordinateTransformation3D::transformForwardToX1CoordinateIgnoringRotation(const double& x1) const
-{
-   if(this->active) return (x1-this->Tx1)/this->Sx1;
-   else             return x1;
-}
-/*======================================================*/
-double CoordinateTransformation3D::transformForwardToX2CoordinateIgnoringRotation(const double& x2) const
-{
-   if(this->active) return (x2-this->Tx2)/this->Sx2;
-   else             return x2;
-}
-/*======================================================*/
-double CoordinateTransformation3D::transformForwardToX3CoordinateIgnoringRotation(const double& x3) const
-{
-   if(this->active) return (x3-this->Tx3)/this->Sx3;
-   else             return x3;
-}
-/*======================================================*/
-/**
-Transform FROM transformed coordinates TO global coordinates.
-@param x1  the transformed x coordinate
-@param x2  the transformed y coordinate
-@param x3  the transformed z coordinate
-**/
-double CoordinateTransformation3D::transformBackwardToX1Coordinate(const double& x1, const double& x2, const double& x3) const
-{
-   if(this->active) return this->fromX1factorX1*x1 + this->fromX1factorX2*x2 + this->fromX1factorX3*x3 + this->fromX1delta;
-   else             return x1;
-}
-/*======================================================*/
-double CoordinateTransformation3D::transformBackwardToX2Coordinate(const double& x1, const double& x2, const double& x3) const
-{
-   if(this->active) return this->fromX2factorX1*x1 + this->fromX2factorX2*x2 + this->fromX2factorX3*x3 + this->fromX2delta;
-   else             return x2;
-}
-/*======================================================*/
-double CoordinateTransformation3D::transformBackwardToX3Coordinate(const double& x1, const double& x2, const double& x3) const
-{
-   if(this->active) return this->fromX3factorX1*x1 + this->fromX3factorX2*x2 + this->fromX3factorX3*x3 + this->fromX3delta;
-   else             return x3;
-}
-/*======================================================*/
-/**
-Transform FROM transformed coordinates TO global coordinates (ignoring rotation).
-@param x1  the transformed x coordinate
-**/
-double CoordinateTransformation3D::transformBackwardToX1CoordinateIgnoringRotation(const double& x1) const
-{
-   if(this->active) return x1*this->Sx1+this->Tx1;
-   else             return x1;
-}
-/*======================================================*/
-double CoordinateTransformation3D::transformBackwardToX2CoordinateIgnoringRotation(const double& x2) const
-{
-   if(this->active) return x2*this->Sx2+this->Tx2;
-   else             return x2;
-}
-/*======================================================*/
-double CoordinateTransformation3D::transformBackwardToX3CoordinateIgnoringRotation(const double& x3) const
-{
-   if(this->active) return x3*this->Sx3+this->Tx3;
-   else             return x3;
-}
-/*======================================================*/
-/**
-Returns a string representation of this transformation.
-@return a string representation of this transformation
-**/
-string CoordinateTransformation3D::toString() const
-{
-   stringstream ss;
-    ss<<" CoordinateTransformation3D\n";
-//    ss<<"[isTransformation="<<this->transformation;
-//    ss<<", isActive="<<this->active<<endl;
-    ss<<" ,a="<<this->Tx1<<", b="<<this->Tx2<<", c="<<this->Tx3<<endl;
-    ss<<" , dx1="<<this->Sx1<<", dx2="<<this->Sx2<<", dx2="<<this->Sx3<<endl;
-//    ss<<" , alpha="<<this->alpha<<", beta="<<this->beta<endl;
-//    ss<<"]";
-//    ss<<"[to11="<<this->to11<<", to12="<<this->to12<<", to13="<<this->to13;
-//    ss<<", to21="<<this->to21<<", to22="<<this->to22<<", to23="<<this->to23;
-//    ss<<", to31="<<this->to31<<", to32="<<this->to32<<", to33="<<this->to33;
-//    ss<<", toA="<<this->toA<<", toB="<<this->toB<<", toC="<<this->toC;
-//    ss<<", from11="<<this->from11<<", from12="<<this->from12<<", from13="<<this->from13;
-//    ss<<", from21="<<this->from21<<", from22="<<this->from22<<", from23="<<this->from23;
-//    ss<<", from31="<<this->from31<<", from32="<<this->from32<<", from33="<<this->from33;
-//    ss<<", fromA="<<this->fromA; ss<<", fromB="<<this->fromB; ss<<", fromC="<<this->fromC;
-//    ss<<"]}";
-   return ss.str();
-}
-                                     
+#include <numerics/geometry3d/CoordinateTransformation3D.h>
+#include <basics/utilities/UbMath.h>
+
+using namespace std;
+
+CoordinateTransformation3D::CoordinateTransformation3D()
+{
+   this->setTransformationValues(0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0);
+}
+/*======================================================*/
+CoordinateTransformation3D::CoordinateTransformation3D(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3, const double& alpha, const double& beta, const double& gamma) 
+{
+   this->setTransformationValues(originX1, originX2, originX3, dx1, dx2, dx3, alpha, beta, gamma);
+}
+/*======================================================*/
+CoordinateTransformation3D::CoordinateTransformation3D(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3) 
+{
+   this->setTransformationValues(originX1, originX2, originX3, dx1, dx2, dx3, 0.0, 0.0, 0.0);
+}
+/*======================================================*/
+CoordinateTransformation3D::CoordinateTransformation3D(CoordinateTransformation3D* transformation)
+{
+   this->setTransformationValues(transformation->Tx1 , transformation->Tx2 , transformation->Tx3 , transformation->Sx1 , transformation->Sx2 , transformation->Sx3, transformation->alpha, transformation->beta, transformation->gamma);
+}
+/*======================================================*/
+// void CoordinateTransformation3D::init()
+// {
+//    this->Tx1   = 0.0;      this->Tx2   = 0.0;	this->Tx3   = 0.0;
+//    this->Sx1   = 1.0;      this->Sx2   = 1.0;	this->Sx3   = 1.0;
+//    this->alpha = 0.0;		this->beta = 0.0;		this->gamma = 0.0;
+// 
+//    this->toX1factorX1   = 1.0; this->toX1factorX2   = 0.0; this->toX1factorX3   = 0.0;
+//    this->toX2factorX1   = 0.0; this->toX2factorX2   = 1.0; this->toX2factorX3   = 0.0;
+//    this->toX3factorX1   = 0.0; this->toX3factorX2   = 0.0; this->toX3factorX3   = 1.0;
+//    this->toX1delta      = 0.0; this->toX2delta      = 0.0; this->toX3delta      = 0.0;
+//    this->fromX1factorX1 = 1.0; this->fromX1factorX2 = 0.0; this->fromX1factorX3 = 0.0;
+//    this->fromX2factorX1 = 0.0; this->fromX2factorX2 = 1.0; this->fromX2factorX3 = 0.0;
+//    this->fromX3factorX1 = 0.0; this->fromX3factorX2 = 0.0; this->fromX3factorX3 = 1.0;
+//    
+//    this->active         = false;
+//    this->transformation = false;
+// }
+/*======================================================*/
+
+/**====  Set transformation values
+@param a     transformed coordinate system x0 (in global coordinates)
+@param b     transformed coordinate system y0 (in global coordinates)
+@param c     transformed coordinate system z0 (in global coordinates)
+@param dx1    x coordinate scaling       (dx_transformed/dx_global)
+@param dx2    y coordinate scaling       (dy_transformed/dy_global)
+@param dx3    z coordinate scaling       (dz_transformed/dz_global)
+@param alpha rotation around z angle    (positive FROM global TO transformed coordinate system)
+@param beta  rotation around y angle            
+@param gamma rotation around x angle            
+@exception IllegalArgumentException if one of the scale values is between -1.0E-8 and 1.0E-8
+**/
+
+void CoordinateTransformation3D::setTransformationValues(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3, const double& alpha, const double& beta, const double& gamma)
+{
+   if(UbMath::zero(dx1) || UbMath::zero(dx2) || UbMath::zero(dx3))
+      throw UbException(UB_EXARGS,"error: at least one delta==0.0");
+   
+   this->Tx1   = originX1; this->Tx2  = originX2; this->Tx3   = originX3;
+   this->Sx1   = dx1;	   this->Sx2  = dx2;	     this->Sx3   = dx3;
+   this->alpha = alpha;	   this->beta = beta;     this->gamma = gamma;
+
+   double ra   = UbMath::PI*alpha/180.0;
+   double cosA = cos(ra);
+   double sinA = sin(ra);
+   double rb   = UbMath::PI*beta/180.0;
+   double cosB = cos(rb);
+   double sinB = sin(rb);
+   double rg   = UbMath::PI*gamma/180.0;
+   double cosG = cos(rg);
+   double sinG = sin(rg);
+
+   //Matrix-Werte von T_invers  (indizes: 12 = spalte 1 zeile 2)
+   double divisor = (Sx1*Sx2*Sx3);
+   
+   this->toX1factorX1 = +cosB*cosA*Sx2*Sx3/divisor;
+   this->toX1factorX2 = -cosB*sinA*Sx1*Sx3/divisor;
+   this->toX1factorX3 = +sinB*Sx1*Sx2/divisor;
+   this->toX1delta    = (-Tx3*Sx1*Sx2*sinB       
+                         +Tx2*Sx1*Sx3*sinA*cosB  
+                         -Tx1*Sx2*Sx3*cosB*cosA)/divisor;
+   
+   this->toX2factorX1 = Sx2*Sx3*(sinG*sinB*cosA+cosG*sinA)/divisor;
+   this->toX2factorX2 = Sx1*Sx3*(-sinG*sinB*sinA+cosG*cosA)/divisor;
+   this->toX2factorX3 = -Sx1*Sx2*cosB*sinG/divisor;
+   this->toX2delta    = (-Tx2*Sx1*Sx3*cosG*cosA
+                         +Tx3*Sx1*Sx2*sinG*cosB
+                         +Tx2*Sx1*Sx3*sinG*sinA*sinB
+                         -Tx1*Sx2*Sx3*cosG*sinA
+                         -Tx1*Sx2*Sx3*sinB*sinG*cosA   )/divisor;
+   
+
+   this->toX3factorX1 = Sx2*Sx3*(-cosG*sinB*cosA+sinG*sinA)/divisor;
+   this->toX3factorX2 = Sx1*Sx3*(sinB*cosG*sinA+sinG*cosA)/divisor;
+   this->toX3factorX3 = Sx1*Sx2*cosB*cosG/divisor;
+   this->toX3delta    = (-Tx2*Sx1*Sx3*sinG*cosA
+                         -Tx3*Sx1*Sx2*cosG*cosB
+                         -Tx2*Sx1*Sx3*cosG*sinA*sinB
+                         -Tx1*Sx2*Sx3*sinG*sinA
+                         +Tx1*Sx2*Sx3*sinB*cosG*cosA  )/divisor;
+                        
+   //Matrix-Werte von T_invers  (indizes: 12 = spalte 1 zeile 2)
+   this->fromX1factorX1 =  cosB*cosA*Sx1;
+   this->fromX1factorX2 =  (sinG*sinB*cosA+cosG*sinA)*Sx1;
+   this->fromX1factorX3 =  (-cosG*sinB*cosA+sinG*sinA)*Sx1;
+   this->fromX1delta    =  Tx1;
+
+   this->fromX2factorX1 =  -cosB*sinA*Sx2;
+   this->fromX2factorX2 =  -(sinG*sinB*sinA-cosG*cosA)*Sx2;
+   this->fromX2factorX3 =  (cosG*sinB*sinA+sinG*cosA)*Sx2;
+   this->fromX2delta    =  Tx2;
+   
+   this->fromX3factorX1 =  sinB*Sx3;
+   this->fromX3factorX2 =  -sinG*cosB*Sx3;
+   this->fromX3factorX3 =  cosG*cosB*Sx3;
+   this->fromX3delta    =  Tx3;
+
+   this->active         =  true;
+   
+   this->transformation =  true;
+}
+/*======================================================*/
+/**
+Set transformation active state (if this IS a transformation)
+@param active true to be active, false otherwise
+**/
+void CoordinateTransformation3D::setActive(const bool& active)
+{
+   if(this->active == active) return;
+   if(this->transformation)   this->active = active;
+}
+/*======================================================*/
+/**
+Transform FROM global coordinates TO transformed coordinates.
+@param x1  the global x coordinate
+@param x2  the global y coordinate
+@param x3  the global z coordinate
+**/
+double CoordinateTransformation3D::transformForwardToX1Coordinate(const double& x1, const double& x2, const double& x3) const
+{
+   if(this->active) return this->toX1factorX1*x1 + this->toX1factorX2*x2 + this->toX1factorX3*x3 + this->toX1delta;
+   else             return x1;
+}
+/*======================================================*/
+double CoordinateTransformation3D::transformForwardToX2Coordinate(const double& x1, const double& x2, const double& x3) const
+{
+   if(this->active) return this->toX2factorX1*x1 + this->toX2factorX2*x2 + this->toX2factorX3*x3 + this->toX2delta;
+   else             return x2;
+}
+/*======================================================*/
+double CoordinateTransformation3D::transformForwardToX3Coordinate(const double& x1, const double& x2, const double& x3) const
+{
+   if(this->active) return this->toX3factorX1*x1 + this->toX3factorX2*x2 + this->toX3factorX3*x3 + this->toX3delta;
+   else             return x3;
+}
+/*======================================================*/
+/**
+Transform FROM global coordinates TO transformed coordinates (ignoring rotation).
+@param x1  the global x coordinate
+**/
+double CoordinateTransformation3D::transformForwardToX1CoordinateIgnoringRotation(const double& x1) const
+{
+   if(this->active) return (x1-this->Tx1)/this->Sx1;
+   else             return x1;
+}
+/*======================================================*/
+double CoordinateTransformation3D::transformForwardToX2CoordinateIgnoringRotation(const double& x2) const
+{
+   if(this->active) return (x2-this->Tx2)/this->Sx2;
+   else             return x2;
+}
+/*======================================================*/
+double CoordinateTransformation3D::transformForwardToX3CoordinateIgnoringRotation(const double& x3) const
+{
+   if(this->active) return (x3-this->Tx3)/this->Sx3;
+   else             return x3;
+}
+/*======================================================*/
+/**
+Transform FROM transformed coordinates TO global coordinates.
+@param x1  the transformed x coordinate
+@param x2  the transformed y coordinate
+@param x3  the transformed z coordinate
+**/
+double CoordinateTransformation3D::transformBackwardToX1Coordinate(const double& x1, const double& x2, const double& x3) const
+{
+   if(this->active) return this->fromX1factorX1*x1 + this->fromX1factorX2*x2 + this->fromX1factorX3*x3 + this->fromX1delta;
+   else             return x1;
+}
+/*======================================================*/
+double CoordinateTransformation3D::transformBackwardToX2Coordinate(const double& x1, const double& x2, const double& x3) const
+{
+   if(this->active) return this->fromX2factorX1*x1 + this->fromX2factorX2*x2 + this->fromX2factorX3*x3 + this->fromX2delta;
+   else             return x2;
+}
+/*======================================================*/
+double CoordinateTransformation3D::transformBackwardToX3Coordinate(const double& x1, const double& x2, const double& x3) const
+{
+   if(this->active) return this->fromX3factorX1*x1 + this->fromX3factorX2*x2 + this->fromX3factorX3*x3 + this->fromX3delta;
+   else             return x3;
+}
+/*======================================================*/
+/**
+Transform FROM transformed coordinates TO global coordinates (ignoring rotation).
+@param x1  the transformed x coordinate
+**/
+double CoordinateTransformation3D::transformBackwardToX1CoordinateIgnoringRotation(const double& x1) const
+{
+   if(this->active) return x1*this->Sx1+this->Tx1;
+   else             return x1;
+}
+/*======================================================*/
+double CoordinateTransformation3D::transformBackwardToX2CoordinateIgnoringRotation(const double& x2) const
+{
+   if(this->active) return x2*this->Sx2+this->Tx2;
+   else             return x2;
+}
+/*======================================================*/
+double CoordinateTransformation3D::transformBackwardToX3CoordinateIgnoringRotation(const double& x3) const
+{
+   if(this->active) return x3*this->Sx3+this->Tx3;
+   else             return x3;
+}
+/*======================================================*/
+/**
+Returns a string representation of this transformation.
+@return a string representation of this transformation
+**/
+string CoordinateTransformation3D::toString() const
+{
+   stringstream ss;
+    ss<<" CoordinateTransformation3D\n";
+//    ss<<"[isTransformation="<<this->transformation;
+//    ss<<", isActive="<<this->active<<endl;
+    ss<<" ,a="<<this->Tx1<<", b="<<this->Tx2<<", c="<<this->Tx3<<endl;
+    ss<<" , dx1="<<this->Sx1<<", dx2="<<this->Sx2<<", dx2="<<this->Sx3<<endl;
+//    ss<<" , alpha="<<this->alpha<<", beta="<<this->beta<endl;
+//    ss<<"]";
+//    ss<<"[to11="<<this->to11<<", to12="<<this->to12<<", to13="<<this->to13;
+//    ss<<", to21="<<this->to21<<", to22="<<this->to22<<", to23="<<this->to23;
+//    ss<<", to31="<<this->to31<<", to32="<<this->to32<<", to33="<<this->to33;
+//    ss<<", toA="<<this->toA<<", toB="<<this->toB<<", toC="<<this->toC;
+//    ss<<", from11="<<this->from11<<", from12="<<this->from12<<", from13="<<this->from13;
+//    ss<<", from21="<<this->from21<<", from22="<<this->from22<<", from23="<<this->from23;
+//    ss<<", from31="<<this->from31<<", from32="<<this->from32<<", from33="<<this->from33;
+//    ss<<", fromA="<<this->fromA; ss<<", fromB="<<this->fromB; ss<<", fromC="<<this->fromC;
+//    ss<<"]}";
+   return ss.str();
+}
+                                     
diff --git a/source/ThirdParty/Library/numerics/geometry3d/CoordinateTransformation3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/CoordinateTransformation3D.h
similarity index 100%
rename from source/ThirdParty/Library/numerics/geometry3d/CoordinateTransformation3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/CoordinateTransformation3D.h
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbCuboid3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbCuboid3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbCuboid3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbCuboid3D.cpp
index eae8f331512e53ec99aefd73bc55d9dadbc9aed3..44b437549d04c48ab5297cacb4876e633633797f 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbCuboid3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbCuboid3D.cpp
@@ -1,633 +1,633 @@
-#include <numerics/geometry3d/GbCuboid3D.h>
-#include <numerics/geometry3d/creator/GbCuboid3DCreator.h>
-
-#include <basics/utilities/UbMath.h>
-
-#include <numerics/geometry3d/GbSystem3D.h>
-#include <numerics/geometry3d/GbTriangle3D.h>
-
-using namespace std;
-
-/*=======================================================*/
-ObObjectCreator* GbCuboid3D::getCreator()
-{
-   return GbCuboid3DCreator::getInstance();
-}
-/*=======================================================*/
-// Konstruktor
-GbCuboid3D::GbCuboid3D() : GbObject3D()
-{
-   this->setName("cuboid");
-   this->p1 = new GbPoint3D(0.0, 0.0, 0.0);
-   this->p2 = new GbPoint3D(0.0, 0.0, 0.0);
-   this->p1->addObserver(this);
-   this->p2->addObserver(this);
-}
-/*=======================================================*/
-GbCuboid3D::GbCuboid3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b):GbObject3D()
-{
-   this->setName("cuboid");
-   this->p1 = new GbPoint3D(x1a, x2a, x3a);
-   this->p1->addObserver(this);
-	this->p2 = new GbPoint3D(x1b, x2b, x3b);     
-   this->p2->addObserver(this);
-}
-/*=======================================================*/
-GbCuboid3D::GbCuboid3D(GbPoint3D* p1, GbPoint3D* p2) : GbObject3D()
-{
-   this->setName("cuboid");
-	if(!p1 || !p2) throw UbException(UB_EXARGS,"one point ==NULL");
-   this->p1 = p1;
-   this->p1->addObserver(this);
-   this->p2 = p2;
-   this->p2->addObserver(this);
-}
-/*=======================================================*/
-GbCuboid3D::GbCuboid3D(GbCuboid3D* cuboid) : GbObject3D()
-{
-   this->setName("cuboid");
-   if(!cuboid->getPoint1() || !cuboid->getPoint2()) throw UbException(UB_EXARGS,"cuboid ==NULL");
-   this->p1 = cuboid->getPoint1()->clone();
-   this->p1->addObserver(this);
-   this->p2 = cuboid->getPoint2()->clone();
-   this->p2->addObserver(this);
-}
-/*=======================================================*/
-// Destruktor
-GbCuboid3D::~GbCuboid3D()
-{
-   //cout<<"~GbCuboid3D()"<<endl;
-   if(this->p1) this->p1->removeObserver(this);
-   if(this->p2) this->p2->removeObserver(this);
-}
-/*=======================================================*/
-void GbCuboid3D::finalize() 
-{ 
-   if(this->p1) 
-   {
-      this->p1->removeObserver(this);
-      this->p1->finalize();
-      delete this->p1; 
-      this->p1=NULL;
-   } 
-   if(this->p2)
-   {
-      this->p2->removeObserver(this);
-      this->p2->finalize();
-      delete this->p2; 
-      this->p2=NULL;
-   }
-}
-/*=======================================================*/
-void GbCuboid3D::setPoint1(GbPoint3D* point1)
-{ 
-   if(this->p1) this->p1->removeObserver(this);
-   this->p1 = point1;  
-   this->p1->addObserver(this);
-
-   this->notifyObserversObjectChanged();
-}
-/*=======================================================*/
-void GbCuboid3D::setPoint2(GbPoint3D* point2)
-{ 
-   if(this->p2) this->p2->removeObserver(this);
-   this->p2 = point2;  
-   this->p2->addObserver(this);
-
-   this->notifyObserversObjectChanged();
-}
-/*=======================================================*/
-void GbCuboid3D::setPoints(GbPoint3D* point1, GbPoint3D* point2)
-{ 
-   if(this->p1) this->p1->removeObserver(this);
-   if(this->p2) this->p2->removeObserver(this);
-
-   this->p1 = point1; 
-   this->p2 = point2;
-
-   this->p1->addObserver(this);
-   this->p2->addObserver(this);
-
-   this->notifyObserversObjectChanged();
-}
-/*=======================================================*/
-void GbCuboid3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) 
-{
-   this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() );
-}
-/*=======================================================*/
-double GbCuboid3D::getX1Centroid()
-{
-   return (0.5*(p1->x1 + p2->x1)); 
-}
-/*=======================================================*/
-double GbCuboid3D::getX1Minimum()   
-{
-	return (this->p1->x1 < this->p2->x1 ? this->p1->x1 : this->p2->x1);
-}
-/*=======================================================*/
-double GbCuboid3D::getX1Maximum()   
-{
-	return (this->p1->x1 > this->p2->x1 ? this->p1->x1 : this->p2->x1);
-}
-/*=======================================================*/
-double GbCuboid3D::getX2Centroid()
-{
-   return (0.5*(p1->x2 + p2->x2)); 
-}
-/*=======================================================*/
-double GbCuboid3D::getX2Minimum()   
-{
-	return (this->p1->x2 < this->p2->x2 ? this->p1->x2 : this->p2->x2);
-}	
-/*=======================================================*/
-double GbCuboid3D::getX2Maximum()   
-{
-	return ( this->p1->x2 > this->p2->x2 ? this->p1->x2 : this->p2->x2);
-}
-/*=======================================================*/
-double GbCuboid3D::getX3Centroid()
-{
-   return (0.5*(p1->x3 + p2->x3)); 
-}
-/*=======================================================*/
-double GbCuboid3D::getX3Minimum()   
-{	
-	return (this->p1->x3 < this->p2->x3 ? this->p1->x3 : this->p2->x3);
-}	
-/*=======================================================*/
-double GbCuboid3D::getX3Maximum()   
-{
-	return (this->p1->x3 > this->p2->x3 ? this->p1->x3 : this->p2->x3);
-}
-/*=======================================================*/
-double GbCuboid3D::getLengthX1() 
-{ 
-   return (this->getX1Maximum() - this->getX1Minimum() ); 
-}
-/*=======================================================*/
-double GbCuboid3D::getLengthX2() 
-{ 
-   return (this->getX2Maximum() - this->getX2Minimum());  
-}
-/*=======================================================*/
-double GbCuboid3D::getLengthX3() 
-{ 
-   return (this->getX3Maximum() - this->getX3Minimum()); 
-}
-/*=======================================================*/
-bool GbCuboid3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
-{
-   //true, wenn 'in Object' oder 'auf Boundary'!
-   if     (UbMath::less(x1p,this->getX1Minimum()))    return false;
-   else if(UbMath::less(x2p,this->getX2Minimum()))    return false;
-   else if(UbMath::less(x3p,this->getX3Minimum()))    return false;
-   else if(UbMath::greater(x1p,this->getX1Maximum())) return false;
-   else if(UbMath::greater(x2p,this->getX2Maximum())) return false;
-   else if(UbMath::greater(x3p,this->getX3Maximum())) return false;
-
-   return true;
-}
-/*=======================================================*/
-bool GbCuboid3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
-{
-   pointIsOnBoundary = false;
-   
-   //true, wenn 'in Object' oder 'auf Boundary'!
-   if     (UbMath::less(x1p,this->getX1Minimum()))    return false;
-	else if(UbMath::less(x2p,this->getX2Minimum()))    return false;
-	else if(UbMath::less(x3p,this->getX3Minimum()))    return false;
-	else if(UbMath::greater(x1p,this->getX1Maximum())) return false;
-	else if(UbMath::greater(x2p,this->getX2Maximum())) return false;
-	else if(UbMath::greater(x3p,this->getX3Maximum())) return false;
-	
-   if     (UbMath::equal(x1p,this->getX1Minimum())) pointIsOnBoundary = true;
-   else if(UbMath::equal(x2p,this->getX2Minimum())) pointIsOnBoundary = true;
-   else if(UbMath::equal(x3p,this->getX3Minimum())) pointIsOnBoundary = true;
-   else if(UbMath::equal(x1p,this->getX1Maximum())) pointIsOnBoundary = true;
-   else if(UbMath::equal(x2p,this->getX2Maximum())) pointIsOnBoundary = true;
-   else if(UbMath::equal(x3p,this->getX3Maximum())) pointIsOnBoundary = true;
-   
-   return true;
-}
-/*=======================================================*/
-bool GbCuboid3D::isCellInsideGbObject3D(const double& x1p1,const double& x2p1,const double& x3p1,const double& x1p2,const double& x2p2,const double& x3p2)
-{
-   if     ( UbMath::less   (x1p1, this->getX1Minimum() ) ) return false;
-   else if( UbMath::less   (x2p1, this->getX2Minimum() ) ) return false;
-   else if( UbMath::less   (x3p1, this->getX3Minimum() ) ) return false;
-   else if( UbMath::greater(x1p2, this->getX1Maximum() ) ) return false;
-   else if( UbMath::greater(x2p2, this->getX2Maximum() ) ) return false;
-   else if( UbMath::greater(x3p2, this->getX3Maximum() ) ) return false;
-
-   return true;
-}
-/*=======================================================*/
-bool GbCuboid3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-//Merksatz: cell oder deren Volumen schneidet oder beinhaltet komplette oder Teile der CuboidUmrandung
-//returns true:
-//  - cell cuts  cuboid3D
-//  - cell boxes cuboid3D
-//returns false:
-//  - cell completely inside cuboid3D ( = cuboid3D boxes cell)
-//  - cell und cuboid3D haben kein gemeinsames Volumen
-{
-   //erstmal die dumm Loesung
-   if(   !this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) 
-      && this->isCellInsideOrCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) )
-   {
-      return true;
-   }
-
-   return false;
-
-   //GbCuboid3D* cube = GbSystem3D::clipRectangle3D(*this->p1, *this->p2, x1a,x2a,x3a,x1b,x2b,x3b);
-   //if(cube) 
-   //{
-   //   cube->finalize();
-   //   delete cube;
-   //   return true;
-   //}
-
-   //return false;
-}
-/*=======================================================*/
-bool GbCuboid3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-//returns true:
-//  - cell completely inside cuboid3D ( = cuboid3D boxes cell)
-//  - cell cuts  cuboid3D
-//  - cell boxes cuboid3D
-//returns false:
-//  - cell und cuboid3D haben kein gemeinsames Volumen
-{
-    //simpler check, da unser GbCuboid3D ein AABB is:
-   //  anfA        midA         endA             anfB    midB    endB
-   //   |            x<-- dxA -->|                 |<-dxB->x       |
-   //                |<----------------- T --------------->|
-   //ist |T| <= dxA + dxB -> overlap!
-
-   if(     UbMath::lessEqual(  std::fabs( this->getX1Centroid() - 0.5*(x1b+x1a)      /*Tx1*/      )
-                             , 0.5*( this->getLengthX1()        + std::fabs(x1b-x1a) /*dx1A+dx1B*/) )
-
-        && UbMath::lessEqual(  std::fabs( this->getX2Centroid() - 0.5*(x2b+x2a)      /*Tx2*/      )
-                             , 0.5*( this->getLengthX2()        + std::fabs(x2b-x2a) /*dx2A+dx2B*/) )
-
-        && UbMath::lessEqual(  std::fabs( this->getX3Centroid() - 0.5*(x3b+x3a)      /*Tx3*/      )
-                             , 0.5*( this->getLengthX3()        + std::fabs(x3b-x3a) /*dx3A+dx3B*/) ) )
-    {
-       return true;
-    }
-
-    return false;
-
-    // if(   this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)
-   //    || this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) return true;
-   //
-   //return false;
-}
-/*=======================================================*/
-vector<GbTriangle3D*> GbCuboid3D::getSurfaceTriangleSet()
-{
-   vector<GbTriangle3D*> triangles;
-   GbPoint3D p1(getX1Minimum(),getX2Minimum(),getX3Minimum());
-   GbPoint3D p2(getX1Maximum(),getX2Minimum(),getX3Minimum());
-   GbPoint3D p3(getX1Maximum(),getX2Maximum(),getX3Minimum());
-   GbPoint3D p4(getX1Minimum(),getX2Maximum(),getX3Minimum());
-   GbPoint3D p5(getX1Minimum(),getX2Minimum(),getX3Maximum());
-   GbPoint3D p6(getX1Maximum(),getX2Minimum(),getX3Maximum());
-   GbPoint3D p7(getX1Maximum(),getX2Maximum(),getX3Maximum());
-   GbPoint3D p8(getX1Minimum(),getX2Maximum(),getX3Maximum());
-
-   GbPoint3D pUnten(getX1Centroid(),getX2Centroid(),getX3Minimum());
-   GbPoint3D pOben(getX1Centroid(),getX2Centroid(),getX3Maximum());
-   GbPoint3D pLinks(getX1Minimum(), getX2Centroid(),getX3Centroid());
-   GbPoint3D pRechts(getX1Maximum(), getX2Centroid(),getX3Centroid());
-   GbPoint3D pVorne(getX1Centroid(),getX2Minimum(),getX3Centroid());
-   GbPoint3D pHinten(getX1Centroid(),getX2Maximum(),getX3Centroid());
-
-   //"unten"
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(pUnten),new GbPoint3D(p3)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(p1),new GbPoint3D(pUnten)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p3),new GbPoint3D(pUnten),new GbPoint3D(p4)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p4),new GbPoint3D(pUnten)));
-   //"oben"
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p5),new GbPoint3D(p6),new GbPoint3D(pOben)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p6),new GbPoint3D(p7),new GbPoint3D(pOben)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p5),new GbPoint3D(pOben),new GbPoint3D(p8)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(pOben),new GbPoint3D(p7),new GbPoint3D(p8)));
-   //"links"
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p4),new GbPoint3D(p1),new GbPoint3D(pLinks)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p4),new GbPoint3D(pLinks),new GbPoint3D(p8)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p8),new GbPoint3D(pLinks),new GbPoint3D(p5)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(pLinks),new GbPoint3D(p1),new GbPoint3D(p5)));
-   //"rechts"                                                               
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(p3),new GbPoint3D(pRechts)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(pRechts),new GbPoint3D(p3),new GbPoint3D(p7)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(pRechts),new GbPoint3D(p6)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(pRechts),new GbPoint3D(p7),new GbPoint3D(p6)));
-   //"hinten"                                                                       
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p3),new GbPoint3D(p4),new GbPoint3D(pHinten)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p3),new GbPoint3D(pHinten),new GbPoint3D(p7)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p7),new GbPoint3D(pHinten),new GbPoint3D(p8)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(pHinten),new GbPoint3D(p4),new GbPoint3D(p8)));
-   //"vorne"                                                                        
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p2),new GbPoint3D(pVorne)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(pVorne),new GbPoint3D(p2),new GbPoint3D(p6)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(pVorne),new GbPoint3D(p5)));
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(pVorne),new GbPoint3D(p6),new GbPoint3D(p5)));
-   return triangles;
-}
-/*=======================================================*/
-void GbCuboid3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles)
-{
-   /*0*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Minimum(),(float)getX3Minimum()));
-   /*1*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Minimum(),(float)getX3Minimum()));
-   /*2*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Maximum(),(float)getX3Minimum()));
-   /*3*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Maximum(),(float)getX3Minimum()));
-   
-   /*4*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Minimum(),(float)getX3Maximum()));
-   /*5*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Minimum(),(float)getX3Maximum()));
-   /*6*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Maximum(),(float)getX3Maximum()));
-   /*7*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Maximum(),(float)getX3Maximum()));
-
-   //"unten"
-   triangles.push_back( makeUbTuple( 0, 1, 2) );
-   triangles.push_back( makeUbTuple( 0, 2, 3) );
-   //"oben"
-   triangles.push_back( makeUbTuple( 4, 5, 6) );
-   triangles.push_back( makeUbTuple( 4, 6, 7) );
-   //"links"
-   triangles.push_back( makeUbTuple( 0, 3, 7) );
-   triangles.push_back( makeUbTuple( 0, 7, 4) );
-   //"rechts"                                                               
-   triangles.push_back( makeUbTuple( 1, 2, 6) );
-   triangles.push_back( makeUbTuple( 1, 6, 5) );
-   //"hinten"                                                                       
-   triangles.push_back( makeUbTuple( 3, 2, 7) );  
-   triangles.push_back( makeUbTuple( 2, 7, 6) );
-   //"vorne"                                                                        
-   triangles.push_back( makeUbTuple( 0, 1, 5) );
-   triangles.push_back( makeUbTuple( 0, 5, 4) );
-}
-/*=======================================================*/
-string GbCuboid3D::toString() 
-{
-   stringstream ss;
-   ss<<"GbCuboid3D[";
-   ss<<"p1="<<this->p1->toString();
-   ss<<", p2="<<this->p2->toString();
-   ss<<"]";
-   return ss.str();
-}
-/*=======================================================*/
-GbPoint3D* GbCuboid3D::calculateInterSectionPoint3D(GbPoint3D& point1, GbPoint3D& point2)
-{
-   throw UbException(UB_EXARGS,"not correct implemented");
-}
-/*=======================================================*/
-GbLine3D* GbCuboid3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
-{
-   return GbSystem3D::createClipLine3D(point1, point2,
-                                       p1->getX1Coordinate(),p1->getX2Coordinate(),p1->getX3Coordinate(),
-                                       p2->getX1Coordinate(),p2->getX2Coordinate(),p2->getX3Coordinate() );
-}
-/*==========================================================*/
-void GbCuboid3D::objectChanged(UbObservable* changedObject)
-{
-   GbPoint3D* point = dynamic_cast<GbPoint3D*>(changedObject);
-   if(!point || (this->p1!=point && this->p2!=point)) return;
-
-   this->notifyObserversObjectChanged();
-}
-/*==========================================================*/
-void GbCuboid3D::objectWillBeDeleted(UbObservable* objectForDeletion)
-{
-   if(this->p1)
-   {
-      UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p1);
-      if(objectForDeletion == observedObj) { this->p1 = NULL; }
-   }
-   if(this->p2)
-   {
-      UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p2);
-      if(objectForDeletion == observedObj) { this->p2 = NULL; }
-   }
-   //ACHTUNG: eigentlich muessten in allen methoden von GbLine if abfragen fuer NULL pointer hin... toDo
-}
-/*=======================================================*/
-void GbCuboid3D::write(UbFileOutput* out) 
-{                                      
-   out->writeString(this->getCreator()->getTypeID());
-   p1->write(out);
-   p2->write(out);
-}
-/*=======================================================*/
-void GbCuboid3D::read(UbFileInput* in) 
-{  
-   in->readString();                                    
-   this->p1 = new GbPoint3D;
-   p1->read(in);
-   in->readString();                                    
-   this->p2 = new GbPoint3D;
-   p2->read(in);
-}
-/*=======================================================*/
-void GbCuboid3D::translate(const double& tx1, const double& tx2, const double& tx3)
-{  
-   this->p1->translate(tx1, tx2, tx3);
-   this->p2->translate(tx1, tx2, tx3);
-   this->notifyObserversObjectChanged();
-}
-/*=======================================================*/
-void GbCuboid3D::scale(const double& sx1, const double& sx2, const double& sx3)
-{  
-   double lenX1 = this->getLengthX1();
-   double lenX2 = this->getLengthX2();
-   double lenX3 = this->getLengthX3();
-
-   double deltaX1 = lenX1*sx1 - lenX1;
-   double deltaX2 = lenX2*sx2 - lenX2;
-   double deltaX3 = lenX3*sx3 - lenX3;
-
-   double p1X1 = this->p1->getX1Coordinate();
-   double p1X2 = this->p1->getX2Coordinate();
-   double p1X3 = this->p1->getX3Coordinate();
-
-   double p2X1 = this->p2->getX1Coordinate();
-   double p2X2 = this->p2->getX2Coordinate();
-   double p2X3 = this->p2->getX3Coordinate();
-
-   this->p1->setCoordinates(p1X1 - 0.5*deltaX1
-                           ,p1X2 - 0.5*deltaX2
-                           ,p1X3 - 0.5*deltaX3);
-
-   this->p2->setCoordinates(p2X1 + 0.5*deltaX1
-                           ,p2X2 + 0.5*deltaX2
-                           ,p2X3 + 0.5*deltaX3);
-}
-/*==========================================================*/
-double GbCuboid3D::getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-{
-   if( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) )       return 1.0*(x1b-x1a)*(x2b-x2a)*(x3b-x3a);
-   if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) )   return 0.0;
-
-   GbCuboid3D* cube = GbSystem3D::clipRectangle3D(*this->p1, *this->p2, x1a,x2a,x3a,x1b,x2b,x3b);
-
-   if(cube) 
-   {
-      double eps;
-      eps  = (cube->getLengthX1())*(cube->getLengthX2())*(cube->getLengthX3());
-      cube->finalize();
-      delete cube;
-      return eps;
-   }
-   return 0.0;
-}
-/*==========================================================*/
-double GbCuboid3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
-{
-   double minB[3]   = { this->getX1Minimum(), this->getX2Minimum(), this->getX3Minimum() };
-   double maxB[3]   = { this->getX1Maximum(), this->getX2Maximum(), this->getX3Maximum() };
-   double origin[3] = { x1,  x2,  x3  }; //point
-   double dir[3]    = { rx1, rx2, rx3 }; //ray 
-
-   bool inside = true;
-   char quadrant[3];
-   int  whichPlane;
-   double maxT[3];
-   double candidatePlane[3];
-
-   /* Find candidate planes; this loop can be avoided if
-   rays cast all from the eye(assume perpsective view) */
-   for(int i=0; i<3; i++)
-   {
-      if(origin[i] < minB[i])
-      {
-         quadrant[i] = 1/*LEFT*/;
-         candidatePlane[i] = minB[i];
-         inside = false;
-      }
-      else if(origin[i] > maxB[i]) 
-      {
-         quadrant[i] = 0/*RIGHT*/;
-         candidatePlane[i] = maxB[i];
-         inside = false;
-      }
-      else	
-      {
-         quadrant[i] = 2/*MIDDLE*/;
-      }
-   }
-   /* Ray origin inside bounding box */
-   if(inside)
-   {
-      //throw UbException(UB_EXARGS,"not done");
-      return 0.0;
-   }
-
-   /* Calculate T distances to candidate planes */
-   for(int i=0; i<3; i++)
-   {
-      if( quadrant[i]!=2/*MIDDLE*/ && fabs(dir[i])>1.E-10 )
-      {
-         maxT[i] = (candidatePlane[i]-origin[i])/dir[i];
-      }
-      else maxT[i] = -1.0;
-   }
-
-   /* Get largest of the maxT's for final choice of intersection */
-   whichPlane = 0;
-   for(int i=1; i<3; i++)
-      if (maxT[whichPlane] < maxT[i])
-            whichPlane = i;
-   
-   /* Check final candidate actually inside box */
-   if(maxT[whichPlane]< -1.E-10) return -1.0;
-   double dummy;
-   for(int i= 0; i<3; i++)
-   {
-      if( whichPlane!= i) 
-      {
-         dummy = origin[i] + maxT[whichPlane]*dir[i];
-         if(dummy < minB[i] || dummy > maxB[i])
-            return -1.0;
-      } 
-   }
-
-   return maxT[whichPlane] ;				/* ray hits box */
-}	
-// /*==========================================================*/
-// double GbCuboid3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
-// {
-//     double absX,absMaxX,absY,absMaxY,absZ,absMaxZ;
-//  
-//     if(rx1<0.0)     absX    = this->getX1Maximum() - x1;
-//     else            absX    = this->getX1Minimum() - x1;
-//     if(1-(rx1<0.0)) absMaxX = this->getX1Maximum() - x1;
-//     else            absMaxX = this->getX1Minimum() - x1;
-//  
-//     if(rx2<0.0)     absY    = this->getX2Maximum() - x2;
-//     else            absY    = this->getX2Minimum() - x2;
-//     if(1-(rx2<0.0)) absMaxY = this->getX2Maximum() - x2;
-//     else            absMaxY = this->getX2Minimum() - x2;
-//  
-//     if(rx3<0.0)     absZ    = this->getX3Maximum() - x3;
-//     else            absZ    = this->getX3Minimum() - x3;
-//     if(1-(rx3<0.0)) absMaxZ = this->getX3Maximum() - x3;
-//     else            absMaxZ = this->getX3Minimum() - x3;
-//  
-//     
-//     //tmin ist die verschneidung des Gerade (Ray) durch die naehere Gerade (MinX oder MaxX)
-//     //tmax ist die verschneidung des Gerade (Ray) durch die weiteste Gerade (MinX oder MaxX)
-//     //analog fuer tymin und tymax 
-//     double tmin, tymin, tzmin, tmax, tymax, tzmax;
-// 
-//     if(!UbMath::zero(rx1)) tmin  = tmax  = 1.0/rx1;     
-//     else if(rx1<0.0)       tmin  = tmax  = -UbMath::getPositiveInfinity<double>();
-//     else                   tmin  = tmax  = UbMath::getPositiveInfinity<double>();
-// 
-//     if(!UbMath::zero(rx2)) tymin = tymax = 1.0/rx2;     
-//     else if(rx2<0.0)       tymin = tymax = -UbMath::getPositiveInfinity<double>();
-//     else                   tymin = tymax = UbMath::getPositiveInfinity<double>();
-// 
-//     if(!UbMath::zero(rx3)) tzmin = tzmax = 1.0/rx3;     
-//     else if(rx1<0.0)       tzmin = tzmax = -UbMath::getPositiveInfinity<double>();
-//     else                   tzmin = tzmax = UbMath::getPositiveInfinity<double>();
-// 
-//     //tmin  *= absX;
-//     //tmax  *= absMaxX;
-//     //tymin *= absY;
-//     //tymax *= absMaxY;
-//     //tzmin *= absZ;
-//     //tzmax *= absMaxZ;
-//  
-//     //0 * 1/0  vermeiden, da es ein Undefined wert produziert 
-//     if( !UbMath::zero(absX) || !UbMath::zero(rx1) ) tmin *= absX;
-//     else                                            tmin  = tymin;
-// 
-//     if( !UbMath::zero(absY) || !UbMath::zero(rx2))    tymin *= absY;
-//     else                                              tymin  = tmin;
-//     
-//     if( !UbMath::zero(absZ) || !UbMath::zero(rx3))    tzmin *= absZ;
-//     else                                              tzmin  = tymin;
-//  
-//     if( !UbMath::zero(absMaxX) || !UbMath::zero(rx1)) tmax *= absMaxX;
-//     else                                              tmax  = tymax;
-//     
-//     if( !UbMath::zero(absMaxY) || !UbMath::zero(rx2)) tymax *= absMaxY;
-//     else                                              tymax  = tmax;
-//     
-//     if( !UbMath::zero(absMaxZ) || !UbMath::zero(rx3)) tzmax *= absMaxZ;
-//     else                                              tzmax = tymax;
-//  
-//     //in dieser Fall gibt es keine Verschneidung
-//     if( (tmin > tymax) || (tymin > tmax) ) return -1;
-// 
-//     tmin = UbMath::max3(tmin,tymin,tzmin);
-//     tmax = UbMath::min3(tmax,tymax,tzmax);
-//  
-//     if( (tmin > tzmax) || (tzmin > tmax) ) return -1;
-//     if(tmin >= 0.0) return tmin ;
-//  
-//     return tmax;
-//}
+#include <numerics/geometry3d/GbCuboid3D.h>
+#include <numerics/geometry3d/creator/GbCuboid3DCreator.h>
+
+#include <basics/utilities/UbMath.h>
+
+#include <numerics/geometry3d/GbSystem3D.h>
+#include <numerics/geometry3d/GbTriangle3D.h>
+
+using namespace std;
+
+/*=======================================================*/
+ObObjectCreator* GbCuboid3D::getCreator()
+{
+   return GbCuboid3DCreator::getInstance();
+}
+/*=======================================================*/
+// Konstruktor
+GbCuboid3D::GbCuboid3D() : GbObject3D()
+{
+   this->setName("cuboid");
+   this->p1 = new GbPoint3D(0.0, 0.0, 0.0);
+   this->p2 = new GbPoint3D(0.0, 0.0, 0.0);
+   this->p1->addObserver(this);
+   this->p2->addObserver(this);
+}
+/*=======================================================*/
+GbCuboid3D::GbCuboid3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b):GbObject3D()
+{
+   this->setName("cuboid");
+   this->p1 = new GbPoint3D(x1a, x2a, x3a);
+   this->p1->addObserver(this);
+	this->p2 = new GbPoint3D(x1b, x2b, x3b);     
+   this->p2->addObserver(this);
+}
+/*=======================================================*/
+GbCuboid3D::GbCuboid3D(GbPoint3D* p1, GbPoint3D* p2) : GbObject3D()
+{
+   this->setName("cuboid");
+	if(!p1 || !p2) throw UbException(UB_EXARGS,"one point ==NULL");
+   this->p1 = p1;
+   this->p1->addObserver(this);
+   this->p2 = p2;
+   this->p2->addObserver(this);
+}
+/*=======================================================*/
+GbCuboid3D::GbCuboid3D(GbCuboid3D* cuboid) : GbObject3D()
+{
+   this->setName("cuboid");
+   if(!cuboid->getPoint1() || !cuboid->getPoint2()) throw UbException(UB_EXARGS,"cuboid ==NULL");
+   this->p1 = cuboid->getPoint1()->clone();
+   this->p1->addObserver(this);
+   this->p2 = cuboid->getPoint2()->clone();
+   this->p2->addObserver(this);
+}
+/*=======================================================*/
+// Destruktor
+GbCuboid3D::~GbCuboid3D()
+{
+   //cout<<"~GbCuboid3D()"<<endl;
+   if(this->p1) this->p1->removeObserver(this);
+   if(this->p2) this->p2->removeObserver(this);
+}
+/*=======================================================*/
+void GbCuboid3D::finalize() 
+{ 
+   if(this->p1) 
+   {
+      this->p1->removeObserver(this);
+      this->p1->finalize();
+      delete this->p1; 
+      this->p1=NULL;
+   } 
+   if(this->p2)
+   {
+      this->p2->removeObserver(this);
+      this->p2->finalize();
+      delete this->p2; 
+      this->p2=NULL;
+   }
+}
+/*=======================================================*/
+void GbCuboid3D::setPoint1(GbPoint3D* point1)
+{ 
+   if(this->p1) this->p1->removeObserver(this);
+   this->p1 = point1;  
+   this->p1->addObserver(this);
+
+   this->notifyObserversObjectChanged();
+}
+/*=======================================================*/
+void GbCuboid3D::setPoint2(GbPoint3D* point2)
+{ 
+   if(this->p2) this->p2->removeObserver(this);
+   this->p2 = point2;  
+   this->p2->addObserver(this);
+
+   this->notifyObserversObjectChanged();
+}
+/*=======================================================*/
+void GbCuboid3D::setPoints(GbPoint3D* point1, GbPoint3D* point2)
+{ 
+   if(this->p1) this->p1->removeObserver(this);
+   if(this->p2) this->p2->removeObserver(this);
+
+   this->p1 = point1; 
+   this->p2 = point2;
+
+   this->p1->addObserver(this);
+   this->p2->addObserver(this);
+
+   this->notifyObserversObjectChanged();
+}
+/*=======================================================*/
+void GbCuboid3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) 
+{
+   this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() );
+}
+/*=======================================================*/
+double GbCuboid3D::getX1Centroid()
+{
+   return (0.5*(p1->x1 + p2->x1)); 
+}
+/*=======================================================*/
+double GbCuboid3D::getX1Minimum()   
+{
+	return (this->p1->x1 < this->p2->x1 ? this->p1->x1 : this->p2->x1);
+}
+/*=======================================================*/
+double GbCuboid3D::getX1Maximum()   
+{
+	return (this->p1->x1 > this->p2->x1 ? this->p1->x1 : this->p2->x1);
+}
+/*=======================================================*/
+double GbCuboid3D::getX2Centroid()
+{
+   return (0.5*(p1->x2 + p2->x2)); 
+}
+/*=======================================================*/
+double GbCuboid3D::getX2Minimum()   
+{
+	return (this->p1->x2 < this->p2->x2 ? this->p1->x2 : this->p2->x2);
+}	
+/*=======================================================*/
+double GbCuboid3D::getX2Maximum()   
+{
+	return ( this->p1->x2 > this->p2->x2 ? this->p1->x2 : this->p2->x2);
+}
+/*=======================================================*/
+double GbCuboid3D::getX3Centroid()
+{
+   return (0.5*(p1->x3 + p2->x3)); 
+}
+/*=======================================================*/
+double GbCuboid3D::getX3Minimum()   
+{	
+	return (this->p1->x3 < this->p2->x3 ? this->p1->x3 : this->p2->x3);
+}	
+/*=======================================================*/
+double GbCuboid3D::getX3Maximum()   
+{
+	return (this->p1->x3 > this->p2->x3 ? this->p1->x3 : this->p2->x3);
+}
+/*=======================================================*/
+double GbCuboid3D::getLengthX1() 
+{ 
+   return (this->getX1Maximum() - this->getX1Minimum() ); 
+}
+/*=======================================================*/
+double GbCuboid3D::getLengthX2() 
+{ 
+   return (this->getX2Maximum() - this->getX2Minimum());  
+}
+/*=======================================================*/
+double GbCuboid3D::getLengthX3() 
+{ 
+   return (this->getX3Maximum() - this->getX3Minimum()); 
+}
+/*=======================================================*/
+bool GbCuboid3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
+{
+   //true, wenn 'in Object' oder 'auf Boundary'!
+   if     (UbMath::less(x1p,this->getX1Minimum()))    return false;
+   else if(UbMath::less(x2p,this->getX2Minimum()))    return false;
+   else if(UbMath::less(x3p,this->getX3Minimum()))    return false;
+   else if(UbMath::greater(x1p,this->getX1Maximum())) return false;
+   else if(UbMath::greater(x2p,this->getX2Maximum())) return false;
+   else if(UbMath::greater(x3p,this->getX3Maximum())) return false;
+
+   return true;
+}
+/*=======================================================*/
+bool GbCuboid3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
+{
+   pointIsOnBoundary = false;
+   
+   //true, wenn 'in Object' oder 'auf Boundary'!
+   if     (UbMath::less(x1p,this->getX1Minimum()))    return false;
+	else if(UbMath::less(x2p,this->getX2Minimum()))    return false;
+	else if(UbMath::less(x3p,this->getX3Minimum()))    return false;
+	else if(UbMath::greater(x1p,this->getX1Maximum())) return false;
+	else if(UbMath::greater(x2p,this->getX2Maximum())) return false;
+	else if(UbMath::greater(x3p,this->getX3Maximum())) return false;
+	
+   if     (UbMath::equal(x1p,this->getX1Minimum())) pointIsOnBoundary = true;
+   else if(UbMath::equal(x2p,this->getX2Minimum())) pointIsOnBoundary = true;
+   else if(UbMath::equal(x3p,this->getX3Minimum())) pointIsOnBoundary = true;
+   else if(UbMath::equal(x1p,this->getX1Maximum())) pointIsOnBoundary = true;
+   else if(UbMath::equal(x2p,this->getX2Maximum())) pointIsOnBoundary = true;
+   else if(UbMath::equal(x3p,this->getX3Maximum())) pointIsOnBoundary = true;
+   
+   return true;
+}
+/*=======================================================*/
+bool GbCuboid3D::isCellInsideGbObject3D(const double& x1p1,const double& x2p1,const double& x3p1,const double& x1p2,const double& x2p2,const double& x3p2)
+{
+   if     ( UbMath::less   (x1p1, this->getX1Minimum() ) ) return false;
+   else if( UbMath::less   (x2p1, this->getX2Minimum() ) ) return false;
+   else if( UbMath::less   (x3p1, this->getX3Minimum() ) ) return false;
+   else if( UbMath::greater(x1p2, this->getX1Maximum() ) ) return false;
+   else if( UbMath::greater(x2p2, this->getX2Maximum() ) ) return false;
+   else if( UbMath::greater(x3p2, this->getX3Maximum() ) ) return false;
+
+   return true;
+}
+/*=======================================================*/
+bool GbCuboid3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+//Merksatz: cell oder deren Volumen schneidet oder beinhaltet komplette oder Teile der CuboidUmrandung
+//returns true:
+//  - cell cuts  cuboid3D
+//  - cell boxes cuboid3D
+//returns false:
+//  - cell completely inside cuboid3D ( = cuboid3D boxes cell)
+//  - cell und cuboid3D haben kein gemeinsames Volumen
+{
+   //erstmal die dumm Loesung
+   if(   !this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) 
+      && this->isCellInsideOrCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) )
+   {
+      return true;
+   }
+
+   return false;
+
+   //GbCuboid3D* cube = GbSystem3D::clipRectangle3D(*this->p1, *this->p2, x1a,x2a,x3a,x1b,x2b,x3b);
+   //if(cube) 
+   //{
+   //   cube->finalize();
+   //   delete cube;
+   //   return true;
+   //}
+
+   //return false;
+}
+/*=======================================================*/
+bool GbCuboid3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+//returns true:
+//  - cell completely inside cuboid3D ( = cuboid3D boxes cell)
+//  - cell cuts  cuboid3D
+//  - cell boxes cuboid3D
+//returns false:
+//  - cell und cuboid3D haben kein gemeinsames Volumen
+{
+    //simpler check, da unser GbCuboid3D ein AABB is:
+   //  anfA        midA         endA             anfB    midB    endB
+   //   |            x<-- dxA -->|                 |<-dxB->x       |
+   //                |<----------------- T --------------->|
+   //ist |T| <= dxA + dxB -> overlap!
+
+   if(     UbMath::lessEqual(  std::fabs( this->getX1Centroid() - 0.5*(x1b+x1a)      /*Tx1*/      )
+                             , 0.5*( this->getLengthX1()        + std::fabs(x1b-x1a) /*dx1A+dx1B*/) )
+
+        && UbMath::lessEqual(  std::fabs( this->getX2Centroid() - 0.5*(x2b+x2a)      /*Tx2*/      )
+                             , 0.5*( this->getLengthX2()        + std::fabs(x2b-x2a) /*dx2A+dx2B*/) )
+
+        && UbMath::lessEqual(  std::fabs( this->getX3Centroid() - 0.5*(x3b+x3a)      /*Tx3*/      )
+                             , 0.5*( this->getLengthX3()        + std::fabs(x3b-x3a) /*dx3A+dx3B*/) ) )
+    {
+       return true;
+    }
+
+    return false;
+
+    // if(   this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)
+   //    || this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) return true;
+   //
+   //return false;
+}
+/*=======================================================*/
+vector<GbTriangle3D*> GbCuboid3D::getSurfaceTriangleSet()
+{
+   vector<GbTriangle3D*> triangles;
+   GbPoint3D p1(getX1Minimum(),getX2Minimum(),getX3Minimum());
+   GbPoint3D p2(getX1Maximum(),getX2Minimum(),getX3Minimum());
+   GbPoint3D p3(getX1Maximum(),getX2Maximum(),getX3Minimum());
+   GbPoint3D p4(getX1Minimum(),getX2Maximum(),getX3Minimum());
+   GbPoint3D p5(getX1Minimum(),getX2Minimum(),getX3Maximum());
+   GbPoint3D p6(getX1Maximum(),getX2Minimum(),getX3Maximum());
+   GbPoint3D p7(getX1Maximum(),getX2Maximum(),getX3Maximum());
+   GbPoint3D p8(getX1Minimum(),getX2Maximum(),getX3Maximum());
+
+   GbPoint3D pUnten(getX1Centroid(),getX2Centroid(),getX3Minimum());
+   GbPoint3D pOben(getX1Centroid(),getX2Centroid(),getX3Maximum());
+   GbPoint3D pLinks(getX1Minimum(), getX2Centroid(),getX3Centroid());
+   GbPoint3D pRechts(getX1Maximum(), getX2Centroid(),getX3Centroid());
+   GbPoint3D pVorne(getX1Centroid(),getX2Minimum(),getX3Centroid());
+   GbPoint3D pHinten(getX1Centroid(),getX2Maximum(),getX3Centroid());
+
+   //"unten"
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(pUnten),new GbPoint3D(p3)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(p1),new GbPoint3D(pUnten)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p3),new GbPoint3D(pUnten),new GbPoint3D(p4)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p4),new GbPoint3D(pUnten)));
+   //"oben"
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p5),new GbPoint3D(p6),new GbPoint3D(pOben)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p6),new GbPoint3D(p7),new GbPoint3D(pOben)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p5),new GbPoint3D(pOben),new GbPoint3D(p8)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(pOben),new GbPoint3D(p7),new GbPoint3D(p8)));
+   //"links"
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p4),new GbPoint3D(p1),new GbPoint3D(pLinks)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p4),new GbPoint3D(pLinks),new GbPoint3D(p8)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p8),new GbPoint3D(pLinks),new GbPoint3D(p5)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(pLinks),new GbPoint3D(p1),new GbPoint3D(p5)));
+   //"rechts"                                                               
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(p3),new GbPoint3D(pRechts)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(pRechts),new GbPoint3D(p3),new GbPoint3D(p7)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p2),new GbPoint3D(pRechts),new GbPoint3D(p6)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(pRechts),new GbPoint3D(p7),new GbPoint3D(p6)));
+   //"hinten"                                                                       
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p3),new GbPoint3D(p4),new GbPoint3D(pHinten)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p3),new GbPoint3D(pHinten),new GbPoint3D(p7)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p7),new GbPoint3D(pHinten),new GbPoint3D(p8)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(pHinten),new GbPoint3D(p4),new GbPoint3D(p8)));
+   //"vorne"                                                                        
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p2),new GbPoint3D(pVorne)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(pVorne),new GbPoint3D(p2),new GbPoint3D(p6)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(pVorne),new GbPoint3D(p5)));
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(pVorne),new GbPoint3D(p6),new GbPoint3D(p5)));
+   return triangles;
+}
+/*=======================================================*/
+void GbCuboid3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles)
+{
+   /*0*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Minimum(),(float)getX3Minimum()));
+   /*1*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Minimum(),(float)getX3Minimum()));
+   /*2*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Maximum(),(float)getX3Minimum()));
+   /*3*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Maximum(),(float)getX3Minimum()));
+   
+   /*4*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Minimum(),(float)getX3Maximum()));
+   /*5*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Minimum(),(float)getX3Maximum()));
+   /*6*/nodes.push_back( makeUbTuple((float)getX1Maximum(),(float)getX2Maximum(),(float)getX3Maximum()));
+   /*7*/nodes.push_back( makeUbTuple((float)getX1Minimum(),(float)getX2Maximum(),(float)getX3Maximum()));
+
+   //"unten"
+   triangles.push_back( makeUbTuple( 0, 1, 2) );
+   triangles.push_back( makeUbTuple( 0, 2, 3) );
+   //"oben"
+   triangles.push_back( makeUbTuple( 4, 5, 6) );
+   triangles.push_back( makeUbTuple( 4, 6, 7) );
+   //"links"
+   triangles.push_back( makeUbTuple( 0, 3, 7) );
+   triangles.push_back( makeUbTuple( 0, 7, 4) );
+   //"rechts"                                                               
+   triangles.push_back( makeUbTuple( 1, 2, 6) );
+   triangles.push_back( makeUbTuple( 1, 6, 5) );
+   //"hinten"                                                                       
+   triangles.push_back( makeUbTuple( 3, 2, 7) );  
+   triangles.push_back( makeUbTuple( 2, 7, 6) );
+   //"vorne"                                                                        
+   triangles.push_back( makeUbTuple( 0, 1, 5) );
+   triangles.push_back( makeUbTuple( 0, 5, 4) );
+}
+/*=======================================================*/
+string GbCuboid3D::toString() 
+{
+   stringstream ss;
+   ss<<"GbCuboid3D[";
+   ss<<"p1="<<this->p1->toString();
+   ss<<", p2="<<this->p2->toString();
+   ss<<"]";
+   return ss.str();
+}
+/*=======================================================*/
+GbPoint3D* GbCuboid3D::calculateInterSectionPoint3D(GbPoint3D& point1, GbPoint3D& point2)
+{
+   throw UbException(UB_EXARGS,"not correct implemented");
+}
+/*=======================================================*/
+GbLine3D* GbCuboid3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
+{
+   return GbSystem3D::createClipLine3D(point1, point2,
+                                       p1->getX1Coordinate(),p1->getX2Coordinate(),p1->getX3Coordinate(),
+                                       p2->getX1Coordinate(),p2->getX2Coordinate(),p2->getX3Coordinate() );
+}
+/*==========================================================*/
+void GbCuboid3D::objectChanged(UbObservable* changedObject)
+{
+   GbPoint3D* point = dynamic_cast<GbPoint3D*>(changedObject);
+   if(!point || (this->p1!=point && this->p2!=point)) return;
+
+   this->notifyObserversObjectChanged();
+}
+/*==========================================================*/
+void GbCuboid3D::objectWillBeDeleted(UbObservable* objectForDeletion)
+{
+   if(this->p1)
+   {
+      UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p1);
+      if(objectForDeletion == observedObj) { this->p1 = NULL; }
+   }
+   if(this->p2)
+   {
+      UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p2);
+      if(objectForDeletion == observedObj) { this->p2 = NULL; }
+   }
+   //ACHTUNG: eigentlich muessten in allen methoden von GbLine if abfragen fuer NULL pointer hin... toDo
+}
+/*=======================================================*/
+void GbCuboid3D::write(UbFileOutput* out) 
+{                                      
+   out->writeString(this->getCreator()->getTypeID());
+   p1->write(out);
+   p2->write(out);
+}
+/*=======================================================*/
+void GbCuboid3D::read(UbFileInput* in) 
+{  
+   in->readString();                                    
+   this->p1 = new GbPoint3D;
+   p1->read(in);
+   in->readString();                                    
+   this->p2 = new GbPoint3D;
+   p2->read(in);
+}
+/*=======================================================*/
+void GbCuboid3D::translate(const double& tx1, const double& tx2, const double& tx3)
+{  
+   this->p1->translate(tx1, tx2, tx3);
+   this->p2->translate(tx1, tx2, tx3);
+   this->notifyObserversObjectChanged();
+}
+/*=======================================================*/
+void GbCuboid3D::scale(const double& sx1, const double& sx2, const double& sx3)
+{  
+   double lenX1 = this->getLengthX1();
+   double lenX2 = this->getLengthX2();
+   double lenX3 = this->getLengthX3();
+
+   double deltaX1 = lenX1*sx1 - lenX1;
+   double deltaX2 = lenX2*sx2 - lenX2;
+   double deltaX3 = lenX3*sx3 - lenX3;
+
+   double p1X1 = this->p1->getX1Coordinate();
+   double p1X2 = this->p1->getX2Coordinate();
+   double p1X3 = this->p1->getX3Coordinate();
+
+   double p2X1 = this->p2->getX1Coordinate();
+   double p2X2 = this->p2->getX2Coordinate();
+   double p2X3 = this->p2->getX3Coordinate();
+
+   this->p1->setCoordinates(p1X1 - 0.5*deltaX1
+                           ,p1X2 - 0.5*deltaX2
+                           ,p1X3 - 0.5*deltaX3);
+
+   this->p2->setCoordinates(p2X1 + 0.5*deltaX1
+                           ,p2X2 + 0.5*deltaX2
+                           ,p2X3 + 0.5*deltaX3);
+}
+/*==========================================================*/
+double GbCuboid3D::getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+{
+   if( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) )       return 1.0*(x1b-x1a)*(x2b-x2a)*(x3b-x3a);
+   if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) )   return 0.0;
+
+   GbCuboid3D* cube = GbSystem3D::clipRectangle3D(*this->p1, *this->p2, x1a,x2a,x3a,x1b,x2b,x3b);
+
+   if(cube) 
+   {
+      double eps;
+      eps  = (cube->getLengthX1())*(cube->getLengthX2())*(cube->getLengthX3());
+      cube->finalize();
+      delete cube;
+      return eps;
+   }
+   return 0.0;
+}
+/*==========================================================*/
+double GbCuboid3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
+{
+   double minB[3]   = { this->getX1Minimum(), this->getX2Minimum(), this->getX3Minimum() };
+   double maxB[3]   = { this->getX1Maximum(), this->getX2Maximum(), this->getX3Maximum() };
+   double origin[3] = { x1,  x2,  x3  }; //point
+   double dir[3]    = { rx1, rx2, rx3 }; //ray 
+
+   bool inside = true;
+   char quadrant[3];
+   int  whichPlane;
+   double maxT[3];
+   double candidatePlane[3];
+
+   /* Find candidate planes; this loop can be avoided if
+   rays cast all from the eye(assume perpsective view) */
+   for(int i=0; i<3; i++)
+   {
+      if(origin[i] < minB[i])
+      {
+         quadrant[i] = 1/*LEFT*/;
+         candidatePlane[i] = minB[i];
+         inside = false;
+      }
+      else if(origin[i] > maxB[i]) 
+      {
+         quadrant[i] = 0/*RIGHT*/;
+         candidatePlane[i] = maxB[i];
+         inside = false;
+      }
+      else	
+      {
+         quadrant[i] = 2/*MIDDLE*/;
+      }
+   }
+   /* Ray origin inside bounding box */
+   if(inside)
+   {
+      //throw UbException(UB_EXARGS,"not done");
+      return 0.0;
+   }
+
+   /* Calculate T distances to candidate planes */
+   for(int i=0; i<3; i++)
+   {
+      if( quadrant[i]!=2/*MIDDLE*/ && fabs(dir[i])>1.E-10 )
+      {
+         maxT[i] = (candidatePlane[i]-origin[i])/dir[i];
+      }
+      else maxT[i] = -1.0;
+   }
+
+   /* Get largest of the maxT's for final choice of intersection */
+   whichPlane = 0;
+   for(int i=1; i<3; i++)
+      if (maxT[whichPlane] < maxT[i])
+            whichPlane = i;
+   
+   /* Check final candidate actually inside box */
+   if(maxT[whichPlane]< -1.E-10) return -1.0;
+   double dummy;
+   for(int i= 0; i<3; i++)
+   {
+      if( whichPlane!= i) 
+      {
+         dummy = origin[i] + maxT[whichPlane]*dir[i];
+         if(dummy < minB[i] || dummy > maxB[i])
+            return -1.0;
+      } 
+   }
+
+   return maxT[whichPlane] ;				/* ray hits box */
+}	
+ /*==========================================================*/
+// double GbCuboid3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
+// {
+//     double absX,absMaxX,absY,absMaxY,absZ,absMaxZ;
+//  
+//     if(rx1<0.0)     absX    = this->getX1Maximum() - x1;
+//     else            absX    = this->getX1Minimum() - x1;
+//     if(1-(rx1<0.0)) absMaxX = this->getX1Maximum() - x1;
+//     else            absMaxX = this->getX1Minimum() - x1;
+//  
+//     if(rx2<0.0)     absY    = this->getX2Maximum() - x2;
+//     else            absY    = this->getX2Minimum() - x2;
+//     if(1-(rx2<0.0)) absMaxY = this->getX2Maximum() - x2;
+//     else            absMaxY = this->getX2Minimum() - x2;
+//  
+//     if(rx3<0.0)     absZ    = this->getX3Maximum() - x3;
+//     else            absZ    = this->getX3Minimum() - x3;
+//     if(1-(rx3<0.0)) absMaxZ = this->getX3Maximum() - x3;
+//     else            absMaxZ = this->getX3Minimum() - x3;
+//  
+//     
+//     //tmin ist die verschneidung des Gerade (Ray) durch die naehere Gerade (MinX oder MaxX)
+//     //tmax ist die verschneidung des Gerade (Ray) durch die weiteste Gerade (MinX oder MaxX)
+//     //analog fuer tymin und tymax 
+//     double tmin, tymin, tzmin, tmax, tymax, tzmax;
+// 
+//     if(!UbMath::zero(rx1)) tmin  = tmax  = 1.0/rx1;     
+//     else if(rx1<0.0)       tmin  = tmax  = -UbMath::getPositiveInfinity<double>();
+//     else                   tmin  = tmax  = UbMath::getPositiveInfinity<double>();
+// 
+//     if(!UbMath::zero(rx2)) tymin = tymax = 1.0/rx2;     
+//     else if(rx2<0.0)       tymin = tymax = -UbMath::getPositiveInfinity<double>();
+//     else                   tymin = tymax = UbMath::getPositiveInfinity<double>();
+// 
+//     if(!UbMath::zero(rx3)) tzmin = tzmax = 1.0/rx3;     
+//     else if(rx1<0.0)       tzmin = tzmax = -UbMath::getPositiveInfinity<double>();
+//     else                   tzmin = tzmax = UbMath::getPositiveInfinity<double>();
+// 
+//     //tmin  *= absX;
+//     //tmax  *= absMaxX;
+//     //tymin *= absY;
+//     //tymax *= absMaxY;
+//     //tzmin *= absZ;
+//     //tzmax *= absMaxZ;
+//  
+//     //0 * 1/0  vermeiden, da es ein Undefined wert produziert 
+//     if( !UbMath::zero(absX) || !UbMath::zero(rx1) ) tmin *= absX;
+//     else                                            tmin  = tymin;
+// 
+//     if( !UbMath::zero(absY) || !UbMath::zero(rx2))    tymin *= absY;
+//     else                                              tymin  = tmin;
+//     
+//     if( !UbMath::zero(absZ) || !UbMath::zero(rx3))    tzmin *= absZ;
+//     else                                              tzmin  = tymin;
+//  
+//     if( !UbMath::zero(absMaxX) || !UbMath::zero(rx1)) tmax *= absMaxX;
+//     else                                              tmax  = tymax;
+//     
+//     if( !UbMath::zero(absMaxY) || !UbMath::zero(rx2)) tymax *= absMaxY;
+//     else                                              tymax  = tmax;
+//     
+//     if( !UbMath::zero(absMaxZ) || !UbMath::zero(rx3)) tzmax *= absMaxZ;
+//     else                                              tzmax = tymax;
+//  
+//     //in dieser Fall gibt es keine Verschneidung
+//     if( (tmin > tymax) || (tymin > tmax) ) return -1;
+// 
+//     tmin = UbMath::max(tmin,tymin,tzmin);
+//     tmax = UbMath::min(tmax,tymax,tzmax);
+//  
+//     if( (tmin > tzmax) || (tzmin > tmax) ) return -1;
+//     if(tmin >= 0.0) return tmin ;
+//  
+//     return tmax;
+//}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbCuboid3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbCuboid3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbCuboid3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbCuboid3D.h
index 4a9a23979199dfb2576f8782429c52e9e5759bd2..fd43768768113b8fbb9933c92f95527c4cd2493a 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbCuboid3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbCuboid3D.h
@@ -1,144 +1,144 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBCUBOID3D_H
-#define GBCUBOID3D_H
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-#include <vector>
-#include <cmath>
-
-#include <numerics/geometry3d/GbPoint3D.h>
-#include <basics/utilities/UbObserver.h>
-#include <basics/utilities/UbMath.h>
-
-class GbLine3D;
-class GbObject3DCreator;
-
-#include <PointerDefinitions.h>
-class GbCuboid3D;
-typedef SPtr<GbCuboid3D> GbCuboid3DPtr;
-
-
-class GbCuboid3D : public GbObject3D, public UbObserver
-{
-public:              
-   GbCuboid3D();
-   GbCuboid3D(const double& minX1,const double& minX2, const double& minX3, const double& maxX1,const double& maxX2, const double& maxX3);
-   GbCuboid3D(GbPoint3D *p1, GbPoint3D *p2);
-   GbCuboid3D(GbCuboid3D *cuboid);
-   ~GbCuboid3D();   
-
-   GbCuboid3D* clone()    { return new GbCuboid3D(this); }
-   void finalize();
-
-   GbPoint3D* getPoint1() { return this->p1; }
-   GbPoint3D* getPoint2() { return this->p2; }
-
-   void setPoint1(GbPoint3D* point1);
-   void setPoint2(GbPoint3D* point2);
-   void setPoints(GbPoint3D* point1, GbPoint3D* point2);
-
-   double getX1Centroid();
-   double getX1Minimum();
-   double getX1Maximum();
-   double getX2Centroid();
-   double getX2Minimum();
-   double getX2Maximum();
-   double getX3Centroid();
-   double getX3Minimum();
-   double getX3Maximum();
-   void setCenterCoordinates(const double& x1, const double& x2, const double& x3);
-
-   void translate(const double& x1, const double& x2, const double& x3);
-   void rotate(const double& rx1, const double& rx2, const double& rx3) {}
-   void scale(const double& sx1, const double& sx2, const double& sx3);
-
-   double getLengthX1();
-   double getLengthX2();
-   double getLengthX3();
-
-   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary);
-   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); 
-   bool isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-
-   GbPoint3D*  calculateInterSectionPoint3D(GbPoint3D& point1, GbPoint3D &point2);
-   //GbCuboid3D* createClippedRectangle3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   GbLine3D*   createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2);
-
-   std::vector<GbTriangle3D*> getSurfaceTriangleSet();
-   void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles);
-
-   bool hasRaytracing() { return true; }
-   /*|r| must be 1! einheitsvector!!*/
-   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
-
-
-   double getDistance(GbPoint3D* p)
-   {
-      return this->getDistance( p->getX1Coordinate(), p->getX2Coordinate(), p->getX3Coordinate() );
-   } 
-   double getDistance(const double& x1p, const double& x2p, const double& x3p)
-   {
-      throw UbException( UB_EXARGS, "not implemented" );
-
-      // falls punkt innerhalt ist: minimalen abstand ausrechnen
-      if( this->isPointInGbObject3D(x1p,x2p,x3p) )
-      {
-         double x1Dist = UbMath::min( std::abs(x1p-this->getX1Minimum()),std::abs(x1p-this->getX1Maximum()) );
-         double x2Dist = UbMath::min( std::abs(x2p-this->getX2Minimum()),std::abs(x2p-this->getX2Maximum()) );
-         double x3Dist = UbMath::min( std::abs(x3p-this->getX3Minimum()),std::abs(x3p-this->getX3Maximum()) );
-
-         return UbMath::min( x1Dist, x2Dist, x3Dist );
-      }
-      else
-      {
-
-      }
-   }
-
-   std::string toString();
-
-   ObObjectCreator* getCreator();
-   void write(UbFileOutput* out);
-   void read(UbFileInput* in);
-
-   //virtuelle Methoden von UbObserver
-   void objectChanged(UbObservable* changedObject);
-   void objectWillBeDeleted(UbObservable* objectForDeletion);
-
-
-   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void SF_SERIALIZE(Archive & ar)
-   {
-      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
-      ar & p1;
-      ar & p2;
-   }
-#endif //CAB_RCF
-
-protected:
-   GbPoint3D* p1;
-   GbPoint3D* p2;
-};
-
-#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
-   UB_AUTO_RUN_NAMED(   SF::registerType<GbCuboid3D>("GbCuboid3D")             , SF_GbCuboid3D     );
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbCuboid3D >()), SF_GbCuboid3D_BD1 );
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbCuboid3D>() ), SF_GbCuboid3D_BD2 );
-#endif //RCF_USE_SF_SERIALIZATION
-
-
-#endif   
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBCUBOID3D_H
+#define GBCUBOID3D_H
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+#include <vector>
+#include <cmath>
+
+#include <numerics/geometry3d/GbPoint3D.h>
+#include <basics/utilities/UbObserver.h>
+#include <basics/utilities/UbMath.h>
+
+class GbLine3D;
+class GbObject3DCreator;
+
+#include <PointerDefinitions.h>
+class GbCuboid3D;
+typedef SPtr<GbCuboid3D> GbCuboid3DPtr;
+
+
+class GbCuboid3D : public GbObject3D, public UbObserver
+{
+public:              
+   GbCuboid3D();
+   GbCuboid3D(const double& minX1,const double& minX2, const double& minX3, const double& maxX1,const double& maxX2, const double& maxX3);
+   GbCuboid3D(GbPoint3D *p1, GbPoint3D *p2);
+   GbCuboid3D(GbCuboid3D *cuboid);
+   ~GbCuboid3D();   
+
+   GbCuboid3D* clone()    { return new GbCuboid3D(this); }
+   void finalize();
+
+   GbPoint3D* getPoint1() { return this->p1; }
+   GbPoint3D* getPoint2() { return this->p2; }
+
+   void setPoint1(GbPoint3D* point1);
+   void setPoint2(GbPoint3D* point2);
+   void setPoints(GbPoint3D* point1, GbPoint3D* point2);
+
+   double getX1Centroid();
+   double getX1Minimum();
+   double getX1Maximum();
+   double getX2Centroid();
+   double getX2Minimum();
+   double getX2Maximum();
+   double getX3Centroid();
+   double getX3Minimum();
+   double getX3Maximum();
+   void setCenterCoordinates(const double& x1, const double& x2, const double& x3);
+
+   void translate(const double& x1, const double& x2, const double& x3);
+   void rotate(const double& rx1, const double& rx2, const double& rx3) {}
+   void scale(const double& sx1, const double& sx2, const double& sx3);
+
+   double getLengthX1();
+   double getLengthX2();
+   double getLengthX3();
+
+   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary);
+   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); 
+   bool isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+
+   GbPoint3D*  calculateInterSectionPoint3D(GbPoint3D& point1, GbPoint3D &point2);
+   //GbCuboid3D* createClippedRectangle3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   GbLine3D*   createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2);
+
+   std::vector<GbTriangle3D*> getSurfaceTriangleSet();
+   void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles);
+
+   bool hasRaytracing() { return true; }
+   /*|r| must be 1! einheitsvector!!*/
+   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
+
+
+   double getDistance(GbPoint3D* p)
+   {
+      return this->getDistance( p->getX1Coordinate(), p->getX2Coordinate(), p->getX3Coordinate() );
+   } 
+   double getDistance(const double& x1p, const double& x2p, const double& x3p)
+   {
+      throw UbException( UB_EXARGS, "not implemented" );
+
+      // falls punkt innerhalt ist: minimalen abstand ausrechnen
+      if( this->isPointInGbObject3D(x1p,x2p,x3p) )
+      {
+         double x1Dist = UbMath::min( std::abs(x1p-this->getX1Minimum()),std::abs(x1p-this->getX1Maximum()) );
+         double x2Dist = UbMath::min( std::abs(x2p-this->getX2Minimum()),std::abs(x2p-this->getX2Maximum()) );
+         double x3Dist = UbMath::min( std::abs(x3p-this->getX3Minimum()),std::abs(x3p-this->getX3Maximum()) );
+
+         return UbMath::min( x1Dist, x2Dist, x3Dist );
+      }
+      else
+      {
+
+      }
+   }
+
+   std::string toString();
+
+   ObObjectCreator* getCreator();
+   void write(UbFileOutput* out);
+   void read(UbFileInput* in);
+
+   //virtuelle Methoden von UbObserver
+   void objectChanged(UbObservable* changedObject);
+   void objectWillBeDeleted(UbObservable* objectForDeletion);
+
+
+   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void SF_SERIALIZE(Archive & ar)
+   {
+      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
+      ar & p1;
+      ar & p2;
+   }
+#endif //CAB_RCF
+
+protected:
+   GbPoint3D* p1;
+   GbPoint3D* p2;
+};
+
+#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
+   UB_AUTO_RUN_NAMED(   SF::registerType<GbCuboid3D>("GbCuboid3D")             , SF_GbCuboid3D     );
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbCuboid3D >()), SF_GbCuboid3D_BD1 );
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbCuboid3D>() ), SF_GbCuboid3D_BD2 );
+#endif //RCF_USE_SF_SERIALIZATION
+
+
+#endif   
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbCylinder3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbCylinder3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbCylinder3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbCylinder3D.cpp
index e439a52966dc20ca95cdc965da9d890ccd8a01e8..1adec348affca3b035a9dea14d2f6856ad6b1d73 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbCylinder3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbCylinder3D.cpp
@@ -1,1262 +1,1262 @@
-#include <numerics/geometry3d/GbCylinder3D.h>
-#include <numerics/geometry3d/GbSystem3D.h>
-#include <numerics/geometry3d/GbPoint3D.h>
-#include <numerics/geometry3d/GbTriangle3D.h>
-#include <basics/utilities/UbInfinity.h>
-
-#include <numerics/geometry3d/creator/GbCylinder3DCreator.h>
-
-using namespace std;
-
-/*=======================================================*/
-ObObjectCreator* GbCylinder3D::getCreator()
-{
-   return GbCylinder3DCreator::getInstance();
-}
-// Konstruktor
-/*==========================================================*/
-GbCylinder3D::GbCylinder3D()
-   : minX1(0.0)   , minX2(0.0)   , minX3(0.0)
-   , maxX1(0.0)   , maxX2(0.0)   , maxX3(0.0)
-   , centerX1(0.0), centerX2(0.0), centerX3(0.0)
-{
-   this->setName("cylinder");
-   GbPoint3D* p1 = new GbPoint3D();
-   GbPoint3D* p2 = new GbPoint3D();
-   mLine = new GbLine3D(p1,p2);
-   this->mLine->addObserver(this);
-   mRad = 0.0;
-   cylinderType = GbCylinder3D::NOTPARALLELTOAXIS;
-   this->mLine->addObserver(this);
-   this->calculateValues();
-}
-/*=======================================================*/
-GbCylinder3D::GbCylinder3D(GbCylinder3D* cylinder)
-   : minX1(0.0)   , minX2(0.0)   , minX3(0.0)
-   , maxX1(0.0)   , maxX2(0.0)   , maxX3(0.0)
-   , centerX1(0.0), centerX2(0.0), centerX3(0.0)
-{
-   this->setName("cylinder");
-   mRad         = cylinder->getRadius();
-   cylinderType = cylinder->cylinderType;
-   mLine        = cylinder->getLine()->clone();
-
-   this->mLine->addObserver(this);
-   this->calculateValues();
-}
-/*==========================================================*/
-GbCylinder3D::GbCylinder3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& rad)
-   : minX1(0.0)   , minX2(0.0)   , minX3(0.0)
-   , maxX1(0.0)   , maxX2(0.0)   , maxX3(0.0)
-   , centerX1(0.0), centerX2(0.0), centerX3(0.0)
-{
-   this->setName("cylinder");
-   mLine = new GbLine3D;
-   //Min/Max, damit gewaehrleistet ist, dass Startpunkt immer der "Achs-Minimale" ist
-   //Anm.: bin nich tsicher ob weiter unten irgendwelche Algos drauf beruhen...
-   //      geht nat nur solange, zylinder achs-parallel, aber das ist erzeit so!!!
-   mLine->setPoints( new GbPoint3D(min(x1a,x1b), min(x2a,x2b), min(x3a,x3b))
-	                 ,new GbPoint3D(max(x1a,x1b), max(x2a,x2b), max(x3a,x3b)));
-   //mLine->setPoints( new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1b, x2b ,x3b ));
-   this->mLine->addObserver(this);
-   mRad = fabs(rad);
-
-   this->calculateValues();
-}
-/*==========================================================*/
-GbCylinder3D::GbCylinder3D(GbPoint3D* p1, GbPoint3D* p2, const double& rad)
-   : minX1(0.0), minX2(0.0), minX3(0.0)
-   , maxX1(0.0), maxX2(0.0), maxX3(0.0)
-   , centerX1(0.0), centerX2(0.0), centerX3(0.0)
-{
-   this->setName("cylinder");
-   mRad = rad;
-
-   mLine = new GbLine3D(p1,p2);
-   this->mLine->addObserver(this);
-   this->calculateValues();
-}
-/*==========================================================*/
-GbCylinder3D::GbCylinder3D(GbLine3D* line, const double& rad)
-   : minX1(0.0), minX2(0.0), minX3(0.0)
-   , maxX1(0.0), maxX2(0.0), maxX3(0.0)
-   , centerX1(0.0), centerX2(0.0), centerX3(0.0)
-{
-   this->setName("cylinder");
-   mRad = rad;
-
-   this->mLine = line;
-   this->mLine->addObserver(this);
-
-   this->calculateValues();
-}
-/*==========================================================*/
-// Destruktor
-GbCylinder3D::~GbCylinder3D()
-{
-   if(mLine) this->mLine->removeObserver(this);
-   mLine = NULL;
-}
-/*=======================================================*/
-void GbCylinder3D::calculateValues()
-{
-   double x1a = mLine->getPoint1()->x1;    double x1b = mLine->getPoint2()->x1;
-   double x2a = mLine->getPoint1()->x2;    double x2b = mLine->getPoint2()->x2;
-   double x3a = mLine->getPoint1()->x3;    double x3b = mLine->getPoint2()->x3;
-
-   if     (x1a!=x1b && x2a==x2b && x3a==x3b)  this->cylinderType = X1PARALLEL;
-   else if(x2a!=x2b && x1a==x1b && x3a==x3b)  this->cylinderType = X2PARALLEL;
-   else if(x3a!=x3b && x1a==x1b && x2a==x2b)  this->cylinderType = X3PARALLEL;
-   // nach dem serialisieren ruft er den Standardkonstruktor auf wo alles 0 ist und bricht sonst hier ab
-   else if(x3a==x3b && x1a==x1b && x2a==x2b)  this->cylinderType = X1PARALLEL; 
-   else                                       this->cylinderType = NOTPARALLELTOAXIS;
-
-   if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS)
-      throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Zylinder erlaubt... isPointInObject3D funzt sonst ned");
-
-   if(this->isParallelToX1Axis())
-   {
-      minX1 = mLine->getX1Minimum();
-      maxX1 = mLine->getX1Maximum();
-      minX2 = mLine->getX2Centroid()-mRad; 
-      maxX2 = mLine->getX2Centroid()+mRad;
-      minX3 = mLine->getX3Centroid()-mRad; 
-      maxX3 = mLine->getX3Centroid()+mRad;
-   }
-   else if(this->isParallelToX2Axis()) 
-   {
-      minX1 = mLine->getX1Centroid()-mRad;
-      maxX1 = mLine->getX1Centroid()+mRad;
-      minX2 = mLine->getX2Minimum();   
-      maxX2 = mLine->getX2Maximum();
-      minX3 = mLine->getX3Centroid()-mRad;
-      maxX3 = mLine->getX3Centroid()+mRad;
-   }
-   else if(this->isParallelToX3Axis()) 
-   {
-      minX1 = mLine->getX1Centroid()-mRad;  
-      maxX1 = mLine->getX1Centroid()+mRad;
-      minX2 = mLine->getX2Centroid()-mRad;
-      maxX2 = mLine->getX2Centroid()+mRad;
-      minX3 = mLine->getX3Minimum();
-      maxX3 = mLine->getX3Maximum();
-   }
-
-   centerX1 = mLine->getX1Centroid();
-   centerX2 = mLine->getX2Centroid();
-   centerX3 = mLine->getX3Centroid();
-}
- 
-/*=======================================================*/
-void GbCylinder3D::finalize()
-{
-   if(this->mLine)
-   {
-      mLine->finalize();
-      delete mLine;
-      mLine=NULL;
-   }
-}
-/*=======================================================*/
-double GbCylinder3D::getHeight()
-{
-   if(mLine) return mLine->getLength(); return 0.0;
-}
-/*=======================================================*/
-GbPoint3D* GbCylinder3D::getPoint1()
-{
-   if(this->mLine) return this->mLine->getPoint1();
-   return NULL;
-}
-/*=======================================================*/
-GbPoint3D* GbCylinder3D::getPoint2()
-{
-   if(this->mLine) return this->mLine->getPoint2();
-   return NULL;
-}
-/*=======================================================*/
-void GbCylinder3D::setRadius(const double& radius)
-{
-   this->mRad = std::fabs(radius);
-   this->notifyObserversObjectChanged();
-}
-/*=======================================================*/
-void GbCylinder3D::setLine(GbLine3D* line)
-{
-   if(this->mLine) this->mLine->removeObserver(this);
-   this->mLine = line;
-   this->mLine->addObserver(this);
-   this->calculateValues();
-
-   this->notifyObserversObjectChanged();
-}
-/*=======================================================*/
-void GbCylinder3D::setPoint1(const double& x1, const double& x2, const double& x3)
-{
-   if(!mLine->getPoint1()) throw UbException(UB_EXARGS,"line has no point1");
-   mLine->getPoint1()->setCoordinates(x1,x2,x3);
-   this->calculateValues();
-
-   //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt...
-}
-/*=======================================================*/
-void GbCylinder3D::setPoint2(const double& x1, const double& x2, const double& x3)
-{
-   if(!mLine->getPoint2()) throw UbException(UB_EXARGS,"line has no point2");
-   mLine->getPoint2()->setCoordinates(x1,x2,x3);
-   this->calculateValues();
-
-   //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt...
-}
-/*==========================================================*/
-bool GbCylinder3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
-{
-   //true, wenn 'in Object' oder 'auf Boundary'!
-   if     ( this->isParallelToX1Axis() && (UbMath::less(x1p,minX1) || UbMath::greater(x1p,maxX1)))  return false;
-   else if( this->isParallelToX2Axis() && (UbMath::less(x2p,minX2) || UbMath::greater(x2p,maxX2)))  return false;
-   else if( this->isParallelToX3Axis() && (UbMath::less(x3p,minX3) || UbMath::greater(x3p,maxX3)))  return false;
-   else if( this->isNotParallelToAxis() ) throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Zylinder erlaubt... isPointInObject3D funzt sonst ned");
-
-   return UbMath::lessEqual(fabs(mLine->getDistance(x1p,x2p,x3p)),fabs(mRad));
-}
-/*==========================================================*/
-bool GbCylinder3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
-{
-   //funzt derzeit nur bei achsparallelen cylindern
-   pointIsOnBoundary = false;
-
-   if     ( this->isParallelToX1Axis() && (UbMath::less(x1p,minX1) || UbMath::greater(x1p,maxX1)))  return false;
-   else if( this->isParallelToX2Axis() && (UbMath::less(x2p,minX2) || UbMath::greater(x2p,maxX2)))  return false;
-   else if( this->isParallelToX3Axis() && (UbMath::less(x3p,minX3) || UbMath::greater(x3p,maxX3)))  return false;
-   else if( this->isNotParallelToAxis() ) throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Zylinder erlaubt... isPointInObject3D funzt sonst ned");
-
-   //true, wenn 'in Object' oder 'auf Boundary'!
-
-   double dis = mLine->getDistance(x1p,x2p,x3p);
-
-   if(UbMath::equal(dis,mRad)) pointIsOnBoundary = true;
- 
-   if     (this->isParallelToX1Axis() && (UbMath::equal(x1p,minX1) || UbMath::equal(x1p,maxX1))) pointIsOnBoundary = true;
-   else if(this->isParallelToX2Axis() && (UbMath::equal(x2p,minX2) || UbMath::equal(x2p,maxX2))) pointIsOnBoundary = true;
-   else if(this->isParallelToX3Axis() && (UbMath::equal(x3p,minX3) || UbMath::equal(x3p,maxX3))) pointIsOnBoundary = true;
-
-   return UbMath::lessEqual(dis,mRad);
-}
-/*==========================================================*/
-string GbCylinder3D::toString()
-{
-	stringstream ss;
-	ss<<"GbCylinder3D[";
-	ss<<"line="<<this->mLine->toString();
-   ss<<", r="<<this->mRad;
-   ss<<"]";
-   return(ss.str());
-}
-/*=======================================================*/
-bool GbCylinder3D::isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-{
-   if(   this->isPointInGbObject3D(x1a, x2a, x3a)
-      && this->isPointInGbObject3D(x1b, x2a, x3a)
-      && this->isPointInGbObject3D(x1b, x2b, x3a)
-      && this->isPointInGbObject3D(x1a, x2b, x3a)
-      && this->isPointInGbObject3D(x1a, x2a, x3b)
-      && this->isPointInGbObject3D(x1b, x2a, x3b)
-      && this->isPointInGbObject3D(x1b, x2b, x3b)
-      && this->isPointInGbObject3D(x1a, x2b, x3b))
-   {
-      return true;
-   }
-   return false;
-}
-/*==========================================================*/
-bool GbCylinder3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-//Merksatz: cell oder deren Volumen schneidet oder beinhaltet komplette oder Teile der CuboidUmrandung
-//returns true:
-//  - cell cuts  cylinder3D
-//  - cell boxes cylinder3D
-//returns false:
-//  - cell completely inside cylinder3D ( = cylinder3D boxes cell)
-//  - cell und cylinder3D haben kein gemeinsames Volumen
-{
-   //erstmal wieder die dumm Loesung
-   if(   this->isCellInsideOrCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)
-      && !this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) )
-   {
-      return true;
-   }
-
-   return false;
-}
-/*==========================================================*/
-bool GbCylinder3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-//returns true:
-//  - cell completely inside cylinder3D ( = cylinder3D boxes cell)
-//  - cell cuts  cylinder3D
-//  - cell boxes cylinder3D
-//returns false:
-//  - cell und cylinder3D haben kein gemeinsames Volumen
-{
-   double dmin   = 0.0;
-
-   if(this->isParallelToX1Axis())
-   {
-      //check liegt Cell komplett !x1-ausserhalb"?
-      if(  UbMath::less   (x1a,minX1) && UbMath::less   (x1b,minX1) ) return false;
-      if(  UbMath::greater(x1a,maxX1) && UbMath::greater(x1b,maxX1) ) return false;
-
-      //mittelpunkt kreis-querschnitt
-      double& midX2 = mLine->getPoint1()->x2;
-      double& midX3 = mLine->getPoint1()->x3;
-      if     ( UbMath::less   ( midX2, x2a ) ) dmin += std::pow( midX2 - x2a, 2.0 ); 
-      else if( UbMath::greater( midX2, x2b ) ) dmin += std::pow( midX2 - x2b, 2.0 );     
-      if     ( UbMath::less   ( midX3, x3a ) ) dmin += std::pow( midX3 - x3a, 2.0 ); 
-      else if( UbMath::greater( midX3, x3b ) ) dmin += std::pow( midX3 - x3b, 2.0 );     
-      if( UbMath::lessEqual( dmin, mRad*mRad) ) return true;
-
-      return false;
-   }
-   else if(this->isParallelToX2Axis())
-   {
-      //check liegt Cell komplett !x2-ausserhalb"?
-      if(  UbMath::less   (x2a,minX2)   && UbMath::less   (x2b,minX2) ) return false;
-      if(  UbMath::greater(x2a,maxX2  ) && UbMath::greater(x2b,maxX2) ) return false;
-
-      //mittelpunkt kreis-querschnitt
-      double& midX1 = mLine->getPoint1()->x1;
-      double& midX3 = mLine->getPoint1()->x3;
-      if     ( UbMath::less   ( midX1, x1a ) ) dmin += std::pow( midX1 - x1a, 2.0 ); 
-      else if( UbMath::greater( midX1, x1b ) ) dmin += std::pow( midX1 - x1b, 2.0 );     
-      if     ( UbMath::less   ( midX3, x3a ) ) dmin += std::pow( midX3 - x3a, 2.0 ); 
-      else if( UbMath::greater( midX3, x3b ) ) dmin += std::pow( midX3 - x3b, 2.0 );     
-      if( UbMath::lessEqual( dmin, mRad*mRad ) ) return true;
-
-   }
-   else if(this->isParallelToX3Axis())
-   {
-      //check liegt Cell komplett !x3-ausserhalb"?
-      if(  UbMath::less   (x3a,minX3) && UbMath::less   (x3b,minX3) ) return false;
-      if(  UbMath::greater(x3a,maxX3) && UbMath::greater(x3b,maxX3) ) return false;
-
-      //mittelpunkt kreis-querschnitt
-      double& midX1 = mLine->getPoint1()->x1;
-      double& midX2 = mLine->getPoint1()->x2;
-      if     ( UbMath::less   ( midX1, x1a ) ) dmin += std::pow( midX1 - x1a, 2.0 ); 
-      else if( UbMath::greater( midX1, x1b ) ) dmin += std::pow( midX1 - x1b, 2.0 );     
-      if     ( UbMath::less   ( midX2, x2a ) ) dmin += std::pow( midX2 - x2a, 2.0 ); 
-      else if( UbMath::greater( midX2, x2b ) ) dmin += std::pow( midX2 - x2b, 2.0 );     
-      if( UbMath::lessEqual( dmin, mRad*mRad ) ) return true;
-   }
-
-   return false;
-}
-/*==========================================================*/
-GbLine3D* GbCylinder3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
-{
-   //liefert immer "innere" linie, also der teil, der vom Zylinder "abgeschnitten" wurde!
-   //funktioniert derzeit nur mit achsenparallelen Zylindern!
-   vector<GbPoint3D*> schnittpunkte;
-
-   double xa,ya,za,xb,yb,zb,xm,ym,zStart,zEnd,t1,t2;
-
-   if(this->isParallelToX1Axis())
-   {
-      xa     = point1.getX2Coordinate();
-      ya     = point1.getX3Coordinate();
-      za     = point1.getX1Coordinate();
-      xb     = point2.getX2Coordinate();
-      yb     = point2.getX3Coordinate();
-      zb     = point2.getX1Coordinate();
-      xm     = mLine->getPoint1()->getX2Coordinate();
-      ym     = mLine->getPoint1()->getX3Coordinate();
-      zStart = mLine->getPoint1()->getX1Coordinate();
-      zEnd   = mLine->getPoint2()->getX1Coordinate();
-   }
-   else if(this->isParallelToX2Axis())
-   {
-      xa     = point1.getX1Coordinate();
-      ya     = point1.getX3Coordinate();
-      za     = point1.getX2Coordinate();
-      xb     = point2.getX1Coordinate();
-      yb     = point2.getX3Coordinate();
-      zb     = point2.getX2Coordinate();
-      xm     = mLine->getPoint1()->getX1Coordinate();
-      ym     = mLine->getPoint1()->getX3Coordinate();
-      zStart = mLine->getPoint1()->getX2Coordinate();
-      zEnd   = mLine->getPoint2()->getX2Coordinate();
-   }
-   else if(this->isParallelToX3Axis())
-   {
-      xa     = point1.getX1Coordinate();
-      ya     = point1.getX2Coordinate();
-      za     = point1.getX3Coordinate();
-      xb     = point2.getX1Coordinate();
-      yb     = point2.getX2Coordinate();
-      zb     = point2.getX3Coordinate();
-      xm     = mLine->getPoint1()->getX1Coordinate();
-      ym     = mLine->getPoint1()->getX2Coordinate();
-      zStart = mLine->getPoint1()->getX3Coordinate();
-      zEnd   = mLine->getPoint2()->getX3Coordinate();
-   }
-   else throw UbException(UB_EXARGS,"funktioniert derzeit nur mit achsenparallelen Zylindern");
-
-   //Bestimmung des Schnittpunktes mit unendlich ausgedehntem Zylinder
-   double r   = mRad;
-   double r2  = r*r;
-   double xa2 = xa*xa;
-   double xb2 = xb*xb;
-   double ya2 = ya*ya;
-   double yb2 = yb*yb;
-   double xm2 = xm*xm;
-   double ym2 = ym*ym;
-
-   double wurzel  = 2.0*xa*xm*yb2+2.0*ya*ym*xb2-2.0*xa*xb*r2+2.0*xa*xb*ym2-2.0*ya*yb*r2+2.0*xa2*yb*ym
-                   +2.0*xa*xm*ya*ym-2.0*xa*xm*yb*ym-2.0*ya*ym*xb*xm+2.0*xb*xm*yb*ym+2.0*ya*yb*xa*xb
-                   -2.0*ya*yb*xa*xm-2.0*ya*yb*xb*xm-2.0*xa*xb*ya*ym-2.0*xa*xb*yb*ym+2.0*xb*xm*ya2
-                   +2.0*ya*yb*xm2-xa2*yb2-xb2*ya2+xa2*r2-xa2*ym2+xb2*r2-xb2*ym2+ya2*r2-ya2*xm2+yb2*r2-yb2*xm2;
-   double nenner  = -2.0*(ya*yb+xa*xb)+xa2+xb2+ya2+yb2;
-   double zaehler =  2.0*(-xa*xm+xb*xm-ya*ym+yb*ym)+xa2-xb2+ya2-yb2;
-
-   if(UbMath::greaterEqual(wurzel,0.0) && !UbMath::zero(nenner) )//fabs(nenner)>1.E-13)
-   {
-      t1 = (zaehler+2.0*sqrt(wurzel))/nenner;
-      t2 = (zaehler-2.0*sqrt(wurzel))/nenner;
-
-      if(UbMath::inClosedInterval(t1, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke
-      {
-         double x = xa*(0.5-0.5*t1)+xb*(0.5+0.5*t1);
-         double y = ya*(0.5-0.5*t1)+yb*(0.5+0.5*t1);
-         double z = za*(0.5-0.5*t1)+zb*(0.5+0.5*t1);
-
-         if(UbMath::inClosedInterval(z,zStart,zEnd)) //zWert muss sich innerhal der cylinderlaenge befinden
-         {
-            if     (this->isParallelToX1Axis()) schnittpunkte.push_back(new GbPoint3D(z,x,y));
-            else if(this->isParallelToX2Axis()) schnittpunkte.push_back(new GbPoint3D(x,z,y));
-            else if(this->isParallelToX3Axis()) schnittpunkte.push_back(new GbPoint3D(x,y,z));
-         }
-      }
-      if(fabs(t2-t1)>1.E-13 && UbMath::inClosedInterval(t2, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke
-      {
-         double x = xa*(0.5-0.5*t2)+xb*(0.5+0.5*t2);
-         double y = ya*(0.5-0.5*t2)+yb*(0.5+0.5*t2);
-         double z = za*(0.5-0.5*t2)+zb*(0.5+0.5*t2);
-
-         if(UbMath::inClosedInterval(z,zStart,zEnd)) //zWert muss sich innerhal der cylinderlaenge befinden
-         {
-            if     (this->isParallelToX1Axis()) schnittpunkte.push_back(new GbPoint3D(z,x,y));
-            else if(this->isParallelToX2Axis()) schnittpunkte.push_back(new GbPoint3D(x,z,y));
-            else if(this->isParallelToX3Axis()) schnittpunkte.push_back(new GbPoint3D(x,y,z));
-         }
-      }
-   }
-   //wenn nenner==0 -> Strecke parallel zu Zylinder! Es muss noch auf Schnittpunkt mit "Deckeln" geprueft werden
-
-   //Schnittpunkt mit Seitenflaechen bestimmen
-   //hierzu wird der schnittpunkt der gegebnen strecke mit den seitenflaechenberechnet
-   //als erstes "schaut man seitlich auf den Zylinder" --> kreisflaechen wird als strecke darsgestellt
-   //mit diesen "strecken" berechnet man Schnittpunkte.
-   //anschliessend wird geprueft, ob der berechnete Schnittpunkt ueberhaupt im kreis liegt
-   //falls ja --> Schnittpunkt vorhanden
-
-   double x1a,y1a,z1a,x1b,y1b,z1b, //uebergebene Strecke
-          x2a,y2a,x2b,y2b,         //erste "Kreisstrecke"
-          x3a,y3a,x3b,y3b,         //zweite "Kreisstrecke"
-          y2m,z2m,y3m,z3m;
-   double nenner1ab;
-
-   if(this->isParallelToX1Axis())
-   {
-      x1a=point1.getX1Coordinate();
-      y1a=point1.getX2Coordinate();
-      z1a=point1.getX3Coordinate();
-      x1b=point2.getX1Coordinate();
-      y1b=point2.getX2Coordinate();
-      z1b=point2.getX3Coordinate();
-
-      x2a=mLine->getPoint1()->getX1Coordinate();
-      y2m=mLine->getPoint1()->getX2Coordinate();
-      z2m=mLine->getPoint1()->getX3Coordinate();
-      y2a=y2m+mRad;
-      x2b=mLine->getPoint1()->getX1Coordinate();
-      y2b=y2m-mRad;
-
-      x3a=mLine->getPoint2()->getX1Coordinate(); //
-      y3m=mLine->getPoint2()->getX2Coordinate();
-      z3m=mLine->getPoint2()->getX3Coordinate();
-      y3a=y3m+mRad;
-      x3b=mLine->getPoint2()->getX1Coordinate();
-      y3b=y3m-mRad;
-   }
-   else if(this->isParallelToX2Axis())
-   {
-      x1a=point1.getX2Coordinate();
-      y1a=point1.getX3Coordinate();
-      z1a=point1.getX1Coordinate();
-      x1b=point2.getX2Coordinate();
-      y1b=point2.getX3Coordinate();
-      z1b=point2.getX1Coordinate();
-
-      x2a=mLine->getPoint1()->getX2Coordinate();
-      y2m=mLine->getPoint1()->getX3Coordinate();
-      z2m=mLine->getPoint1()->getX1Coordinate();
-      y2a=y2m+mRad;
-      x2b=mLine->getPoint1()->getX2Coordinate();
-      y2b=y2m-mRad;
-
-      x3a=mLine->getPoint2()->getX2Coordinate(); //
-      y3m=mLine->getPoint2()->getX3Coordinate();
-      z3m=mLine->getPoint2()->getX1Coordinate();
-      y3a=y3m+mRad;
-      x3b=mLine->getPoint2()->getX2Coordinate();
-      y3b=y3m-mRad;
-   }
-   else if(this->isParallelToX3Axis())
-   {
-      x1a=point1.getX3Coordinate();
-      y1a=point1.getX2Coordinate();
-      z1a=point1.getX1Coordinate();
-      x1b=point2.getX3Coordinate();
-      y1b=point2.getX2Coordinate();
-      z1b=point2.getX1Coordinate();
-
-      x2a=mLine->getPoint1()->getX3Coordinate();
-      y2m=mLine->getPoint1()->getX2Coordinate();
-      z2m=mLine->getPoint1()->getX1Coordinate();
-      y2a=y2m+mRad;
-      x2b=mLine->getPoint1()->getX3Coordinate();
-      y2b=y2m-mRad;
-
-      x3a=mLine->getPoint2()->getX3Coordinate(); //
-      y3m=mLine->getPoint2()->getX2Coordinate();
-      z3m=mLine->getPoint2()->getX1Coordinate();
-      y3a=y3m+mRad;
-      x3b=mLine->getPoint2()->getX3Coordinate();
-      y3b=y3m-mRad;
-   }
-   else throw UbException(UB_EXARGS,"funktioniert derzeit nur mit achsenparallelen Zylindern");
-
-   nenner1ab = -y1a*x2a+y1a*x2b+y1b*x2a-y1b*x2b+x1a*y2a-x1a*y2b-x1b*y2a+x1b*y2b;
-   //double nenner2 = x1a*y2a-x1a*y2b-x1b*y2a+x1b*y2b-y1a*x2a+y1a*x2b+y1b*x2a-y1b*x2b;
-   if(fabs(nenner1ab)>1.E-13) //andernfalls sind die beiden Strecken parallel
-   {
-      //tStrecke ist fuer gegebene Strecke!
-      double t1ab = (-y1a*x2a+y1a*x2b-2.0*y2a*x2b+x1a*y2a-x1a*y2b-x1b*y2b+2.0*y2b*x2a+x1b*y2a-y1b*x2a+y1b*x2b)/nenner1ab;
-      //double tStrecke = -(-x1a*y2a+x1a*y2b+2.0*y2a*x2b+y1a*x2a-2.0*x2a*y2b-y1a*x2b+y1b*x2a-y1b*x2b-x1b*y2a+x1b*y2b)/nenner2;
-      //wenn -1 <= t2 <= +1 -> SP mit strecke
-      if(UbMath::inClosedInterval(t1ab, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke
-      {
-         double x,y,z,abstand_ist;
-         if     (this->isParallelToX1Axis())
-         {
-            x = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab);
-            y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab);
-            z = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab);
-            abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-z)*(z3m-z));
-         }
-         else if(this->isParallelToX2Axis())
-         {
-            y = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab);
-            z = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab);
-            x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab);
-            abstand_ist=sqrt((y3m-z)*(y3m-z)+(z3m-x)*(z3m-x));
-         }
-         else if(this->isParallelToX3Axis())
-         {
-            z = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab);
-            y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab);
-            x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab);
-            abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-x)*(z3m-x));
-         }
-         else throw UbException(UB_EXARGS,"funktioniert derzeit nur mit achsenparallelen Zylindern");
-         
-         //pruefen, ob Punkt Element von Kreisflaeche
-         //double abstand_ist=sqrt((y2m-y)*(y2m-y)+(z2m-z)*(z2m-z));
-         if(UbMath::lessEqual(abstand_ist,mRad))  //Punkt ist Schnittpunkt
-         {
-            bool exists = false;
-            for(int pos=0;pos<(int)schnittpunkte.size();++pos)
-            {
-               if(    fabs(schnittpunkte[pos]->getX1Coordinate()-x)<1.E-13
-                   && fabs(schnittpunkte[pos]->getX2Coordinate()-y)<1.E-13
-                   && fabs(schnittpunkte[pos]->getX3Coordinate()-z)<1.E-13 ) exists=true;
-            }
-
-            if(!exists) schnittpunkte.push_back(new GbPoint3D(x,y,z));
-         }
-      }
-   }
-
-   nenner1ab = -y1a*x3a+y1a*x3b+y1b*x3a-y1b*x3b+x1a*y3a-x1a*y3b-x1b*y3a+x1b*y3b;
-
-   if(fabs(nenner1ab)>1.E-13) //andernfalls sind die beiden Strecken parallel
-   {
-      //tStrecke ist fuer gegebene Strecke!
-      double t1ab = (-y1a*x3a+y1a*x3b-x1b*y3b-2.0*y3a*x3b-x1a*y3b+2.0*y3b*x3a+x1a*y3a+x1b*y3a-y1b*x3a+y1b*x3b)/nenner1ab;
-
-      if(UbMath::inClosedInterval(t1ab, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke
-      {
-         double x,y,z,abstand_ist;
-         if     (this->isParallelToX1Axis())
-         {
-            x = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab);
-            y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab);
-            z = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab);
-            abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-z)*(z3m-z));
-         }
-         else if(this->isParallelToX2Axis())
-         {
-            y = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab);
-            z = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab);
-            x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab);
-            abstand_ist=sqrt((y3m-z)*(y3m-z)+(z3m-x)*(z3m-x));
-         }
-         else if(this->isParallelToX3Axis())
-         {
-            z = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab);
-            y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab);
-            x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab);
-            abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-x)*(z3m-x));
-         }
-         else throw UbException(UB_EXARGS,"cylinder must be parallel to one axis");
-
-         //pruefen, ob Punkt Element von Kreisflaeche
-         //double abstand_ist=sqrt((y2m-y)*(y2m-y)+(z2m-z)*(z2m-z));
-
-         if(UbMath::lessEqual(abstand_ist,mRad))  //Punkt ist Schnittpunkt
-         {
-            bool exists = false;
-            for(int pos=0;pos<(int)schnittpunkte.size();++pos)
-            {
-               if(   fabs(schnittpunkte[pos]->getX1Coordinate()-x)<1.E-13
-                  && fabs(schnittpunkte[pos]->getX2Coordinate()-y)<1.E-13
-                  && fabs(schnittpunkte[pos]->getX3Coordinate()-z)<1.E-13 ) exists=true;
-            }
-
-            if(!exists) schnittpunkte.push_back(new GbPoint3D(x,y,z));
-         }
-      }
-   }
-
-   int nofSchnittpunkte = (int)schnittpunkte.size();
-   if     (nofSchnittpunkte==0) return NULL;
-   else if(nofSchnittpunkte >2) throw UbException(UB_EXARGS,"more than three intersection points - not possible");
-   else if(nofSchnittpunkte==2) return new GbLine3D(schnittpunkte[0],schnittpunkte[1]);
-   else if(nofSchnittpunkte==1)
-   {
-      if     (this->isPointInGbObject3D(&point1)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point1));
-      else if(this->isPointInGbObject3D(&point2)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point2));
-      else  return new GbLine3D(schnittpunkte[0],new GbPoint3D(*(schnittpunkte[0]))); //strecke beruehrt clippedLine reduziert sich auf einen Punkt!!!
-   }
-
-   return NULL;
-}
-/*==========================================================*/
-vector<GbTriangle3D*> GbCylinder3D::getSurfaceTriangleSet()
-{
-   double x1ma,x1mb,x2m,x3m;
-   if( this->isParallelToX1Axis() )
-   {
-      x1ma = this->getX1Minimum();
-      x1mb = this->getX1Maximum();
-      x2m  = this->getX2Centroid();
-      x3m  = this->getX3Centroid();
-   }
-   else if( this->isParallelToX2Axis() )
-   {
-      x1ma = this->getX2Minimum();
-      x1mb = this->getX2Maximum();
-      x2m  = this->getX1Centroid();
-      x3m  = this->getX3Centroid();
-   }
-   else if( this->isParallelToX3Axis() )
-   {
-      x1ma = this->getX3Minimum();
-      x1mb = this->getX3Maximum();
-      x2m  = this->getX2Centroid();
-      x3m  = this->getX1Centroid();
-   }
-   else throw UbException(UB_EXARGS,"cylinder not axis prallel");
-
-   vector<GbTriangle3D*> triangles;
-
-   int segmentsCircle  = 20;
-   double deltaPhi = UbMath::PI/(double)segmentsCircle;
-
-   double phiX1a,phiX1b;
-   double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d;
-
-   double dXCylinder =  fabs((x1mb-x1ma))/(double)segmentsCircle;
-   int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder);
-   for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++)
-   {
-      x1a = x1d = x1ma+segCyl*dXCylinder;
-      x1b = x1c = x1a+dXCylinder;
-
-      for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi)
-      {
-         phiX1b = phiX1a+deltaPhi;
-
-         x2a =  x2m+mRad*std::sin(phiX1a);
-         x3a =  x3m+mRad*std::cos(phiX1a);
-         x2b =  x2m+mRad*std::sin(phiX1b);
-         x3b =  x3m+mRad*std::cos(phiX1b);
-
-         if( this->isParallelToX1Axis() )
-         {
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x1b,x2b,x3b),new GbPoint3D(x1b,x2a,x3a),new GbPoint3D(x1a,x2a,x3a)));
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1a,x2b,x3b),new GbPoint3D(x1b,x2b,x3b)));
-         }
-         else if( this->isParallelToX2Axis() )
-         {
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x2b,x1b,x3b),new GbPoint3D(x2a,x1b,x3a),new GbPoint3D(x2a,x1a,x3a)));
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x2a,x1a,x3a),new GbPoint3D(x2b,x1a,x3b),new GbPoint3D(x2b,x1b,x3b)));
-         }
-         else if( this->isParallelToX3Axis() )
-         {
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x3b,x2b,x1b),new GbPoint3D(x3a,x2a,x1b),new GbPoint3D(x3a,x2a,x1a)));
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x3a,x2a,x1a),new GbPoint3D(x3b,x2b,x1a),new GbPoint3D(x3b,x2b,x1b)));
-         }
-
-      }
-   }
-
-   int segmentsSide = (int)(mRad/dXCylinder);
-   double radius0, radius1;
-   for(int segCyl = 0; segCyl<segmentsSide; segCyl++)
-   {
-      radius0 = segCyl*dXCylinder;
-      radius1 = radius0+dXCylinder;
-      if(segCyl==segmentsSide-1) radius1=mRad;
-
-      for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi)
-      {
-         phiX1b = phiX1a+deltaPhi;
-
-         x2a =  x2m+radius0*std::sin(phiX1a);
-         x3a =  x3m+radius0*std::cos(phiX1a);
-         x2b =  x2m+radius0*std::sin(phiX1b);
-         x3b =  x3m+radius0*std::cos(phiX1b);
-         x2c =  x2m+radius1*std::sin(phiX1b);
-         x3c =  x3m+radius1*std::cos(phiX1b);
-         x2d =  x2m+radius1*std::sin(phiX1a);
-         x3d =  x3m+radius1*std::cos(phiX1a);
-
-         if( this->isParallelToX1Axis() )
-         {
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x1ma,x2a,x3a),new GbPoint3D(x1ma,x2b,x3b),new GbPoint3D(x1ma,x2c,x3c)));
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x1ma,x2c,x3c),new GbPoint3D(x1ma,x2d,x3d),new GbPoint3D(x1ma,x2a,x3a)));
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x1mb,x2c,x3c),new GbPoint3D(x1mb,x2b,x3b),new GbPoint3D(x1mb,x2a,x3a)));
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x1mb,x2a,x3a),new GbPoint3D(x1mb,x2d,x3d),new GbPoint3D(x1mb,x2c,x3c)));
-         }
-         else if( this->isParallelToX2Axis() )
-         {
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x2a,x1ma,x3a),new GbPoint3D(x2b,x1ma,x3b),new GbPoint3D(x2c,x1ma,x3c)));
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x2c,x1ma,x3c),new GbPoint3D(x2d,x1ma,x3d),new GbPoint3D(x2a,x1ma,x3a)));
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x2c,x1mb,x3c),new GbPoint3D(x2b,x1mb,x3b),new GbPoint3D(x2a,x1mb,x3a)));
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x2a,x1mb,x3a),new GbPoint3D(x2d,x1mb,x3d),new GbPoint3D(x2c,x1mb,x3c)));
-         }
-         else if( this->isParallelToX3Axis() )
-         {
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x3a,x2a,x1ma),new GbPoint3D(x3b,x2b,x1ma),new GbPoint3D(x3c,x2c,x1ma)));
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x3c,x2c,x1ma),new GbPoint3D(x3d,x2d,x1ma),new GbPoint3D(x3a,x2a,x1ma)));
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x3c,x2c,x1mb),new GbPoint3D(x3b,x2b,x1mb),new GbPoint3D(x3a,x2a,x1mb)));
-            triangles.push_back(new GbTriangle3D(new GbPoint3D(x3a,x2a,x1mb),new GbPoint3D(x3d,x2d,x1mb),new GbPoint3D(x3c,x2c,x1mb)));
-         }
-      }
-   }
-
-   return triangles;
-}
-/*==========================================================*/
-void GbCylinder3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles)
-{
-   float x1ma,x1mb,x2m,x3m;
-   if( this->isParallelToX1Axis() )
-   {
-      x1ma = (float)this->getX1Minimum();
-      x1mb = (float)this->getX1Maximum();
-      x2m  = (float)this->getX2Centroid();
-      x3m  = (float)this->getX3Centroid();
-   }
-   else if( this->isParallelToX2Axis() )
-   {
-      x1ma = (float)this->getX2Minimum();
-      x1mb = (float)this->getX2Maximum();
-      x2m  = (float)this->getX1Centroid();
-      x3m  = (float)this->getX3Centroid();
-   }
-   else if( this->isParallelToX3Axis() )
-   {
-      x1ma = (float)this->getX3Minimum();
-      x1mb = (float)this->getX3Maximum();
-      x2m  = (float)this->getX2Centroid();
-      x3m  = (float)this->getX1Centroid();
-   }
-   else throw UbException(UB_EXARGS,"cylinder not axis prallel");
-
-   int segmentsCircle  = 20;
-   double deltaPhi = UbMath::PI/(double)segmentsCircle;
-
-   double phiX1a,phiX1b;
-   float x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d;
-
-   double dXCylinder =  fabs((x1mb-x1ma))/(double)segmentsCircle;
-   int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder);
-   int nodenr = 0;
-   for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++)
-   {
-      x1a = x1d = (float)(x1ma+segCyl*dXCylinder);
-      x1b = x1c = (float)(x1a+dXCylinder);
-
-      for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi)
-      {
-         phiX1b = phiX1a+deltaPhi;
-
-         x2a =  (float)(x2m+mRad*std::sin(phiX1a));
-         x3a =  (float)(x3m+mRad*std::cos(phiX1a));
-         x2b =  (float)(x2m+mRad*std::sin(phiX1b));
-         x3b =  (float)(x3m+mRad*std::cos(phiX1b));
-
-         if( this->isParallelToX1Axis() )
-         {
-            nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2a,x3a) );
-            nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2b,x3b) );
-         }
-         else if( this->isParallelToX2Axis() )
-         {
-            nodes.push_back( makeUbTuple(x2b,x1b,x3b) ); nodes.push_back( makeUbTuple(x2a,x1b,x3a) ); nodes.push_back( makeUbTuple(x2a,x1a,x3a) );
-            nodes.push_back( makeUbTuple(x2a,x1a,x3a) ); nodes.push_back( makeUbTuple(x2b,x1a,x3b) ); nodes.push_back( makeUbTuple(x2b,x1b,x3b) );
-         }
-         else if( this->isParallelToX3Axis() )
-         {
-            nodes.push_back( makeUbTuple(x3b,x2b,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1a) );
-            nodes.push_back( makeUbTuple(x3a,x2a,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1b) );
-         }
-         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
-         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
-      }
-   }
-
-   int segmentsSide = (int)(mRad/dXCylinder);
-   double radius0, radius1;
-   for(int segCyl = 0; segCyl<segmentsSide; segCyl++)
-   {
-      radius0 = segCyl*dXCylinder;
-      radius1 = radius0+dXCylinder;
-      if(segCyl==segmentsSide-1) radius1=mRad;
-
-      for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi)
-      {
-         phiX1b = phiX1a+deltaPhi;
-
-         x2a = x2m+(float)(radius0*std::sin(phiX1a));
-         x3a = x3m+(float)(radius0*std::cos(phiX1a));
-         x2b = x2m+(float)(radius0*std::sin(phiX1b));
-         x3b = x3m+(float)(radius0*std::cos(phiX1b));
-         x2c = x2m+(float)(radius1*std::sin(phiX1b));
-         x3c = x3m+(float)(radius1*std::cos(phiX1b));
-         x2d = x2m+(float)(radius1*std::sin(phiX1a));
-         x3d = x3m+(float)(radius1*std::cos(phiX1a));
-
-         if( this->isParallelToX1Axis() )
-         {
-            nodes.push_back( makeUbTuple(x1ma,x2a,x3a) ); nodes.push_back( makeUbTuple(x1ma,x2b,x3b) ); nodes.push_back( makeUbTuple(x1ma,x2c,x3c) );
-            nodes.push_back( makeUbTuple(x1ma,x2c,x3c) ); nodes.push_back( makeUbTuple(x1ma,x2d,x3d) ); nodes.push_back( makeUbTuple(x1ma,x2a,x3a) );
-            nodes.push_back( makeUbTuple(x1mb,x2c,x3c) ); nodes.push_back( makeUbTuple(x1mb,x2b,x3b) ); nodes.push_back( makeUbTuple(x1mb,x2a,x3a) );
-            nodes.push_back( makeUbTuple(x1mb,x2a,x3a) ); nodes.push_back( makeUbTuple(x1mb,x2d,x3d) ); nodes.push_back( makeUbTuple(x1mb,x2c,x3c) );
-         }
-         else if( this->isParallelToX2Axis() )
-         {
-            nodes.push_back( makeUbTuple(x2a,x1ma,x3a) ); nodes.push_back( makeUbTuple(x2b,x1ma,x3b) ); nodes.push_back( makeUbTuple(x2c,x1ma,x3c) );
-            nodes.push_back( makeUbTuple(x2c,x1ma,x3c) ); nodes.push_back( makeUbTuple(x2d,x1ma,x3d) ); nodes.push_back( makeUbTuple(x2a,x1ma,x3a) );
-            nodes.push_back( makeUbTuple(x2c,x1mb,x3c) ); nodes.push_back( makeUbTuple(x2b,x1mb,x3b) ); nodes.push_back( makeUbTuple(x2a,x1mb,x3a) );
-            nodes.push_back( makeUbTuple(x2a,x1mb,x3a) ); nodes.push_back( makeUbTuple(x2d,x1mb,x3d) ); nodes.push_back( makeUbTuple(x2c,x1mb,x3c) );
-         }
-         else if( this->isParallelToX3Axis() )
-         {
-            nodes.push_back( makeUbTuple(x3a,x2a,x1ma) ); nodes.push_back( makeUbTuple(x3b,x2b,x1ma) ); nodes.push_back( makeUbTuple(x3c,x2c,x1ma) );
-            nodes.push_back( makeUbTuple(x3c,x2c,x1ma) ); nodes.push_back( makeUbTuple(x3d,x2d,x1ma) ); nodes.push_back( makeUbTuple(x3a,x2a,x1ma) );
-            nodes.push_back( makeUbTuple(x3c,x2c,x1mb) ); nodes.push_back( makeUbTuple(x3b,x2b,x1mb) ); nodes.push_back( makeUbTuple(x3a,x2a,x1mb) );
-            nodes.push_back( makeUbTuple(x3a,x2a,x1mb) ); nodes.push_back( makeUbTuple(x3d,x2d,x1mb) ); nodes.push_back( makeUbTuple(x3c,x2c,x1mb) );
-         }
-
-         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
-         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
-         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
-         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
-      }
-   }
-}
-/*==========================================================*/
-void GbCylinder3D::addSurfaceTriangleSetSegments(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles, int segmentsRound, int segmentsHeight )
-{
-   float x1ma,x1mb,x2m,x3m;
-   if( this->isParallelToX1Axis() )
-   {
-      x1ma = (float)this->getX1Minimum();
-      x1mb = (float)this->getX1Maximum();
-      x2m  = (float)this->getX2Centroid();
-      x3m  = (float)this->getX3Centroid();
-   }
-   else if( this->isParallelToX2Axis() )
-   {
-      x1ma = (float)this->getX2Minimum();
-      x1mb = (float)this->getX2Maximum();
-      x2m  = (float)this->getX1Centroid();
-      x3m  = (float)this->getX3Centroid();
-   }
-   else if( this->isParallelToX3Axis() )
-   {
-      x1ma = (float)this->getX3Minimum();
-      x1mb = (float)this->getX3Maximum();
-      x2m  = (float)this->getX2Centroid();
-      x3m  = (float)this->getX1Centroid();
-   }
-   else throw UbException(UB_EXARGS,"cylinder not axis prallel");
-
-   int segmentsCircle  = segmentsRound;
-   double deltaPhi = UbMath::PI/(double)segmentsCircle;
-
-   double phiX1a,phiX1b;
-   float x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d;
-
-   double dXCylinder =  fabs((x1mb-x1ma))/(double)segmentsHeight; //hier evtl. segmentsheight
-   int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder);
-   int nodenr = 0;
-   for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++)
-   {
-      x1a = x1d = (float)(x1ma+segCyl*dXCylinder);
-      x1b = x1c = (float)(x1a+dXCylinder);
-
-      //for(phiX1a=2.0*UbMath::PI; phiX1a>0.0; phiX1a-=deltaPhi)
-      for(phiX1a=0.0; phiX1a<2.0*UbMath::PI-0.5*deltaPhi; phiX1a+=deltaPhi)
-      {
-         phiX1b = phiX1a+deltaPhi;
-
-         x2a =  (float)(x2m+mRad*std::sin(phiX1a));
-         x3a =  (float)(x3m+mRad*std::cos(phiX1a));
-         x2b =  (float)(x2m+mRad*std::sin(phiX1b));
-         x3b =  (float)(x3m+mRad*std::cos(phiX1b));
-
-         if( this->isParallelToX1Axis() )
-         {
-            nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2a,x3a) );
-            nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2b,x3b) );
-         }
-         else if( this->isParallelToX2Axis() )
-         {
-            nodes.push_back( makeUbTuple(x2b,x1b,x3b) ); nodes.push_back( makeUbTuple(x2a,x1b,x3a) ); nodes.push_back( makeUbTuple(x2a,x1a,x3a) );
-            nodes.push_back( makeUbTuple(x2a,x1a,x3a) ); nodes.push_back( makeUbTuple(x2b,x1a,x3b) ); nodes.push_back( makeUbTuple(x2b,x1b,x3b) );
-         }
-         else if( this->isParallelToX3Axis() )
-         {
-            nodes.push_back( makeUbTuple(x3b,x2b,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1a) );
-            nodes.push_back( makeUbTuple(x3a,x2a,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1b) );
-         }
-         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
-         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
-      }
-   }
-
-   int segmentsSide = (int)(mRad/dXCylinder);
-   double radius0, radius1;
-   for(int segCyl = 0; segCyl<segmentsSide; segCyl++)
-   {
-      radius0 = segCyl*dXCylinder;
-      radius1 = radius0+dXCylinder;
-      if(segCyl==segmentsSide-1) radius1=mRad;
-
-      //for(phiX1a=2.0*UbMath::PI; phiX1a>0.0; phiX1a-=deltaPhi)
-      for(phiX1a=0.0; phiX1a<2.0*UbMath::PI-0.5*deltaPhi; phiX1a+=deltaPhi)
-      {
-         phiX1b = phiX1a+deltaPhi;
-
-         x2a = x2m+(float)(radius0*std::sin(phiX1a));
-         x3a = x3m+(float)(radius0*std::cos(phiX1a));
-         x2b = x2m+(float)(radius0*std::sin(phiX1b));
-         x3b = x3m+(float)(radius0*std::cos(phiX1b));
-         x2c = x2m+(float)(radius1*std::sin(phiX1b));
-         x3c = x3m+(float)(radius1*std::cos(phiX1b));
-         x2d = x2m+(float)(radius1*std::sin(phiX1a));
-         x3d = x3m+(float)(radius1*std::cos(phiX1a));
-
-         if( this->isParallelToX1Axis() )
-         {
-            nodes.push_back( makeUbTuple(x1ma,x2a,x3a) ); nodes.push_back( makeUbTuple(x1ma,x2b,x3b) ); nodes.push_back( makeUbTuple(x1ma,x2c,x3c) );
-            nodes.push_back( makeUbTuple(x1ma,x2c,x3c) ); nodes.push_back( makeUbTuple(x1ma,x2d,x3d) ); nodes.push_back( makeUbTuple(x1ma,x2a,x3a) );
-            nodes.push_back( makeUbTuple(x1mb,x2c,x3c) ); nodes.push_back( makeUbTuple(x1mb,x2b,x3b) ); nodes.push_back( makeUbTuple(x1mb,x2a,x3a) );
-            nodes.push_back( makeUbTuple(x1mb,x2a,x3a) ); nodes.push_back( makeUbTuple(x1mb,x2d,x3d) ); nodes.push_back( makeUbTuple(x1mb,x2c,x3c) );
-         }
-         else if( this->isParallelToX2Axis() )
-         {
-            nodes.push_back( makeUbTuple(x2a,x1ma,x3a) ); nodes.push_back( makeUbTuple(x2b,x1ma,x3b) ); nodes.push_back( makeUbTuple(x2c,x1ma,x3c) );
-            nodes.push_back( makeUbTuple(x2c,x1ma,x3c) ); nodes.push_back( makeUbTuple(x2d,x1ma,x3d) ); nodes.push_back( makeUbTuple(x2a,x1ma,x3a) );
-            nodes.push_back( makeUbTuple(x2c,x1mb,x3c) ); nodes.push_back( makeUbTuple(x2b,x1mb,x3b) ); nodes.push_back( makeUbTuple(x2a,x1mb,x3a) );
-            nodes.push_back( makeUbTuple(x2a,x1mb,x3a) ); nodes.push_back( makeUbTuple(x2d,x1mb,x3d) ); nodes.push_back( makeUbTuple(x2c,x1mb,x3c) );
-         }
-         else if( this->isParallelToX3Axis() )
-         {
-            nodes.push_back( makeUbTuple(x3a,x2a,x1ma) ); nodes.push_back( makeUbTuple(x3b,x2b,x1ma) ); nodes.push_back( makeUbTuple(x3c,x2c,x1ma) );
-            nodes.push_back( makeUbTuple(x3c,x2c,x1ma) ); nodes.push_back( makeUbTuple(x3d,x2d,x1ma) ); nodes.push_back( makeUbTuple(x3a,x2a,x1ma) );
-            nodes.push_back( makeUbTuple(x3c,x2c,x1mb) ); nodes.push_back( makeUbTuple(x3b,x2b,x1mb) ); nodes.push_back( makeUbTuple(x3a,x2a,x1mb) );
-            nodes.push_back( makeUbTuple(x3a,x2a,x1mb) ); nodes.push_back( makeUbTuple(x3d,x2d,x1mb) ); nodes.push_back( makeUbTuple(x3c,x2c,x1mb) );
-         }
-
-         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
-         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
-         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
-         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
-      }
-   }
-}
-
-/*==========================================================*/
-void GbCylinder3D::objectChanged(UbObservable* changedObject)
-{
-   GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject);
-   if(!line || this->mLine!=line) return;
-
-   this->notifyObserversObjectChanged();
-}
-/*==========================================================*/
-void GbCylinder3D::objectWillBeDeleted(UbObservable* objectForDeletion)
-{
-   if(this->mLine)
-   {
-      UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine);
-      if(objectForDeletion == observedObj) { this->mLine = NULL; }
-   }
-}
-/*=======================================================*/
-void GbCylinder3D::scale(const double& sx1, const double& sx2, const double& sx3)
-{
-   if( this->isParallelToX1Axis() )
-   {
-      if(!UbMath::equal(sx2,sx3)) throw UbException(UB_EXARGS,"|| to x1 -> different scaling sx2 and sx3 not possible");
-      this->mRad*=sx2;
-   }
-   else if( this->isParallelToX2Axis() )
-   {
-      if(!UbMath::equal(sx1,sx3)) throw UbException(UB_EXARGS,"|| to x2 -> different scaling sx1 and sx3 not possible");
-      this->mRad*=sx1;
-   }
-   else if( this->isParallelToX3Axis() )
-   {
-      if(!UbMath::equal(sx1,sx2)) throw UbException(UB_EXARGS,"|| to x3 -> different scaling sx1 and sx2 not possible");
-      this->mRad*=sx1;
-   }
-   else throw UbException(UB_EXARGS,"unknown direction");
-
-   this->mLine->scale(sx1,sx2,sx3);
-   //notify observer wird automatisch aufgerufen
-}
-/*==========================================================*/
-void GbCylinder3D::write(UbFileOutput* out)
-{
-   out->writeString(this->getCreator()->getTypeID());
-   mLine->write(out);
-   out->writeDouble(mRad);
-   out->writeInteger(cylinderType);
-}
-/*==========================================================*/
-void GbCylinder3D::read(UbFileInput* in)
-{
-   in->readString();
-   mLine = new GbLine3D;
-   mLine->read(in);
-   mRad         = in->readDouble();
-   cylinderType = in->readInteger();
-}
-/*==========================================================*/
-double GbCylinder3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
-{
-   /*
-   Distance D of the intersection between a Ray((ox1,ox2,ox3),(dx1,dx2,dx3)) and a Plane P: ax+by+cz+d=0
-   dc = a*dx1 + b*dx2 + c*dx3
-   dw = a*ox1 + b*ox2 + c*ox3 + d
-   D =   - dw / dc
-   */
-   double px1, px2, px3;
-   double d = Ub::inf; // Distance to Min or Max Plane of the Zylinder
-                       // final distance should be less that d
-
-   if( this->isParallelToX1Axis() )
-   {
-      if     (UbMath::equal(x1 ,minX1) && UbMath::negative(rx1))    return -1.0;
-      else if(UbMath::equal(x1 ,maxX1) && UbMath::positive(rx1))    return -1.0;
-
-      //falls die Linie nicht parallel zu den Seitenflaechen ist
-      if( x1< minX1  ||  x1 > maxX1 ) //nur fuer punkte links und rechts des cylinders
-      {
-         px1 = (x1 < minX1 ? minX1 : maxX1);
-         //falls die Linie nicht parallel zu den Seitenflaechen ist
-         if( !UbMath::zero(rx1) )
-         {
-            // Plane a= 0, b= 1, c=0 d= -1*px2
-            d   = -1.0*(x1 - px1) / rx1;
-            px2 = x2 + d*rx2;
-            px3 = x3 + d*rx3;
-
-            if(UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad))
-            {
-               if     (x1 < minX1 && rx1>0.0 ) d = Ub::inf;  //punkt liegt "links" vom cylinder und strahl hat evtl weiteren SP auf oberflaeche
-               else if(x1 > maxX1 && rx1<0.0 ) d = Ub::inf;
-               else return -1.0;
-            }
-            else return d;
-         }
-         else return -1.0;
-      }
-      else
-      {
-         //if     (UbMath::negative(rx1)) d = -1.0 * (x1 - minX1) / rx1;
-         //else if(UbMath::positive(rx1)) d = -1.0 * (x1 - maxX1) / rx1;
-         if     (UbMath::negative(rx1)) d = -1.0 * (x1 - maxX1) / rx1;
-         else if(UbMath::positive(rx1)) d = -1.0 * (x1 - minX1) / rx1;
-      }
-   }
-   else if( this->isParallelToX2Axis() )
-   {
-      if     (UbMath::equal(x2 ,minX2) && UbMath::negative(rx2))    return -1;
-      else if(UbMath::equal(x2 ,maxX2) && UbMath::positive(rx2))    return -1;
-
-      if( minX2 > x2  ||  x2 > maxX2 )
-      {
-         px2 = (x2 < minX2 ? minX2 : maxX2);
-         //falls die Linie nicht parallel zu den Seitenflaechen ist
-         if( !UbMath::zero(rx2) )
-         {
-            // Plane a= 0, b= 1, c=0 d= -1*px2
-            d   = -1*(x2 - px2) / rx2;
-            px1 = x1 + d*rx1;
-            px3 = x3 + d*rx3;
-
-            if (UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad))
-            {
-               if     (x2 < minX2 && rx2>0.0 ) d = Ub::inf;  //punkt liegt "links oberhalb" vom cylinder und strahl mit pos x1 hat evtl weiteren SP auf oberflaeche
-               else if(x2 > maxX2 && rx2<0.0 ) d = Ub::inf;
-               else return -1.0;
-            }
-            else return d;
-         }
-         else return -1.0;
-      }
-      else
-      {
-         if     (UbMath::negative(rx2)) d = -1.0 * (x2 - minX2) / rx2;
-         else if(UbMath::positive(rx2)) d = -1.0 * (x2 - maxX2) / rx2;
-      }
-   }
-   else if( this->isParallelToX3Axis() )
-   {
-      if     (UbMath::equal(x3, minX3) && UbMath::negative(rx3)) return -1.0;
-      else if(UbMath::equal(x3, maxX3) && UbMath::positive(rx3)) return -1.0;
-
-      if(minX3 > x3  ||  x3 > maxX3 )
-      {
-         px3 = (x3 < minX3 ? minX3 : maxX3);
-         //falls die Linie nicht parallel zu den Seitenflaechen ist
-         if (!UbMath::zero(rx3))
-         {
-            // Plane a= 0, b= 0, c=1 d= -1*px3
-            d   = -1.0*(x3 - px3) / rx3;
-            px2 = x2 + d*rx2;
-            px1 = x1 + d*rx1;
-            if( UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad) )
-            {
-               if     (x3 < minX3 && rx3>0.0 ) d = Ub::inf;
-               else if(x3 > maxX3 && rx3<0.0 ) d = Ub::inf;
-               else return -1.0;
-            }
-            else return d;
-         }
-         else return -1.0;
-      }
-      else
-      {
-         if     (UbMath::negative(rx3)) d = -1.0 * (x3 - minX3) / rx3;
-         else if(UbMath::positive(rx3)) d = -1.0 * (x3 - maxX3) / rx3;
-      }
-   }
-   else throw UbException(UB_EXARGS,"funzt nur bei achsen parallelem cylinder");
-   //////////////////////////////////////////////////////////////////////////
-   //Q berechnen fuer Infinity Zylinder
-   double axisX1 = mLine->getPoint2()->x1 - mLine->getPoint1()->x1;  /* Axis of the cylinder   */
-   double axisX2 = mLine->getPoint2()->x2 - mLine->getPoint1()->x2;  /* mit p1 als base of cylinder */
-   double axisX3 = mLine->getPoint2()->x3 - mLine->getPoint1()->x3;
-
-   //double dirlen = mLine->getLength();
-   //double abs, t, s;
-
-   double RCx1 = x1 - mLine->getPoint1()->x1;
-   double RCx2 = x2 - mLine->getPoint1()->x2;
-   double RCx3 = x3 - mLine->getPoint1()->x3;
-
-   //n = ray x axis
-   double nx1 = rx2*axisX3 - rx3*axisX2;
-   double nx2 = rx3*axisX1 - rx1*axisX3;
-   double nx3 = rx1*axisX2 - rx2*axisX1;
-   double nLength = nx1*nx1 + nx2*nx2 + nx3*nx3;
-
-   double abs;
-   if( UbMath::zero( nLength ) )
-   {  /* ray parallel to cyl  */
-      //abs = RC dot axis
-      double tmpabs = RCx1*axisX1 + RCx2*axisX2 + RCx3*axisX3;
-      double dx1 = RCx1 - tmpabs*axisX1;
-      double dx2 = RCx2 - tmpabs*axisX2;
-      double dx3 = RCx3 - tmpabs*axisX3;
-      if( UbMath::greater( dx1*dx1 + dx2*dx2 + dx3*dx3 , mRad*mRad) )
-         return -1.0;
-   }
-
-   //normalize "n"
-   nLength = std::sqrt(nLength);
-   double invnLength = 1.0/nLength;
-   nx1*=invnLength;
-   nx2*=invnLength;
-   nx3*=invnLength;
-
-   //shortest distance  = fabs( RC dot n )
-   abs = std::fabs( RCx1*nx1 + RCx2*nx2 + RCx3*nx3 );
-
-   if( UbMath::lessEqual(abs, mRad) )
-   {                    /* if ray hits cylinder */
-      //Ox1 = RC x axis
-      double Ox1 = RCx2*axisX3 - RCx3*axisX2;
-      double Ox2 = RCx3*axisX1 - RCx1*axisX3;
-      double Ox3 = RCx1*axisX2 - RCx2*axisX1;
-      //t = - O dot n / nLength;
-      double t = - (Ox1*nx1 + Ox2*nx2 + Ox3*nx3) / nLength;
-
-      //O = n x axis;
-      Ox1 = nx2*axisX3 - nx3*axisX2;
-      Ox2 = nx3*axisX1 - nx1*axisX3;
-      Ox3 = nx1*axisX2 - nx2*axisX1;
-
-      //normalize O
-      invnLength = 1.0/std::sqrt(Ox1*Ox1 + Ox2*Ox2 + Ox3*Ox3);
-      Ox1*=invnLength;
-      Ox2*=invnLength;
-      Ox3*=invnLength;
-
-      double s = std::fabs( sqrt(mRad*mRad - abs*abs) / (rx1*Ox1 + rx2*Ox2 + rx3*Ox3) );
-
-      //Wert a) t-s: entering distance
-      //     b) t+s: exiting  distance
-      //
-      // -> we only consider factors in ray-dir -> means positive values!
-      //    (s is always positive)
-
-      if(t>s)
-      {
-         return UbMath::min( t-s, d );
-      }
-      else if( (t+s) > 0 )
-      {
-         return UbMath::min( t+s, d );
-      }
-   }
-
-   return -1.0;
-}
-/*==========================================================*/
+#include <numerics/geometry3d/GbCylinder3D.h>
+#include <numerics/geometry3d/GbSystem3D.h>
+#include <numerics/geometry3d/GbPoint3D.h>
+#include <numerics/geometry3d/GbTriangle3D.h>
+#include <basics/utilities/UbInfinity.h>
+
+#include <numerics/geometry3d/creator/GbCylinder3DCreator.h>
+
+using namespace std;
+
+/*=======================================================*/
+ObObjectCreator* GbCylinder3D::getCreator()
+{
+   return GbCylinder3DCreator::getInstance();
+}
+// Konstruktor
+/*==========================================================*/
+GbCylinder3D::GbCylinder3D()
+   : minX1(0.0)   , minX2(0.0)   , minX3(0.0)
+   , maxX1(0.0)   , maxX2(0.0)   , maxX3(0.0)
+   , centerX1(0.0), centerX2(0.0), centerX3(0.0)
+{
+   this->setName("cylinder");
+   GbPoint3D* p1 = new GbPoint3D();
+   GbPoint3D* p2 = new GbPoint3D();
+   mLine = new GbLine3D(p1,p2);
+   this->mLine->addObserver(this);
+   mRad = 0.0;
+   cylinderType = GbCylinder3D::NOTPARALLELTOAXIS;
+   this->mLine->addObserver(this);
+   this->calculateValues();
+}
+/*=======================================================*/
+GbCylinder3D::GbCylinder3D(GbCylinder3D* cylinder)
+   : minX1(0.0)   , minX2(0.0)   , minX3(0.0)
+   , maxX1(0.0)   , maxX2(0.0)   , maxX3(0.0)
+   , centerX1(0.0), centerX2(0.0), centerX3(0.0)
+{
+   this->setName("cylinder");
+   mRad         = cylinder->getRadius();
+   cylinderType = cylinder->cylinderType;
+   mLine        = cylinder->getLine()->clone();
+
+   this->mLine->addObserver(this);
+   this->calculateValues();
+}
+/*==========================================================*/
+GbCylinder3D::GbCylinder3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& rad)
+   : minX1(0.0)   , minX2(0.0)   , minX3(0.0)
+   , maxX1(0.0)   , maxX2(0.0)   , maxX3(0.0)
+   , centerX1(0.0), centerX2(0.0), centerX3(0.0)
+{
+   this->setName("cylinder");
+   mLine = new GbLine3D;
+   //Min/Max, damit gewaehrleistet ist, dass Startpunkt immer der "Achs-Minimale" ist
+   //Anm.: bin nich tsicher ob weiter unten irgendwelche Algos drauf beruhen...
+   //      geht nat nur solange, zylinder achs-parallel, aber das ist erzeit so!!!
+   mLine->setPoints( new GbPoint3D(min(x1a,x1b), min(x2a,x2b), min(x3a,x3b))
+	                 ,new GbPoint3D(max(x1a,x1b), max(x2a,x2b), max(x3a,x3b)));
+   //mLine->setPoints( new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1b, x2b ,x3b ));
+   this->mLine->addObserver(this);
+   mRad = fabs(rad);
+
+   this->calculateValues();
+}
+/*==========================================================*/
+GbCylinder3D::GbCylinder3D(GbPoint3D* p1, GbPoint3D* p2, const double& rad)
+   : minX1(0.0), minX2(0.0), minX3(0.0)
+   , maxX1(0.0), maxX2(0.0), maxX3(0.0)
+   , centerX1(0.0), centerX2(0.0), centerX3(0.0)
+{
+   this->setName("cylinder");
+   mRad = rad;
+
+   mLine = new GbLine3D(p1,p2);
+   this->mLine->addObserver(this);
+   this->calculateValues();
+}
+/*==========================================================*/
+GbCylinder3D::GbCylinder3D(GbLine3D* line, const double& rad)
+   : minX1(0.0), minX2(0.0), minX3(0.0)
+   , maxX1(0.0), maxX2(0.0), maxX3(0.0)
+   , centerX1(0.0), centerX2(0.0), centerX3(0.0)
+{
+   this->setName("cylinder");
+   mRad = rad;
+
+   this->mLine = line;
+   this->mLine->addObserver(this);
+
+   this->calculateValues();
+}
+/*==========================================================*/
+// Destruktor
+GbCylinder3D::~GbCylinder3D()
+{
+   if(mLine) this->mLine->removeObserver(this);
+   mLine = NULL;
+}
+/*=======================================================*/
+void GbCylinder3D::calculateValues()
+{
+   double x1a = mLine->getPoint1()->x1;    double x1b = mLine->getPoint2()->x1;
+   double x2a = mLine->getPoint1()->x2;    double x2b = mLine->getPoint2()->x2;
+   double x3a = mLine->getPoint1()->x3;    double x3b = mLine->getPoint2()->x3;
+
+   if     (x1a!=x1b && x2a==x2b && x3a==x3b)  this->cylinderType = X1PARALLEL;
+   else if(x2a!=x2b && x1a==x1b && x3a==x3b)  this->cylinderType = X2PARALLEL;
+   else if(x3a!=x3b && x1a==x1b && x2a==x2b)  this->cylinderType = X3PARALLEL;
+   // nach dem serialisieren ruft er den Standardkonstruktor auf wo alles 0 ist und bricht sonst hier ab
+   else if(x3a==x3b && x1a==x1b && x2a==x2b)  this->cylinderType = X1PARALLEL; 
+   else                                       this->cylinderType = NOTPARALLELTOAXIS;
+
+   if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS)
+      throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Zylinder erlaubt... isPointInObject3D funzt sonst ned");
+
+   if(this->isParallelToX1Axis())
+   {
+      minX1 = mLine->getX1Minimum();
+      maxX1 = mLine->getX1Maximum();
+      minX2 = mLine->getX2Centroid()-mRad; 
+      maxX2 = mLine->getX2Centroid()+mRad;
+      minX3 = mLine->getX3Centroid()-mRad; 
+      maxX3 = mLine->getX3Centroid()+mRad;
+   }
+   else if(this->isParallelToX2Axis()) 
+   {
+      minX1 = mLine->getX1Centroid()-mRad;
+      maxX1 = mLine->getX1Centroid()+mRad;
+      minX2 = mLine->getX2Minimum();   
+      maxX2 = mLine->getX2Maximum();
+      minX3 = mLine->getX3Centroid()-mRad;
+      maxX3 = mLine->getX3Centroid()+mRad;
+   }
+   else if(this->isParallelToX3Axis()) 
+   {
+      minX1 = mLine->getX1Centroid()-mRad;  
+      maxX1 = mLine->getX1Centroid()+mRad;
+      minX2 = mLine->getX2Centroid()-mRad;
+      maxX2 = mLine->getX2Centroid()+mRad;
+      minX3 = mLine->getX3Minimum();
+      maxX3 = mLine->getX3Maximum();
+   }
+
+   centerX1 = mLine->getX1Centroid();
+   centerX2 = mLine->getX2Centroid();
+   centerX3 = mLine->getX3Centroid();
+}
+ 
+/*=======================================================*/
+void GbCylinder3D::finalize()
+{
+   if(this->mLine)
+   {
+      mLine->finalize();
+      delete mLine;
+      mLine=NULL;
+   }
+}
+/*=======================================================*/
+double GbCylinder3D::getHeight()
+{
+   if(mLine) return mLine->getLength(); return 0.0;
+}
+/*=======================================================*/
+GbPoint3D* GbCylinder3D::getPoint1()
+{
+   if(this->mLine) return this->mLine->getPoint1();
+   return NULL;
+}
+/*=======================================================*/
+GbPoint3D* GbCylinder3D::getPoint2()
+{
+   if(this->mLine) return this->mLine->getPoint2();
+   return NULL;
+}
+/*=======================================================*/
+void GbCylinder3D::setRadius(const double& radius)
+{
+   this->mRad = std::fabs(radius);
+   this->notifyObserversObjectChanged();
+}
+/*=======================================================*/
+void GbCylinder3D::setLine(GbLine3D* line)
+{
+   if(this->mLine) this->mLine->removeObserver(this);
+   this->mLine = line;
+   this->mLine->addObserver(this);
+   this->calculateValues();
+
+   this->notifyObserversObjectChanged();
+}
+/*=======================================================*/
+void GbCylinder3D::setPoint1(const double& x1, const double& x2, const double& x3)
+{
+   if(!mLine->getPoint1()) throw UbException(UB_EXARGS,"line has no point1");
+   mLine->getPoint1()->setCoordinates(x1,x2,x3);
+   this->calculateValues();
+
+   //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt...
+}
+/*=======================================================*/
+void GbCylinder3D::setPoint2(const double& x1, const double& x2, const double& x3)
+{
+   if(!mLine->getPoint2()) throw UbException(UB_EXARGS,"line has no point2");
+   mLine->getPoint2()->setCoordinates(x1,x2,x3);
+   this->calculateValues();
+
+   //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt...
+}
+/*==========================================================*/
+bool GbCylinder3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
+{
+   //true, wenn 'in Object' oder 'auf Boundary'!
+   if     ( this->isParallelToX1Axis() && (UbMath::less(x1p,minX1) || UbMath::greater(x1p,maxX1)))  return false;
+   else if( this->isParallelToX2Axis() && (UbMath::less(x2p,minX2) || UbMath::greater(x2p,maxX2)))  return false;
+   else if( this->isParallelToX3Axis() && (UbMath::less(x3p,minX3) || UbMath::greater(x3p,maxX3)))  return false;
+   else if( this->isNotParallelToAxis() ) throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Zylinder erlaubt... isPointInObject3D funzt sonst ned");
+
+   return UbMath::lessEqual(fabs(mLine->getDistance(x1p,x2p,x3p)),fabs(mRad));
+}
+/*==========================================================*/
+bool GbCylinder3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
+{
+   //funzt derzeit nur bei achsparallelen cylindern
+   pointIsOnBoundary = false;
+
+   if     ( this->isParallelToX1Axis() && (UbMath::less(x1p,minX1) || UbMath::greater(x1p,maxX1)))  return false;
+   else if( this->isParallelToX2Axis() && (UbMath::less(x2p,minX2) || UbMath::greater(x2p,maxX2)))  return false;
+   else if( this->isParallelToX3Axis() && (UbMath::less(x3p,minX3) || UbMath::greater(x3p,maxX3)))  return false;
+   else if( this->isNotParallelToAxis() ) throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Zylinder erlaubt... isPointInObject3D funzt sonst ned");
+
+   //true, wenn 'in Object' oder 'auf Boundary'!
+
+   double dis = mLine->getDistance(x1p,x2p,x3p);
+
+   if(UbMath::equal(dis,mRad)) pointIsOnBoundary = true;
+ 
+   if     (this->isParallelToX1Axis() && (UbMath::equal(x1p,minX1) || UbMath::equal(x1p,maxX1))) pointIsOnBoundary = true;
+   else if(this->isParallelToX2Axis() && (UbMath::equal(x2p,minX2) || UbMath::equal(x2p,maxX2))) pointIsOnBoundary = true;
+   else if(this->isParallelToX3Axis() && (UbMath::equal(x3p,minX3) || UbMath::equal(x3p,maxX3))) pointIsOnBoundary = true;
+
+   return UbMath::lessEqual(dis,mRad);
+}
+/*==========================================================*/
+string GbCylinder3D::toString()
+{
+	stringstream ss;
+	ss<<"GbCylinder3D[";
+	ss<<"line="<<this->mLine->toString();
+   ss<<", r="<<this->mRad;
+   ss<<"]";
+   return(ss.str());
+}
+/*=======================================================*/
+bool GbCylinder3D::isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+{
+   if(   this->isPointInGbObject3D(x1a, x2a, x3a)
+      && this->isPointInGbObject3D(x1b, x2a, x3a)
+      && this->isPointInGbObject3D(x1b, x2b, x3a)
+      && this->isPointInGbObject3D(x1a, x2b, x3a)
+      && this->isPointInGbObject3D(x1a, x2a, x3b)
+      && this->isPointInGbObject3D(x1b, x2a, x3b)
+      && this->isPointInGbObject3D(x1b, x2b, x3b)
+      && this->isPointInGbObject3D(x1a, x2b, x3b))
+   {
+      return true;
+   }
+   return false;
+}
+/*==========================================================*/
+bool GbCylinder3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+//Merksatz: cell oder deren Volumen schneidet oder beinhaltet komplette oder Teile der CuboidUmrandung
+//returns true:
+//  - cell cuts  cylinder3D
+//  - cell boxes cylinder3D
+//returns false:
+//  - cell completely inside cylinder3D ( = cylinder3D boxes cell)
+//  - cell und cylinder3D haben kein gemeinsames Volumen
+{
+   //erstmal wieder die dumm Loesung
+   if(   this->isCellInsideOrCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)
+      && !this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) )
+   {
+      return true;
+   }
+
+   return false;
+}
+/*==========================================================*/
+bool GbCylinder3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+//returns true:
+//  - cell completely inside cylinder3D ( = cylinder3D boxes cell)
+//  - cell cuts  cylinder3D
+//  - cell boxes cylinder3D
+//returns false:
+//  - cell und cylinder3D haben kein gemeinsames Volumen
+{
+   double dmin   = 0.0;
+
+   if(this->isParallelToX1Axis())
+   {
+      //check liegt Cell komplett !x1-ausserhalb"?
+      if(  UbMath::less   (x1a,minX1) && UbMath::less   (x1b,minX1) ) return false;
+      if(  UbMath::greater(x1a,maxX1) && UbMath::greater(x1b,maxX1) ) return false;
+
+      //mittelpunkt kreis-querschnitt
+      double& midX2 = mLine->getPoint1()->x2;
+      double& midX3 = mLine->getPoint1()->x3;
+      if     ( UbMath::less   ( midX2, x2a ) ) dmin += std::pow( midX2 - x2a, 2.0 ); 
+      else if( UbMath::greater( midX2, x2b ) ) dmin += std::pow( midX2 - x2b, 2.0 );     
+      if     ( UbMath::less   ( midX3, x3a ) ) dmin += std::pow( midX3 - x3a, 2.0 ); 
+      else if( UbMath::greater( midX3, x3b ) ) dmin += std::pow( midX3 - x3b, 2.0 );     
+      if( UbMath::lessEqual( dmin, mRad*mRad) ) return true;
+
+      return false;
+   }
+   else if(this->isParallelToX2Axis())
+   {
+      //check liegt Cell komplett !x2-ausserhalb"?
+      if(  UbMath::less   (x2a,minX2)   && UbMath::less   (x2b,minX2) ) return false;
+      if(  UbMath::greater(x2a,maxX2  ) && UbMath::greater(x2b,maxX2) ) return false;
+
+      //mittelpunkt kreis-querschnitt
+      double& midX1 = mLine->getPoint1()->x1;
+      double& midX3 = mLine->getPoint1()->x3;
+      if     ( UbMath::less   ( midX1, x1a ) ) dmin += std::pow( midX1 - x1a, 2.0 ); 
+      else if( UbMath::greater( midX1, x1b ) ) dmin += std::pow( midX1 - x1b, 2.0 );     
+      if     ( UbMath::less   ( midX3, x3a ) ) dmin += std::pow( midX3 - x3a, 2.0 ); 
+      else if( UbMath::greater( midX3, x3b ) ) dmin += std::pow( midX3 - x3b, 2.0 );     
+      if( UbMath::lessEqual( dmin, mRad*mRad ) ) return true;
+
+   }
+   else if(this->isParallelToX3Axis())
+   {
+      //check liegt Cell komplett !x3-ausserhalb"?
+      if(  UbMath::less   (x3a,minX3) && UbMath::less   (x3b,minX3) ) return false;
+      if(  UbMath::greater(x3a,maxX3) && UbMath::greater(x3b,maxX3) ) return false;
+
+      //mittelpunkt kreis-querschnitt
+      double& midX1 = mLine->getPoint1()->x1;
+      double& midX2 = mLine->getPoint1()->x2;
+      if     ( UbMath::less   ( midX1, x1a ) ) dmin += std::pow( midX1 - x1a, 2.0 ); 
+      else if( UbMath::greater( midX1, x1b ) ) dmin += std::pow( midX1 - x1b, 2.0 );     
+      if     ( UbMath::less   ( midX2, x2a ) ) dmin += std::pow( midX2 - x2a, 2.0 ); 
+      else if( UbMath::greater( midX2, x2b ) ) dmin += std::pow( midX2 - x2b, 2.0 );     
+      if( UbMath::lessEqual( dmin, mRad*mRad ) ) return true;
+   }
+
+   return false;
+}
+/*==========================================================*/
+GbLine3D* GbCylinder3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
+{
+   //liefert immer "innere" linie, also der teil, der vom Zylinder "abgeschnitten" wurde!
+   //funktioniert derzeit nur mit achsenparallelen Zylindern!
+   vector<GbPoint3D*> schnittpunkte;
+
+   double xa,ya,za,xb,yb,zb,xm,ym,zStart,zEnd,t1,t2;
+
+   if(this->isParallelToX1Axis())
+   {
+      xa     = point1.getX2Coordinate();
+      ya     = point1.getX3Coordinate();
+      za     = point1.getX1Coordinate();
+      xb     = point2.getX2Coordinate();
+      yb     = point2.getX3Coordinate();
+      zb     = point2.getX1Coordinate();
+      xm     = mLine->getPoint1()->getX2Coordinate();
+      ym     = mLine->getPoint1()->getX3Coordinate();
+      zStart = mLine->getPoint1()->getX1Coordinate();
+      zEnd   = mLine->getPoint2()->getX1Coordinate();
+   }
+   else if(this->isParallelToX2Axis())
+   {
+      xa     = point1.getX1Coordinate();
+      ya     = point1.getX3Coordinate();
+      za     = point1.getX2Coordinate();
+      xb     = point2.getX1Coordinate();
+      yb     = point2.getX3Coordinate();
+      zb     = point2.getX2Coordinate();
+      xm     = mLine->getPoint1()->getX1Coordinate();
+      ym     = mLine->getPoint1()->getX3Coordinate();
+      zStart = mLine->getPoint1()->getX2Coordinate();
+      zEnd   = mLine->getPoint2()->getX2Coordinate();
+   }
+   else if(this->isParallelToX3Axis())
+   {
+      xa     = point1.getX1Coordinate();
+      ya     = point1.getX2Coordinate();
+      za     = point1.getX3Coordinate();
+      xb     = point2.getX1Coordinate();
+      yb     = point2.getX2Coordinate();
+      zb     = point2.getX3Coordinate();
+      xm     = mLine->getPoint1()->getX1Coordinate();
+      ym     = mLine->getPoint1()->getX2Coordinate();
+      zStart = mLine->getPoint1()->getX3Coordinate();
+      zEnd   = mLine->getPoint2()->getX3Coordinate();
+   }
+   else throw UbException(UB_EXARGS,"funktioniert derzeit nur mit achsenparallelen Zylindern");
+
+   //Bestimmung des Schnittpunktes mit unendlich ausgedehntem Zylinder
+   double r   = mRad;
+   double r2  = r*r;
+   double xa2 = xa*xa;
+   double xb2 = xb*xb;
+   double ya2 = ya*ya;
+   double yb2 = yb*yb;
+   double xm2 = xm*xm;
+   double ym2 = ym*ym;
+
+   double wurzel  = 2.0*xa*xm*yb2+2.0*ya*ym*xb2-2.0*xa*xb*r2+2.0*xa*xb*ym2-2.0*ya*yb*r2+2.0*xa2*yb*ym
+                   +2.0*xa*xm*ya*ym-2.0*xa*xm*yb*ym-2.0*ya*ym*xb*xm+2.0*xb*xm*yb*ym+2.0*ya*yb*xa*xb
+                   -2.0*ya*yb*xa*xm-2.0*ya*yb*xb*xm-2.0*xa*xb*ya*ym-2.0*xa*xb*yb*ym+2.0*xb*xm*ya2
+                   +2.0*ya*yb*xm2-xa2*yb2-xb2*ya2+xa2*r2-xa2*ym2+xb2*r2-xb2*ym2+ya2*r2-ya2*xm2+yb2*r2-yb2*xm2;
+   double nenner  = -2.0*(ya*yb+xa*xb)+xa2+xb2+ya2+yb2;
+   double zaehler =  2.0*(-xa*xm+xb*xm-ya*ym+yb*ym)+xa2-xb2+ya2-yb2;
+
+   if(UbMath::greaterEqual(wurzel,0.0) && !UbMath::zero(nenner) )//fabs(nenner)>1.E-13)
+   {
+      t1 = (zaehler+2.0*sqrt(wurzel))/nenner;
+      t2 = (zaehler-2.0*sqrt(wurzel))/nenner;
+
+      if(UbMath::inClosedInterval(t1, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke
+      {
+         double x = xa*(0.5-0.5*t1)+xb*(0.5+0.5*t1);
+         double y = ya*(0.5-0.5*t1)+yb*(0.5+0.5*t1);
+         double z = za*(0.5-0.5*t1)+zb*(0.5+0.5*t1);
+
+         if(UbMath::inClosedInterval(z,zStart,zEnd)) //zWert muss sich innerhal der cylinderlaenge befinden
+         {
+            if     (this->isParallelToX1Axis()) schnittpunkte.push_back(new GbPoint3D(z,x,y));
+            else if(this->isParallelToX2Axis()) schnittpunkte.push_back(new GbPoint3D(x,z,y));
+            else if(this->isParallelToX3Axis()) schnittpunkte.push_back(new GbPoint3D(x,y,z));
+         }
+      }
+      if(fabs(t2-t1)>1.E-13 && UbMath::inClosedInterval(t2, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke
+      {
+         double x = xa*(0.5-0.5*t2)+xb*(0.5+0.5*t2);
+         double y = ya*(0.5-0.5*t2)+yb*(0.5+0.5*t2);
+         double z = za*(0.5-0.5*t2)+zb*(0.5+0.5*t2);
+
+         if(UbMath::inClosedInterval(z,zStart,zEnd)) //zWert muss sich innerhal der cylinderlaenge befinden
+         {
+            if     (this->isParallelToX1Axis()) schnittpunkte.push_back(new GbPoint3D(z,x,y));
+            else if(this->isParallelToX2Axis()) schnittpunkte.push_back(new GbPoint3D(x,z,y));
+            else if(this->isParallelToX3Axis()) schnittpunkte.push_back(new GbPoint3D(x,y,z));
+         }
+      }
+   }
+   //wenn nenner==0 -> Strecke parallel zu Zylinder! Es muss noch auf Schnittpunkt mit "Deckeln" geprueft werden
+
+   //Schnittpunkt mit Seitenflaechen bestimmen
+   //hierzu wird der schnittpunkt der gegebnen strecke mit den seitenflaechenberechnet
+   //als erstes "schaut man seitlich auf den Zylinder" --> kreisflaechen wird als strecke darsgestellt
+   //mit diesen "strecken" berechnet man Schnittpunkte.
+   //anschliessend wird geprueft, ob der berechnete Schnittpunkt ueberhaupt im kreis liegt
+   //falls ja --> Schnittpunkt vorhanden
+
+   double x1a,y1a,z1a,x1b,y1b,z1b, //uebergebene Strecke
+          x2a,y2a,x2b,y2b,         //erste "Kreisstrecke"
+          x3a,y3a,x3b,y3b,         //zweite "Kreisstrecke"
+          y2m,z2m,y3m,z3m;
+   double nenner1ab;
+
+   if(this->isParallelToX1Axis())
+   {
+      x1a=point1.getX1Coordinate();
+      y1a=point1.getX2Coordinate();
+      z1a=point1.getX3Coordinate();
+      x1b=point2.getX1Coordinate();
+      y1b=point2.getX2Coordinate();
+      z1b=point2.getX3Coordinate();
+
+      x2a=mLine->getPoint1()->getX1Coordinate();
+      y2m=mLine->getPoint1()->getX2Coordinate();
+      z2m=mLine->getPoint1()->getX3Coordinate();
+      y2a=y2m+mRad;
+      x2b=mLine->getPoint1()->getX1Coordinate();
+      y2b=y2m-mRad;
+
+      x3a=mLine->getPoint2()->getX1Coordinate(); //
+      y3m=mLine->getPoint2()->getX2Coordinate();
+      z3m=mLine->getPoint2()->getX3Coordinate();
+      y3a=y3m+mRad;
+      x3b=mLine->getPoint2()->getX1Coordinate();
+      y3b=y3m-mRad;
+   }
+   else if(this->isParallelToX2Axis())
+   {
+      x1a=point1.getX2Coordinate();
+      y1a=point1.getX3Coordinate();
+      z1a=point1.getX1Coordinate();
+      x1b=point2.getX2Coordinate();
+      y1b=point2.getX3Coordinate();
+      z1b=point2.getX1Coordinate();
+
+      x2a=mLine->getPoint1()->getX2Coordinate();
+      y2m=mLine->getPoint1()->getX3Coordinate();
+      z2m=mLine->getPoint1()->getX1Coordinate();
+      y2a=y2m+mRad;
+      x2b=mLine->getPoint1()->getX2Coordinate();
+      y2b=y2m-mRad;
+
+      x3a=mLine->getPoint2()->getX2Coordinate(); //
+      y3m=mLine->getPoint2()->getX3Coordinate();
+      z3m=mLine->getPoint2()->getX1Coordinate();
+      y3a=y3m+mRad;
+      x3b=mLine->getPoint2()->getX2Coordinate();
+      y3b=y3m-mRad;
+   }
+   else if(this->isParallelToX3Axis())
+   {
+      x1a=point1.getX3Coordinate();
+      y1a=point1.getX2Coordinate();
+      z1a=point1.getX1Coordinate();
+      x1b=point2.getX3Coordinate();
+      y1b=point2.getX2Coordinate();
+      z1b=point2.getX1Coordinate();
+
+      x2a=mLine->getPoint1()->getX3Coordinate();
+      y2m=mLine->getPoint1()->getX2Coordinate();
+      z2m=mLine->getPoint1()->getX1Coordinate();
+      y2a=y2m+mRad;
+      x2b=mLine->getPoint1()->getX3Coordinate();
+      y2b=y2m-mRad;
+
+      x3a=mLine->getPoint2()->getX3Coordinate(); //
+      y3m=mLine->getPoint2()->getX2Coordinate();
+      z3m=mLine->getPoint2()->getX1Coordinate();
+      y3a=y3m+mRad;
+      x3b=mLine->getPoint2()->getX3Coordinate();
+      y3b=y3m-mRad;
+   }
+   else throw UbException(UB_EXARGS,"funktioniert derzeit nur mit achsenparallelen Zylindern");
+
+   nenner1ab = -y1a*x2a+y1a*x2b+y1b*x2a-y1b*x2b+x1a*y2a-x1a*y2b-x1b*y2a+x1b*y2b;
+   //double nenner2 = x1a*y2a-x1a*y2b-x1b*y2a+x1b*y2b-y1a*x2a+y1a*x2b+y1b*x2a-y1b*x2b;
+   if(fabs(nenner1ab)>1.E-13) //andernfalls sind die beiden Strecken parallel
+   {
+      //tStrecke ist fuer gegebene Strecke!
+      double t1ab = (-y1a*x2a+y1a*x2b-2.0*y2a*x2b+x1a*y2a-x1a*y2b-x1b*y2b+2.0*y2b*x2a+x1b*y2a-y1b*x2a+y1b*x2b)/nenner1ab;
+      //double tStrecke = -(-x1a*y2a+x1a*y2b+2.0*y2a*x2b+y1a*x2a-2.0*x2a*y2b-y1a*x2b+y1b*x2a-y1b*x2b-x1b*y2a+x1b*y2b)/nenner2;
+      //wenn -1 <= t2 <= +1 -> SP mit strecke
+      if(UbMath::inClosedInterval(t1ab, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke
+      {
+         double x,y,z,abstand_ist;
+         if     (this->isParallelToX1Axis())
+         {
+            x = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab);
+            y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab);
+            z = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab);
+            abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-z)*(z3m-z));
+         }
+         else if(this->isParallelToX2Axis())
+         {
+            y = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab);
+            z = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab);
+            x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab);
+            abstand_ist=sqrt((y3m-z)*(y3m-z)+(z3m-x)*(z3m-x));
+         }
+         else if(this->isParallelToX3Axis())
+         {
+            z = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab);
+            y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab);
+            x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab);
+            abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-x)*(z3m-x));
+         }
+         else throw UbException(UB_EXARGS,"funktioniert derzeit nur mit achsenparallelen Zylindern");
+         
+         //pruefen, ob Punkt Element von Kreisflaeche
+         //double abstand_ist=sqrt((y2m-y)*(y2m-y)+(z2m-z)*(z2m-z));
+         if(UbMath::lessEqual(abstand_ist,mRad))  //Punkt ist Schnittpunkt
+         {
+            bool exists = false;
+            for(int pos=0;pos<(int)schnittpunkte.size();++pos)
+            {
+               if(    fabs(schnittpunkte[pos]->getX1Coordinate()-x)<1.E-13
+                   && fabs(schnittpunkte[pos]->getX2Coordinate()-y)<1.E-13
+                   && fabs(schnittpunkte[pos]->getX3Coordinate()-z)<1.E-13 ) exists=true;
+            }
+
+            if(!exists) schnittpunkte.push_back(new GbPoint3D(x,y,z));
+         }
+      }
+   }
+
+   nenner1ab = -y1a*x3a+y1a*x3b+y1b*x3a-y1b*x3b+x1a*y3a-x1a*y3b-x1b*y3a+x1b*y3b;
+
+   if(fabs(nenner1ab)>1.E-13) //andernfalls sind die beiden Strecken parallel
+   {
+      //tStrecke ist fuer gegebene Strecke!
+      double t1ab = (-y1a*x3a+y1a*x3b-x1b*y3b-2.0*y3a*x3b-x1a*y3b+2.0*y3b*x3a+x1a*y3a+x1b*y3a-y1b*x3a+y1b*x3b)/nenner1ab;
+
+      if(UbMath::inClosedInterval(t1ab, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke
+      {
+         double x,y,z,abstand_ist;
+         if     (this->isParallelToX1Axis())
+         {
+            x = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab);
+            y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab);
+            z = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab);
+            abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-z)*(z3m-z));
+         }
+         else if(this->isParallelToX2Axis())
+         {
+            y = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab);
+            z = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab);
+            x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab);
+            abstand_ist=sqrt((y3m-z)*(y3m-z)+(z3m-x)*(z3m-x));
+         }
+         else if(this->isParallelToX3Axis())
+         {
+            z = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab);
+            y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab);
+            x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab);
+            abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-x)*(z3m-x));
+         }
+         else throw UbException(UB_EXARGS,"cylinder must be parallel to one axis");
+
+         //pruefen, ob Punkt Element von Kreisflaeche
+         //double abstand_ist=sqrt((y2m-y)*(y2m-y)+(z2m-z)*(z2m-z));
+
+         if(UbMath::lessEqual(abstand_ist,mRad))  //Punkt ist Schnittpunkt
+         {
+            bool exists = false;
+            for(int pos=0;pos<(int)schnittpunkte.size();++pos)
+            {
+               if(   fabs(schnittpunkte[pos]->getX1Coordinate()-x)<1.E-13
+                  && fabs(schnittpunkte[pos]->getX2Coordinate()-y)<1.E-13
+                  && fabs(schnittpunkte[pos]->getX3Coordinate()-z)<1.E-13 ) exists=true;
+            }
+
+            if(!exists) schnittpunkte.push_back(new GbPoint3D(x,y,z));
+         }
+      }
+   }
+
+   int nofSchnittpunkte = (int)schnittpunkte.size();
+   if     (nofSchnittpunkte==0) return NULL;
+   else if(nofSchnittpunkte >2) throw UbException(UB_EXARGS,"more than three intersection points - not possible");
+   else if(nofSchnittpunkte==2) return new GbLine3D(schnittpunkte[0],schnittpunkte[1]);
+   else if(nofSchnittpunkte==1)
+   {
+      if     (this->isPointInGbObject3D(&point1)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point1));
+      else if(this->isPointInGbObject3D(&point2)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point2));
+      else  return new GbLine3D(schnittpunkte[0],new GbPoint3D(*(schnittpunkte[0]))); //strecke beruehrt clippedLine reduziert sich auf einen Punkt!!!
+   }
+
+   return NULL;
+}
+/*==========================================================*/
+vector<GbTriangle3D*> GbCylinder3D::getSurfaceTriangleSet()
+{
+   double x1ma,x1mb,x2m,x3m;
+   if( this->isParallelToX1Axis() )
+   {
+      x1ma = this->getX1Minimum();
+      x1mb = this->getX1Maximum();
+      x2m  = this->getX2Centroid();
+      x3m  = this->getX3Centroid();
+   }
+   else if( this->isParallelToX2Axis() )
+   {
+      x1ma = this->getX2Minimum();
+      x1mb = this->getX2Maximum();
+      x2m  = this->getX1Centroid();
+      x3m  = this->getX3Centroid();
+   }
+   else if( this->isParallelToX3Axis() )
+   {
+      x1ma = this->getX3Minimum();
+      x1mb = this->getX3Maximum();
+      x2m  = this->getX2Centroid();
+      x3m  = this->getX1Centroid();
+   }
+   else throw UbException(UB_EXARGS,"cylinder not axis prallel");
+
+   vector<GbTriangle3D*> triangles;
+
+   int segmentsCircle  = 20;
+   double deltaPhi = UbMath::PI/(double)segmentsCircle;
+
+   double phiX1a,phiX1b;
+   double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d;
+
+   double dXCylinder =  fabs((x1mb-x1ma))/(double)segmentsCircle;
+   int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder);
+   for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++)
+   {
+      x1a = x1d = x1ma+segCyl*dXCylinder;
+      x1b = x1c = x1a+dXCylinder;
+
+      for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi)
+      {
+         phiX1b = phiX1a+deltaPhi;
+
+         x2a =  x2m+mRad*std::sin(phiX1a);
+         x3a =  x3m+mRad*std::cos(phiX1a);
+         x2b =  x2m+mRad*std::sin(phiX1b);
+         x3b =  x3m+mRad*std::cos(phiX1b);
+
+         if( this->isParallelToX1Axis() )
+         {
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x1b,x2b,x3b),new GbPoint3D(x1b,x2a,x3a),new GbPoint3D(x1a,x2a,x3a)));
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1a,x2b,x3b),new GbPoint3D(x1b,x2b,x3b)));
+         }
+         else if( this->isParallelToX2Axis() )
+         {
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x2b,x1b,x3b),new GbPoint3D(x2a,x1b,x3a),new GbPoint3D(x2a,x1a,x3a)));
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x2a,x1a,x3a),new GbPoint3D(x2b,x1a,x3b),new GbPoint3D(x2b,x1b,x3b)));
+         }
+         else if( this->isParallelToX3Axis() )
+         {
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x3b,x2b,x1b),new GbPoint3D(x3a,x2a,x1b),new GbPoint3D(x3a,x2a,x1a)));
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x3a,x2a,x1a),new GbPoint3D(x3b,x2b,x1a),new GbPoint3D(x3b,x2b,x1b)));
+         }
+
+      }
+   }
+
+   int segmentsSide = (int)(mRad/dXCylinder);
+   double radius0, radius1;
+   for(int segCyl = 0; segCyl<segmentsSide; segCyl++)
+   {
+      radius0 = segCyl*dXCylinder;
+      radius1 = radius0+dXCylinder;
+      if(segCyl==segmentsSide-1) radius1=mRad;
+
+      for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi)
+      {
+         phiX1b = phiX1a+deltaPhi;
+
+         x2a =  x2m+radius0*std::sin(phiX1a);
+         x3a =  x3m+radius0*std::cos(phiX1a);
+         x2b =  x2m+radius0*std::sin(phiX1b);
+         x3b =  x3m+radius0*std::cos(phiX1b);
+         x2c =  x2m+radius1*std::sin(phiX1b);
+         x3c =  x3m+radius1*std::cos(phiX1b);
+         x2d =  x2m+radius1*std::sin(phiX1a);
+         x3d =  x3m+radius1*std::cos(phiX1a);
+
+         if( this->isParallelToX1Axis() )
+         {
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x1ma,x2a,x3a),new GbPoint3D(x1ma,x2b,x3b),new GbPoint3D(x1ma,x2c,x3c)));
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x1ma,x2c,x3c),new GbPoint3D(x1ma,x2d,x3d),new GbPoint3D(x1ma,x2a,x3a)));
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x1mb,x2c,x3c),new GbPoint3D(x1mb,x2b,x3b),new GbPoint3D(x1mb,x2a,x3a)));
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x1mb,x2a,x3a),new GbPoint3D(x1mb,x2d,x3d),new GbPoint3D(x1mb,x2c,x3c)));
+         }
+         else if( this->isParallelToX2Axis() )
+         {
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x2a,x1ma,x3a),new GbPoint3D(x2b,x1ma,x3b),new GbPoint3D(x2c,x1ma,x3c)));
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x2c,x1ma,x3c),new GbPoint3D(x2d,x1ma,x3d),new GbPoint3D(x2a,x1ma,x3a)));
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x2c,x1mb,x3c),new GbPoint3D(x2b,x1mb,x3b),new GbPoint3D(x2a,x1mb,x3a)));
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x2a,x1mb,x3a),new GbPoint3D(x2d,x1mb,x3d),new GbPoint3D(x2c,x1mb,x3c)));
+         }
+         else if( this->isParallelToX3Axis() )
+         {
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x3a,x2a,x1ma),new GbPoint3D(x3b,x2b,x1ma),new GbPoint3D(x3c,x2c,x1ma)));
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x3c,x2c,x1ma),new GbPoint3D(x3d,x2d,x1ma),new GbPoint3D(x3a,x2a,x1ma)));
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x3c,x2c,x1mb),new GbPoint3D(x3b,x2b,x1mb),new GbPoint3D(x3a,x2a,x1mb)));
+            triangles.push_back(new GbTriangle3D(new GbPoint3D(x3a,x2a,x1mb),new GbPoint3D(x3d,x2d,x1mb),new GbPoint3D(x3c,x2c,x1mb)));
+         }
+      }
+   }
+
+   return triangles;
+}
+/*==========================================================*/
+void GbCylinder3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles)
+{
+   float x1ma,x1mb,x2m,x3m;
+   if( this->isParallelToX1Axis() )
+   {
+      x1ma = (float)this->getX1Minimum();
+      x1mb = (float)this->getX1Maximum();
+      x2m  = (float)this->getX2Centroid();
+      x3m  = (float)this->getX3Centroid();
+   }
+   else if( this->isParallelToX2Axis() )
+   {
+      x1ma = (float)this->getX2Minimum();
+      x1mb = (float)this->getX2Maximum();
+      x2m  = (float)this->getX1Centroid();
+      x3m  = (float)this->getX3Centroid();
+   }
+   else if( this->isParallelToX3Axis() )
+   {
+      x1ma = (float)this->getX3Minimum();
+      x1mb = (float)this->getX3Maximum();
+      x2m  = (float)this->getX2Centroid();
+      x3m  = (float)this->getX1Centroid();
+   }
+   else throw UbException(UB_EXARGS,"cylinder not axis prallel");
+
+   int segmentsCircle  = 20;
+   double deltaPhi = UbMath::PI/(double)segmentsCircle;
+
+   double phiX1a,phiX1b;
+   float x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d;
+
+   double dXCylinder =  fabs((x1mb-x1ma))/(double)segmentsCircle;
+   int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder);
+   int nodenr = 0;
+   for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++)
+   {
+      x1a = x1d = (float)(x1ma+segCyl*dXCylinder);
+      x1b = x1c = (float)(x1a+dXCylinder);
+
+      for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi)
+      {
+         phiX1b = phiX1a+deltaPhi;
+
+         x2a =  (float)(x2m+mRad*std::sin(phiX1a));
+         x3a =  (float)(x3m+mRad*std::cos(phiX1a));
+         x2b =  (float)(x2m+mRad*std::sin(phiX1b));
+         x3b =  (float)(x3m+mRad*std::cos(phiX1b));
+
+         if( this->isParallelToX1Axis() )
+         {
+            nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2a,x3a) );
+            nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2b,x3b) );
+         }
+         else if( this->isParallelToX2Axis() )
+         {
+            nodes.push_back( makeUbTuple(x2b,x1b,x3b) ); nodes.push_back( makeUbTuple(x2a,x1b,x3a) ); nodes.push_back( makeUbTuple(x2a,x1a,x3a) );
+            nodes.push_back( makeUbTuple(x2a,x1a,x3a) ); nodes.push_back( makeUbTuple(x2b,x1a,x3b) ); nodes.push_back( makeUbTuple(x2b,x1b,x3b) );
+         }
+         else if( this->isParallelToX3Axis() )
+         {
+            nodes.push_back( makeUbTuple(x3b,x2b,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1a) );
+            nodes.push_back( makeUbTuple(x3a,x2a,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1b) );
+         }
+         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
+         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
+      }
+   }
+
+   int segmentsSide = (int)(mRad/dXCylinder);
+   double radius0, radius1;
+   for(int segCyl = 0; segCyl<segmentsSide; segCyl++)
+   {
+      radius0 = segCyl*dXCylinder;
+      radius1 = radius0+dXCylinder;
+      if(segCyl==segmentsSide-1) radius1=mRad;
+
+      for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi)
+      {
+         phiX1b = phiX1a+deltaPhi;
+
+         x2a = x2m+(float)(radius0*std::sin(phiX1a));
+         x3a = x3m+(float)(radius0*std::cos(phiX1a));
+         x2b = x2m+(float)(radius0*std::sin(phiX1b));
+         x3b = x3m+(float)(radius0*std::cos(phiX1b));
+         x2c = x2m+(float)(radius1*std::sin(phiX1b));
+         x3c = x3m+(float)(radius1*std::cos(phiX1b));
+         x2d = x2m+(float)(radius1*std::sin(phiX1a));
+         x3d = x3m+(float)(radius1*std::cos(phiX1a));
+
+         if( this->isParallelToX1Axis() )
+         {
+            nodes.push_back( makeUbTuple(x1ma,x2a,x3a) ); nodes.push_back( makeUbTuple(x1ma,x2b,x3b) ); nodes.push_back( makeUbTuple(x1ma,x2c,x3c) );
+            nodes.push_back( makeUbTuple(x1ma,x2c,x3c) ); nodes.push_back( makeUbTuple(x1ma,x2d,x3d) ); nodes.push_back( makeUbTuple(x1ma,x2a,x3a) );
+            nodes.push_back( makeUbTuple(x1mb,x2c,x3c) ); nodes.push_back( makeUbTuple(x1mb,x2b,x3b) ); nodes.push_back( makeUbTuple(x1mb,x2a,x3a) );
+            nodes.push_back( makeUbTuple(x1mb,x2a,x3a) ); nodes.push_back( makeUbTuple(x1mb,x2d,x3d) ); nodes.push_back( makeUbTuple(x1mb,x2c,x3c) );
+         }
+         else if( this->isParallelToX2Axis() )
+         {
+            nodes.push_back( makeUbTuple(x2a,x1ma,x3a) ); nodes.push_back( makeUbTuple(x2b,x1ma,x3b) ); nodes.push_back( makeUbTuple(x2c,x1ma,x3c) );
+            nodes.push_back( makeUbTuple(x2c,x1ma,x3c) ); nodes.push_back( makeUbTuple(x2d,x1ma,x3d) ); nodes.push_back( makeUbTuple(x2a,x1ma,x3a) );
+            nodes.push_back( makeUbTuple(x2c,x1mb,x3c) ); nodes.push_back( makeUbTuple(x2b,x1mb,x3b) ); nodes.push_back( makeUbTuple(x2a,x1mb,x3a) );
+            nodes.push_back( makeUbTuple(x2a,x1mb,x3a) ); nodes.push_back( makeUbTuple(x2d,x1mb,x3d) ); nodes.push_back( makeUbTuple(x2c,x1mb,x3c) );
+         }
+         else if( this->isParallelToX3Axis() )
+         {
+            nodes.push_back( makeUbTuple(x3a,x2a,x1ma) ); nodes.push_back( makeUbTuple(x3b,x2b,x1ma) ); nodes.push_back( makeUbTuple(x3c,x2c,x1ma) );
+            nodes.push_back( makeUbTuple(x3c,x2c,x1ma) ); nodes.push_back( makeUbTuple(x3d,x2d,x1ma) ); nodes.push_back( makeUbTuple(x3a,x2a,x1ma) );
+            nodes.push_back( makeUbTuple(x3c,x2c,x1mb) ); nodes.push_back( makeUbTuple(x3b,x2b,x1mb) ); nodes.push_back( makeUbTuple(x3a,x2a,x1mb) );
+            nodes.push_back( makeUbTuple(x3a,x2a,x1mb) ); nodes.push_back( makeUbTuple(x3d,x2d,x1mb) ); nodes.push_back( makeUbTuple(x3c,x2c,x1mb) );
+         }
+
+         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
+         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
+         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
+         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
+      }
+   }
+}
+/*==========================================================*/
+void GbCylinder3D::addSurfaceTriangleSetSegments(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles, int segmentsRound, int segmentsHeight )
+{
+   float x1ma,x1mb,x2m,x3m;
+   if( this->isParallelToX1Axis() )
+   {
+      x1ma = (float)this->getX1Minimum();
+      x1mb = (float)this->getX1Maximum();
+      x2m  = (float)this->getX2Centroid();
+      x3m  = (float)this->getX3Centroid();
+   }
+   else if( this->isParallelToX2Axis() )
+   {
+      x1ma = (float)this->getX2Minimum();
+      x1mb = (float)this->getX2Maximum();
+      x2m  = (float)this->getX1Centroid();
+      x3m  = (float)this->getX3Centroid();
+   }
+   else if( this->isParallelToX3Axis() )
+   {
+      x1ma = (float)this->getX3Minimum();
+      x1mb = (float)this->getX3Maximum();
+      x2m  = (float)this->getX2Centroid();
+      x3m  = (float)this->getX1Centroid();
+   }
+   else throw UbException(UB_EXARGS,"cylinder not axis prallel");
+
+   int segmentsCircle  = segmentsRound;
+   double deltaPhi = UbMath::PI/(double)segmentsCircle;
+
+   double phiX1a,phiX1b;
+   float x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d;
+
+   double dXCylinder =  fabs((x1mb-x1ma))/(double)segmentsHeight; //hier evtl. segmentsheight
+   int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder);
+   int nodenr = 0;
+   for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++)
+   {
+      x1a = x1d = (float)(x1ma+segCyl*dXCylinder);
+      x1b = x1c = (float)(x1a+dXCylinder);
+
+      //for(phiX1a=2.0*UbMath::PI; phiX1a>0.0; phiX1a-=deltaPhi)
+      for(phiX1a=0.0; phiX1a<2.0*UbMath::PI-0.5*deltaPhi; phiX1a+=deltaPhi)
+      {
+         phiX1b = phiX1a+deltaPhi;
+
+         x2a =  (float)(x2m+mRad*std::sin(phiX1a));
+         x3a =  (float)(x3m+mRad*std::cos(phiX1a));
+         x2b =  (float)(x2m+mRad*std::sin(phiX1b));
+         x3b =  (float)(x3m+mRad*std::cos(phiX1b));
+
+         if( this->isParallelToX1Axis() )
+         {
+            nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2a,x3a) );
+            nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2b,x3b) );
+         }
+         else if( this->isParallelToX2Axis() )
+         {
+            nodes.push_back( makeUbTuple(x2b,x1b,x3b) ); nodes.push_back( makeUbTuple(x2a,x1b,x3a) ); nodes.push_back( makeUbTuple(x2a,x1a,x3a) );
+            nodes.push_back( makeUbTuple(x2a,x1a,x3a) ); nodes.push_back( makeUbTuple(x2b,x1a,x3b) ); nodes.push_back( makeUbTuple(x2b,x1b,x3b) );
+         }
+         else if( this->isParallelToX3Axis() )
+         {
+            nodes.push_back( makeUbTuple(x3b,x2b,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1a) );
+            nodes.push_back( makeUbTuple(x3a,x2a,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1b) );
+         }
+         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
+         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
+      }
+   }
+
+   int segmentsSide = (int)(mRad/dXCylinder);
+   double radius0, radius1;
+   for(int segCyl = 0; segCyl<segmentsSide; segCyl++)
+   {
+      radius0 = segCyl*dXCylinder;
+      radius1 = radius0+dXCylinder;
+      if(segCyl==segmentsSide-1) radius1=mRad;
+
+      //for(phiX1a=2.0*UbMath::PI; phiX1a>0.0; phiX1a-=deltaPhi)
+      for(phiX1a=0.0; phiX1a<2.0*UbMath::PI-0.5*deltaPhi; phiX1a+=deltaPhi)
+      {
+         phiX1b = phiX1a+deltaPhi;
+
+         x2a = x2m+(float)(radius0*std::sin(phiX1a));
+         x3a = x3m+(float)(radius0*std::cos(phiX1a));
+         x2b = x2m+(float)(radius0*std::sin(phiX1b));
+         x3b = x3m+(float)(radius0*std::cos(phiX1b));
+         x2c = x2m+(float)(radius1*std::sin(phiX1b));
+         x3c = x3m+(float)(radius1*std::cos(phiX1b));
+         x2d = x2m+(float)(radius1*std::sin(phiX1a));
+         x3d = x3m+(float)(radius1*std::cos(phiX1a));
+
+         if( this->isParallelToX1Axis() )
+         {
+            nodes.push_back( makeUbTuple(x1ma,x2a,x3a) ); nodes.push_back( makeUbTuple(x1ma,x2b,x3b) ); nodes.push_back( makeUbTuple(x1ma,x2c,x3c) );
+            nodes.push_back( makeUbTuple(x1ma,x2c,x3c) ); nodes.push_back( makeUbTuple(x1ma,x2d,x3d) ); nodes.push_back( makeUbTuple(x1ma,x2a,x3a) );
+            nodes.push_back( makeUbTuple(x1mb,x2c,x3c) ); nodes.push_back( makeUbTuple(x1mb,x2b,x3b) ); nodes.push_back( makeUbTuple(x1mb,x2a,x3a) );
+            nodes.push_back( makeUbTuple(x1mb,x2a,x3a) ); nodes.push_back( makeUbTuple(x1mb,x2d,x3d) ); nodes.push_back( makeUbTuple(x1mb,x2c,x3c) );
+         }
+         else if( this->isParallelToX2Axis() )
+         {
+            nodes.push_back( makeUbTuple(x2a,x1ma,x3a) ); nodes.push_back( makeUbTuple(x2b,x1ma,x3b) ); nodes.push_back( makeUbTuple(x2c,x1ma,x3c) );
+            nodes.push_back( makeUbTuple(x2c,x1ma,x3c) ); nodes.push_back( makeUbTuple(x2d,x1ma,x3d) ); nodes.push_back( makeUbTuple(x2a,x1ma,x3a) );
+            nodes.push_back( makeUbTuple(x2c,x1mb,x3c) ); nodes.push_back( makeUbTuple(x2b,x1mb,x3b) ); nodes.push_back( makeUbTuple(x2a,x1mb,x3a) );
+            nodes.push_back( makeUbTuple(x2a,x1mb,x3a) ); nodes.push_back( makeUbTuple(x2d,x1mb,x3d) ); nodes.push_back( makeUbTuple(x2c,x1mb,x3c) );
+         }
+         else if( this->isParallelToX3Axis() )
+         {
+            nodes.push_back( makeUbTuple(x3a,x2a,x1ma) ); nodes.push_back( makeUbTuple(x3b,x2b,x1ma) ); nodes.push_back( makeUbTuple(x3c,x2c,x1ma) );
+            nodes.push_back( makeUbTuple(x3c,x2c,x1ma) ); nodes.push_back( makeUbTuple(x3d,x2d,x1ma) ); nodes.push_back( makeUbTuple(x3a,x2a,x1ma) );
+            nodes.push_back( makeUbTuple(x3c,x2c,x1mb) ); nodes.push_back( makeUbTuple(x3b,x2b,x1mb) ); nodes.push_back( makeUbTuple(x3a,x2a,x1mb) );
+            nodes.push_back( makeUbTuple(x3a,x2a,x1mb) ); nodes.push_back( makeUbTuple(x3d,x2d,x1mb) ); nodes.push_back( makeUbTuple(x3c,x2c,x1mb) );
+         }
+
+         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
+         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
+         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
+         triangles.push_back( makeUbTuple(nodenr  , nodenr+1, nodenr+2) );  nodenr+=3;
+      }
+   }
+}
+
+/*==========================================================*/
+void GbCylinder3D::objectChanged(UbObservable* changedObject)
+{
+   GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject);
+   if(!line || this->mLine!=line) return;
+
+   this->notifyObserversObjectChanged();
+}
+/*==========================================================*/
+void GbCylinder3D::objectWillBeDeleted(UbObservable* objectForDeletion)
+{
+   if(this->mLine)
+   {
+      UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine);
+      if(objectForDeletion == observedObj) { this->mLine = NULL; }
+   }
+}
+/*=======================================================*/
+void GbCylinder3D::scale(const double& sx1, const double& sx2, const double& sx3)
+{
+   if( this->isParallelToX1Axis() )
+   {
+      if(!UbMath::equal(sx2,sx3)) throw UbException(UB_EXARGS,"|| to x1 -> different scaling sx2 and sx3 not possible");
+      this->mRad*=sx2;
+   }
+   else if( this->isParallelToX2Axis() )
+   {
+      if(!UbMath::equal(sx1,sx3)) throw UbException(UB_EXARGS,"|| to x2 -> different scaling sx1 and sx3 not possible");
+      this->mRad*=sx1;
+   }
+   else if( this->isParallelToX3Axis() )
+   {
+      if(!UbMath::equal(sx1,sx2)) throw UbException(UB_EXARGS,"|| to x3 -> different scaling sx1 and sx2 not possible");
+      this->mRad*=sx1;
+   }
+   else throw UbException(UB_EXARGS,"unknown direction");
+
+   this->mLine->scale(sx1,sx2,sx3);
+   //notify observer wird automatisch aufgerufen
+}
+/*==========================================================*/
+void GbCylinder3D::write(UbFileOutput* out)
+{
+   out->writeString(this->getCreator()->getTypeID());
+   mLine->write(out);
+   out->writeDouble(mRad);
+   out->writeInteger(cylinderType);
+}
+/*==========================================================*/
+void GbCylinder3D::read(UbFileInput* in)
+{
+   in->readString();
+   mLine = new GbLine3D;
+   mLine->read(in);
+   mRad         = in->readDouble();
+   cylinderType = in->readInteger();
+}
+/*==========================================================*/
+double GbCylinder3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
+{
+   /*
+   Distance D of the intersection between a Ray((ox1,ox2,ox3),(dx1,dx2,dx3)) and a Plane P: ax+by+cz+d=0
+   dc = a*dx1 + b*dx2 + c*dx3
+   dw = a*ox1 + b*ox2 + c*ox3 + d
+   D =   - dw / dc
+   */
+   double px1, px2, px3;
+   double d = Ub::inf; // Distance to Min or Max Plane of the Zylinder
+                       // final distance should be less that d
+
+   if( this->isParallelToX1Axis() )
+   {
+      if     (UbMath::equal(x1 ,minX1) && UbMath::negative(rx1))    return -1.0;
+      else if(UbMath::equal(x1 ,maxX1) && UbMath::positive(rx1))    return -1.0;
+
+      //falls die Linie nicht parallel zu den Seitenflaechen ist
+      if( x1< minX1  ||  x1 > maxX1 ) //nur fuer punkte links und rechts des cylinders
+      {
+         px1 = (x1 < minX1 ? minX1 : maxX1);
+         //falls die Linie nicht parallel zu den Seitenflaechen ist
+         if( !UbMath::zero(rx1) )
+         {
+            // Plane a= 0, b= 1, c=0 d= -1*px2
+            d   = -1.0*(x1 - px1) / rx1;
+            px2 = x2 + d*rx2;
+            px3 = x3 + d*rx3;
+
+            if(UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad))
+            {
+               if     (x1 < minX1 && rx1>0.0 ) d = Ub::inf;  //punkt liegt "links" vom cylinder und strahl hat evtl weiteren SP auf oberflaeche
+               else if(x1 > maxX1 && rx1<0.0 ) d = Ub::inf;
+               else return -1.0;
+            }
+            else return d;
+         }
+         else return -1.0;
+      }
+      else
+      {
+         //if     (UbMath::negative(rx1)) d = -1.0 * (x1 - minX1) / rx1;
+         //else if(UbMath::positive(rx1)) d = -1.0 * (x1 - maxX1) / rx1;
+         if     (UbMath::negative(rx1)) d = -1.0 * (x1 - maxX1) / rx1;
+         else if(UbMath::positive(rx1)) d = -1.0 * (x1 - minX1) / rx1;
+      }
+   }
+   else if( this->isParallelToX2Axis() )
+   {
+      if     (UbMath::equal(x2 ,minX2) && UbMath::negative(rx2))    return -1;
+      else if(UbMath::equal(x2 ,maxX2) && UbMath::positive(rx2))    return -1;
+
+      if( minX2 > x2  ||  x2 > maxX2 )
+      {
+         px2 = (x2 < minX2 ? minX2 : maxX2);
+         //falls die Linie nicht parallel zu den Seitenflaechen ist
+         if( !UbMath::zero(rx2) )
+         {
+            // Plane a= 0, b= 1, c=0 d= -1*px2
+            d   = -1*(x2 - px2) / rx2;
+            px1 = x1 + d*rx1;
+            px3 = x3 + d*rx3;
+
+            if (UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad))
+            {
+               if     (x2 < minX2 && rx2>0.0 ) d = Ub::inf;  //punkt liegt "links oberhalb" vom cylinder und strahl mit pos x1 hat evtl weiteren SP auf oberflaeche
+               else if(x2 > maxX2 && rx2<0.0 ) d = Ub::inf;
+               else return -1.0;
+            }
+            else return d;
+         }
+         else return -1.0;
+      }
+      else
+      {
+         if     (UbMath::negative(rx2)) d = -1.0 * (x2 - minX2) / rx2;
+         else if(UbMath::positive(rx2)) d = -1.0 * (x2 - maxX2) / rx2;
+      }
+   }
+   else if( this->isParallelToX3Axis() )
+   {
+      if     (UbMath::equal(x3, minX3) && UbMath::negative(rx3)) return -1.0;
+      else if(UbMath::equal(x3, maxX3) && UbMath::positive(rx3)) return -1.0;
+
+      if(minX3 > x3  ||  x3 > maxX3 )
+      {
+         px3 = (x3 < minX3 ? minX3 : maxX3);
+         //falls die Linie nicht parallel zu den Seitenflaechen ist
+         if (!UbMath::zero(rx3))
+         {
+            // Plane a= 0, b= 0, c=1 d= -1*px3
+            d   = -1.0*(x3 - px3) / rx3;
+            px2 = x2 + d*rx2;
+            px1 = x1 + d*rx1;
+            if( UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad) )
+            {
+               if     (x3 < minX3 && rx3>0.0 ) d = Ub::inf;
+               else if(x3 > maxX3 && rx3<0.0 ) d = Ub::inf;
+               else return -1.0;
+            }
+            else return d;
+         }
+         else return -1.0;
+      }
+      else
+      {
+         if     (UbMath::negative(rx3)) d = -1.0 * (x3 - minX3) / rx3;
+         else if(UbMath::positive(rx3)) d = -1.0 * (x3 - maxX3) / rx3;
+      }
+   }
+   else throw UbException(UB_EXARGS,"funzt nur bei achsen parallelem cylinder");
+   //////////////////////////////////////////////////////////////////////////
+   //Q berechnen fuer Infinity Zylinder
+   double axisX1 = mLine->getPoint2()->x1 - mLine->getPoint1()->x1;  /* Axis of the cylinder   */
+   double axisX2 = mLine->getPoint2()->x2 - mLine->getPoint1()->x2;  /* mit p1 als base of cylinder */
+   double axisX3 = mLine->getPoint2()->x3 - mLine->getPoint1()->x3;
+
+   //double dirlen = mLine->getLength();
+   //double abs, t, s;
+
+   double RCx1 = x1 - mLine->getPoint1()->x1;
+   double RCx2 = x2 - mLine->getPoint1()->x2;
+   double RCx3 = x3 - mLine->getPoint1()->x3;
+
+   //n = ray x axis
+   double nx1 = rx2*axisX3 - rx3*axisX2;
+   double nx2 = rx3*axisX1 - rx1*axisX3;
+   double nx3 = rx1*axisX2 - rx2*axisX1;
+   double nLength = nx1*nx1 + nx2*nx2 + nx3*nx3;
+
+   double abs;
+   if( UbMath::zero( nLength ) )
+   {  /* ray parallel to cyl  */
+      //abs = RC dot axis
+      double tmpabs = RCx1*axisX1 + RCx2*axisX2 + RCx3*axisX3;
+      double dx1 = RCx1 - tmpabs*axisX1;
+      double dx2 = RCx2 - tmpabs*axisX2;
+      double dx3 = RCx3 - tmpabs*axisX3;
+      if( UbMath::greater( dx1*dx1 + dx2*dx2 + dx3*dx3 , mRad*mRad) )
+         return -1.0;
+   }
+
+   //normalize "n"
+   nLength = std::sqrt(nLength);
+   double invnLength = 1.0/nLength;
+   nx1*=invnLength;
+   nx2*=invnLength;
+   nx3*=invnLength;
+
+   //shortest distance  = fabs( RC dot n )
+   abs = std::fabs( RCx1*nx1 + RCx2*nx2 + RCx3*nx3 );
+
+   if( UbMath::lessEqual(abs, mRad) )
+   {                    /* if ray hits cylinder */
+      //Ox1 = RC x axis
+      double Ox1 = RCx2*axisX3 - RCx3*axisX2;
+      double Ox2 = RCx3*axisX1 - RCx1*axisX3;
+      double Ox3 = RCx1*axisX2 - RCx2*axisX1;
+      //t = - O dot n / nLength;
+      double t = - (Ox1*nx1 + Ox2*nx2 + Ox3*nx3) / nLength;
+
+      //O = n x axis;
+      Ox1 = nx2*axisX3 - nx3*axisX2;
+      Ox2 = nx3*axisX1 - nx1*axisX3;
+      Ox3 = nx1*axisX2 - nx2*axisX1;
+
+      //normalize O
+      invnLength = 1.0/std::sqrt(Ox1*Ox1 + Ox2*Ox2 + Ox3*Ox3);
+      Ox1*=invnLength;
+      Ox2*=invnLength;
+      Ox3*=invnLength;
+
+      double s = std::fabs( sqrt(mRad*mRad - abs*abs) / (rx1*Ox1 + rx2*Ox2 + rx3*Ox3) );
+
+      //Wert a) t-s: entering distance
+      //     b) t+s: exiting  distance
+      //
+      // -> we only consider factors in ray-dir -> means positive values!
+      //    (s is always positive)
+
+      if(t>s)
+      {
+         return UbMath::min( t-s, d );
+      }
+      else if( (t+s) > 0 )
+      {
+         return UbMath::min( t+s, d );
+      }
+   }
+
+   return -1.0;
+}
+/*==========================================================*/
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbCylinder3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbCylinder3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbCylinder3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbCylinder3D.h
index 46aef1dc49086b423138e44056a598d917a29d77..e32d2008f20d50a20be917b431152bf24630d5a2 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbCylinder3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbCylinder3D.h
@@ -1,153 +1,153 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBCYLINDER3D_H
-#define GBCYLINDER3D_H
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-#include <vector>
-#include <cmath>
-
-#include <numerics/geometry3d/GbObject3D.h>
-#include <numerics/geometry3d/GbLine3D.h>
-#include <basics/utilities/UbObserver.h>
-
-class GbPoint3D;
-class GbLine3D;
-class GbTriangle3D;
-
-class GbObject3DCreator;
-
-#include <PointerDefinitions.h>
-class GbCylinder3D;
-typedef SPtr<GbCylinder3D> GbCylinder3DPtr;
-
-
-class GbCylinder3D : public GbObject3D , public UbObserver 
-{
-public:
-   GbCylinder3D();
-	GbCylinder3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& radius);
-	GbCylinder3D(GbPoint3D* p1, GbPoint3D* p2, const double& radius);
-	GbCylinder3D(GbLine3D* line, const double& rad);
-	GbCylinder3D(GbCylinder3D* cylinder);
-	~GbCylinder3D();    
-
-	GbCylinder3D* clone() { return new GbCylinder3D(this); }
-	void finalize();
-
-	double     getRadius() { return this->mRad; };
-	GbLine3D*  getLine() {return mLine;}
-	GbPoint3D* getPoint1();
-	GbPoint3D* getPoint2();
-
-	void setRadius(const double& radius);
-	void setLine(GbLine3D* line);
-	void setPoint1(const double& x1, const double& x2, const double& x3);
-	void setPoint2(const double& x1, const double& x2, const double& x3);
-
-	bool isParallelToX1Axis() { return((this->cylinderType & X1PARALLEL        )    ==  X1PARALLEL        );}
-	bool isParallelToX2Axis() { return((this->cylinderType & X2PARALLEL        )    ==  X2PARALLEL        );}
-	bool isParallelToX3Axis() { return((this->cylinderType & X3PARALLEL        )    ==  X3PARALLEL        );}
-	bool isNotParallelToAxis(){ return((this->cylinderType & NOTPARALLELTOAXIS )    ==  NOTPARALLELTOAXIS );}
-
-	double getHeight(); 
-
-	void scale(const double& sx1, const double& sx2, const double& sx3);
-
-   void translate(const double& x1, const double& x2, const double& x3) 
-   {
-      this->mLine->translate( x1, x2, x3 );
-      this->calculateValues();
-      //this->notifyObserversObjectChanged();
-   }
-
-   double getX1Centroid() { return centerX1; }
-   double getX1Minimum()  { return minX1;    }
-	double getX1Maximum()  { return maxX1;    }
-	double getX2Centroid() { return centerX2; }
-	double getX2Minimum()  { return minX2;    }
-	double getX2Maximum()  { return maxX2;    }
-	double getX3Centroid() { return centerX3; }
-	double getX3Minimum()  { return minX3;    }
-	double getX3Maximum()  { return maxX3;    }
-
-	bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); 
-	bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); 
-   bool isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-
-	GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2);
-   
-   //SG ausdokumentieren, da der nur unendlcihe Zylinder macht ...
-   //bool hasRaytracing() { return true; }
-   bool hasRaytracing() { return false; }
-   bool raytracingSupportsPointsInside() { return true; }
-   
-   
-   /*|r| must be 1! einheitsvector!!*/
-   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
-
-	std::vector<GbTriangle3D*> getSurfaceTriangleSet();
-   void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles);
-   void addSurfaceTriangleSetSegments(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles, int segmentsRound, int segmentsHeight );
-
-	std::string toString();
-	ObObjectCreator* getCreator();
-	void write(UbFileOutput* out);
-	void read(UbFileInput* in);
-
-	//virtuelle Methoden von UbObserver
-	void objectChanged(UbObservable* changedObject);
-	void objectWillBeDeleted(UbObservable* objectForDeletion);
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void SF_SERIALIZE(Archive & ar)
-   {
-      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
-      ar & mLine;
-      ar & mRad;
-      ar & cylinderType;
-      
-      if( ArchiveTools::isReading(ar) )
-         this->calculateValues();
-   }
-#endif //CAB_RCF
-   
-   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
-
-
-protected:
-   void calculateValues();
-
-   GbLine3D* mLine;
-	double    mRad;
-
-   double minX1, minX2, minX3;
-   double maxX1, maxX2, maxX3;
-   double centerX1, centerX2, centerX3;
-
-	int cylinderType;
-
-	//void berechneQuerschnittsWerte();
-   static const int NOTPARALLELTOAXIS  = (1<<0); //1
-   static const int X1PARALLEL         = (1<<1); //2
-   static const int X2PARALLEL         = (1<<2); //4
-   static const int X3PARALLEL         = (1<<3); //8
-};
-
-#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
-   UB_AUTO_RUN_NAMED(   SF::registerType<GbCylinder3D >("GbCylinder3D")           , SF_GbCylinder3D     );
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbCylinder3D >() ), SF_GbCylinder3D_BD1 );
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbCylinder3D>()  ), SF_GbCylinder3D_BD2 );
-#endif //RCF_USE_SF_SERIALIZATION
-
-#endif   
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBCYLINDER3D_H
+#define GBCYLINDER3D_H
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+#include <vector>
+#include <cmath>
+
+#include <numerics/geometry3d/GbObject3D.h>
+#include <numerics/geometry3d/GbLine3D.h>
+#include <basics/utilities/UbObserver.h>
+
+class GbPoint3D;
+class GbLine3D;
+class GbTriangle3D;
+
+class GbObject3DCreator;
+
+#include <PointerDefinitions.h>
+class GbCylinder3D;
+typedef SPtr<GbCylinder3D> GbCylinder3DPtr;
+
+
+class GbCylinder3D : public GbObject3D , public UbObserver 
+{
+public:
+   GbCylinder3D();
+	GbCylinder3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& radius);
+	GbCylinder3D(GbPoint3D* p1, GbPoint3D* p2, const double& radius);
+	GbCylinder3D(GbLine3D* line, const double& rad);
+	GbCylinder3D(GbCylinder3D* cylinder);
+	~GbCylinder3D();    
+
+	GbCylinder3D* clone() { return new GbCylinder3D(this); }
+	void finalize();
+
+	double     getRadius() { return this->mRad; };
+	GbLine3D*  getLine() {return mLine;}
+	GbPoint3D* getPoint1();
+	GbPoint3D* getPoint2();
+
+	void setRadius(const double& radius);
+	void setLine(GbLine3D* line);
+	void setPoint1(const double& x1, const double& x2, const double& x3);
+	void setPoint2(const double& x1, const double& x2, const double& x3);
+
+	bool isParallelToX1Axis() { return((this->cylinderType & X1PARALLEL        )    ==  X1PARALLEL        );}
+	bool isParallelToX2Axis() { return((this->cylinderType & X2PARALLEL        )    ==  X2PARALLEL        );}
+	bool isParallelToX3Axis() { return((this->cylinderType & X3PARALLEL        )    ==  X3PARALLEL        );}
+	bool isNotParallelToAxis(){ return((this->cylinderType & NOTPARALLELTOAXIS )    ==  NOTPARALLELTOAXIS );}
+
+	double getHeight(); 
+
+	void scale(const double& sx1, const double& sx2, const double& sx3);
+
+   void translate(const double& x1, const double& x2, const double& x3) 
+   {
+      this->mLine->translate( x1, x2, x3 );
+      this->calculateValues();
+      //this->notifyObserversObjectChanged();
+   }
+
+   double getX1Centroid() { return centerX1; }
+   double getX1Minimum()  { return minX1;    }
+	double getX1Maximum()  { return maxX1;    }
+	double getX2Centroid() { return centerX2; }
+	double getX2Minimum()  { return minX2;    }
+	double getX2Maximum()  { return maxX2;    }
+	double getX3Centroid() { return centerX3; }
+	double getX3Minimum()  { return minX3;    }
+	double getX3Maximum()  { return maxX3;    }
+
+	bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); 
+	bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); 
+   bool isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+
+	GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2);
+   
+   //SG ausdokumentieren, da der nur unendlcihe Zylinder macht ...
+   //bool hasRaytracing() { return true; }
+   bool hasRaytracing() { return false; }
+   bool raytracingSupportsPointsInside() { return true; }
+   
+   
+   /*|r| must be 1! einheitsvector!!*/
+   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
+
+	std::vector<GbTriangle3D*> getSurfaceTriangleSet();
+   void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles);
+   void addSurfaceTriangleSetSegments(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles, int segmentsRound, int segmentsHeight );
+
+	std::string toString();
+	ObObjectCreator* getCreator();
+	void write(UbFileOutput* out);
+	void read(UbFileInput* in);
+
+	//virtuelle Methoden von UbObserver
+	void objectChanged(UbObservable* changedObject);
+	void objectWillBeDeleted(UbObservable* objectForDeletion);
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void SF_SERIALIZE(Archive & ar)
+   {
+      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
+      ar & mLine;
+      ar & mRad;
+      ar & cylinderType;
+      
+      if( ArchiveTools::isReading(ar) )
+         this->calculateValues();
+   }
+#endif //CAB_RCF
+   
+   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
+
+
+protected:
+   void calculateValues();
+
+   GbLine3D* mLine;
+	double    mRad;
+
+   double minX1, minX2, minX3;
+   double maxX1, maxX2, maxX3;
+   double centerX1, centerX2, centerX3;
+
+	int cylinderType;
+
+	//void berechneQuerschnittsWerte();
+   static const int NOTPARALLELTOAXIS  = (1<<0); //1
+   static const int X1PARALLEL         = (1<<1); //2
+   static const int X2PARALLEL         = (1<<2); //4
+   static const int X3PARALLEL         = (1<<3); //8
+};
+
+#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
+   UB_AUTO_RUN_NAMED(   SF::registerType<GbCylinder3D >("GbCylinder3D")           , SF_GbCylinder3D     );
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbCylinder3D >() ), SF_GbCylinder3D_BD1 );
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbCylinder3D>()  ), SF_GbCylinder3D_BD2 );
+#endif //RCF_USE_SF_SERIALIZATION
+
+#endif   
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbHalfSpace3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbHalfSpace3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbHalfSpace3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbHalfSpace3D.cpp
index 0d1072db51f301511642803e076dcd5afd63a925..cb4ec6c4e41b34f4925552fa2378fe1cb2b81c59 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbHalfSpace3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbHalfSpace3D.cpp
@@ -1,99 +1,99 @@
-#include <numerics/geometry3d/GbHalfSpace3D.h>
-
-using namespace std;
-
-/*==========================================================*/
-GbHalfSpace3D::GbHalfSpace3D(GbTriangle3D* triangle)
-{
-   GbPoint3D* PointA = triangle->getPoint1();
-   GbPoint3D* PointB = triangle->getPoint2();
-   GbPoint3D* PointC = triangle->getPoint3();
-          
-   GbVector3D A(PointA->x1, PointA->x2, PointA->x3 );
-   GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 );
-   GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 );
-   GbVector3D BACA = BA.Cross(CA);
-   //this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize();
-   BACA.Normalize(); 
-   //this->Normal = BACA; 
-   normalX = BACA[0];
-   normalY = BACA[1]; 
-   normalZ = BACA[2]; 
-   //this->d = this->Normal.Dot(A);
-   this->d = normalX*A[0] + normalY*A[1] + normalZ*A[2] ;
-}
-/*==========================================================*/
-GbHalfSpace3D::GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC)
-{
-   GbVector3D A(PointA->x1, PointA->x2, PointA->x3 );
-   GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 );
-   GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 );
-   GbVector3D BACA = BA.Cross(CA);
-	//this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize();
-   BACA.Normalize(); 
-	//this->Normal = BACA; 
-   normalX = BACA[0];
-   normalY = BACA[1]; 
-   normalZ = BACA[2]; 
-   //this->d = this->Normal.Dot(A);
-   this->d = normalX*A[0] + normalY*A[1] + normalZ*A[2] ;
-}
-/*==========================================================*/
-GbHalfSpace3D::GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB)
-{
-   GbVector3D A(PointA->x1, PointA->x2, PointA->x3 );
-   GbVector3D B(PointB->x1, PointB->x2, PointB->x3 );
-	GbVector3D K(0.0,0.0,0.99); // the vector from PointA - third point
-   
-	GbVector3D PointBA = B-A;
-	GbVector3D PointBAK = PointBA.Cross(K);
-   PointBAK.Normalize();
-	
-   //this->Normal = PointBAK;
-   normalX = PointBAK[0];
-   normalY = PointBAK[1]; 
-   normalZ = PointBAK[2]; 
-   
-   //this->d = this->Normal.Dot(A);
-   this->d = normalX*PointA->x1 + normalY*PointA->x2 + normalZ*PointA->x3;
-}
-/*==========================================================*/
-GbHalfSpace3D::GbHalfSpace3D(  const double& p1x, const double& p1y, const double& p1z
-                             , const double& p2x, const double& p2y, const double& p2z
-                             , const double& p3x, const double& p3y, const double& p3z )
-{
-   double p2minusP1x = p2x-p1x;
-   double p2minusP1y = p2y-p1y;
-   double p2minusP1z = p2z-p1z;
-   
-   double P3minusP1x = p3x-p1x;
-   double P3minusP1y = p3y-p1y;
-   double P3minusP1z = p3z-p1z;
-   
-   //normal = BA x CA
-   normalX = p2minusP1y*P3minusP1z - p2minusP1z*P3minusP1y;
-   normalY = p2minusP1z*P3minusP1x - p2minusP1x*P3minusP1z;
-   normalZ = p2minusP1x*P3minusP1y - p2minusP1y*P3minusP1x;
-   
-   //normalize BACA
-   double oneOverNormalLength = 1.0 / ( std::sqrt( normalX*normalX + normalY*normalY + normalZ*normalZ ) );
-   normalX *= oneOverNormalLength;
-   normalY *= oneOverNormalLength;
-   normalZ *= oneOverNormalLength;
-
-   //d = normal * p1
-   this->d = normalX*p1x + normalY*p1y + normalZ*p1z;
-}
-/*==========================================================*/
-GbHalfSpace3D::GbHalfSpace3D( const double& p1x, const double& p1y, const double& p1z,
-                              const double& nx, const double& ny, const double& nz)
-{
-	//normal = BA x CA
-	normalX =nx;
-	normalY =ny;
-	normalZ =nz;
-
-	//d = normal * p1
-	this->d = nx*p1x + ny*p1y + nz*p1z;
-}
-/*==========================================================*/
+#include <numerics/geometry3d/GbHalfSpace3D.h>
+
+using namespace std;
+
+/*==========================================================*/
+GbHalfSpace3D::GbHalfSpace3D(GbTriangle3D* triangle)
+{
+   GbPoint3D* PointA = triangle->getPoint1();
+   GbPoint3D* PointB = triangle->getPoint2();
+   GbPoint3D* PointC = triangle->getPoint3();
+          
+   GbVector3D A(PointA->x1, PointA->x2, PointA->x3 );
+   GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 );
+   GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 );
+   GbVector3D BACA = BA.Cross(CA);
+   //this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize();
+   BACA.Normalize(); 
+   //this->Normal = BACA; 
+   normalX = BACA[0];
+   normalY = BACA[1]; 
+   normalZ = BACA[2]; 
+   //this->d = this->Normal.Dot(A);
+   this->d = normalX*A[0] + normalY*A[1] + normalZ*A[2] ;
+}
+/*==========================================================*/
+GbHalfSpace3D::GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC)
+{
+   GbVector3D A(PointA->x1, PointA->x2, PointA->x3 );
+   GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 );
+   GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 );
+   GbVector3D BACA = BA.Cross(CA);
+	//this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize();
+   BACA.Normalize(); 
+	//this->Normal = BACA; 
+   normalX = BACA[0];
+   normalY = BACA[1]; 
+   normalZ = BACA[2]; 
+   //this->d = this->Normal.Dot(A);
+   this->d = normalX*A[0] + normalY*A[1] + normalZ*A[2] ;
+}
+/*==========================================================*/
+GbHalfSpace3D::GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB)
+{
+   GbVector3D A(PointA->x1, PointA->x2, PointA->x3 );
+   GbVector3D B(PointB->x1, PointB->x2, PointB->x3 );
+	GbVector3D K(0.0,0.0,0.99); // the vector from PointA - third point
+   
+	GbVector3D PointBA = B-A;
+	GbVector3D PointBAK = PointBA.Cross(K);
+   PointBAK.Normalize();
+	
+   //this->Normal = PointBAK;
+   normalX = PointBAK[0];
+   normalY = PointBAK[1]; 
+   normalZ = PointBAK[2]; 
+   
+   //this->d = this->Normal.Dot(A);
+   this->d = normalX*PointA->x1 + normalY*PointA->x2 + normalZ*PointA->x3;
+}
+/*==========================================================*/
+GbHalfSpace3D::GbHalfSpace3D(  const double& p1x, const double& p1y, const double& p1z
+                             , const double& p2x, const double& p2y, const double& p2z
+                             , const double& p3x, const double& p3y, const double& p3z )
+{
+   double p2minusP1x = p2x-p1x;
+   double p2minusP1y = p2y-p1y;
+   double p2minusP1z = p2z-p1z;
+   
+   double P3minusP1x = p3x-p1x;
+   double P3minusP1y = p3y-p1y;
+   double P3minusP1z = p3z-p1z;
+   
+   //normal = BA x CA
+   normalX = p2minusP1y*P3minusP1z - p2minusP1z*P3minusP1y;
+   normalY = p2minusP1z*P3minusP1x - p2minusP1x*P3minusP1z;
+   normalZ = p2minusP1x*P3minusP1y - p2minusP1y*P3minusP1x;
+   
+   //normalize BACA
+   double oneOverNormalLength = 1.0 / ( std::sqrt( normalX*normalX + normalY*normalY + normalZ*normalZ ) );
+   normalX *= oneOverNormalLength;
+   normalY *= oneOverNormalLength;
+   normalZ *= oneOverNormalLength;
+
+   //d = normal * p1
+   this->d = normalX*p1x + normalY*p1y + normalZ*p1z;
+}
+/*==========================================================*/
+GbHalfSpace3D::GbHalfSpace3D( const double& p1x, const double& p1y, const double& p1z,
+                              const double& nx, const double& ny, const double& nz)
+{
+	//normal = BA x CA
+	normalX =nx;
+	normalY =ny;
+	normalZ =nz;
+
+	//d = normal * p1
+	this->d = nx*p1x + ny*p1y + nz*p1z;
+}
+/*==========================================================*/
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbHalfSpace3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbHalfSpace3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbHalfSpace3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbHalfSpace3D.h
index 1e858f841b7ba2e693d07909f6bc54efa754f5c4..4e4dd86ebaeca267aa980c9c456571d06284a6e5 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbHalfSpace3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbHalfSpace3D.h
@@ -1,84 +1,84 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBHALFSPACE3D_H
-#define GBHALFSPACE3D_H
-
-#include <sstream>
-#include <iostream>
-
-#include <basics/utilities/UbMath.h>
-
-#include <numerics/geometry3d/GbPoint3D.h>
-#include <numerics/geometry3d/GbTriangle3D.h>
-#include <numerics/geometry3d/GbVector3D.h>
-
-#include <PointerDefinitions.h>
-
-
-/*=========================================================================*/
-/* GbHalfSpace3D                                                             */
-/*                                                                         */
-/**
-* This Class helps in performing some operations on a halfspace defined by 2 or 3 points
-*/
-
-class GbHalfSpace3D                            
-{
-public:
-   GbHalfSpace3D(GbTriangle3D* triangle);
-
-   GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC);
-
-   GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB);
-
-   GbHalfSpace3D(  const double& p1x, const double& p1y, const double& p1z
-                 , const double& p2x, const double& p2y, const double& p2z
-                 , const double& p3x, const double& p3y, const double& p3z );
-   GbHalfSpace3D( const double& p1x, const double& p1y, const double& p1z,
-                  const double& nx, const double& ny, const double& nz);
-
-   /*=======================================================*/
-   std::string getTypeID() {return "GbHalfSpace3D"; }
-   /*=============================================*/
-   bool ptInside(const double& x, const double& y, const double& z)
-   {
-      return UbMath::greaterEqual( normalX*x + normalY*y + normalZ*z, this->d );
-   }
-   /*=============================================*/
-   bool ptInside(GbPoint3D* pointX)
-   {
-      //GbVector3D X(PointX->x1, PointX->x2, PointX->x3 );
-      //return UbMath::greaterEqual(this->Normal.Dot(X), this->d);      
-      return UbMath::greaterEqual(  normalX*pointX->x1 + normalY*pointX->x2 + normalZ*pointX->x3, this->d );
-   }
-   /*=============================================*/
-   bool ptInside(GbVector3D& x)
-   {
-      //return UbMath::greaterEqual(this->Normal.Dot(X), this->d);
-      return UbMath::greaterEqual(  normalX*x[0] + normalY*x[1] + normalZ*x[2], this->d );
-   }
-   /*=============================================*/
-   double getDistance(const double& x1p, const double& x2p, const double& x3p)
-   {
-      return (normalX*x1p + normalY*x2p + normalZ*x3p) - this->d;
-   }
-
-   const double& getNormalX() { return this->normalX; }
-   const double& getNormalY() { return this->normalY; }
-   const double& getNormalZ() { return this->normalZ; }
-   const double& getD()       { return this->d;       }
-
-private:
-   //GbVector3D Normal;
-   double normalX;
-   double normalY;
-   double normalZ;
-   double d;
-};
-/*=========================================================================*/
-
-#endif //GBHALFSPACE3D_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBHALFSPACE3D_H
+#define GBHALFSPACE3D_H
+
+#include <sstream>
+#include <iostream>
+
+#include <basics/utilities/UbMath.h>
+
+#include <numerics/geometry3d/GbPoint3D.h>
+#include <numerics/geometry3d/GbTriangle3D.h>
+#include <numerics/geometry3d/GbVector3D.h>
+
+#include <PointerDefinitions.h>
+
+
+/*=========================================================================*/
+/* GbHalfSpace3D                                                             */
+/*                                                                         */
+/**
+* This Class helps in performing some operations on a halfspace defined by 2 or 3 points
+*/
+
+class GbHalfSpace3D                            
+{
+public:
+   GbHalfSpace3D(GbTriangle3D* triangle);
+
+   GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC);
+
+   GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB);
+
+   GbHalfSpace3D(  const double& p1x, const double& p1y, const double& p1z
+                 , const double& p2x, const double& p2y, const double& p2z
+                 , const double& p3x, const double& p3y, const double& p3z );
+   GbHalfSpace3D( const double& p1x, const double& p1y, const double& p1z,
+                  const double& nx, const double& ny, const double& nz);
+
+   /*=======================================================*/
+   std::string getTypeID() {return "GbHalfSpace3D"; }
+   /*=============================================*/
+   bool ptInside(const double& x, const double& y, const double& z)
+   {
+      return UbMath::greaterEqual( normalX*x + normalY*y + normalZ*z, this->d );
+   }
+   /*=============================================*/
+   bool ptInside(GbPoint3D* pointX)
+   {
+      //GbVector3D X(PointX->x1, PointX->x2, PointX->x3 );
+      //return UbMath::greaterEqual(this->Normal.Dot(X), this->d);      
+      return UbMath::greaterEqual(  normalX*pointX->x1 + normalY*pointX->x2 + normalZ*pointX->x3, this->d );
+   }
+   /*=============================================*/
+   bool ptInside(GbVector3D& x)
+   {
+      //return UbMath::greaterEqual(this->Normal.Dot(X), this->d);
+      return UbMath::greaterEqual(  normalX*x[0] + normalY*x[1] + normalZ*x[2], this->d );
+   }
+   /*=============================================*/
+   double getDistance(const double& x1p, const double& x2p, const double& x3p)
+   {
+      return (normalX*x1p + normalY*x2p + normalZ*x3p) - this->d;
+   }
+
+   const double& getNormalX() { return this->normalX; }
+   const double& getNormalY() { return this->normalY; }
+   const double& getNormalZ() { return this->normalZ; }
+   const double& getD()       { return this->d;       }
+
+private:
+   //GbVector3D Normal;
+   double normalX;
+   double normalY;
+   double normalZ;
+   double d;
+};
+/*=========================================================================*/
+
+#endif //GBHALFSPACE3D_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbHalfSpaceKrischan3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbHalfSpaceKrischan3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbHalfSpaceKrischan3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbHalfSpaceKrischan3D.cpp
index 0cfb68ce2b7b38091c63869cbf78107798318b70..522f52f0af1e02434c27781e9d53cd2340ca6544 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbHalfSpaceKrischan3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbHalfSpaceKrischan3D.cpp
@@ -1,267 +1,267 @@
-#include <numerics/geometry3d/GbHalfSpaceKrischan3D.h>
-
-using namespace std;
-
-/*==========================================================*/
-GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(GbTriangle3D* triangle)
-{
-   GbPoint3D* PointA = triangle->getPoint1();
-   GbPoint3D* PointB = triangle->getPoint2();
-   GbPoint3D* PointC = triangle->getPoint3();
-          
-   GbVector3D A(PointA->x1, PointA->x2, PointA->x3 );
-   GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 );
-   GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 );
-   GbVector3D BACA = BA.Cross(CA);
-   //this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize();
-   BACA.Normalize(); 
-   this->Normal = BACA; 
-   this->d = this->Normal.Dot(A);
-}
-/*==========================================================*/
-GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC)
-{
-   GbVector3D A(PointA->x1, PointA->x2, PointA->x3 );
-   GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 );
-   GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 );
-   GbVector3D BACA = BA.Cross(CA);
-	//this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize();
-   BACA.Normalize(); 
-	this->Normal = BACA; 
-	this->d = this->Normal.Dot(A);
-}
-/*==========================================================*/
-GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB)
-{
-   GbVector3D A(PointA->x1, PointA->x2, PointA->x3 );
-   GbVector3D B(PointB->x1, PointB->x2, PointB->x3 );
-	GbVector3D K(0.0,0.0,0.99); // the vector from PointA - third point
-   
-	GbVector3D PointBA = B-A;
-	GbVector3D PointBAK = PointBA.Cross(K);
-   PointBAK.Normalize();
-	this->Normal = PointBAK;
-	this->d = this->Normal.Dot(A);
-}
-/*==========================================================*/
-GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(  const double& p1x, const double& p1y, const double& p1z
-                             , const double& p2x, const double& p2y, const double& p2z
-                             , const double& p3x, const double& p3y, const double& p3z )
-{
-   GbVector3D A( p1x, p1y, p1z );
-   GbVector3D BA(p2x-p1x, p2y-p1y, p2z-p1z );
-   GbVector3D CA(p3x-p1x, p3y-p1y, p3z-p1z );
-   GbVector3D BACA = BA.Cross(CA);
-
-   BACA.Normalize(); 
-   this->Normal = BACA; 
-   this->d = this->Normal.Dot(A);
-}
-/*==========================================================*/
-GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(double nx, double ny, double nz, double dist)
-{
-   this->Normal = GbVector3D(nx,ny,nz);
-   this->Normal.Normalize();
-   this->d = dist;
-}
-/*==========================================================*/
-double GbHalfSpaceKrischan3D::getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-{
-
-	double x1 = x1b-x1a;
-   double x2 = x2b-x2a;
-   double x3 = x3b-x3a;
-
-   if( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) )       return 1.0*x1*x2*x3;
-   if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) )   return 0.0;
-
-   double alpha=0.0;
-   double internX1,internX2,internX3;
-
-   for(int x1vers=0;x1vers<2;x1vers++){
-      for(int x2vers=0;x2vers<2;x2vers++){
-         for(int x3vers=0;x3vers<2;x3vers++){
-            internX1 = x1a + (x1b-x1a)*x1vers;
-            internX2 = x2a + (x2b-x2a)*x2vers;
-            internX3 = x3a + (x3b-x3a)*x3vers;
-
-            // if point is INSIDE the halfspace, distance is smaller than zero
-            // --> loop determines the minimum alpha...i.e. the alpha with maximum absolute value for all points INSIDE the halfspace
-            if( UbMath::lessEqual( this->getDistance(internX1,internX2,internX3) , alpha ) )
-               alpha = this->getDistance(internX1,internX2,internX3);
-            //cout<<zelltyp<<" "<<kugel->getDistance(internX1,internX2,internX3)<<" "<<alpha<<endl;
-         }//end first for
-      }//end second for
-   }//end third for
-
-   // PLIC needs alphas > 0.0
-   alpha = (-1)*alpha;
-
-
-
-   double n[3];
-   n[0] = this->Normal[0];
-   n[1] = this->Normal[1];
-   n[2] = this->Normal[2];
-
-   //cout << "Koordinaten:  "<<x1<<" "<<x2<<" "<<x3<<endl;
-   //cout << "Deltas:       "<<deltaX1<<" "<<deltaX2<<" "<<deltaX3<<endl;
-   //cout << "Halbe Zelle:  "<<halfcelldelta<<endl;
-
-   //cout<<"Centroid:  "<<kugel->getX1Centroid()<<" "<<kugel->getX2Centroid()<<" "<<kugel->getX3Centroid()<<endl;
-
-   //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl;
-
-   double normLength;
-   normLength = sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]);
-   n[0] /= normLength;
-   n[1] /= normLength;
-   n[2] /= normLength;
-
-   if( UbMath::less(n[0],0.0) ) n[0] = -n[0];
-   if( UbMath::less(n[1],0.0) ) n[1] = -n[1];
-   if( UbMath::less(n[2],0.0) ) n[2] = -n[2];
-
-   //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl;
-
-   double dummy;
-   if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;}
-   if( UbMath::greater(n[1],n[2])) {dummy=n[2]; n[2]=n[1]; n[1]=dummy;}
-   if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;}
-
-   //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl;
-
-   double n1,n2,n3;
-   n1=n[0];
-   n2=n[1];
-   n3=n[2];
-
-   double preresult=0.0,result=0.0;
-
-   // 1D Check
-   if ( UbMath::lessEqual(n1,0.00001)&&UbMath::lessEqual(n2,0.00001) )
-   {
-      result = alpha * x1 * x2;
-   }                  
-   // 2D Check
-   else if ( UbMath::lessEqual(n1,0.00001) )
-   {
-      preresult = (2*n2*n3);
-      result = (alpha*alpha)/preresult;
-
-      if( UbMath::greater(alpha,n2*x2) )
-      {
-         result += -(alpha-n2*x2)*(alpha-n2*x2)/preresult;
-      }
-      if( UbMath::greater(alpha,n3*x3) )
-      {
-         result += -(alpha-n3*x3)*(alpha-n3*x3)/preresult;
-      }
-      if( UbMath::greater(alpha,n2*x2+n3*x3) )
-      {
-         result += (alpha-n2*x2-n3*x3)*(alpha-n2*x2-n3*x3)/preresult;
-      }
-
-      // tiefenrichtung mit einmultiplizieren...
-      result *= x1;
-   }	
-   // 3D Check
-   else	
-   { 	
-      preresult =6*n1*n2*n3;
-
-      result = alpha*alpha*alpha/preresult;
-
-      if ( UbMath::greater (alpha,n1*x1))
-      {
-         result+=-((alpha-n1*x1)*(alpha-n1*x1)*(alpha-n1*x1))/preresult;
-      }
-      if (UbMath::greater(alpha,n2*x2))
-      {
-         result+=-((alpha-n2*x2)*(alpha-n2*x2)*(alpha-n2*x2))/preresult;
-      }
-      if (UbMath::greater(alpha,n3*x3))
-      {
-         result+=-((alpha-n3*x3)*(alpha-n3*x3)*(alpha-n3*x3))/preresult;
-      }
-      if (UbMath::greater(alpha,(n1*x1+n2*x2)))
-      {
-         result+=((alpha-(n1*x1+n2*x2))*(alpha-(n1*x1+n2*x2))*(alpha-(n1*x1+n2*x2)))/preresult;
-      }
-      if (UbMath::greater(alpha,(n1*x1+n3*x3)))
-      {
-         result+=((alpha-(n1*x1+n3*x3))*(alpha-(n1*x1+n3*x3))*(alpha-(n1*x1+n3*x3)))/preresult;
-      }
-      if (UbMath::greater(alpha,(n2*x2+n3*x3)))
-      {
-         result+=((alpha-(n2*x2+n3*x3))*(alpha-(n2*x2+n3*x3))*(alpha-(n2*x2+n3*x3)))/preresult;
-      }
-
-      //NEW
-      if (UbMath::greater(alpha,(n1*x1+n2*x2+n3*x3)))
-      {
-         result+= -((alpha-(n1*x1+n2*x2+n3*x3))*(alpha-(n1*x1+n2*x2+n3*x3))*(alpha-(n1*x1+n2*x2+n3*x3)))/preresult;
-      }
-
-   }
-
-   if( !UbMath::inClosedInterval( result/ (x1*x2*x3), -0.01, 1.01) )
-   {
-      stringstream errMsg;
-
-      errMsg << "Danger...Fuellstand "<<result<<" nicht im Interfall [0.0..1.0]" << endl;
-      errMsg << "NormVec: " << n1 << " " << n2 << " " << n3 << endl;
-      errMsg << "Cell:    " << x1 << " " << x2 << " " << x3 << endl;
-      errMsg << "Alpha:   " << alpha << endl;
- 
-
-      throw UbException( UB_EXARGS, errMsg.str() );
-   }
-
-   return result;
-
-
-   //double eps=0.0;
-   //if( UbMath::equal(n1,0.0) && UbMath::equal(n2,0.0) )
-   //{
-   //   eps = alpha/n3;
-   //}
-   //else if( UbMath::equal(n1,0.0) )
-   //{
-   //   double dim1,dim2;
-   //   dim1 = alpha/n2;
-   //   dim2 = alpha/n3;
-
-   //   eps = 0.5*dim1*dim2;
-   //   if( UbMath::greater(dim1,1.0) )   eps -= 0.5*(dim1-1.0)*dim2/dim1*(dim1-1.0);
-   //   if( UbMath::greater(dim2,1.0) )   eps -= 0.5*(dim2-1.0)*dim1/dim2*(dim2-1.0);
-   //}
-   //else
-   //{
-   //   eps = alpha*alpha*alpha;
-   //   if( UbMath::greater(alpha,n1) )
-   //      eps -= (alpha-n1)*(alpha-n1)*(alpha-n1);
-   //   if( UbMath::greater(alpha,n2) )
-   //      eps -= (alpha-n2)*(alpha-n2)*(alpha-n2);
-   //   if( UbMath::greater(alpha,n3) )
-   //      eps -= (alpha-n3)*(alpha-n3)*(alpha-n3);
-
-   //   if( UbMath::greater(alpha,n1+n2) )
-   //      eps += (alpha-n1-n2)*(alpha-n1-n2)*(alpha-n1-n2);
-   //   if( UbMath::greater(alpha,n1+n3) )
-   //      eps += (alpha-n1-n3)*(alpha-n1-n3)*(alpha-n1-n3);
-   //   if( UbMath::greater(alpha,n2+n3) )
-   //      eps += (alpha-n2-n3)*(alpha-n2-n3)*(alpha-n2-n3);
-
-   //   //attention: use without delta_i
-   //   eps = eps / (6*n[0]*n[1]*n[2]);
-
-   //   eps = eps / (deltaX1*deltaX2*deltaX3);
-   //}
-
-
-   //return(eps) ;
-   //cout << "alpha ist " << alpha << endl;
-   //cout << "fillLevel ist " << eps << endl;
-}
-/*==========================================================*/
+#include <numerics/geometry3d/GbHalfSpaceKrischan3D.h>
+
+using namespace std;
+
+/*==========================================================*/
+GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(GbTriangle3D* triangle)
+{
+   GbPoint3D* PointA = triangle->getPoint1();
+   GbPoint3D* PointB = triangle->getPoint2();
+   GbPoint3D* PointC = triangle->getPoint3();
+          
+   GbVector3D A(PointA->x1, PointA->x2, PointA->x3 );
+   GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 );
+   GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 );
+   GbVector3D BACA = BA.Cross(CA);
+   //this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize();
+   BACA.Normalize(); 
+   this->Normal = BACA; 
+   this->d = this->Normal.Dot(A);
+}
+/*==========================================================*/
+GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC)
+{
+   GbVector3D A(PointA->x1, PointA->x2, PointA->x3 );
+   GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 );
+   GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 );
+   GbVector3D BACA = BA.Cross(CA);
+	//this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize();
+   BACA.Normalize(); 
+	this->Normal = BACA; 
+	this->d = this->Normal.Dot(A);
+}
+/*==========================================================*/
+GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB)
+{
+   GbVector3D A(PointA->x1, PointA->x2, PointA->x3 );
+   GbVector3D B(PointB->x1, PointB->x2, PointB->x3 );
+	GbVector3D K(0.0,0.0,0.99); // the vector from PointA - third point
+   
+	GbVector3D PointBA = B-A;
+	GbVector3D PointBAK = PointBA.Cross(K);
+   PointBAK.Normalize();
+	this->Normal = PointBAK;
+	this->d = this->Normal.Dot(A);
+}
+/*==========================================================*/
+GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(  const double& p1x, const double& p1y, const double& p1z
+                             , const double& p2x, const double& p2y, const double& p2z
+                             , const double& p3x, const double& p3y, const double& p3z )
+{
+   GbVector3D A( p1x, p1y, p1z );
+   GbVector3D BA(p2x-p1x, p2y-p1y, p2z-p1z );
+   GbVector3D CA(p3x-p1x, p3y-p1y, p3z-p1z );
+   GbVector3D BACA = BA.Cross(CA);
+
+   BACA.Normalize(); 
+   this->Normal = BACA; 
+   this->d = this->Normal.Dot(A);
+}
+/*==========================================================*/
+GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(double nx, double ny, double nz, double dist)
+{
+   this->Normal = GbVector3D(nx,ny,nz);
+   this->Normal.Normalize();
+   this->d = dist;
+}
+/*==========================================================*/
+double GbHalfSpaceKrischan3D::getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+{
+
+	double x1 = x1b-x1a;
+   double x2 = x2b-x2a;
+   double x3 = x3b-x3a;
+
+   if( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) )       return 1.0*x1*x2*x3;
+   if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) )   return 0.0;
+
+   double alpha=0.0;
+   double internX1,internX2,internX3;
+
+   for(int x1vers=0;x1vers<2;x1vers++){
+      for(int x2vers=0;x2vers<2;x2vers++){
+         for(int x3vers=0;x3vers<2;x3vers++){
+            internX1 = x1a + (x1b-x1a)*x1vers;
+            internX2 = x2a + (x2b-x2a)*x2vers;
+            internX3 = x3a + (x3b-x3a)*x3vers;
+
+            // if point is INSIDE the halfspace, distance is smaller than zero
+            // --> loop determines the minimum alpha...i.e. the alpha with maximum absolute value for all points INSIDE the halfspace
+            if( UbMath::lessEqual( this->getDistance(internX1,internX2,internX3) , alpha ) )
+               alpha = this->getDistance(internX1,internX2,internX3);
+            //cout<<zelltyp<<" "<<kugel->getDistance(internX1,internX2,internX3)<<" "<<alpha<<endl;
+         }//end first for
+      }//end second for
+   }//end third for
+
+   // PLIC needs alphas > 0.0
+   alpha = (-1)*alpha;
+
+
+
+   double n[3];
+   n[0] = this->Normal[0];
+   n[1] = this->Normal[1];
+   n[2] = this->Normal[2];
+
+   //cout << "Koordinaten:  "<<x1<<" "<<x2<<" "<<x3<<endl;
+   //cout << "Deltas:       "<<deltaX1<<" "<<deltaX2<<" "<<deltaX3<<endl;
+   //cout << "Halbe Zelle:  "<<halfcelldelta<<endl;
+
+   //cout<<"Centroid:  "<<kugel->getX1Centroid()<<" "<<kugel->getX2Centroid()<<" "<<kugel->getX3Centroid()<<endl;
+
+   //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl;
+
+   double normLength;
+   normLength = sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]);
+   n[0] /= normLength;
+   n[1] /= normLength;
+   n[2] /= normLength;
+
+   if( UbMath::less(n[0],0.0) ) n[0] = -n[0];
+   if( UbMath::less(n[1],0.0) ) n[1] = -n[1];
+   if( UbMath::less(n[2],0.0) ) n[2] = -n[2];
+
+   //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl;
+
+   double dummy;
+   if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;}
+   if( UbMath::greater(n[1],n[2])) {dummy=n[2]; n[2]=n[1]; n[1]=dummy;}
+   if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;}
+
+   //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl;
+
+   double n1,n2,n3;
+   n1=n[0];
+   n2=n[1];
+   n3=n[2];
+
+   double preresult=0.0,result=0.0;
+
+   // 1D Check
+   if ( UbMath::lessEqual(n1,0.00001)&&UbMath::lessEqual(n2,0.00001) )
+   {
+      result = alpha * x1 * x2;
+   }                  
+   // 2D Check
+   else if ( UbMath::lessEqual(n1,0.00001) )
+   {
+      preresult = (2*n2*n3);
+      result = (alpha*alpha)/preresult;
+
+      if( UbMath::greater(alpha,n2*x2) )
+      {
+         result += -(alpha-n2*x2)*(alpha-n2*x2)/preresult;
+      }
+      if( UbMath::greater(alpha,n3*x3) )
+      {
+         result += -(alpha-n3*x3)*(alpha-n3*x3)/preresult;
+      }
+      if( UbMath::greater(alpha,n2*x2+n3*x3) )
+      {
+         result += (alpha-n2*x2-n3*x3)*(alpha-n2*x2-n3*x3)/preresult;
+      }
+
+      // tiefenrichtung mit einmultiplizieren...
+      result *= x1;
+   }	
+   // 3D Check
+   else	
+   { 	
+      preresult =6*n1*n2*n3;
+
+      result = alpha*alpha*alpha/preresult;
+
+      if ( UbMath::greater (alpha,n1*x1))
+      {
+         result+=-((alpha-n1*x1)*(alpha-n1*x1)*(alpha-n1*x1))/preresult;
+      }
+      if (UbMath::greater(alpha,n2*x2))
+      {
+         result+=-((alpha-n2*x2)*(alpha-n2*x2)*(alpha-n2*x2))/preresult;
+      }
+      if (UbMath::greater(alpha,n3*x3))
+      {
+         result+=-((alpha-n3*x3)*(alpha-n3*x3)*(alpha-n3*x3))/preresult;
+      }
+      if (UbMath::greater(alpha,(n1*x1+n2*x2)))
+      {
+         result+=((alpha-(n1*x1+n2*x2))*(alpha-(n1*x1+n2*x2))*(alpha-(n1*x1+n2*x2)))/preresult;
+      }
+      if (UbMath::greater(alpha,(n1*x1+n3*x3)))
+      {
+         result+=((alpha-(n1*x1+n3*x3))*(alpha-(n1*x1+n3*x3))*(alpha-(n1*x1+n3*x3)))/preresult;
+      }
+      if (UbMath::greater(alpha,(n2*x2+n3*x3)))
+      {
+         result+=((alpha-(n2*x2+n3*x3))*(alpha-(n2*x2+n3*x3))*(alpha-(n2*x2+n3*x3)))/preresult;
+      }
+
+      //NEW
+      if (UbMath::greater(alpha,(n1*x1+n2*x2+n3*x3)))
+      {
+         result+= -((alpha-(n1*x1+n2*x2+n3*x3))*(alpha-(n1*x1+n2*x2+n3*x3))*(alpha-(n1*x1+n2*x2+n3*x3)))/preresult;
+      }
+
+   }
+
+   if( !UbMath::inClosedInterval( result/ (x1*x2*x3), -0.01, 1.01) )
+   {
+      stringstream errMsg;
+
+      errMsg << "Danger...Fuellstand "<<result<<" nicht im Interfall [0.0..1.0]" << endl;
+      errMsg << "NormVec: " << n1 << " " << n2 << " " << n3 << endl;
+      errMsg << "Cell:    " << x1 << " " << x2 << " " << x3 << endl;
+      errMsg << "Alpha:   " << alpha << endl;
+ 
+
+      throw UbException( UB_EXARGS, errMsg.str() );
+   }
+
+   return result;
+
+
+   //double eps=0.0;
+   //if( UbMath::equal(n1,0.0) && UbMath::equal(n2,0.0) )
+   //{
+   //   eps = alpha/n3;
+   //}
+   //else if( UbMath::equal(n1,0.0) )
+   //{
+   //   double dim1,dim2;
+   //   dim1 = alpha/n2;
+   //   dim2 = alpha/n3;
+
+   //   eps = 0.5*dim1*dim2;
+   //   if( UbMath::greater(dim1,1.0) )   eps -= 0.5*(dim1-1.0)*dim2/dim1*(dim1-1.0);
+   //   if( UbMath::greater(dim2,1.0) )   eps -= 0.5*(dim2-1.0)*dim1/dim2*(dim2-1.0);
+   //}
+   //else
+   //{
+   //   eps = alpha*alpha*alpha;
+   //   if( UbMath::greater(alpha,n1) )
+   //      eps -= (alpha-n1)*(alpha-n1)*(alpha-n1);
+   //   if( UbMath::greater(alpha,n2) )
+   //      eps -= (alpha-n2)*(alpha-n2)*(alpha-n2);
+   //   if( UbMath::greater(alpha,n3) )
+   //      eps -= (alpha-n3)*(alpha-n3)*(alpha-n3);
+
+   //   if( UbMath::greater(alpha,n1+n2) )
+   //      eps += (alpha-n1-n2)*(alpha-n1-n2)*(alpha-n1-n2);
+   //   if( UbMath::greater(alpha,n1+n3) )
+   //      eps += (alpha-n1-n3)*(alpha-n1-n3)*(alpha-n1-n3);
+   //   if( UbMath::greater(alpha,n2+n3) )
+   //      eps += (alpha-n2-n3)*(alpha-n2-n3)*(alpha-n2-n3);
+
+   //   //attention: use without delta_i
+   //   eps = eps / (6*n[0]*n[1]*n[2]);
+
+   //   eps = eps / (deltaX1*deltaX2*deltaX3);
+   //}
+
+
+   //return(eps) ;
+   //cout << "alpha ist " << alpha << endl;
+   //cout << "fillLevel ist " << eps << endl;
+}
+/*==========================================================*/
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbHalfSpaceKrischan3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbHalfSpaceKrischan3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbHalfSpaceKrischan3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbHalfSpaceKrischan3D.h
index 1765eec1ede944576cd22fdc57d054c4a4cee12f..a9146718bd79bf695023ed1bf3eb248622338477 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbHalfSpaceKrischan3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbHalfSpaceKrischan3D.h
@@ -1,205 +1,205 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GbHalfSpaceKrischan3D_H
-#define GbHalfSpaceKrischan3D_H
-
-#include <sstream>
-#include <iostream>
-
-#include <basics/utilities/UbMath.h>
-
-#include <numerics/geometry3d/GbPoint3D.h>
-#include <numerics/geometry3d/GbTriangle3D.h>
-#include <numerics/geometry3d/GbVector3D.h>
-#include <numerics/geometry3d/GbLine3D.h>
-
-/*=========================================================================*/
-/* GbHalfSpaceKrischan3D                                                             */
-/*                                                                         */
-/**
-* This Class helps in performing some operations on a halfspace defined by 2 or 3 points
-*/
-
-class GbHalfSpaceKrischan3D : public GbObject3D , public UbObserver                           
-{
-public:
-   GbHalfSpaceKrischan3D(GbTriangle3D* triangle);
-
-   GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC);
-   
-   GbHalfSpaceKrischan3D(double nx, double ny, double nz, double dist);
-
-   GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB);
-
-   GbHalfSpaceKrischan3D(  const double& p1x, const double& p1y, const double& p1z
-                 , const double& p2x, const double& p2y, const double& p2z
-                 , const double& p3x, const double& p3y, const double& p3z );
-
-   /*=======================================================*/
-   virtual ~GbHalfSpaceKrischan3D() { }
-   /*=======================================================*/
-   std::string getTypeID() {return "GbHalfSpaceKrischan3D"; }
-   /*=============================================*/
-   bool ptInside(const double& x, const double& y, const double& z)
-   {
-      return UbMath::lessEqual(Normal[0]*x+Normal[1]*y+Normal[2]*z, this->d);
-   }
-   /*=============================================*/
-   bool ptInside(GbPoint3D* PointX)
-   {
-      GbVector3D X(PointX->x1, PointX->x2, PointX->x3 );
-      return UbMath::lessEqual(this->Normal.Dot(X), this->d);      
-   }
-   /*=============================================*/
-   bool ptInside(GbVector3D &X)
-   {
-      return UbMath::lessEqual(this->Normal.Dot(X), this->d);
-   }
-
-   /*=====================================================*/
-   //true, wenn 'in Object' oder 'auf Boundary'!
-   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
-   {
-      return (ptInside(x1p,x2p,x3p));
-   }
-   /*=====================================================*/
-   //true, wenn 'in Object' oder 'auf Boundary'!
-   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
-   {
-      return (ptInside(x1p,x2p,x3p));
-   }
-
-   void finalize(){}
-   ObObjectCreator* getCreator(){ return NULL; }
-
-   double getX1Centroid(){ return      0.0; }
-   double getX1Minimum() { return -99999.0; }
-   double getX1Maximum() { return  99999.0; }
-   double getX2Centroid(){ return      0.0; }
-   double getX2Minimum() { return -99999.0; }
-   double getX2Maximum() { return  99999.0; }
-   double getX3Centroid(){ return      0.0; }
-   double getX3Minimum() { return -99999.0; }
-   double getX3Maximum() { return  99999.0; }
-
-   void write(UbFileOutput* out){}
-   void read(UbFileInput* in){}
-
-   GbLine3D* createClippedLine3D (GbPoint3D &point1, GbPoint3D &point2)
-   {
-	   GbPoint3D *p1 = new GbPoint3D(point1);
-	   GbPoint3D *p2 = new GbPoint3D(point2);
-
-	   GbVector3D p1p2( p2->x1-p1->x1, p2->x2-p1->x2, p2->x3-p1->x3);
-
-	   double dist1 = getDistance( p1->x1,p1->x2,p1->x3 );
-	   double dist2 = getDistance( p2->x1,p2->x2,p2->x3 );
-		   
-	   double totalDist = std::abs(dist1) + std::abs(dist2);
-
-	   // Falls erster Punkt nicht drinliegt
-	   if( !ptInside(p1) )
-	   {
-		   if( !ptInside(p2) ) return NULL;
-
-		   // distance ausrechnen (groesser null)
-		   if( UbMath::less( dist1, 0.0 ) )   throw UbException( UB_EXARGS, "Punkt ausserhalb, aber Distanz kleiner null???" );
-
-		   p1->x1 = p1->x1 + dist1/totalDist*p1p2[0];
-		   p1->x2 = p1->x2 + dist1/totalDist*p1p2[1];
-		   p1->x3 = p1->x3 + dist1/totalDist*p1p2[2];	   
-	   }
-	   // Falls zweiter Punkt nicht drinliegt
-	   if( !ptInside(p2) )
-	   {
-		   if( !ptInside(p1) ) return NULL;
-
-		   // distance ausrechnen (groesser null)
-		   if( UbMath::less( dist2, 0.0 ) )   throw UbException( UB_EXARGS, "Punkt ausserhalb, aber Distanz kleiner null???" );
-
-		   p2->x1 = p2->x1 - dist2/totalDist*p1p2[0];
-		   p2->x2 = p2->x2 - dist2/totalDist*p1p2[1];
-		   p2->x3 = p2->x3 - dist2/totalDist*p1p2[2];	   
-	   }
-
-	   return new GbLine3D(p1,p2);
-   }
- 
-
-   double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-
-   double getDistance(const double& x1p, const double& x2p, const double& x3p)
-   {
-      return (Normal[0]*x1p + Normal[1]*x2p + Normal[2]*x3p) - this->d;
-   }
-
-   void getNormal( double& n1, double& n2, double& n3 )
-   {
-      n1 = this->Normal[0];
-      n2 = this->Normal[1];
-      n3 = this->Normal[2];
-   }
-
-   void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles)
-   {
-	   std::cout << " addSurfaceTriangleSet(): TO BE DONE AND CHECKED ... " << std::endl;
-   }
-
-   std::vector<GbTriangle3D*> getSurfaceTriangleSet()
-   {
-      std::vector<GbTriangle3D*> triangles;
-      GbPoint3D p1( 0.0,0.0,0.0 );
-      GbPoint3D p2( 1.0,0.0,0.0 );
-      GbPoint3D p3( 0.0,1.0,0.0 );
-
-      triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p2),new GbPoint3D(p3)));
-
-      return triangles;
-   }
-
-   void objectChanged(UbObservable* changedObject)
-   {
-      return;
-      
-      //GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject);
-      //if(!line || this->mLine!=line) return;
-      //this->notifyObserversObjectChanged();
-   }
-   /*==========================================================*/
-   void objectWillBeDeleted(UbObservable* objectForDeletion)
-   {
-      return;
-      //if(this->mLine)
-      //{
-      //   UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine);
-      //   if(objectForDeletion == observedObj) { this->mLine = NULL; }
-      //}
-   }
-
-   ObObject*   clone(){ return NULL; };
-
-   std::string toString()
-   { 
-	   std::stringstream temp;
-
-	   temp << "GbHalfSpaceKrischan3D:   ";
-	   temp << " Distance   " << this->d;
-	   temp << " Norm vec   " << this->Normal[0];
-	   temp << " " << this->Normal[1];
-	   temp << " " << this->Normal[2];
-	   
-	   
-	   return temp.str();
-   };
-
-private:
-   GbVector3D Normal;
-   double d;
-};
-/*=========================================================================*/
-
-#endif //GbHalfSpaceKrischan3D_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GbHalfSpaceKrischan3D_H
+#define GbHalfSpaceKrischan3D_H
+
+#include <sstream>
+#include <iostream>
+
+#include <basics/utilities/UbMath.h>
+
+#include <numerics/geometry3d/GbPoint3D.h>
+#include <numerics/geometry3d/GbTriangle3D.h>
+#include <numerics/geometry3d/GbVector3D.h>
+#include <numerics/geometry3d/GbLine3D.h>
+
+/*=========================================================================*/
+/* GbHalfSpaceKrischan3D                                                             */
+/*                                                                         */
+/**
+* This Class helps in performing some operations on a halfspace defined by 2 or 3 points
+*/
+
+class GbHalfSpaceKrischan3D : public GbObject3D , public UbObserver                           
+{
+public:
+   GbHalfSpaceKrischan3D(GbTriangle3D* triangle);
+
+   GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC);
+   
+   GbHalfSpaceKrischan3D(double nx, double ny, double nz, double dist);
+
+   GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB);
+
+   GbHalfSpaceKrischan3D(  const double& p1x, const double& p1y, const double& p1z
+                 , const double& p2x, const double& p2y, const double& p2z
+                 , const double& p3x, const double& p3y, const double& p3z );
+
+   /*=======================================================*/
+   virtual ~GbHalfSpaceKrischan3D() { }
+   /*=======================================================*/
+   std::string getTypeID() {return "GbHalfSpaceKrischan3D"; }
+   /*=============================================*/
+   bool ptInside(const double& x, const double& y, const double& z)
+   {
+      return UbMath::lessEqual(Normal[0]*x+Normal[1]*y+Normal[2]*z, this->d);
+   }
+   /*=============================================*/
+   bool ptInside(GbPoint3D* PointX)
+   {
+      GbVector3D X(PointX->x1, PointX->x2, PointX->x3 );
+      return UbMath::lessEqual(this->Normal.Dot(X), this->d);      
+   }
+   /*=============================================*/
+   bool ptInside(GbVector3D &X)
+   {
+      return UbMath::lessEqual(this->Normal.Dot(X), this->d);
+   }
+
+   /*=====================================================*/
+   //true, wenn 'in Object' oder 'auf Boundary'!
+   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
+   {
+      return (ptInside(x1p,x2p,x3p));
+   }
+   /*=====================================================*/
+   //true, wenn 'in Object' oder 'auf Boundary'!
+   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
+   {
+      return (ptInside(x1p,x2p,x3p));
+   }
+
+   void finalize(){}
+   ObObjectCreator* getCreator(){ return NULL; }
+
+   double getX1Centroid(){ return      0.0; }
+   double getX1Minimum() { return -99999.0; }
+   double getX1Maximum() { return  99999.0; }
+   double getX2Centroid(){ return      0.0; }
+   double getX2Minimum() { return -99999.0; }
+   double getX2Maximum() { return  99999.0; }
+   double getX3Centroid(){ return      0.0; }
+   double getX3Minimum() { return -99999.0; }
+   double getX3Maximum() { return  99999.0; }
+
+   void write(UbFileOutput* out){}
+   void read(UbFileInput* in){}
+
+   GbLine3D* createClippedLine3D (GbPoint3D &point1, GbPoint3D &point2)
+   {
+	   GbPoint3D *p1 = new GbPoint3D(point1);
+	   GbPoint3D *p2 = new GbPoint3D(point2);
+
+	   GbVector3D p1p2( p2->x1-p1->x1, p2->x2-p1->x2, p2->x3-p1->x3);
+
+	   double dist1 = getDistance( p1->x1,p1->x2,p1->x3 );
+	   double dist2 = getDistance( p2->x1,p2->x2,p2->x3 );
+		   
+	   double totalDist = std::abs(dist1) + std::abs(dist2);
+
+	   // Falls erster Punkt nicht drinliegt
+	   if( !ptInside(p1) )
+	   {
+		   if( !ptInside(p2) ) return NULL;
+
+		   // distance ausrechnen (groesser null)
+		   if( UbMath::less( dist1, 0.0 ) )   throw UbException( UB_EXARGS, "Punkt ausserhalb, aber Distanz kleiner null???" );
+
+		   p1->x1 = p1->x1 + dist1/totalDist*p1p2[0];
+		   p1->x2 = p1->x2 + dist1/totalDist*p1p2[1];
+		   p1->x3 = p1->x3 + dist1/totalDist*p1p2[2];	   
+	   }
+	   // Falls zweiter Punkt nicht drinliegt
+	   if( !ptInside(p2) )
+	   {
+		   if( !ptInside(p1) ) return NULL;
+
+		   // distance ausrechnen (groesser null)
+		   if( UbMath::less( dist2, 0.0 ) )   throw UbException( UB_EXARGS, "Punkt ausserhalb, aber Distanz kleiner null???" );
+
+		   p2->x1 = p2->x1 - dist2/totalDist*p1p2[0];
+		   p2->x2 = p2->x2 - dist2/totalDist*p1p2[1];
+		   p2->x3 = p2->x3 - dist2/totalDist*p1p2[2];	   
+	   }
+
+	   return new GbLine3D(p1,p2);
+   }
+ 
+
+   double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+
+   double getDistance(const double& x1p, const double& x2p, const double& x3p)
+   {
+      return (Normal[0]*x1p + Normal[1]*x2p + Normal[2]*x3p) - this->d;
+   }
+
+   void getNormal( double& n1, double& n2, double& n3 )
+   {
+      n1 = this->Normal[0];
+      n2 = this->Normal[1];
+      n3 = this->Normal[2];
+   }
+
+   void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles)
+   {
+	   std::cout << " addSurfaceTriangleSet(): TO BE DONE AND CHECKED ... " << std::endl;
+   }
+
+   std::vector<GbTriangle3D*> getSurfaceTriangleSet()
+   {
+      std::vector<GbTriangle3D*> triangles;
+      GbPoint3D p1( 0.0,0.0,0.0 );
+      GbPoint3D p2( 1.0,0.0,0.0 );
+      GbPoint3D p3( 0.0,1.0,0.0 );
+
+      triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p2),new GbPoint3D(p3)));
+
+      return triangles;
+   }
+
+   void objectChanged(UbObservable* changedObject)
+   {
+      return;
+      
+      //GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject);
+      //if(!line || this->mLine!=line) return;
+      //this->notifyObserversObjectChanged();
+   }
+   /*==========================================================*/
+   void objectWillBeDeleted(UbObservable* objectForDeletion)
+   {
+      return;
+      //if(this->mLine)
+      //{
+      //   UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine);
+      //   if(objectForDeletion == observedObj) { this->mLine = NULL; }
+      //}
+   }
+
+   ObObject*   clone(){ return NULL; };
+
+   std::string toString()
+   { 
+	   std::stringstream temp;
+
+	   temp << "GbHalfSpaceKrischan3D:   ";
+	   temp << " Distance   " << this->d;
+	   temp << " Norm vec   " << this->Normal[0];
+	   temp << " " << this->Normal[1];
+	   temp << " " << this->Normal[2];
+	   
+	   
+	   return temp.str();
+   };
+
+private:
+   GbVector3D Normal;
+   double d;
+};
+/*=========================================================================*/
+
+#endif //GbHalfSpaceKrischan3D_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbLine3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbLine3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbLine3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbLine3D.cpp
index 7cd729d8aca94749f3c92c49c5aec9a8e806f858..cac15fa0591cbb0f1ce57b2fa78afde6fdca7b31 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbLine3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbLine3D.cpp
@@ -1,240 +1,240 @@
-#include <numerics/geometry3d/GbLine3D.h>
-#include <numerics/geometry3d/creator/GbLine3DCreator.h>
-
-#include <numerics/geometry3d/GbSystem3D.h>
-#include <numerics/geometry3d/GbCuboid3D.h>
-#include <numerics/geometry3d/GbTriangle3D.h>
-
-using namespace std;
-
-ObObjectCreator* GbLine3D::getCreator()
-{
-   return GbLine3DCreator::getInstance();
-}
-/*=======================================================*/
-GbLine3D::GbLine3D()
-{
-   p1     = NULL;
-   p2     = NULL;                       
-   length = 0.0;
-}
-/*=======================================================*/
-GbLine3D::GbLine3D(GbPoint3D* point1, GbPoint3D* point2)
-{
-   this->p1 = point1;
-   this->p2 = point2;
-   this->p1->addObserver(this);
-   this->p2->addObserver(this);
-   this->calculateValues();
-}
-/*=======================================================*/
-GbLine3D::GbLine3D(GbLine3D* line)
-{
-   this->p1 = line->p1->clone();            
-   this->p2 = line->p2->clone();
-   this->p1->addObserver(this);
-   this->p2->addObserver(this);
-   this->calculateValues();
-}
-/*=======================================================*/
-GbLine3D::~GbLine3D() 
-{
-   if(this->p1) this->p1->removeObserver(this);
-   if(this->p2) this->p2->removeObserver(this);
-}
-/*=======================================================*/
-void GbLine3D::finalize() 
-{
-   if(this->p1) 
-   {
-      this->p1->removeObserver(this);
-      this->p1->finalize();
-      delete this->p1;
-      this->p1 = NULL;
-   }
-   if(this->p2)
-   {
-      this->p2->removeObserver(this);
-      this->p2->finalize();
-      delete this->p2;
-      this->p2 = NULL;
-   }
-}
-/*=======================================================*/
-vector<GbTriangle3D*> GbLine3D::getSurfaceTriangleSet()
-{
-   vector<GbTriangle3D*> triangles;
-   GbPoint3D p1(getX1Minimum(),getX2Minimum(),getX3Minimum());
-   GbPoint3D p2(getX1Centroid(),getX2Centroid(),getX3Centroid());
-   GbPoint3D p3(getX1Maximum(),getX2Maximum(),getX3Maximum());
- 
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p2),new GbPoint3D(p3)));
-   
-   return triangles;
-}
-/*=======================================================*/
-void GbLine3D::setPoint1(GbPoint3D* point1)
-{ 
-   if(this->p1) this->p1->removeObserver(this);
-   this->p1 = point1;  
-   this->p1->addObserver(this);
-
-   if(this->p1 && this->p2) this->calculateValues(); 
-}
-/*=======================================================*/
-void GbLine3D::setPoint2(GbPoint3D* point2)
-{ 
-   if(this->p2) this->p2->removeObserver(this);
-   this->p2 = point2;  
-   this->p2->addObserver(this);
-
-   if(this->p1 && this->p2) this->calculateValues(); 
-}
-/*=======================================================*/
-void GbLine3D::setPoints(GbPoint3D* point1, GbPoint3D* point2)
-{ 
-   if(this->p1) this->p1->removeObserver(this);
-   if(this->p2) this->p2->removeObserver(this);
-
-   this->p1 = point1; 
-   this->p2 = point2;
-
-   this->p1->addObserver(this);
-   this->p2->addObserver(this);
-
-   this->calculateValues(); 
-}
-/*=======================================================*/
-string GbLine3D::toString()
-{
-   stringstream ss;
-   ss<<"GbLine3D[p1=";
-   ss<<this->p1->toString()<<",p2="<<this->p2->toString()<<",l="<<this->getLength()<<"]";
-   return(ss.str());
-}
-/*=======================================================*/
-GbPoint3D* GbLine3D::calculateIntersectionPoint3D(GbLine3D* line)
-{
-   throw UbException(UB_EXARGS," not implemented");
-   //return(GbSystem::calculateIntersectionPoint3D(*this->p1, *this->p2, *line->p1, *line->p2));
-}
-/*======================================================================*/
-GbLine3D* GbLine3D::createClippedLine3D(GbCuboid3D* cuboid)
-{
-   return GbSystem3D::createClipLine3D(*this->p1, *this->p2, cuboid->getPoint1()->x1, cuboid->getPoint1()->x2, cuboid->getPoint1()->x3, cuboid->getPoint2()->x1, cuboid->getPoint2()->x2, cuboid->getPoint2()->x3);
-}                           
-/*======================================================================*/
-GbLine3D* GbLine3D::createClippedLine3D(GbPoint3D* pA, GbPoint3D* pE)
-{
-   return GbSystem3D::createClipLine3D(*this->p1, *this->p2, pA->x1, pA->x2, pA->x3, pE->x1, pE->x2, pE->x3);
-}
-/*======================================================================*/
-double GbLine3D::getDistance(const GbPoint3D& point)
-{
-   return this->getDistance(point.x1,point.x2,point.x3);
-}
-/*======================================================================*/
-double GbLine3D::getDistance(const double& x1,const double& x2,const double& x3)
-{
-   double dx1 = this->p2->x1 - this->p1->x1;
-   double dx2 = this->p2->x2 - this->p1->x2;
-   double dx3 = this->p2->x3 - this->p1->x3;
-
-   //double vec[3];
-   double a0 = x1 - p1->x1;
-   double a1 = x2 - p1->x2;
-   double a2 = x3 - p1->x3;
-
-   double kreuzProd0 = a1 * dx3 - a2 * dx2;
-   double kreuzProd1 = a2 * dx1 - a0 * dx3;
-   double kreuzProd2 = a0 * dx2 - a1 * dx1;
-
-   return (std::sqrt(kreuzProd0*kreuzProd0+kreuzProd1*kreuzProd1+kreuzProd2*kreuzProd2))/length;
-}
-/*=======================================================*/
-void GbLine3D::calculateValues()
-{
-   double dx1 = this->p2->x1 - this->p1->x1;
-   double dx2 = this->p2->x2 - this->p1->x2;
-   double dx3 = this->p2->x3 - this->p1->x3;
-   this->length = std::sqrt(dx1*dx1+dx2*dx2+dx3*dx3);
-}
-/*==========================================================*/
-void GbLine3D::objectChanged(UbObservable* changedObject)
-{
-   GbPoint3D* point = dynamic_cast<GbPoint3D*>(changedObject);
-   if(!point || (this->p1!=point && this->p2!=point)) return;
-
-   this->calculateValues();
-}
-/*==========================================================*/
-void GbLine3D::objectWillBeDeleted(UbObservable* objectForDeletion)
-{
-   if(this->p1)
-   {
-      UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p1);
-      if(objectForDeletion == observedObj) { this->p1 = NULL; length = 0.0; }
-   }
-   if(this->p2)
-   {
-      UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p2);
-      if(objectForDeletion == observedObj) { this->p2 = NULL; length = 0.0; }
-   }
-   //ACHTUNG: eigentlich muessten in allen methoden von GbLine if abfragen fuer NULL pointer hin... toDo
-}
-/*==========================================================*/
-void GbLine3D::write(UbFileOutput* out) 
-{                                      
-   out->writeString(this->getCreator()->getTypeID());
-   p1->write(out);
-   p2->write(out);
-}
-/*==========================================================*/
-void GbLine3D::read(UbFileInput* in) 
-{  
-   p1 = new GbPoint3D;
-   p2 = new GbPoint3D;
-   in->readString();                                    
-   p1->read(in);
-   p1->addObserver(this);
-   in->readString();                                    
-   p2->read(in);
-   p2->addObserver(this);
-   this->calculateValues();
-}
-/*==========================================================*/
-void GbLine3D::scale(const double& sx1, const double& sx2, const double& sx3)
-{  
-   double p1X1 = this->p1->getX1Coordinate();
-   double p1X2 = this->p1->getX2Coordinate();
-   double p1X3 = this->p1->getX3Coordinate();
-
-   double p2X1 = this->p2->getX1Coordinate();
-   double p2X2 = this->p2->getX2Coordinate();
-   double p2X3 = this->p2->getX3Coordinate();
-
-   double lenX1 = fabs( p1X1 - p2X1 );
-   double lenX2 = fabs( p1X2 - p2X2 );
-   double lenX3 = fabs( p1X3 - p2X3 );
-
-   double deltaX1 = lenX1*sx1 - lenX1;
-   double deltaX2 = lenX2*sx2 - lenX2;
-   double deltaX3 = lenX3*sx3 - lenX3;
-
-   if(p1X1<p2X1) { p1X1 -=  0.5*deltaX1;   p2X1 +=  0.5*deltaX1; }
-   else          { p1X1 +=  0.5*deltaX1;   p2X1 -=  0.5*deltaX1; }
-   if(p1X2<p2X2) { p1X2 -=  0.5*deltaX2;   p2X2 +=  0.5*deltaX2; }
-   else          { p1X2 +=  0.5*deltaX2;   p2X2 -=  0.5*deltaX2; }
-   if(p1X3<p2X3) { p1X3 -=  0.5*deltaX3;   p2X3 +=  0.5*deltaX3; }
-   else          { p1X3 +=  0.5*deltaX3;   p2X3 -=  0.5*deltaX3; }
-
-   this->p1->setCoordinates(p1X1,p1X2,p1X3);
-   this->p2->setCoordinates(p2X1,p2X2,p2X3);
-}
-/*=======================================================*/
-void GbLine3D::translate(const double& tx1, const double& tx2, const double& tx3)
-{  
-   this->p1->translate(tx1, tx2, tx3);
-   this->p2->translate(tx1, tx2, tx3);
-   //this->notifyObserversObjectChanged();
-}
+#include <numerics/geometry3d/GbLine3D.h>
+#include <numerics/geometry3d/creator/GbLine3DCreator.h>
+
+#include <numerics/geometry3d/GbSystem3D.h>
+#include <numerics/geometry3d/GbCuboid3D.h>
+#include <numerics/geometry3d/GbTriangle3D.h>
+
+using namespace std;
+
+ObObjectCreator* GbLine3D::getCreator()
+{
+   return GbLine3DCreator::getInstance();
+}
+/*=======================================================*/
+GbLine3D::GbLine3D()
+{
+   p1     = NULL;
+   p2     = NULL;                       
+   length = 0.0;
+}
+/*=======================================================*/
+GbLine3D::GbLine3D(GbPoint3D* point1, GbPoint3D* point2)
+{
+   this->p1 = point1;
+   this->p2 = point2;
+   this->p1->addObserver(this);
+   this->p2->addObserver(this);
+   this->calculateValues();
+}
+/*=======================================================*/
+GbLine3D::GbLine3D(GbLine3D* line)
+{
+   this->p1 = line->p1->clone();            
+   this->p2 = line->p2->clone();
+   this->p1->addObserver(this);
+   this->p2->addObserver(this);
+   this->calculateValues();
+}
+/*=======================================================*/
+GbLine3D::~GbLine3D() 
+{
+   if(this->p1) this->p1->removeObserver(this);
+   if(this->p2) this->p2->removeObserver(this);
+}
+/*=======================================================*/
+void GbLine3D::finalize() 
+{
+   if(this->p1) 
+   {
+      this->p1->removeObserver(this);
+      this->p1->finalize();
+      delete this->p1;
+      this->p1 = NULL;
+   }
+   if(this->p2)
+   {
+      this->p2->removeObserver(this);
+      this->p2->finalize();
+      delete this->p2;
+      this->p2 = NULL;
+   }
+}
+/*=======================================================*/
+vector<GbTriangle3D*> GbLine3D::getSurfaceTriangleSet()
+{
+   vector<GbTriangle3D*> triangles;
+   GbPoint3D p1(getX1Minimum(),getX2Minimum(),getX3Minimum());
+   GbPoint3D p2(getX1Centroid(),getX2Centroid(),getX3Centroid());
+   GbPoint3D p3(getX1Maximum(),getX2Maximum(),getX3Maximum());
+ 
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p2),new GbPoint3D(p3)));
+   
+   return triangles;
+}
+/*=======================================================*/
+void GbLine3D::setPoint1(GbPoint3D* point1)
+{ 
+   if(this->p1) this->p1->removeObserver(this);
+   this->p1 = point1;  
+   this->p1->addObserver(this);
+
+   if(this->p1 && this->p2) this->calculateValues(); 
+}
+/*=======================================================*/
+void GbLine3D::setPoint2(GbPoint3D* point2)
+{ 
+   if(this->p2) this->p2->removeObserver(this);
+   this->p2 = point2;  
+   this->p2->addObserver(this);
+
+   if(this->p1 && this->p2) this->calculateValues(); 
+}
+/*=======================================================*/
+void GbLine3D::setPoints(GbPoint3D* point1, GbPoint3D* point2)
+{ 
+   if(this->p1) this->p1->removeObserver(this);
+   if(this->p2) this->p2->removeObserver(this);
+
+   this->p1 = point1; 
+   this->p2 = point2;
+
+   this->p1->addObserver(this);
+   this->p2->addObserver(this);
+
+   this->calculateValues(); 
+}
+/*=======================================================*/
+string GbLine3D::toString()
+{
+   stringstream ss;
+   ss<<"GbLine3D[p1=";
+   ss<<this->p1->toString()<<",p2="<<this->p2->toString()<<",l="<<this->getLength()<<"]";
+   return(ss.str());
+}
+/*=======================================================*/
+GbPoint3D* GbLine3D::calculateIntersectionPoint3D(GbLine3D* line)
+{
+   throw UbException(UB_EXARGS," not implemented");
+   //return(GbSystem::calculateIntersectionPoint3D(*this->p1, *this->p2, *line->p1, *line->p2));
+}
+/*======================================================================*/
+GbLine3D* GbLine3D::createClippedLine3D(GbCuboid3D* cuboid)
+{
+   return GbSystem3D::createClipLine3D(*this->p1, *this->p2, cuboid->getPoint1()->x1, cuboid->getPoint1()->x2, cuboid->getPoint1()->x3, cuboid->getPoint2()->x1, cuboid->getPoint2()->x2, cuboid->getPoint2()->x3);
+}                           
+/*======================================================================*/
+GbLine3D* GbLine3D::createClippedLine3D(GbPoint3D* pA, GbPoint3D* pE)
+{
+   return GbSystem3D::createClipLine3D(*this->p1, *this->p2, pA->x1, pA->x2, pA->x3, pE->x1, pE->x2, pE->x3);
+}
+/*======================================================================*/
+double GbLine3D::getDistance(const GbPoint3D& point)
+{
+   return this->getDistance(point.x1,point.x2,point.x3);
+}
+/*======================================================================*/
+double GbLine3D::getDistance(const double& x1,const double& x2,const double& x3)
+{
+   double dx1 = this->p2->x1 - this->p1->x1;
+   double dx2 = this->p2->x2 - this->p1->x2;
+   double dx3 = this->p2->x3 - this->p1->x3;
+
+   //double vec[3];
+   double a0 = x1 - p1->x1;
+   double a1 = x2 - p1->x2;
+   double a2 = x3 - p1->x3;
+
+   double kreuzProd0 = a1 * dx3 - a2 * dx2;
+   double kreuzProd1 = a2 * dx1 - a0 * dx3;
+   double kreuzProd2 = a0 * dx2 - a1 * dx1;
+
+   return (std::sqrt(kreuzProd0*kreuzProd0+kreuzProd1*kreuzProd1+kreuzProd2*kreuzProd2))/length;
+}
+/*=======================================================*/
+void GbLine3D::calculateValues()
+{
+   double dx1 = this->p2->x1 - this->p1->x1;
+   double dx2 = this->p2->x2 - this->p1->x2;
+   double dx3 = this->p2->x3 - this->p1->x3;
+   this->length = std::sqrt(dx1*dx1+dx2*dx2+dx3*dx3);
+}
+/*==========================================================*/
+void GbLine3D::objectChanged(UbObservable* changedObject)
+{
+   GbPoint3D* point = dynamic_cast<GbPoint3D*>(changedObject);
+   if(!point || (this->p1!=point && this->p2!=point)) return;
+
+   this->calculateValues();
+}
+/*==========================================================*/
+void GbLine3D::objectWillBeDeleted(UbObservable* objectForDeletion)
+{
+   if(this->p1)
+   {
+      UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p1);
+      if(objectForDeletion == observedObj) { this->p1 = NULL; length = 0.0; }
+   }
+   if(this->p2)
+   {
+      UbObservable* observedObj = dynamic_cast<UbObservable*>(this->p2);
+      if(objectForDeletion == observedObj) { this->p2 = NULL; length = 0.0; }
+   }
+   //ACHTUNG: eigentlich muessten in allen methoden von GbLine if abfragen fuer NULL pointer hin... toDo
+}
+/*==========================================================*/
+void GbLine3D::write(UbFileOutput* out) 
+{                                      
+   out->writeString(this->getCreator()->getTypeID());
+   p1->write(out);
+   p2->write(out);
+}
+/*==========================================================*/
+void GbLine3D::read(UbFileInput* in) 
+{  
+   p1 = new GbPoint3D;
+   p2 = new GbPoint3D;
+   in->readString();                                    
+   p1->read(in);
+   p1->addObserver(this);
+   in->readString();                                    
+   p2->read(in);
+   p2->addObserver(this);
+   this->calculateValues();
+}
+/*==========================================================*/
+void GbLine3D::scale(const double& sx1, const double& sx2, const double& sx3)
+{  
+   double p1X1 = this->p1->getX1Coordinate();
+   double p1X2 = this->p1->getX2Coordinate();
+   double p1X3 = this->p1->getX3Coordinate();
+
+   double p2X1 = this->p2->getX1Coordinate();
+   double p2X2 = this->p2->getX2Coordinate();
+   double p2X3 = this->p2->getX3Coordinate();
+
+   double lenX1 = fabs( p1X1 - p2X1 );
+   double lenX2 = fabs( p1X2 - p2X2 );
+   double lenX3 = fabs( p1X3 - p2X3 );
+
+   double deltaX1 = lenX1*sx1 - lenX1;
+   double deltaX2 = lenX2*sx2 - lenX2;
+   double deltaX3 = lenX3*sx3 - lenX3;
+
+   if(p1X1<p2X1) { p1X1 -=  0.5*deltaX1;   p2X1 +=  0.5*deltaX1; }
+   else          { p1X1 +=  0.5*deltaX1;   p2X1 -=  0.5*deltaX1; }
+   if(p1X2<p2X2) { p1X2 -=  0.5*deltaX2;   p2X2 +=  0.5*deltaX2; }
+   else          { p1X2 +=  0.5*deltaX2;   p2X2 -=  0.5*deltaX2; }
+   if(p1X3<p2X3) { p1X3 -=  0.5*deltaX3;   p2X3 +=  0.5*deltaX3; }
+   else          { p1X3 +=  0.5*deltaX3;   p2X3 -=  0.5*deltaX3; }
+
+   this->p1->setCoordinates(p1X1,p1X2,p1X3);
+   this->p2->setCoordinates(p2X1,p2X2,p2X3);
+}
+/*=======================================================*/
+void GbLine3D::translate(const double& tx1, const double& tx2, const double& tx3)
+{  
+   this->p1->translate(tx1, tx2, tx3);
+   this->p2->translate(tx1, tx2, tx3);
+   //this->notifyObserversObjectChanged();
+}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbLine3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbLine3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbLine3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbLine3D.h
index d6665e9ba7bf589acf4339bf30562e1163b6bfc8..d338db3e54e3e2a98d653fdc19a14c69ae5487d4 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbLine3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbLine3D.h
@@ -1,136 +1,136 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBLINE3D_H
-#define GBLINE3D_H
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-#include <sstream>
-#include <cmath>
-          
-#include <basics/utilities/UbObserver.h>
-
-#include <numerics/geometry3d/GbObject3D.h>
-#include <numerics/geometry3d/GbPoint3D.h>
-
-class GbCuboid3D;
-class GbObject3DCreator;
-
-#include <PointerDefinitions.h>
-
-
-/*=========================================================================*/
-/* GbLine3D                                                                */
-/*                                                                         */
-/**
- * This Class provides basic 3D line objects.
- * The describing points are observed by 3D line objects.
- * <BR><BR><HR>
-*/
-
-class GbLine3D	: public GbObject3D , public UbObserver
-{
-public:
-   GbLine3D();
-	GbLine3D(GbPoint3D* point1, GbPoint3D* point2);
-	GbLine3D(GbLine3D* line);
-   ~GbLine3D(); 
-
-   GbLine3D* clone() { return new GbLine3D(this); }
-   void finalize();
-
-   void setPoint1(GbPoint3D* point1);
-   void setPoint2(GbPoint3D* point2);
-   void setPoints(GbPoint3D* point1, GbPoint3D* point2);
-
-   void deletePoint1() { if(this->p1) {this->p1->removeObserver(this); delete this->p1; this->p1=NULL;} }
-   void deletePoint2() { if(this->p2) {this->p2->removeObserver(this); delete this->p2; this->p2=NULL;} }
-   void deletePoints() { this->deletePoint1(); this->deletePoint2(); }
-
-   GbPoint3D* getPoint1() { return this->p1; }
-   GbPoint3D* getPoint2() { return this->p2; }    
-   
-   double getLength()     { return(this->length); }
-	
-   double getX1Centroid() { return((this->p1->x1+this->p2->x1)*0.5);}
-   double getX2Centroid() { return((this->p1->x2+this->p2->x2)*0.5); };
-   double getX3Centroid() { return((this->p1->x3+this->p2->x3)*0.5); }
-   
-   double getX1Minimum()  { return(this->p1->x1 < this->p2->x1 ? this->p1->x1 : this->p2->x1); }
-   double getX2Minimum()  { return(this->p1->x2 < this->p2->x2 ? this->p1->x2 : this->p2->x2); }
-   double getX3Minimum()  { return(this->p1->x3 < this->p2->x3 ? this->p1->x3 : this->p2->x3); }
-   
-   double getX1Maximum()  { return(this->p1->x1 > this->p2->x1 ? this->p1->x1 : this->p2->x1); }
-   double getX2Maximum()  { return(this->p1->x2 > this->p2->x2 ? this->p1->x2 : this->p2->x2); }
-   double getX3Maximum()  { return(this->p1->x3 > this->p2->x3 ? this->p1->x3 : this->p2->x3); }
-	                                               
-   void scale(const double& sx1, const double& sx2, const double& sx3);
-   void translate(const double& tx1, const double& tx2, const double& tx3);
-
-   GbPoint3D* calculateIntersectionPoint3D(GbLine3D* line);
-   GbLine3D*  createClippedLine3D(GbCuboid3D* cuboid);
-   GbLine3D*  createClippedLine3D(GbPoint3D* pA, GbPoint3D* pE);
-   
-   double     getDistance(const GbPoint3D& point);
-   double     getDistance(const double& x1,const double& x2,const double& x3);
-
-   std::vector<GbTriangle3D*> getSurfaceTriangleSet();
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3)
-   {
-      throw UbException(UB_EXARGS,"not implemented");
-   }
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)
-   {
-      throw UbException(UB_EXARGS,"not implemented");
-   }
-   bool isCellInsideGbObject3D(const double& x11,const double& x21,const double& x31,const double& x12,const double& x22,const double& x32) { return false; }
-
-   GbLine3D* createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2)
-   {
-      throw UbException(UB_EXARGS,"not implemented");
-   }
-
-   //virtuelle Methoden von UbObserver
-   void objectChanged(UbObservable* changedObject);
-   void objectWillBeDeleted(UbObservable* objectForDeletion);
-
-   std::string toString();
-   ObObjectCreator* getCreator();
-   void write(UbFileOutput* out);
-   void read(UbFileInput* in);
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void SF_SERIALIZE(Archive & ar)
-   {
-      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
-      ar & p1;
-      ar & p2;
-      ar & length;
-      if( ArchiveTools::isReading(ar) ) this->calculateValues();
-   }
-#endif //CAB_RCF
-
-   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
-protected:
-   GbPoint3D* p1;
-	GbPoint3D* p2;
-	double     length;
-
-private:
-   void calculateValues();
-};
-
-#ifdef RCF_USE_SF_SERIALIZATION
-    UB_AUTO_RUN_NAMED(   SF::registerType<GbLine3D>("GbLine3D"), SF_GbLine3D  );
-    UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbLine3D >()), SF_GbLine3D_BD1 );
-    UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbLine3D>() ), SF_GbLine3D_BD2 );
-#endif //RCF_USE_SF_SERIALIZATION
-
-#endif
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBLINE3D_H
+#define GBLINE3D_H
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+#include <sstream>
+#include <cmath>
+          
+#include <basics/utilities/UbObserver.h>
+
+#include <numerics/geometry3d/GbObject3D.h>
+#include <numerics/geometry3d/GbPoint3D.h>
+
+class GbCuboid3D;
+class GbObject3DCreator;
+
+#include <PointerDefinitions.h>
+
+
+/*=========================================================================*/
+/* GbLine3D                                                                */
+/*                                                                         */
+/**
+ * This Class provides basic 3D line objects.
+ * The describing points are observed by 3D line objects.
+ * <BR><BR><HR>
+*/
+
+class GbLine3D	: public GbObject3D , public UbObserver
+{
+public:
+   GbLine3D();
+	GbLine3D(GbPoint3D* point1, GbPoint3D* point2);
+	GbLine3D(GbLine3D* line);
+   ~GbLine3D(); 
+
+   GbLine3D* clone() { return new GbLine3D(this); }
+   void finalize();
+
+   void setPoint1(GbPoint3D* point1);
+   void setPoint2(GbPoint3D* point2);
+   void setPoints(GbPoint3D* point1, GbPoint3D* point2);
+
+   void deletePoint1() { if(this->p1) {this->p1->removeObserver(this); delete this->p1; this->p1=NULL;} }
+   void deletePoint2() { if(this->p2) {this->p2->removeObserver(this); delete this->p2; this->p2=NULL;} }
+   void deletePoints() { this->deletePoint1(); this->deletePoint2(); }
+
+   GbPoint3D* getPoint1() { return this->p1; }
+   GbPoint3D* getPoint2() { return this->p2; }    
+   
+   double getLength()     { return(this->length); }
+	
+   double getX1Centroid() { return((this->p1->x1+this->p2->x1)*0.5);}
+   double getX2Centroid() { return((this->p1->x2+this->p2->x2)*0.5); };
+   double getX3Centroid() { return((this->p1->x3+this->p2->x3)*0.5); }
+   
+   double getX1Minimum()  { return(this->p1->x1 < this->p2->x1 ? this->p1->x1 : this->p2->x1); }
+   double getX2Minimum()  { return(this->p1->x2 < this->p2->x2 ? this->p1->x2 : this->p2->x2); }
+   double getX3Minimum()  { return(this->p1->x3 < this->p2->x3 ? this->p1->x3 : this->p2->x3); }
+   
+   double getX1Maximum()  { return(this->p1->x1 > this->p2->x1 ? this->p1->x1 : this->p2->x1); }
+   double getX2Maximum()  { return(this->p1->x2 > this->p2->x2 ? this->p1->x2 : this->p2->x2); }
+   double getX3Maximum()  { return(this->p1->x3 > this->p2->x3 ? this->p1->x3 : this->p2->x3); }
+	                                               
+   void scale(const double& sx1, const double& sx2, const double& sx3);
+   void translate(const double& tx1, const double& tx2, const double& tx3);
+
+   GbPoint3D* calculateIntersectionPoint3D(GbLine3D* line);
+   GbLine3D*  createClippedLine3D(GbCuboid3D* cuboid);
+   GbLine3D*  createClippedLine3D(GbPoint3D* pA, GbPoint3D* pE);
+   
+   double     getDistance(const GbPoint3D& point);
+   double     getDistance(const double& x1,const double& x2,const double& x3);
+
+   std::vector<GbTriangle3D*> getSurfaceTriangleSet();
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3)
+   {
+      throw UbException(UB_EXARGS,"not implemented");
+   }
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)
+   {
+      throw UbException(UB_EXARGS,"not implemented");
+   }
+   bool isCellInsideGbObject3D(const double& x11,const double& x21,const double& x31,const double& x12,const double& x22,const double& x32) { return false; }
+
+   GbLine3D* createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2)
+   {
+      throw UbException(UB_EXARGS,"not implemented");
+   }
+
+   //virtuelle Methoden von UbObserver
+   void objectChanged(UbObservable* changedObject);
+   void objectWillBeDeleted(UbObservable* objectForDeletion);
+
+   std::string toString();
+   ObObjectCreator* getCreator();
+   void write(UbFileOutput* out);
+   void read(UbFileInput* in);
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void SF_SERIALIZE(Archive & ar)
+   {
+      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
+      ar & p1;
+      ar & p2;
+      ar & length;
+      if( ArchiveTools::isReading(ar) ) this->calculateValues();
+   }
+#endif //CAB_RCF
+
+   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
+protected:
+   GbPoint3D* p1;
+	GbPoint3D* p2;
+	double     length;
+
+private:
+   void calculateValues();
+};
+
+#ifdef RCF_USE_SF_SERIALIZATION
+    UB_AUTO_RUN_NAMED(   SF::registerType<GbLine3D>("GbLine3D"), SF_GbLine3D  );
+    UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbLine3D >()), SF_GbLine3D_BD1 );
+    UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbLine3D>() ), SF_GbLine3D_BD2 );
+#endif //RCF_USE_SF_SERIALIZATION
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbMeshTools3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbMeshTools3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbMeshTools3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbMeshTools3D.h
index e5430ca9af27c461d2ac7eabb1f10c47b0f9917f..9805e33a6b57ec89b9bf62300cfa247616016c09 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbMeshTools3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbMeshTools3D.h
@@ -1,402 +1,402 @@
-#ifndef GBMESHTOOLS3D_H
-#define GBMESHTOOLS3D_H
-
-#include <sstream>
-#include <iostream>
-#include <vector>
-
-#include <basics/utilities/UbMath.h>
-
-namespace GbMeshTools3D
-{
-   inline int planeBoxOverlap(float normal[3], float vert[3], float maxbox[3])	// -NJMP-
-   {
-      int q;
-      float vmin[3],vmax[3],v;
-
-      for(q=0;q<=2;q++)
-      {
-         v=vert[q];					// -NJMP-
-         if(normal[q]>0.0f)
-         {
-            vmin[q]=-maxbox[q] - v;	// -NJMP-
-            vmax[q]= maxbox[q] - v;	// -NJMP-
-         }
-         else
-         {
-            vmin[q]= maxbox[q] - v;	// -NJMP-
-            vmax[q]=-maxbox[q] - v;	// -NJMP-
-         }
-      }
-      if(( normal[0]*vmin[0] + normal[1]*vmin[1] + normal[2]*vmin[2] )>0.0f ) return 0;	// -NJMP-
-      if(( normal[0]*vmax[0] + normal[1]*vmax[1] + normal[2]*vmax[2] )>=0.0f) return 1;	// -NJMP-
-      return 0;
-   }
-
-   //Testet auf schnittpunkt Box <-> Dreieck
-   //boxcenter   = Mittelpunkt der Box
-   //boxhalfsize = Halbe Laenge/Hoehe/Breite der Box
-   //triverts    = Koordinaten der Deickspunkte 
-   inline int triBoxOverlap(float boxcenter[3],float boxhalfsize[3],float triverts[3][3])
-   {
-      /*    use separating axis theorem to test overlap between triangle and box */
-      /*    need to test for overlap in these directions: */
-      /*    1) the {x,y,z}-directions (actually, since we use the AABB of the triangle */
-      /*       we do not even need to test these) */
-      /*    2) normal of the triangle */
-      /*    3) crossproduct(edge from tri, {x,y,z}-directin) */
-      /*       this gives 3x3=9 more tests */
-
-      float v0[3],v1[3],v2[3];
-
-      //   float axis[3];
-
-      float min,max,p0,p1,p2,rad,fex,fey,fez;		// -NJMP- "d" local variable removed
-      float normal[3],e0[3],e1[3],e2[3];
-
-      /* This is the fastest branch on Sun */
-      /* move everything so that the boxcenter is in (0,0,0) */
-      //SUB(v0,triverts[0],boxcenter);
-      //#define SUB(dest,v1,v2) 
-      v0[0]=triverts[0][0]-boxcenter[0]; 
-      v0[1]=triverts[0][1]-boxcenter[1]; 
-      v0[2]=triverts[0][2]-boxcenter[2]; 
-
-      //SUB(v1,triverts[1],boxcenter);
-      //#define SUB(dest,v1,v2) 
-      v1[0]=triverts[1][0]-boxcenter[0]; 
-      v1[1]=triverts[1][1]-boxcenter[1]; 
-      v1[2]=triverts[1][2]-boxcenter[2]; 
-
-      //SUB(v2,triverts[2],boxcenter);
-      //#define SUB(dest,v1,v2) 
-      v2[0]=triverts[2][0]-boxcenter[0]; 
-      v2[1]=triverts[2][1]-boxcenter[1]; 
-      v2[2]=triverts[2][2]-boxcenter[2]; 
-
-      /* compute triangle edges */
-      //SUB(e0,v1,v0);      /* tri edge 0 */
-      //#define SUB(dest,v1,v2) 
-      e0[0]=v1[0]-v0[0]; 
-      e0[1]=v1[1]-v0[1]; 
-      e0[2]=v1[2]-v0[2]; 
-
-      //SUB(e1,v2,v1);      /* tri edge 1 */
-      //#define SUB(dest,v1,v2) 
-      e1[0]=v2[0]-v1[0]; 
-      e1[1]=v2[1]-v1[1]; 
-      e1[2]=v2[2]-v1[2]; 
-
-      //SUB(e2,v0,v2);      /* tri edge 2 */
-      //#define SUB(dest,v1,v2) 
-      e2[0]=v0[0]-v2[0]; 
-      e2[1]=v0[1]-v2[1]; 
-      e2[2]=v0[2]-v2[2]; 
-
-      /* Bullet 3:  */
-      /*  test the 9 tests first (this was faster) */
-      fex = fabsf(e0[0]);
-      fey = fabsf(e0[1]);
-      fez = fabsf(e0[2]);
-
-      //AXISTEST_X01(e0[2], e0[1], fez, fey);
-      //#define AXISTEST_X01(a, b, fa, fb)			
-      p0 = e0[2]*v0[1] - e0[1]*v0[2];			       	   
-      p2 = e0[2]*v2[1] - e0[1]*v2[2];			       	   
-      if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} 
-      rad = fez * boxhalfsize[1] + fey * boxhalfsize[2];   
-      if(min>rad || max<-rad) return 0;
-
-      //AXISTEST_Y02(e0[2], e0[0], fez, fex);
-      //#define AXISTEST_Y02(a, b, fa, fb)			
-      p0 = -e0[2]*v0[0] + e0[0]*v0[2];		      	   
-      p2 = -e0[2]*v2[0] + e0[0]*v2[2];	       	       	   
-      if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} 
-      rad = fez * boxhalfsize[0] + fex * boxhalfsize[2];  
-      if(min>rad || max<-rad) return 0;
-
-      //AXISTEST_Z12(e0[1], e0[0], fey, fex);
-      //#define AXISTEST_Z12(a, b, fa, fb)		
-      p1 = e0[1]*v1[0] - e0[0]*v1[1];			           
-      p2 = e0[1]*v2[0] - e0[0]*v2[1];			       	   
-      if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} 
-      rad = fey * boxhalfsize[0] + fex * boxhalfsize[1];   
-      if(min>rad || max<-rad) return 0;
-      
-      fex = fabsf(e1[0]);
-      fey = fabsf(e1[1]);
-      fez = fabsf(e1[2]);
-
-      //AXISTEST_X01(e1[2], e1[1], fez, fey);
-      //#define AXISTEST_X01(a, b, fa, fb)			
-      p0 = e1[2]*v0[1] - e1[1]*v0[2];			       	   
-      p2 = e1[2]*v2[1] - e1[1]*v2[2];			       	   
-      if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} 
-      rad = fez * boxhalfsize[1] + fey * boxhalfsize[2];   
-      if(min>rad || max<-rad) return 0;
-      
-      //AXISTEST_Y02(e1[2], e1[0], fez, fex);
-      //#define AXISTEST_Y02(a, b, fa, fb)			
-      p0 = -e1[2]*v0[0] + e1[0]*v0[2];		      	   
-      p2 = -e1[2]*v2[0] + e1[0]*v2[2];	       	       	   
-      if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} 
-      rad = fez * boxhalfsize[0] + fex * boxhalfsize[2];   
-      if(min>rad || max<-rad) return 0;
-
-      //AXISTEST_Z0(e1[1], e1[0], fey, fex);
-      //#define AXISTEST_Z0(a, b, fa, fb)	
-      p0 = e1[1]*v0[0] - e1[0]*v0[1];				  
-      p1 = e1[1]*v1[0] - e1[0]*v1[1];			          
-      if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} 
-      rad = fey * boxhalfsize[0] + fex * boxhalfsize[2];   
-      if(min>rad || max<-rad) return 0;
-
-      fex = fabsf(e2[0]);
-      fey = fabsf(e2[1]);
-      fez = fabsf(e2[2]);
-      //AXISTEST_X2(e2[2], e2[1], fez, fey);
-      //#define AXISTEST_X2(a, b, fa, fb)			
-      p0 = e2[2]*v0[1] - e2[1]*v0[2];			           
-      p1 = e2[2]*v1[1] - e2[1]*v1[2];			       	   
-      if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} 
-      rad = fez * boxhalfsize[1] + fey * boxhalfsize[2];  
-      if(min>rad || max<-rad) return 0;
-      
-      //AXISTEST_Y1(e2[2], e2[0], fez, fex);
-      //#define AXISTEST_Y1(a, b, fa, fb)			
-      p0 = -e2[2]*v0[0] + e2[0]*v0[2];		      	  
-      p1 = -e2[2]*v1[0] + e2[0]*v1[2];	     	       	   
-      if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} 
-      rad = fez * boxhalfsize[0] + fex * boxhalfsize[2];   
-      if(min>rad || max<-rad) return 0;
-      
-      //AXISTEST_Z12(e2[1], e2[0], fey, fex);
-      //#define AXISTEST_Z12(a, b, fa, fb)		
-      p1 = e2[1]*v1[0] - e2[0]*v1[1];			           
-      p2 = e2[1]*v2[0] - e2[0]*v2[1];			       	   
-      if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} 
-      rad = fey * boxhalfsize[0] + fex * boxhalfsize[1];   
-      if(min>rad || max<-rad) return 0;
-   
-      /* Bullet 1: */
-      /*  first test overlap in the {x,y,z}-directions */
-      /*  find min, max of the triangle each direction, and test for overlap in */
-      /*  that direction -- this is equivalent to testing a minimal AABB around */
-      /*  the triangle against the AABB */
-      /* test in X-direction */
-      //FINDMINMAX(v0[0],v1[0],v2[0],min,max);
-      min = (float)UbMath::min(v0[0],v1[0],v2[0]);
-      max = (float)UbMath::max(v0[0],v1[0],v2[0]);
-      if(min>boxhalfsize[0] || max<-boxhalfsize[0]) return 0;
-
-      /* test in Y-direction */
-      //FINDMINMAX(v0[1],v1[1],v2[1],min,max);
-      min = (float)UbMath::min(v0[1],v1[1],v2[1]);
-      max = (float)UbMath::max(v0[1],v1[1],v2[1]);
-      if(min>boxhalfsize[1] || max<-boxhalfsize[1]) return 0;
-
-      /* test in Z-direction */
-      //FINDMINMAX(v0[2],v1[2],v2[2],min,max);
-      min = (float)UbMath::min(v0[2],v1[2],v2[2]);
-      max = (float)UbMath::max(v0[2],v1[2],v2[2]);
-
-      if(min>boxhalfsize[2] || max<-boxhalfsize[2]) return 0;
-
-      /* Bullet 2: */
-      /*  test if the box intersects the plane of the triangle */
-      /*  compute plane equation of triangle: normal*x+d=0 */
-      //CROSS(normal,e0,e1);
-      //#define CROSS(dest,v1,v2) 
-      normal[0]=e0[1]*e1[2]-e0[2]*e1[1]; 
-      normal[1]=e0[2]*e1[0]-e0[0]*e1[2]; 
-      normal[2]=e0[0]*e1[1]-e0[1]*e1[0]; 
-
-      // -NJMP- (line removed here)
-      if(!planeBoxOverlap(normal,v0,boxhalfsize)) return 0;	// -NJMP-
-      return 1;   /* box and triangle overlaps */
-   }
-
-
- 
-};
-
-#endif
-
-//original - NICHT LOESCHEN - von kroete lynn
-
-//#define X 0
-//#define Y 1
-//#define Z 2
-//
-//#define CROSS(dest,v1,v2) 
-//   dest[0]=v1[1]*v2[2]-v1[2]*v2[1]; 
-//   dest[1]=v1[2]*v2[0]-v1[0]*v2[2]; 
-//   dest[2]=v1[0]*v2[1]-v1[1]*v2[0]; 
-//
-//#define DOT(v1,v2) (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2])
-//
-//#define SUB(dest,v1,v2) 
-//   dest[0]=v1[0]-v2[0]; 
-//   dest[1]=v1[1]-v2[1]; 
-//   dest[2]=v1[2]-v2[2]; 
-//
-//#define FINDMINMAX(x0,x1,x2,min,max) 
-//   min = max = x0;   
-//   if(x1<min) min=x1;
-//   if(x1>max) max=x1;
-//   if(x2<min) min=x2;
-//   if(x2>max) max=x2;
-//
-//int planeBoxOverlap(float normal[3], float vert[3], float maxbox[3])	// -NJMP-
-//{
-//   int q;
-//   float vmin[3],vmax[3],v;
-//
-//   for(q=X;q<=Z;q++)
-//   {
-//      v=vert[q];					// -NJMP-
-//      if(normal[q]>0.0f)
-//      {
-//         vmin[q]=-maxbox[q] - v;	// -NJMP-
-//         vmax[q]= maxbox[q] - v;	// -NJMP-
-//      }
-//      else
-//      {
-//         vmin[q]= maxbox[q] - v;	// -NJMP-
-//         vmax[q]=-maxbox[q] - v;	// -NJMP-
-//      }
-//   }
-//   if(DOT(normal,vmin)>0.0f) return 0;	// -NJMP-
-//   if(DOT(normal,vmax)>=0.0f) return 1;	// -NJMP-
-//   return 0;
-//}
-//
-///*======================== X-tests ========================
-//
-//#define AXISTEST_X01(a, b, fa, fb)			   
-//   p0 = a*v0[Y] - b*v0[Z];			       	   
-//   p2 = a*v2[Y] - b*v2[Z];			       	   
-//      if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} 
-//   rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z];   
-//   if(min>rad || max<-rad) return 0;
-//
-//#define AXISTEST_X2(a, b, fa, fb)			   
-//   p0 = a*v0[Y] - b*v0[Z];			          
-//   p1 = a*v1[Y] - b*v1[Z];			       	   
-//      if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} 
-//   rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z];   
-//   if(min>rad || max<-rad) return 0;
-//
-//
-//
-///*======================== Y-tests ========================
-//
-//#define AXISTEST_Y02(a, b, fa, fb)			   
-//   p0 = -a*v0[X] + b*v0[Z];		      	   
-//   p2 = -a*v2[X] + b*v2[Z];	       	       	   
-//   if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} 
-//   rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z];   
-//   if(min>rad || max<-rad) return 0;
-//
-//#define AXISTEST_Y1(a, b, fa, fb)			   
-//   p0 = -a*v0[X] + b*v0[Z];		      	   
-//   p1 = -a*v1[X] + b*v1[Z];	     	       	   
-//      if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} 
-//   rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z];   
-//   if(min>rad || max<-rad) return 0;
-//
-//======================== Z-tests ========================
-//
-//#define AXISTEST_Z12(a, b, fa, fb)			   
-//   p1 = a*v1[X] - b*v1[Y];			           
-//   p2 = a*v2[X] - b*v2[Y];			       	   
-//      if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} 
-//   rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y];   
-//   if(min>rad || max<-rad) return 0;
-//
-//#define AXISTEST_Z0(a, b, fa, fb)			   
-//   p0 = a*v0[X] - b*v0[Y];				   
-//   p1 = a*v1[X] - b*v1[Y];			           
-//      if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;}
-//   rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y];   
-//   if(min>rad || max<-rad) return 0;
-//
-//int triBoxOverlap(float boxcenter[3],float boxhalfsize[3],float triverts[3][3])
-//{
-//      //use separating axis theorem to test overlap between triangle and box 
-//      //need to test for overlap in these directions: 
-//      //1) the {x,y,z}-directions (actually, since we use the AABB of the triangle 
-//      //   we do not even need to test these) 
-//      //2) normal of the triangle 
-//      //3) crossproduct(edge from tri, {x,y,z}-directin) 
-//      //   this gives 3x3=9 more tests 
-//
-//   float v0[3],v1[3],v2[3];
-//
-//   //   float axis[3];
-//
-//   float min,max,p0,p1,p2,rad,fex,fey,fez;		// -NJMP- "d" local variable removed
-//   float normal[3],e0[3],e1[3],e2[3];
-//
-//   /* This is the fastest branch on Sun */
-//   /* move everything so that the boxcenter is in (0,0,0) */
-//   SUB(v0,triverts[0],boxcenter);
-//   SUB(v1,triverts[1],boxcenter);
-//   SUB(v2,triverts[2],boxcenter);
-//
-//   /* compute triangle edges */
-//   SUB(e0,v1,v0);      /* tri edge 0 */
-//   SUB(e1,v2,v1);      /* tri edge 1 */
-//   SUB(e2,v0,v2);      /* tri edge 2 */
-//
-//   /* Bullet 3:  */
-//   /*  test the 9 tests first (this was faster) */
-//   fex = fabsf(e0[X]);
-//   fey = fabsf(e0[Y]);
-//   fez = fabsf(e0[Z]);
-//
-//   AXISTEST_X01(e0[Z], e0[Y], fez, fey);
-//   AXISTEST_Y02(e0[Z], e0[X], fez, fex);
-//   AXISTEST_Z12(e0[Y], e0[X], fey, fex);
-//   fex = fabsf(e1[X]);
-//   fey = fabsf(e1[Y]);
-//   fez = fabsf(e1[Z]);
-//
-//   AXISTEST_X01(e1[Z], e1[Y], fez, fey);
-//   AXISTEST_Y02(e1[Z], e1[X], fez, fex);
-//   AXISTEST_Z0(e1[Y], e1[X], fey, fex);
-//
-//   fex = fabsf(e2[X]);
-//   fey = fabsf(e2[Y]);
-//   fez = fabsf(e2[Z]);
-//   AXISTEST_X2(e2[Z], e2[Y], fez, fey);
-//   AXISTEST_Y1(e2[Z], e2[X], fez, fex);
-//   AXISTEST_Z12(e2[Y], e2[X], fey, fex);
-//
-//   /* Bullet 1: */
-//   /*  first test overlap in the {x,y,z}-directions */
-//   /*  find min, max of the triangle each direction, and test for overlap in */
-//   /*  that direction -- this is equivalent to testing a minimal AABB around */
-//   /*  the triangle against the AABB */
-//   /* test in X-direction */
-//   FINDMINMAX(v0[X],v1[X],v2[X],min,max);
-//   if(min>boxhalfsize[X] || max<-boxhalfsize[X]) return 0;
-//
-//   /* test in Y-direction */
-//   FINDMINMAX(v0[Y],v1[Y],v2[Y],min,max);
-//   if(min>boxhalfsize[Y] || max<-boxhalfsize[Y]) return 0;
-//
-//   /* test in Z-direction */
-//   FINDMINMAX(v0[Z],v1[Z],v2[Z],min,max);
-//   if(min>boxhalfsize[Z] || max<-boxhalfsize[Z]) return 0;
-//
-//   /* Bullet 2: */
-//   /*  test if the box intersects the plane of the triangle */
-//   /*  compute plane equation of triangle: normal*x+d=0 */
-//   CROSS(normal,e0,e1);
-//
-//   // -NJMP- (line removed here)
-//   if(!planeBoxOverlap(normal,v0,boxhalfsize)) return 0;	// -NJMP-
-//   return 1;   /* box and triangle overlaps */
-//}
-
+#ifndef GBMESHTOOLS3D_H
+#define GBMESHTOOLS3D_H
+
+#include <sstream>
+#include <iostream>
+#include <vector>
+
+#include <basics/utilities/UbMath.h>
+
+namespace GbMeshTools3D
+{
+   inline int planeBoxOverlap(float normal[3], float vert[3], float maxbox[3])	// -NJMP-
+   {
+      int q;
+      float vmin[3],vmax[3],v;
+
+      for(q=0;q<=2;q++)
+      {
+         v=vert[q];					// -NJMP-
+         if(normal[q]>0.0f)
+         {
+            vmin[q]=-maxbox[q] - v;	// -NJMP-
+            vmax[q]= maxbox[q] - v;	// -NJMP-
+         }
+         else
+         {
+            vmin[q]= maxbox[q] - v;	// -NJMP-
+            vmax[q]=-maxbox[q] - v;	// -NJMP-
+         }
+      }
+      if(( normal[0]*vmin[0] + normal[1]*vmin[1] + normal[2]*vmin[2] )>0.0f ) return 0;	// -NJMP-
+      if(( normal[0]*vmax[0] + normal[1]*vmax[1] + normal[2]*vmax[2] )>=0.0f) return 1;	// -NJMP-
+      return 0;
+   }
+
+   //Testet auf schnittpunkt Box <-> Dreieck
+   //boxcenter   = Mittelpunkt der Box
+   //boxhalfsize = Halbe Laenge/Hoehe/Breite der Box
+   //triverts    = Koordinaten der Deickspunkte 
+   inline int triBoxOverlap(float boxcenter[3],float boxhalfsize[3],float triverts[3][3])
+   {
+      /*    use separating axis theorem to test overlap between triangle and box */
+      /*    need to test for overlap in these directions: */
+      /*    1) the {x,y,z}-directions (actually, since we use the AABB of the triangle */
+      /*       we do not even need to test these) */
+      /*    2) normal of the triangle */
+      /*    3) crossproduct(edge from tri, {x,y,z}-directin) */
+      /*       this gives 3x3=9 more tests */
+
+      float v0[3],v1[3],v2[3];
+
+      //   float axis[3];
+
+      float min,max,p0,p1,p2,rad,fex,fey,fez;		// -NJMP- "d" local variable removed
+      float normal[3],e0[3],e1[3],e2[3];
+
+      /* This is the fastest branch on Sun */
+      /* move everything so that the boxcenter is in (0,0,0) */
+      //SUB(v0,triverts[0],boxcenter);
+      //#define SUB(dest,v1,v2) 
+      v0[0]=triverts[0][0]-boxcenter[0]; 
+      v0[1]=triverts[0][1]-boxcenter[1]; 
+      v0[2]=triverts[0][2]-boxcenter[2]; 
+
+      //SUB(v1,triverts[1],boxcenter);
+      //#define SUB(dest,v1,v2) 
+      v1[0]=triverts[1][0]-boxcenter[0]; 
+      v1[1]=triverts[1][1]-boxcenter[1]; 
+      v1[2]=triverts[1][2]-boxcenter[2]; 
+
+      //SUB(v2,triverts[2],boxcenter);
+      //#define SUB(dest,v1,v2) 
+      v2[0]=triverts[2][0]-boxcenter[0]; 
+      v2[1]=triverts[2][1]-boxcenter[1]; 
+      v2[2]=triverts[2][2]-boxcenter[2]; 
+
+      /* compute triangle edges */
+      //SUB(e0,v1,v0);      /* tri edge 0 */
+      //#define SUB(dest,v1,v2) 
+      e0[0]=v1[0]-v0[0]; 
+      e0[1]=v1[1]-v0[1]; 
+      e0[2]=v1[2]-v0[2]; 
+
+      //SUB(e1,v2,v1);      /* tri edge 1 */
+      //#define SUB(dest,v1,v2) 
+      e1[0]=v2[0]-v1[0]; 
+      e1[1]=v2[1]-v1[1]; 
+      e1[2]=v2[2]-v1[2]; 
+
+      //SUB(e2,v0,v2);      /* tri edge 2 */
+      //#define SUB(dest,v1,v2) 
+      e2[0]=v0[0]-v2[0]; 
+      e2[1]=v0[1]-v2[1]; 
+      e2[2]=v0[2]-v2[2]; 
+
+      /* Bullet 3:  */
+      /*  test the 9 tests first (this was faster) */
+      fex = fabsf(e0[0]);
+      fey = fabsf(e0[1]);
+      fez = fabsf(e0[2]);
+
+      //AXISTEST_X01(e0[2], e0[1], fez, fey);
+      //#define AXISTEST_X01(a, b, fa, fb)			
+      p0 = e0[2]*v0[1] - e0[1]*v0[2];			       	   
+      p2 = e0[2]*v2[1] - e0[1]*v2[2];			       	   
+      if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} 
+      rad = fez * boxhalfsize[1] + fey * boxhalfsize[2];   
+      if(min>rad || max<-rad) return 0;
+
+      //AXISTEST_Y02(e0[2], e0[0], fez, fex);
+      //#define AXISTEST_Y02(a, b, fa, fb)			
+      p0 = -e0[2]*v0[0] + e0[0]*v0[2];		      	   
+      p2 = -e0[2]*v2[0] + e0[0]*v2[2];	       	       	   
+      if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} 
+      rad = fez * boxhalfsize[0] + fex * boxhalfsize[2];  
+      if(min>rad || max<-rad) return 0;
+
+      //AXISTEST_Z12(e0[1], e0[0], fey, fex);
+      //#define AXISTEST_Z12(a, b, fa, fb)		
+      p1 = e0[1]*v1[0] - e0[0]*v1[1];			           
+      p2 = e0[1]*v2[0] - e0[0]*v2[1];			       	   
+      if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} 
+      rad = fey * boxhalfsize[0] + fex * boxhalfsize[1];   
+      if(min>rad || max<-rad) return 0;
+      
+      fex = fabsf(e1[0]);
+      fey = fabsf(e1[1]);
+      fez = fabsf(e1[2]);
+
+      //AXISTEST_X01(e1[2], e1[1], fez, fey);
+      //#define AXISTEST_X01(a, b, fa, fb)			
+      p0 = e1[2]*v0[1] - e1[1]*v0[2];			       	   
+      p2 = e1[2]*v2[1] - e1[1]*v2[2];			       	   
+      if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} 
+      rad = fez * boxhalfsize[1] + fey * boxhalfsize[2];   
+      if(min>rad || max<-rad) return 0;
+      
+      //AXISTEST_Y02(e1[2], e1[0], fez, fex);
+      //#define AXISTEST_Y02(a, b, fa, fb)			
+      p0 = -e1[2]*v0[0] + e1[0]*v0[2];		      	   
+      p2 = -e1[2]*v2[0] + e1[0]*v2[2];	       	       	   
+      if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} 
+      rad = fez * boxhalfsize[0] + fex * boxhalfsize[2];   
+      if(min>rad || max<-rad) return 0;
+
+      //AXISTEST_Z0(e1[1], e1[0], fey, fex);
+      //#define AXISTEST_Z0(a, b, fa, fb)	
+      p0 = e1[1]*v0[0] - e1[0]*v0[1];				  
+      p1 = e1[1]*v1[0] - e1[0]*v1[1];			          
+      if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} 
+      rad = fey * boxhalfsize[0] + fex * boxhalfsize[2];   
+      if(min>rad || max<-rad) return 0;
+
+      fex = fabsf(e2[0]);
+      fey = fabsf(e2[1]);
+      fez = fabsf(e2[2]);
+      //AXISTEST_X2(e2[2], e2[1], fez, fey);
+      //#define AXISTEST_X2(a, b, fa, fb)			
+      p0 = e2[2]*v0[1] - e2[1]*v0[2];			           
+      p1 = e2[2]*v1[1] - e2[1]*v1[2];			       	   
+      if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} 
+      rad = fez * boxhalfsize[1] + fey * boxhalfsize[2];  
+      if(min>rad || max<-rad) return 0;
+      
+      //AXISTEST_Y1(e2[2], e2[0], fez, fex);
+      //#define AXISTEST_Y1(a, b, fa, fb)			
+      p0 = -e2[2]*v0[0] + e2[0]*v0[2];		      	  
+      p1 = -e2[2]*v1[0] + e2[0]*v1[2];	     	       	   
+      if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} 
+      rad = fez * boxhalfsize[0] + fex * boxhalfsize[2];   
+      if(min>rad || max<-rad) return 0;
+      
+      //AXISTEST_Z12(e2[1], e2[0], fey, fex);
+      //#define AXISTEST_Z12(a, b, fa, fb)		
+      p1 = e2[1]*v1[0] - e2[0]*v1[1];			           
+      p2 = e2[1]*v2[0] - e2[0]*v2[1];			       	   
+      if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} 
+      rad = fey * boxhalfsize[0] + fex * boxhalfsize[1];   
+      if(min>rad || max<-rad) return 0;
+   
+      /* Bullet 1: */
+      /*  first test overlap in the {x,y,z}-directions */
+      /*  find min, max of the triangle each direction, and test for overlap in */
+      /*  that direction -- this is equivalent to testing a minimal AABB around */
+      /*  the triangle against the AABB */
+      /* test in X-direction */
+      //FINDMINMAX(v0[0],v1[0],v2[0],min,max);
+      min = (float)UbMath::min(v0[0],v1[0],v2[0]);
+      max = (float)UbMath::max(v0[0],v1[0],v2[0]);
+      if(min>boxhalfsize[0] || max<-boxhalfsize[0]) return 0;
+
+      /* test in Y-direction */
+      //FINDMINMAX(v0[1],v1[1],v2[1],min,max);
+      min = (float)UbMath::min(v0[1],v1[1],v2[1]);
+      max = (float)UbMath::max(v0[1],v1[1],v2[1]);
+      if(min>boxhalfsize[1] || max<-boxhalfsize[1]) return 0;
+
+      /* test in Z-direction */
+      //FINDMINMAX(v0[2],v1[2],v2[2],min,max);
+      min = (float)UbMath::min(v0[2],v1[2],v2[2]);
+      max = (float)UbMath::max(v0[2],v1[2],v2[2]);
+
+      if(min>boxhalfsize[2] || max<-boxhalfsize[2]) return 0;
+
+      /* Bullet 2: */
+      /*  test if the box intersects the plane of the triangle */
+      /*  compute plane equation of triangle: normal*x+d=0 */
+      //CROSS(normal,e0,e1);
+      //#define CROSS(dest,v1,v2) 
+      normal[0]=e0[1]*e1[2]-e0[2]*e1[1]; 
+      normal[1]=e0[2]*e1[0]-e0[0]*e1[2]; 
+      normal[2]=e0[0]*e1[1]-e0[1]*e1[0]; 
+
+      // -NJMP- (line removed here)
+      if(!planeBoxOverlap(normal,v0,boxhalfsize)) return 0;	// -NJMP-
+      return 1;   /* box and triangle overlaps */
+   }
+
+
+ 
+};
+
+#endif
+
+//original - NICHT LOESCHEN - von kroete lynn
+
+//#define X 0
+//#define Y 1
+//#define Z 2
+//
+//#define CROSS(dest,v1,v2) 
+//   dest[0]=v1[1]*v2[2]-v1[2]*v2[1]; 
+//   dest[1]=v1[2]*v2[0]-v1[0]*v2[2]; 
+//   dest[2]=v1[0]*v2[1]-v1[1]*v2[0]; 
+//
+//#define DOT(v1,v2) (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2])
+//
+//#define SUB(dest,v1,v2) 
+//   dest[0]=v1[0]-v2[0]; 
+//   dest[1]=v1[1]-v2[1]; 
+//   dest[2]=v1[2]-v2[2]; 
+//
+//#define FINDMINMAX(x0,x1,x2,min,max) 
+//   min = max = x0;   
+//   if(x1<min) min=x1;
+//   if(x1>max) max=x1;
+//   if(x2<min) min=x2;
+//   if(x2>max) max=x2;
+//
+//int planeBoxOverlap(float normal[3], float vert[3], float maxbox[3])	// -NJMP-
+//{
+//   int q;
+//   float vmin[3],vmax[3],v;
+//
+//   for(q=X;q<=Z;q++)
+//   {
+//      v=vert[q];					// -NJMP-
+//      if(normal[q]>0.0f)
+//      {
+//         vmin[q]=-maxbox[q] - v;	// -NJMP-
+//         vmax[q]= maxbox[q] - v;	// -NJMP-
+//      }
+//      else
+//      {
+//         vmin[q]= maxbox[q] - v;	// -NJMP-
+//         vmax[q]=-maxbox[q] - v;	// -NJMP-
+//      }
+//   }
+//   if(DOT(normal,vmin)>0.0f) return 0;	// -NJMP-
+//   if(DOT(normal,vmax)>=0.0f) return 1;	// -NJMP-
+//   return 0;
+//}
+//
+///*======================== X-tests ========================
+//
+//#define AXISTEST_X01(a, b, fa, fb)			   
+//   p0 = a*v0[Y] - b*v0[Z];			       	   
+//   p2 = a*v2[Y] - b*v2[Z];			       	   
+//      if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} 
+//   rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z];   
+//   if(min>rad || max<-rad) return 0;
+//
+//#define AXISTEST_X2(a, b, fa, fb)			   
+//   p0 = a*v0[Y] - b*v0[Z];			          
+//   p1 = a*v1[Y] - b*v1[Z];			       	   
+//      if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} 
+//   rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z];   
+//   if(min>rad || max<-rad) return 0;
+//
+//
+//
+///*======================== Y-tests ========================
+//
+//#define AXISTEST_Y02(a, b, fa, fb)			   
+//   p0 = -a*v0[X] + b*v0[Z];		      	   
+//   p2 = -a*v2[X] + b*v2[Z];	       	       	   
+//   if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} 
+//   rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z];   
+//   if(min>rad || max<-rad) return 0;
+//
+//#define AXISTEST_Y1(a, b, fa, fb)			   
+//   p0 = -a*v0[X] + b*v0[Z];		      	   
+//   p1 = -a*v1[X] + b*v1[Z];	     	       	   
+//      if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} 
+//   rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z];   
+//   if(min>rad || max<-rad) return 0;
+//
+//======================== Z-tests ========================
+//
+//#define AXISTEST_Z12(a, b, fa, fb)			   
+//   p1 = a*v1[X] - b*v1[Y];			           
+//   p2 = a*v2[X] - b*v2[Y];			       	   
+//      if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} 
+//   rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y];   
+//   if(min>rad || max<-rad) return 0;
+//
+//#define AXISTEST_Z0(a, b, fa, fb)			   
+//   p0 = a*v0[X] - b*v0[Y];				   
+//   p1 = a*v1[X] - b*v1[Y];			           
+//      if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;}
+//   rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y];   
+//   if(min>rad || max<-rad) return 0;
+//
+//int triBoxOverlap(float boxcenter[3],float boxhalfsize[3],float triverts[3][3])
+//{
+//      //use separating axis theorem to test overlap between triangle and box 
+//      //need to test for overlap in these directions: 
+//      //1) the {x,y,z}-directions (actually, since we use the AABB of the triangle 
+//      //   we do not even need to test these) 
+//      //2) normal of the triangle 
+//      //3) crossproduct(edge from tri, {x,y,z}-directin) 
+//      //   this gives 3x3=9 more tests 
+//
+//   float v0[3],v1[3],v2[3];
+//
+//   //   float axis[3];
+//
+//   float min,max,p0,p1,p2,rad,fex,fey,fez;		// -NJMP- "d" local variable removed
+//   float normal[3],e0[3],e1[3],e2[3];
+//
+//   /* This is the fastest branch on Sun */
+//   /* move everything so that the boxcenter is in (0,0,0) */
+//   SUB(v0,triverts[0],boxcenter);
+//   SUB(v1,triverts[1],boxcenter);
+//   SUB(v2,triverts[2],boxcenter);
+//
+//   /* compute triangle edges */
+//   SUB(e0,v1,v0);      /* tri edge 0 */
+//   SUB(e1,v2,v1);      /* tri edge 1 */
+//   SUB(e2,v0,v2);      /* tri edge 2 */
+//
+//   /* Bullet 3:  */
+//   /*  test the 9 tests first (this was faster) */
+//   fex = fabsf(e0[X]);
+//   fey = fabsf(e0[Y]);
+//   fez = fabsf(e0[Z]);
+//
+//   AXISTEST_X01(e0[Z], e0[Y], fez, fey);
+//   AXISTEST_Y02(e0[Z], e0[X], fez, fex);
+//   AXISTEST_Z12(e0[Y], e0[X], fey, fex);
+//   fex = fabsf(e1[X]);
+//   fey = fabsf(e1[Y]);
+//   fez = fabsf(e1[Z]);
+//
+//   AXISTEST_X01(e1[Z], e1[Y], fez, fey);
+//   AXISTEST_Y02(e1[Z], e1[X], fez, fex);
+//   AXISTEST_Z0(e1[Y], e1[X], fey, fex);
+//
+//   fex = fabsf(e2[X]);
+//   fey = fabsf(e2[Y]);
+//   fez = fabsf(e2[Z]);
+//   AXISTEST_X2(e2[Z], e2[Y], fez, fey);
+//   AXISTEST_Y1(e2[Z], e2[X], fez, fex);
+//   AXISTEST_Z12(e2[Y], e2[X], fey, fex);
+//
+//   /* Bullet 1: */
+//   /*  first test overlap in the {x,y,z}-directions */
+//   /*  find min, max of the triangle each direction, and test for overlap in */
+//   /*  that direction -- this is equivalent to testing a minimal AABB around */
+//   /*  the triangle against the AABB */
+//   /* test in X-direction */
+//   FINDMINMAX(v0[X],v1[X],v2[X],min,max);
+//   if(min>boxhalfsize[X] || max<-boxhalfsize[X]) return 0;
+//
+//   /* test in Y-direction */
+//   FINDMINMAX(v0[Y],v1[Y],v2[Y],min,max);
+//   if(min>boxhalfsize[Y] || max<-boxhalfsize[Y]) return 0;
+//
+//   /* test in Z-direction */
+//   FINDMINMAX(v0[Z],v1[Z],v2[Z],min,max);
+//   if(min>boxhalfsize[Z] || max<-boxhalfsize[Z]) return 0;
+//
+//   /* Bullet 2: */
+//   /*  test if the box intersects the plane of the triangle */
+//   /*  compute plane equation of triangle: normal*x+d=0 */
+//   CROSS(normal,e0,e1);
+//
+//   // -NJMP- (line removed here)
+//   if(!planeBoxOverlap(normal,v0,boxhalfsize)) return 0;	// -NJMP-
+//   return 1;   /* box and triangle overlaps */
+//}
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbObject3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbObject3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbObject3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbObject3D.cpp
index 85f0332e1443d9c8cc593f78c9bf494f8b807af2..b48d256ee86c3a009b223c85672c219505bc28ff 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbObject3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbObject3D.cpp
@@ -1,88 +1,88 @@
-#include <numerics/geometry3d/GbObject3D.h>
-#include <numerics/geometry3d/creator/GbObject3DCreator.h>
-#include <numerics/geometry3d/GbPoint3D.h>
-#include <basics/utilities/UbMath.h>                 
-
-using namespace std;
-
-string GbObject3D::getTypeID()
-{
-      return this->getCreator()->getTypeID();
-}
-/*======================================================================*/
-bool GbObject3D::isPointInGbObject3D(GbPoint3D* p)
-{
-   return this->isPointInGbObject3D(p->getX1Centroid(),p->getX2Coordinate(),p->getX3Coordinate());
-} 
-/*======================================================================*/
-bool GbObject3D::isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) 
-{
-
-   if(   this->isPointInGbObject3D(x1a, x2a, x3a) 
-      && this->isPointInGbObject3D(x1b, x2a, x3a) 
-      && this->isPointInGbObject3D(x1b, x2b, x3a)
-      && this->isPointInGbObject3D(x1a, x2b, x3a) 
-      && this->isPointInGbObject3D(x1a, x2a, x3b)
-      && this->isPointInGbObject3D(x1b, x2a, x3b)
-      && this->isPointInGbObject3D(x1b, x2b, x3b)
-      && this->isPointInGbObject3D(x1a, x2b, x3b))
-   {
-      return true;
-   }
-
-   return false;
-}
-/*======================================================================*/
-bool GbObject3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) 
-{
-   if(   this->isPointInGbObject3D(x1a, x2a, x3a)      
-      || this->isPointInGbObject3D(x1b, x2a, x3a)      
-      || this->isPointInGbObject3D(x1b, x2b, x3a)      
-      || this->isPointInGbObject3D(x1a, x2b, x3a)      
-      || this->isPointInGbObject3D(x1a, x2a, x3b)      
-      || this->isPointInGbObject3D(x1b, x2a, x3b)      
-      || this->isPointInGbObject3D(x1b, x2b, x3b)      
-      || this->isPointInGbObject3D(x1a, x2b, x3b) )    
-   {
-      if(   !this->isPointInGbObject3D(x1a, x2a, x3a) 
-         || !this->isPointInGbObject3D(x1b, x2a, x3a) 
-         || !this->isPointInGbObject3D(x1b, x2b, x3a) 
-         || !this->isPointInGbObject3D(x1a, x2b, x3a)
-         || !this->isPointInGbObject3D(x1a, x2a, x3b)
-         || !this->isPointInGbObject3D(x1b, x2a, x3b)
-         || !this->isPointInGbObject3D(x1b, x2b, x3b)
-         || !this->isPointInGbObject3D(x1a, x2b, x3b)) return true;
-   }
-   return false;
-}
-/*======================================================================*/
-bool GbObject3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-{
-   if(   this->isPointInGbObject3D(x1a, x2a, x3a)   
-      || this->isPointInGbObject3D(x1b, x2a, x3a)   
-      || this->isPointInGbObject3D(x1b, x2b, x3a)   
-      || this->isPointInGbObject3D(x1a, x2b, x3a)   
-      || this->isPointInGbObject3D(x1a, x2a, x3b)   
-      || this->isPointInGbObject3D(x1b, x2a, x3b)   
-      || this->isPointInGbObject3D(x1b, x2b, x3b)   
-      || this->isPointInGbObject3D(x1a, x2b, x3b))  
-   {
-      return true;
-   }
-
-   return false;
-}
-/*=======================================================*/
-bool GbObject3D::isInsideCell(const double& minX1,const double& minX2,const double& minX3,const double& maxX1,const double& maxX2,const double& maxX3)
-{
-   if(   UbMath::greaterEqual(this->getX1Minimum(),minX1)
-      && UbMath::greaterEqual(this->getX2Minimum(),minX2)
-      && UbMath::greaterEqual(this->getX3Minimum(),minX3)
-      && UbMath::lessEqual(this->getX1Maximum(),maxX1) 
-      && UbMath::lessEqual(this->getX2Maximum(),maxX2)   
-      && UbMath::lessEqual(this->getX2Maximum(),maxX3)     ) return true;
-
-   return false;
-}
-
-
+#include <numerics/geometry3d/GbObject3D.h>
+#include <numerics/geometry3d/creator/GbObject3DCreator.h>
+#include <numerics/geometry3d/GbPoint3D.h>
+#include <basics/utilities/UbMath.h>                 
+
+using namespace std;
+
+string GbObject3D::getTypeID()
+{
+      return this->getCreator()->getTypeID();
+}
+/*======================================================================*/
+bool GbObject3D::isPointInGbObject3D(GbPoint3D* p)
+{
+   return this->isPointInGbObject3D(p->getX1Centroid(),p->getX2Coordinate(),p->getX3Coordinate());
+} 
+/*======================================================================*/
+bool GbObject3D::isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) 
+{
+
+   if(   this->isPointInGbObject3D(x1a, x2a, x3a) 
+      && this->isPointInGbObject3D(x1b, x2a, x3a) 
+      && this->isPointInGbObject3D(x1b, x2b, x3a)
+      && this->isPointInGbObject3D(x1a, x2b, x3a) 
+      && this->isPointInGbObject3D(x1a, x2a, x3b)
+      && this->isPointInGbObject3D(x1b, x2a, x3b)
+      && this->isPointInGbObject3D(x1b, x2b, x3b)
+      && this->isPointInGbObject3D(x1a, x2b, x3b))
+   {
+      return true;
+   }
+
+   return false;
+}
+/*======================================================================*/
+bool GbObject3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) 
+{
+   if(   this->isPointInGbObject3D(x1a, x2a, x3a)      
+      || this->isPointInGbObject3D(x1b, x2a, x3a)      
+      || this->isPointInGbObject3D(x1b, x2b, x3a)      
+      || this->isPointInGbObject3D(x1a, x2b, x3a)      
+      || this->isPointInGbObject3D(x1a, x2a, x3b)      
+      || this->isPointInGbObject3D(x1b, x2a, x3b)      
+      || this->isPointInGbObject3D(x1b, x2b, x3b)      
+      || this->isPointInGbObject3D(x1a, x2b, x3b) )    
+   {
+      if(   !this->isPointInGbObject3D(x1a, x2a, x3a) 
+         || !this->isPointInGbObject3D(x1b, x2a, x3a) 
+         || !this->isPointInGbObject3D(x1b, x2b, x3a) 
+         || !this->isPointInGbObject3D(x1a, x2b, x3a)
+         || !this->isPointInGbObject3D(x1a, x2a, x3b)
+         || !this->isPointInGbObject3D(x1b, x2a, x3b)
+         || !this->isPointInGbObject3D(x1b, x2b, x3b)
+         || !this->isPointInGbObject3D(x1a, x2b, x3b)) return true;
+   }
+   return false;
+}
+/*======================================================================*/
+bool GbObject3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+{
+   if(   this->isPointInGbObject3D(x1a, x2a, x3a)   
+      || this->isPointInGbObject3D(x1b, x2a, x3a)   
+      || this->isPointInGbObject3D(x1b, x2b, x3a)   
+      || this->isPointInGbObject3D(x1a, x2b, x3a)   
+      || this->isPointInGbObject3D(x1a, x2a, x3b)   
+      || this->isPointInGbObject3D(x1b, x2a, x3b)   
+      || this->isPointInGbObject3D(x1b, x2b, x3b)   
+      || this->isPointInGbObject3D(x1a, x2b, x3b))  
+   {
+      return true;
+   }
+
+   return false;
+}
+/*=======================================================*/
+bool GbObject3D::isInsideCell(const double& minX1,const double& minX2,const double& minX3,const double& maxX1,const double& maxX2,const double& maxX3)
+{
+   if(   UbMath::greaterEqual(this->getX1Minimum(),minX1)
+      && UbMath::greaterEqual(this->getX2Minimum(),minX2)
+      && UbMath::greaterEqual(this->getX3Minimum(),minX3)
+      && UbMath::lessEqual(this->getX1Maximum(),maxX1) 
+      && UbMath::lessEqual(this->getX2Maximum(),maxX2)   
+      && UbMath::lessEqual(this->getX2Maximum(),maxX3)     ) return true;
+
+   return false;
+}
+
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbObject3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbObject3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbObject3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbObject3D.h
index 05cc32a0524b8d8381b0fb1b9328ad9d6be48f9a..49f6511d45bc6e6cd8eab619921b3c6c53d28dcc 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbObject3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbObject3D.h
@@ -1,172 +1,172 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBOBJECT3D_H
-#define GBOBJECT3D_H
-
-#include <string>
-#include <vector>
-
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-#include <basics/utilities/UbSystem.h>
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbFileInput.h>
-#include <basics/utilities/UbFileOutput.h>
-#include <basics/utilities/UbObservable.h>
-#include <basics/utilities/UbTuple.h>
-#include <basics/objects/ObObject.h>
-
-class GbPoint3D;
-class GbLine3D;
-class GbTriangle3D;
-class GbObject3DCreator;
-
-#ifdef CAB_CTL
-#include <ctl.h>
-#endif
-
-#include <PointerDefinitions.h>
-
-
-/*=========================================================================*/
-/* GbObject3D                                                              */
-/*                                                                         */
-/**
- * This Interface provides basic 3D geometry objects methods.
- * <BR><BR><HR>
- * @author <A HREF="mailto:geller@cab.bau.tu-bs.de">S. Geller</A>
- * @author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
- * @version 1.0 - 02.02.05
-*/
-class GbObject3D : public ObObject
-{
-public:
-#ifdef CAB_CTL
-   virtual ctl::oStream &write(ctl::oStream &os) const
-   {
-      return os;
-   }
-   virtual ctl::iStream &read(ctl::iStream &is)
-   {
-      return is;
-   }
-#endif
-
-   virtual ~GbObject3D(){}
-
-   //ueberschriebene methode von ObObject
-   virtual std::string getTypeID();
-
-   //abstract Methods
-   virtual void finalize() =0 ; //detroys also all dynamic objects (e.g. GbPoints in GbLine)
-   virtual ObObjectCreator* getCreator()=0;
-
-   /**
-    * Returns the centroid x1 coordinate of this 3D object.
-    * @return the centroid x1 coordinate of this 3D object
-    */
-   virtual double getX1Centroid()=0;
-   /**
-    * Returns the minimum x1 coordinate of this 3D object.
-    * @return the minimum x1 coordinate of this 3D object
-    */
-   virtual double getX1Minimum()=0;
-   /**
-    * Returns the maximum x1 coordinate of this 3D object.
-    * @return the maximum x1 coordinate of this 3D object
-    */
-   virtual double getX1Maximum()=0;
-   /**
-    * Returns the centroid x2 coordinate of this 3D object.
-    * @return the centroid x2 coordinate of this 3D object
-    */
-   virtual double getX2Centroid()=0;
-   /**
-    * Returns the minimum x2 coordinate of this 3D object.
-    * @return the minimum x2 coordinate of this 3D object
-    */
-   virtual double getX2Minimum()=0;
-   /**
-    * Returns the maximum x2 coordinate of this 3D object.
-    * @return the maximum x2 coordinate of this 3D object
-    */
-   virtual double getX2Maximum()=0;
-
-	virtual double getX3Centroid()=0;
-   /**
-    * Returns the minimum x2 coordinate of this 3D object.
-    * @return the minimum x2 coordinate of this 3D object
-    */
-   virtual double getX3Minimum()=0;
-   /**
-    * Returns the maximum x2 coordinate of this 3D object.
-    * @return the maximum x2 coordinate of this 3D object
-    */
-   virtual double getX3Maximum()=0;
-
-   /*=======================================================*/
-   double getLengthX1() { return (getX1Maximum()-getX1Minimum()); }
-   double getLengthX2() { return (getX2Maximum()-getX2Minimum()); }
-   double getLengthX3() { return (getX3Maximum()-getX3Minimum()); }
-
-   virtual void setCenterX1Coordinate(const double& value) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); }
-   virtual void setCenterX2Coordinate(const double& value) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); }
-   virtual void setCenterX3Coordinate(const double& value) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); }
-   virtual void setCenterCoordinates(const double& x1, const double& x2, const double& x3) { throw UbException(UB_EXARGS, "not implemented for " + (std::string)typeid(*this).name()); }
-   virtual void setCenterCoordinates(const UbTupleDouble3& position) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); }
-
-   //Rotates the Point in relation to the origen.
-   //Parameters must be radian measure.
-   virtual void rotate(const double& rx1, const double& rx2, const double& rx3) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); }
-   virtual void translate(const double& x1, const double& x2, const double& x3) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); }
-   virtual void scale(const double& sx1, const double& sx2, const double& sx3)  { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); }
-
-   virtual void write(UbFileOutput* out)=0;
-   virtual void read(UbFileInput* in)=0;
-
-   virtual bool isPointInGbObject3D(GbPoint3D* p);
-   virtual bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)=0;
-   virtual bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3)=0;
-
-   virtual bool isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   virtual bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   virtual bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   virtual double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b){ return -1.0;};
-
-   virtual bool isInsideCell(const double& minX1,const double& minX2,const double& minX3,const double& maxX1,const double& maxX2,const double& maxX3);
-
-   virtual GbLine3D* createClippedLine3D (GbPoint3D &point1, GbPoint3D &point2)=0;
-   virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet()=0;
-
-   virtual void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles) { throw UbException("GbObject3D::addSurfaceTriangleSet - not implemented for "+(std::string)typeid(*this).name()); }
-
-   virtual bool hasRaytracing() { return false; }
-   virtual bool raytracingSupportsPointsInside() { return false; }
-   //|r| must be 1! einheitsvector!!
-   //return negativ value oder zero if no intersection
-   virtual double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) { throw UbException("GbObject3D::getIntersectionRaytraceFactor - not implemented"); }
-#ifdef CAB_RCF
-   template<class Archive>
-   void SF_SERIALIZE(Archive & ar)
-   {
-      SF_SERIALIZE_PARENT<ObObject>(ar, *this);
-   }
-#endif //CAB_RCF
-};
-/*=========================================================================*/
-
-#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
-   SF_NO_CTOR(GbObject3D);
-   UB_AUTO_RUN_NAMED(SF::registerType<GbObject3D>("GbObject3D") , SF_GbObject3D);
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived<ObObject, GbObject3D >() ), SF_GbObject3D_BD1 );
-#endif //RCF_USE_SF_SERIALIZATION
-
-
-#endif
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBOBJECT3D_H
+#define GBOBJECT3D_H
+
+#include <string>
+#include <vector>
+
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+#include <basics/utilities/UbSystem.h>
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbFileInput.h>
+#include <basics/utilities/UbFileOutput.h>
+#include <basics/utilities/UbObservable.h>
+#include <basics/utilities/UbTuple.h>
+#include <basics/objects/ObObject.h>
+
+class GbPoint3D;
+class GbLine3D;
+class GbTriangle3D;
+class GbObject3DCreator;
+
+#ifdef CAB_CTL
+#include <ctl.h>
+#endif
+
+#include <PointerDefinitions.h>
+
+
+/*=========================================================================*/
+/* GbObject3D                                                              */
+/*                                                                         */
+/**
+ * This Interface provides basic 3D geometry objects methods.
+ * <BR><BR><HR>
+ * @author <A HREF="mailto:geller@cab.bau.tu-bs.de">S. Geller</A>
+ * @author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A>
+ * @version 1.0 - 02.02.05
+*/
+class GbObject3D : public ObObject
+{
+public:
+#ifdef CAB_CTL
+   virtual ctl::oStream &write(ctl::oStream &os) const
+   {
+      return os;
+   }
+   virtual ctl::iStream &read(ctl::iStream &is)
+   {
+      return is;
+   }
+#endif
+
+   virtual ~GbObject3D(){}
+
+   //ueberschriebene methode von ObObject
+   virtual std::string getTypeID();
+
+   //abstract Methods
+   virtual void finalize() =0 ; //detroys also all dynamic objects (e.g. GbPoints in GbLine)
+   virtual ObObjectCreator* getCreator()=0;
+
+   /**
+    * Returns the centroid x1 coordinate of this 3D object.
+    * @return the centroid x1 coordinate of this 3D object
+    */
+   virtual double getX1Centroid()=0;
+   /**
+    * Returns the minimum x1 coordinate of this 3D object.
+    * @return the minimum x1 coordinate of this 3D object
+    */
+   virtual double getX1Minimum()=0;
+   /**
+    * Returns the maximum x1 coordinate of this 3D object.
+    * @return the maximum x1 coordinate of this 3D object
+    */
+   virtual double getX1Maximum()=0;
+   /**
+    * Returns the centroid x2 coordinate of this 3D object.
+    * @return the centroid x2 coordinate of this 3D object
+    */
+   virtual double getX2Centroid()=0;
+   /**
+    * Returns the minimum x2 coordinate of this 3D object.
+    * @return the minimum x2 coordinate of this 3D object
+    */
+   virtual double getX2Minimum()=0;
+   /**
+    * Returns the maximum x2 coordinate of this 3D object.
+    * @return the maximum x2 coordinate of this 3D object
+    */
+   virtual double getX2Maximum()=0;
+
+	virtual double getX3Centroid()=0;
+   /**
+    * Returns the minimum x2 coordinate of this 3D object.
+    * @return the minimum x2 coordinate of this 3D object
+    */
+   virtual double getX3Minimum()=0;
+   /**
+    * Returns the maximum x2 coordinate of this 3D object.
+    * @return the maximum x2 coordinate of this 3D object
+    */
+   virtual double getX3Maximum()=0;
+
+   /*=======================================================*/
+   double getLengthX1() { return (getX1Maximum()-getX1Minimum()); }
+   double getLengthX2() { return (getX2Maximum()-getX2Minimum()); }
+   double getLengthX3() { return (getX3Maximum()-getX3Minimum()); }
+
+   virtual void setCenterX1Coordinate(const double& value) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); }
+   virtual void setCenterX2Coordinate(const double& value) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); }
+   virtual void setCenterX3Coordinate(const double& value) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); }
+   virtual void setCenterCoordinates(const double& x1, const double& x2, const double& x3) { throw UbException(UB_EXARGS, "not implemented for " + (std::string)typeid(*this).name()); }
+   virtual void setCenterCoordinates(const UbTupleDouble3& position) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); }
+
+   //Rotates the Point in relation to the origen.
+   //Parameters must be radian measure.
+   virtual void rotate(const double& rx1, const double& rx2, const double& rx3) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); }
+   virtual void translate(const double& x1, const double& x2, const double& x3) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); }
+   virtual void scale(const double& sx1, const double& sx2, const double& sx3)  { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); }
+
+   virtual void write(UbFileOutput* out)=0;
+   virtual void read(UbFileInput* in)=0;
+
+   virtual bool isPointInGbObject3D(GbPoint3D* p);
+   virtual bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)=0;
+   virtual bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3)=0;
+
+   virtual bool isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   virtual bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   virtual bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   virtual double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b){ return -1.0;};
+
+   virtual bool isInsideCell(const double& minX1,const double& minX2,const double& minX3,const double& maxX1,const double& maxX2,const double& maxX3);
+
+   virtual GbLine3D* createClippedLine3D (GbPoint3D &point1, GbPoint3D &point2)=0;
+   virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet()=0;
+
+   virtual void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles) { throw UbException("GbObject3D::addSurfaceTriangleSet - not implemented for "+(std::string)typeid(*this).name()); }
+
+   virtual bool hasRaytracing() { return false; }
+   virtual bool raytracingSupportsPointsInside() { return false; }
+   //|r| must be 1! einheitsvector!!
+   //return negativ value oder zero if no intersection
+   virtual double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) { throw UbException("GbObject3D::getIntersectionRaytraceFactor - not implemented"); }
+#ifdef CAB_RCF
+   template<class Archive>
+   void SF_SERIALIZE(Archive & ar)
+   {
+      SF_SERIALIZE_PARENT<ObObject>(ar, *this);
+   }
+#endif //CAB_RCF
+};
+/*=========================================================================*/
+
+#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
+   SF_NO_CTOR(GbObject3D);
+   UB_AUTO_RUN_NAMED(SF::registerType<GbObject3D>("GbObject3D") , SF_GbObject3D);
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived<ObObject, GbObject3D >() ), SF_GbObject3D_BD1 );
+#endif //RCF_USE_SF_SERIALIZATION
+
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbObject3DManager.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbObject3DManager.cpp
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/GbObject3DManager.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbObject3DManager.cpp
index 38fc910e8b5223295677abaf1e87c217f411da3d..e7ca650de7e8d3699195fa16c4767e11305b74c8 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbObject3DManager.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbObject3DManager.cpp
@@ -1,285 +1,285 @@
-#include <numerics/geometry3d/GbObject3DManager.h>      
-#include <numerics/geometry3d/GbObject3D.h>       
-#include <numerics/geometry3d/creator/GbObject3DFactory.h>
-
-using namespace std;
-
-GbObject3DEntry::GbObject3DEntry(GbObject3DManager *parent, GbObject3D *geoObject, bool active, string name):ObObjectEntry(parent, geoObject)
-{
-   //this->parent = parent;
-   //this->geoObject = geoObject;
-   this->active = active;
-   this->name = name;
-}
-
-/*======================================================*/
-/*==     nun halt der Manager                       ====*/
-/*======================================================*/
-
-GbObject3DManager::GbObject3DManager(): ObObjectManager()
-{
-   this->tableModel = new GbObject3DTableModel(this);
-}
-/*======================================================*/
-GbObject3DManager::~GbObject3DManager()
-{
-//   this->gbObject3DList.clear();
-}
-/*======================================================*/
-ObObjectFactory* GbObject3DManager::getObObjectFactory()
-{
-   return GbObject3DFactory::getInstance();
-}
-
-/*======================================================*/
-ObObjectEntry* GbObject3DManager::createNewObObjectEntry(ObObject *obj)
-{ 
-   GbObject3D *geoobject = dynamic_cast<GbObject3D*>(obj);
-   return new GbObject3DEntry(this, geoobject, true, geoobject->getTypeID()); 
-}
-
-/*======================================================*/
-//UbTableModel* GbObject3DManager::getTableModel()
-//{
-//   return this->tablemodel;
-//}
-
-/*======================================================*/
-//bool GbObject3DManager::addGbObject3D(GbObject3D *geoObject)
-//{
-//   return this->addGbObject3D(geoObject, true, "GeoObject");
-//}
-//
-///*======================================================*/
-bool GbObject3DManager::addGbObject3D(GbObject3D *geoObject, string name)
-{
-   GbObject3DEntry *entry = new GbObject3DEntry (this, geoObject, true, name);
-   return ObObjectManager::addObObjectEntry(entry);
-}
-//bool GbObject3DManager::addGbObject3D(GbObject3D *geoObject, bool active, string name)  
-//{
-//   GbObject3DEntry *entry = new GbObject3DEntry (this, geoObject, true, name);
-//   return ObObjectManager::addObObjectEntry(entry);
-//}
-//
-/*======================================================*/
-bool GbObject3DManager::removeGbObject3D(GbObject3D *geoObject)
-{
-   return ObObjectManager::removeObObject(geoObject);
-}
-/*======================================================*/
-bool GbObject3DManager::removeGbObject3D(int index)
-{
-   return ObObjectManager::removeObObject(index);
-}
-/*======================================================*/
-//void GbObject3DManager::removeAllGbObject3Ds() 
-//{  
-//    this->gbObject3DList.clear();
-//}
-/*======================================================*/
-int GbObject3DManager::getNumberOfGbObject3Ds()
-{ 
-   return GbObject3DManager::getNumberOfObObjects();
-}
-/*======================================================*/
-vector<GbObject3D*>* GbObject3DManager::getAllGbObject3Ds()  
-{ 
-   throw UbException(UB_EXARGS,"not implemented");
-   //vector<GbObject3D*> *geoVektor = new vector<GbObject3D*>;
-   //for(int u=0; u<(int)this->gbObject3DList.size();u++)
-   //{
-   //   GbObject3D* geoObject = dynamic_cast<GbObject3D*>((gbObject3DList)[u]->getObject());
-   //   geoVektor->push_back(geoObject);
-   //}
-   //return geoVektor;  
-}
-/*======================================================*/
-GbObject3D* GbObject3DManager::getGbObject3D(int index)
-{
-   if(index <  0)                            return NULL;
-   if(index >= this->getNumberOfObObjects()) return NULL;
-
-   GbObject3D* geoObject = dynamic_cast<GbObject3D*>(this->getObObject(index));
-   return(geoObject);
-}
-/*======================================================*/
-//GbObject3DEntry* GbObject3DManager::getGbObject3DEntry(int index)
-//{
-//   if(index <  0)                                 return NULL;
-//   if(index >= (int)this->gbObject3DList.size())  return NULL;
-//
-//   return((this->gbObject3DList)[index]);
-//}
-/*====================================================*/
-void GbObject3DManager::write(UbFileOutput *out) 
-{                    
-   int size = this->getNumberOfObObjects();
-   out->writeInteger(size);
-   out->writeString("// #GbObjects");
-
-   GbObject3D *geoObject;
-   for(int pos=0; pos<size; pos++)          
-   {
-      out->writeLine();
-      geoObject = dynamic_cast<GbObject3D*>(this->getObObject(pos));
-      cout<<pos<<".:"<<geoObject->toString()<<endl;
-      geoObject->write(out);
-   }
-}
-/*======================================================================*/
-void GbObject3DManager::read(UbFileInput *in) 
-{
-   this->removeAllObObjects();
-   
-   int n = in->readInteger();                          
-   
-   cout<<"GbObject3DManager::read "<<n<<" GbObject3Ds\n";
-   GbObject3D *geoObject;
-   for(int pos=1; pos<=n; pos++)
-   {
-      in->readLine();
-      cout<<" - GbObject3D "<<pos<<" ...";
-      geoObject = GbObject3DFactory::getInstance()->createGbObject3D(in);
-      
-      GbObject3DEntry *entry = new GbObject3DEntry(this, geoObject, true, "GeoObject");
-      this->addObObjectEntry(entry);
-      cout<<"done\n";
-   }
-}
-/*======================================================*/
-string GbObject3DManager::toString()
-{
-   stringstream ss; ss<<endl;
-   
-   int size = this->getNumberOfObObjects();
-   for(int pos=0; pos<size; pos++)          
-   {
-      ObObject* geoObject = this->getObObject(pos);
-      ss<<(pos+1)<<". "<<geoObject->toString()<<endl;
-   }
-   string back = ss.str();
-   return back;
-}
-
-/*======================================================*/
-/*======================================================*/
-/*======================================================*/
-
-GbObject3DTableModel::GbObject3DTableModel(GbObject3DManager* manager)
-{
-   this->objectManager = manager;
-}
-
-/*======================================================*/
-GbObject3DTableModel::~GbObject3DTableModel(void)
-{
-}
-
-/*======================================================*/
-//Gibt die Anzahl der Spalten zurueck.
-int GbObject3DTableModel::getColumnNumber()
-{
-   return 3;
-}
-
-/*======================================================*/
-std::string GbObject3DTableModel::getColumnLabel(int column)
-{
-   switch(column)
-   {
-   case COL_NAME: return "Name";
-   case COL_TYPE: return "Type";
-   case COL_ACTIVE: return "Active";
-   default: throw UbException(UB_EXARGS,"falscher Spaltenindex");
-   }
-}
-
-/*======================================================*/
-int GbObject3DTableModel::getRowNumber()
-{
-   return this->objectManager->getNumberOfGbObject3Ds();
-}
-/*======================================================*/
-int GbObject3DTableModel::getSelectedRowIndex()
-{
-   return 0;
-   //	return this->objectManager->getSelectedIndex();
-}
-
-/*======================================================*/
-int GbObject3DTableModel::getColumnType(int column)
-{
-   switch(column) {
-   case COL_NAME :
-      return UbTableModel::COL_TYPE_STRING;
-      break;
-   case COL_TYPE :
-      return UbTableModel::COL_TYPE_STRING;
-      break;
-   case COL_ACTIVE :
-      return UbTableModel::COL_TYPE_BOOL;
-      break;
-   }
-   return -1;
-}
-
-//Gibt den Eintag der Tabelle an der angegebenen Spalten- und 
-//Zeilenposition in Form eines String Werts zurueck.
-std::string GbObject3DTableModel::getStringValue(int row, int col)
-{
-   GbObject3DEntry* gbObjEntry = dynamic_cast<GbObject3DEntry*>(this->objectManager->getObObjectEntry(row));
-   switch(col) {
-   case COL_NAME:
-      return gbObjEntry->name;
-      break;
-   case COL_TYPE:
-      return gbObjEntry->getObject()->getTypeID();
-      break;
-   case COL_ACTIVE:
-      if ( gbObjEntry->active ) return "True";
-      return "False";
-      break;
-   }
-   return "Fehler";
-}
-
-/*======================================================*/
-//bool GbObject3DManager::selectGbObject3D(int index)
-//{
-//   cout<<"GbObject3DManager::selectGbObject3D(int index):"<<index<<endl;
-//   if (index > (int)this->gbObject3DList.size()-1 || index < 0) return false; 
-//   if ( this->selectedObject == this->getGbObject3D(index) ) return true;
-//   this->selectedObject = this->getGbObject3D(index);
-//   this->notifyObserversObjectChanged();
-//   return true;
-//}
-///*======================================================*/
-//bool GbObject3DManager::selectGbObject3D(GbObject3D* geoObject)
-//{
-//   for(int pos=0; pos<(int)this->gbObject3DList.size(); pos++)
-//   {
-//      if(this->gbObject3DList[pos]->geoObject==geoObject) 
-//      {
-//         return this->selectGbObject3D(pos);
-//      }
-//   }
-//   return false;
-//}
-///*======================================================*/
-//GbObject3D* GbObject3DManager::getSelectedGbObject3D()
-//{
-//   return this->selectedObject;
-//}
-///*======================================================*/
-//int GbObject3DManager::getSelectedIndex()
-//{
-//   for(int pos=0; pos<(int)this->gbObject3DList.size(); pos++)
-//   {
-//      if(this->gbObject3DList[pos]->geoObject==this->selectedObject) 
-//      {
-//         return pos;
-//      }
-//   }
-//   return -1;
-//}
+#include <numerics/geometry3d/GbObject3DManager.h>      
+#include <numerics/geometry3d/GbObject3D.h>       
+#include <numerics/geometry3d/creator/GbObject3DFactory.h>
+
+using namespace std;
+
+GbObject3DEntry::GbObject3DEntry(GbObject3DManager *parent, GbObject3D *geoObject, bool active, string name):ObObjectEntry(parent, geoObject)
+{
+   //this->parent = parent;
+   //this->geoObject = geoObject;
+   this->active = active;
+   this->name = name;
+}
+
+/*======================================================*/
+/*==     nun halt der Manager                       ====*/
+/*======================================================*/
+
+GbObject3DManager::GbObject3DManager(): ObObjectManager()
+{
+   this->tableModel = new GbObject3DTableModel(this);
+}
+/*======================================================*/
+GbObject3DManager::~GbObject3DManager()
+{
+//   this->gbObject3DList.clear();
+}
+/*======================================================*/
+ObObjectFactory* GbObject3DManager::getObObjectFactory()
+{
+   return GbObject3DFactory::getInstance();
+}
+
+/*======================================================*/
+ObObjectEntry* GbObject3DManager::createNewObObjectEntry(ObObject *obj)
+{ 
+   GbObject3D *geoobject = dynamic_cast<GbObject3D*>(obj);
+   return new GbObject3DEntry(this, geoobject, true, geoobject->getTypeID()); 
+}
+
+/*======================================================*/
+//UbTableModel* GbObject3DManager::getTableModel()
+//{
+//   return this->tablemodel;
+//}
+
+/*======================================================*/
+//bool GbObject3DManager::addGbObject3D(GbObject3D *geoObject)
+//{
+//   return this->addGbObject3D(geoObject, true, "GeoObject");
+//}
+//
+///*======================================================*/
+bool GbObject3DManager::addGbObject3D(GbObject3D *geoObject, string name)
+{
+   GbObject3DEntry *entry = new GbObject3DEntry (this, geoObject, true, name);
+   return ObObjectManager::addObObjectEntry(entry);
+}
+//bool GbObject3DManager::addGbObject3D(GbObject3D *geoObject, bool active, string name)  
+//{
+//   GbObject3DEntry *entry = new GbObject3DEntry (this, geoObject, true, name);
+//   return ObObjectManager::addObObjectEntry(entry);
+//}
+//
+/*======================================================*/
+bool GbObject3DManager::removeGbObject3D(GbObject3D *geoObject)
+{
+   return ObObjectManager::removeObObject(geoObject);
+}
+/*======================================================*/
+bool GbObject3DManager::removeGbObject3D(int index)
+{
+   return ObObjectManager::removeObObject(index);
+}
+/*======================================================*/
+//void GbObject3DManager::removeAllGbObject3Ds() 
+//{  
+//    this->gbObject3DList.clear();
+//}
+/*======================================================*/
+int GbObject3DManager::getNumberOfGbObject3Ds()
+{ 
+   return GbObject3DManager::getNumberOfObObjects();
+}
+/*======================================================*/
+vector<GbObject3D*>* GbObject3DManager::getAllGbObject3Ds()  
+{ 
+   throw UbException(UB_EXARGS,"not implemented");
+   //vector<GbObject3D*> *geoVektor = new vector<GbObject3D*>;
+   //for(int u=0; u<(int)this->gbObject3DList.size();u++)
+   //{
+   //   GbObject3D* geoObject = dynamic_cast<GbObject3D*>((gbObject3DList)[u]->getObject());
+   //   geoVektor->push_back(geoObject);
+   //}
+   //return geoVektor;  
+}
+/*======================================================*/
+GbObject3D* GbObject3DManager::getGbObject3D(int index)
+{
+   if(index <  0)                            return NULL;
+   if(index >= this->getNumberOfObObjects()) return NULL;
+
+   GbObject3D* geoObject = dynamic_cast<GbObject3D*>(this->getObObject(index));
+   return(geoObject);
+}
+/*======================================================*/
+//GbObject3DEntry* GbObject3DManager::getGbObject3DEntry(int index)
+//{
+//   if(index <  0)                                 return NULL;
+//   if(index >= (int)this->gbObject3DList.size())  return NULL;
+//
+//   return((this->gbObject3DList)[index]);
+//}
+/*====================================================*/
+void GbObject3DManager::write(UbFileOutput *out) 
+{                    
+   int size = this->getNumberOfObObjects();
+   out->writeInteger(size);
+   out->writeString("// #GbObjects");
+
+   GbObject3D *geoObject;
+   for(int pos=0; pos<size; pos++)          
+   {
+      out->writeLine();
+      geoObject = dynamic_cast<GbObject3D*>(this->getObObject(pos));
+      cout<<pos<<".:"<<geoObject->toString()<<endl;
+      geoObject->write(out);
+   }
+}
+/*======================================================================*/
+void GbObject3DManager::read(UbFileInput *in) 
+{
+   this->removeAllObObjects();
+   
+   int n = in->readInteger();                          
+   
+   cout<<"GbObject3DManager::read "<<n<<" GbObject3Ds\n";
+   GbObject3D *geoObject;
+   for(int pos=1; pos<=n; pos++)
+   {
+      in->readLine();
+      cout<<" - GbObject3D "<<pos<<" ...";
+      geoObject = GbObject3DFactory::getInstance()->createGbObject3D(in);
+      
+      GbObject3DEntry *entry = new GbObject3DEntry(this, geoObject, true, "GeoObject");
+      this->addObObjectEntry(entry);
+      cout<<"done\n";
+   }
+}
+/*======================================================*/
+string GbObject3DManager::toString()
+{
+   stringstream ss; ss<<endl;
+   
+   int size = this->getNumberOfObObjects();
+   for(int pos=0; pos<size; pos++)          
+   {
+      ObObject* geoObject = this->getObObject(pos);
+      ss<<(pos+1)<<". "<<geoObject->toString()<<endl;
+   }
+   string back = ss.str();
+   return back;
+}
+
+/*======================================================*/
+/*======================================================*/
+/*======================================================*/
+
+GbObject3DTableModel::GbObject3DTableModel(GbObject3DManager* manager)
+{
+   this->objectManager = manager;
+}
+
+/*======================================================*/
+GbObject3DTableModel::~GbObject3DTableModel(void)
+{
+}
+
+/*======================================================*/
+//Gibt die Anzahl der Spalten zurueck.
+int GbObject3DTableModel::getColumnNumber()
+{
+   return 3;
+}
+
+/*======================================================*/
+std::string GbObject3DTableModel::getColumnLabel(int column)
+{
+   switch(column)
+   {
+   case COL_NAME: return "Name";
+   case COL_TYPE: return "Type";
+   case COL_ACTIVE: return "Active";
+   default: throw UbException(UB_EXARGS,"falscher Spaltenindex");
+   }
+}
+
+/*======================================================*/
+int GbObject3DTableModel::getRowNumber()
+{
+   return this->objectManager->getNumberOfGbObject3Ds();
+}
+/*======================================================*/
+int GbObject3DTableModel::getSelectedRowIndex()
+{
+   return 0;
+   //	return this->objectManager->getSelectedIndex();
+}
+
+/*======================================================*/
+int GbObject3DTableModel::getColumnType(int column)
+{
+   switch(column) {
+   case COL_NAME :
+      return UbTableModel::COL_TYPE_STRING;
+      break;
+   case COL_TYPE :
+      return UbTableModel::COL_TYPE_STRING;
+      break;
+   case COL_ACTIVE :
+      return UbTableModel::COL_TYPE_BOOL;
+      break;
+   }
+   return -1;
+}
+
+//Gibt den Eintag der Tabelle an der angegebenen Spalten- und 
+//Zeilenposition in Form eines String Werts zurueck.
+std::string GbObject3DTableModel::getStringValue(int row, int col)
+{
+   GbObject3DEntry* gbObjEntry = dynamic_cast<GbObject3DEntry*>(this->objectManager->getObObjectEntry(row));
+   switch(col) {
+   case COL_NAME:
+      return gbObjEntry->name;
+      break;
+   case COL_TYPE:
+      return gbObjEntry->getObject()->getTypeID();
+      break;
+   case COL_ACTIVE:
+      if ( gbObjEntry->active ) return "True";
+      return "False";
+      break;
+   }
+   return "Fehler";
+}
+
+/*======================================================*/
+//bool GbObject3DManager::selectGbObject3D(int index)
+//{
+//   cout<<"GbObject3DManager::selectGbObject3D(int index):"<<index<<endl;
+//   if (index > (int)this->gbObject3DList.size()-1 || index < 0) return false; 
+//   if ( this->selectedObject == this->getGbObject3D(index) ) return true;
+//   this->selectedObject = this->getGbObject3D(index);
+//   this->notifyObserversObjectChanged();
+//   return true;
+//}
+///*======================================================*/
+//bool GbObject3DManager::selectGbObject3D(GbObject3D* geoObject)
+//{
+//   for(int pos=0; pos<(int)this->gbObject3DList.size(); pos++)
+//   {
+//      if(this->gbObject3DList[pos]->geoObject==geoObject) 
+//      {
+//         return this->selectGbObject3D(pos);
+//      }
+//   }
+//   return false;
+//}
+///*======================================================*/
+//GbObject3D* GbObject3DManager::getSelectedGbObject3D()
+//{
+//   return this->selectedObject;
+//}
+///*======================================================*/
+//int GbObject3DManager::getSelectedIndex()
+//{
+//   for(int pos=0; pos<(int)this->gbObject3DList.size(); pos++)
+//   {
+//      if(this->gbObject3DList[pos]->geoObject==this->selectedObject) 
+//      {
+//         return pos;
+//      }
+//   }
+//   return -1;
+//}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbObject3DManager.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbObject3DManager.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/GbObject3DManager.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbObject3DManager.h
index f48f469355b555e6d3b983cc25aaca247c79b9a5..5f698f090e5be352ee10b70f798cdc7c914151bc 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbObject3DManager.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbObject3DManager.h
@@ -1,119 +1,119 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBOBJECT3DMANAGER_H
-#define GBOBJECT3DMANAGER_H
-
-#include <string>
-#include <sstream>
-#include <vector>
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbFileInput.h>
-#include <basics/utilities/UbFileOutput.h>
-#include <basics/utilities/UbTableModel.h>
-#include <basics/objects/ObObjectManager.h>
-
-#include <PointerDefinitions.h>
-                                                  
-class GbObject3D;   
-class GbObject3DManager;
-class GbObject3DTableModel;
-
-class GbObject3DEntry  : public ObObjectEntry
-{
-   friend class GbObject3DManager;
-   friend class GbObject3DTableModel;
-public:
-   std::string getName() { return this->name;}
-private:
-   //GbObject3DManager *parent;
-   //GbObject3D        *geoObject;
-   bool        active;
-   std::string name;
-   
-
-   GbObject3DEntry(GbObject3DManager* parent, GbObject3D* geoObject, bool active, std::string name);
- 
-};
-
-
-class GbObject3DManager  : public ObObjectManager 
-{                                           
-public:
-   GbObject3DManager();
-   ~GbObject3DManager();
-
-   ObObjectEntry* createNewObObjectEntry(ObObject *obj);
-   ObObjectFactory* getObObjectFactory();
-
-
-   //bool addGbObject3D(GbObject3D *geoObject3D);  
-   bool addGbObject3D(GbObject3D *geoObject3D, std::string name);   
-   //bool addGbObject3D(GbObject3D *geoObject3D, bool active, std::string name);   
-
-   bool removeGbObject3D(GbObject3D *geoObject3D);
-   bool removeGbObject3D(int index);
-
-   int getNumberOfGbObject3Ds();                 
-   std::vector<GbObject3D*>* getAllGbObject3Ds();
-   GbObject3D* getGbObject3D(int index);
-
-   //keine Definition dafuer da ...
-   //void writeValidationAVSFile(string filename);
-   //void writeSurfaceAVSFile(string filename);
-
-   //public final OctConstructionDescriptor[] getAllActiveConstructions()
-   //public final OctSpecificConstructionInstrument getSpecificConstructionInstrumentInstance(int index)
-   //public final boolean isConstructionActive(int index)
-   //public final boolean isConstructionVisible(int index)
-   //public final void activateConstruction(int index, boolean active)
-   //public final void visibleConstruction(int index, boolean visible)
-  // UbTableModel* getTableModel();
-   //void objectChanged(UbObservable* observable);
-   //void objectWillBeDeleted(UbObservable* observable);
-
-
-   void read(UbFileInput *in);
-   void write(UbFileOutput *out); 
-
-   std::string toString();
-
-private:
-   //GbObject3DTableModel* tablemodel;
-  // GbObject3D* selectedObject;
-   //vector<GbObject3DEntry*> gbObject3DList;
-};
-
-class GbObject3DTableModel : public UbTableModel
-{
-public:
-
-   static const int COL_NAME   = 0;
-   static const int COL_TYPE   = 1;
-   static const int COL_ACTIVE = 2;
-
-   GbObject3DTableModel(GbObject3DManager* manager);
-   ~GbObject3DTableModel(void);
-
-   //////////////////////////////////////////////////////////////////////////
-   //Geerbt von CabTable
-   int getColumnNumber(void);
-   int getRowNumber();
-
-   std::string getColumnLabel(int column);
-
-   int getColumnType(int);
-   std::string getStringValue(int row, int col);
-   int getSelectedRowIndex();
-   //bool GetBoolValue(int row, int col);
-   void setStringValue(int row, int col, std::string str) { throw UbException(UB_EXARGS,"not implemented"); }
-
-protected:
-   GbObject3DManager* objectManager;
-};
-
-#endif
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBOBJECT3DMANAGER_H
+#define GBOBJECT3DMANAGER_H
+
+#include <string>
+#include <sstream>
+#include <vector>
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbFileInput.h>
+#include <basics/utilities/UbFileOutput.h>
+#include <basics/utilities/UbTableModel.h>
+#include <basics/objects/ObObjectManager.h>
+
+#include <PointerDefinitions.h>
+                                                  
+class GbObject3D;   
+class GbObject3DManager;
+class GbObject3DTableModel;
+
+class GbObject3DEntry  : public ObObjectEntry
+{
+   friend class GbObject3DManager;
+   friend class GbObject3DTableModel;
+public:
+   std::string getName() { return this->name;}
+private:
+   //GbObject3DManager *parent;
+   //GbObject3D        *geoObject;
+   bool        active;
+   std::string name;
+   
+
+   GbObject3DEntry(GbObject3DManager* parent, GbObject3D* geoObject, bool active, std::string name);
+ 
+};
+
+
+class GbObject3DManager  : public ObObjectManager 
+{                                           
+public:
+   GbObject3DManager();
+   ~GbObject3DManager();
+
+   ObObjectEntry* createNewObObjectEntry(ObObject *obj);
+   ObObjectFactory* getObObjectFactory();
+
+
+   //bool addGbObject3D(GbObject3D *geoObject3D);  
+   bool addGbObject3D(GbObject3D *geoObject3D, std::string name);   
+   //bool addGbObject3D(GbObject3D *geoObject3D, bool active, std::string name);   
+
+   bool removeGbObject3D(GbObject3D *geoObject3D);
+   bool removeGbObject3D(int index);
+
+   int getNumberOfGbObject3Ds();                 
+   std::vector<GbObject3D*>* getAllGbObject3Ds();
+   GbObject3D* getGbObject3D(int index);
+
+   //keine Definition dafuer da ...
+   //void writeValidationAVSFile(string filename);
+   //void writeSurfaceAVSFile(string filename);
+
+   //public final OctConstructionDescriptor[] getAllActiveConstructions()
+   //public final OctSpecificConstructionInstrument getSpecificConstructionInstrumentInstance(int index)
+   //public final boolean isConstructionActive(int index)
+   //public final boolean isConstructionVisible(int index)
+   //public final void activateConstruction(int index, boolean active)
+   //public final void visibleConstruction(int index, boolean visible)
+  // UbTableModel* getTableModel();
+   //void objectChanged(UbObservable* observable);
+   //void objectWillBeDeleted(UbObservable* observable);
+
+
+   void read(UbFileInput *in);
+   void write(UbFileOutput *out); 
+
+   std::string toString();
+
+private:
+   //GbObject3DTableModel* tablemodel;
+  // GbObject3D* selectedObject;
+   //vector<GbObject3DEntry*> gbObject3DList;
+};
+
+class GbObject3DTableModel : public UbTableModel
+{
+public:
+
+   static const int COL_NAME   = 0;
+   static const int COL_TYPE   = 1;
+   static const int COL_ACTIVE = 2;
+
+   GbObject3DTableModel(GbObject3DManager* manager);
+   ~GbObject3DTableModel(void);
+
+   //////////////////////////////////////////////////////////////////////////
+   //Geerbt von CabTable
+   int getColumnNumber(void);
+   int getRowNumber();
+
+   std::string getColumnLabel(int column);
+
+   int getColumnType(int);
+   std::string getStringValue(int row, int col);
+   int getSelectedRowIndex();
+   //bool GetBoolValue(int row, int col);
+   void setStringValue(int row, int col, std::string str) { throw UbException(UB_EXARGS,"not implemented"); }
+
+protected:
+   GbObject3DManager* objectManager;
+};
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbObjectGroup3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbObjectGroup3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbObjectGroup3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbObjectGroup3D.cpp
index 3e8c4087d537ae4c0bcf03155b032c459ade327f..4a6301a4d4d48f1627296369e65964fe92f27e9d 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbObjectGroup3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbObjectGroup3D.cpp
@@ -1,146 +1,146 @@
-#include <numerics/geometry3d/GbObjectGroup3D.h>
-#include <numerics/geometry3d/GbSystem3D.h>
-#include <numerics/geometry3d/GbPoint3D.h>
-#include <numerics/geometry3d/GbLine3D.h>
-#include <numerics/geometry3d/GbTriangle3D.h>
-
-using namespace std;
-
-/*=====================================================*/
-GbObjectGroup3D::GbObjectGroup3D()
-{
-   this->setName("ObjectGroup");
-}
-/*=====================================================*/
-GbObjectGroup3D::~GbObjectGroup3D()
-{
-}
-/*=====================================================*/
-void GbObjectGroup3D::finalize()
-{
-   throw UbException(UB_EXARGS,"not implemented.");
-}
-/*=======================================================*/
-void GbObjectGroup3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3)
-{
-   throw UbException(UB_EXARGS,"not implemented.");
-}
-/*=====================================================*/
-double GbObjectGroup3D::getDistance(GbPoint3D* p)
-{
-   throw UbException(UB_EXARGS,"not implemented.");
-}
-/*=====================================================*/
-
-void GbObjectGroup3D::setCenterX1Coordinate(const double& value)
-{
-   throw UbException(UB_EXARGS,"not implemented.");
-}
-/*=====================================================*/
-void GbObjectGroup3D::setCenterX2Coordinate(const double& value)
-{
-   throw UbException(UB_EXARGS,"not implemented.");
-}
-/*=====================================================*/
-void GbObjectGroup3D::setCenterX3Coordinate(const double& value)
-{
-   throw UbException(UB_EXARGS,"not implemented.");
-}
-/*=====================================================*/
-void GbObjectGroup3D::setRadius(const double& radius)
-{
-   throw UbException(UB_EXARGS,"not implemented.");
-}
-/*=====================================================*/
-double GbObjectGroup3D::getDistance(const double& x1p, const double& x2p, const double& x3p)
-{
-   throw UbException(UB_EXARGS,"not implemented.");
-}
-/*=====================================================*/
-//true, wenn 'in Object' oder 'auf Boundary'!
-bool GbObjectGroup3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
-{
-   return false;
-}
-/*=====================================================*/
-//true, wenn 'in Object' oder 'auf Boundary'!
-bool GbObjectGroup3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
-{
-   return false;
-}
-/*=====================================================*/
-string GbObjectGroup3D::toString()
-{
-	stringstream ss;
-	ss<< "GbObjectGroup3D[";
-	ss <<"mid="<<midPoint->toString()<<", r="<<radius<<"]";
-	return ss.str();
-}
-/*=====================================================*/
-GbLine3D* GbObjectGroup3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
-{
-   return NULL;
-}
-/*=========================================================================*/
-vector<GbTriangle3D*> GbObjectGroup3D::getSurfaceTriangleSet()
-{
-   vector<GbTriangle3D*> allTriangles;
-
-   //loop ueber alle objekte in der group
-   for( std::list< GbObject3D* >::iterator iter = this->geoobjects.begin();
-                                          iter != this->geoobjects.end();
-                                          iter++ )
-   {
-      vector<GbTriangle3D*> triangles;
-      triangles = (*iter)->getSurfaceTriangleSet();
-
-      for( size_t i=0;i<triangles.size(); i++ )
-      {
-         //kopieren...
-         allTriangles.push_back( triangles[i] );
-      }
-   }
-   return allTriangles;
-}
-/*=======================================================*/
-void GbObjectGroup3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles)
-{
-}
-/*=======================================================*/
-void GbObjectGroup3D::write(UbFileOutput* out)
-{
-   out->writeString(this->getCreator()->getTypeID());
-   midPoint->write(out);
-   out->writeDouble(radius);
-   out->writeInteger((int)triangulationMode);
-}
-/*=======================================================*/
-void GbObjectGroup3D::read(UbFileInput* in)
-{
-}
-/*=======================================================*/
-bool GbObjectGroup3D::hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction)
-{
-   return false;
-}
-/*=======================================================*/
-bool GbObjectGroup3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-{
-   return false;
-}
-/*=======================================================*/
-bool GbObjectGroup3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-{
-   return false;
-}
-/*==========================================================*/
-double GbObjectGroup3D::getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-{
-   return 0.0;
-}
-/*==========================================================*/
-double GbObjectGroup3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
-{
-   return 0.0;
-}
-/*=======================================================*/
+#include <numerics/geometry3d/GbObjectGroup3D.h>
+#include <numerics/geometry3d/GbSystem3D.h>
+#include <numerics/geometry3d/GbPoint3D.h>
+#include <numerics/geometry3d/GbLine3D.h>
+#include <numerics/geometry3d/GbTriangle3D.h>
+
+using namespace std;
+
+/*=====================================================*/
+GbObjectGroup3D::GbObjectGroup3D()
+{
+   this->setName("ObjectGroup");
+}
+/*=====================================================*/
+GbObjectGroup3D::~GbObjectGroup3D()
+{
+}
+/*=====================================================*/
+void GbObjectGroup3D::finalize()
+{
+   throw UbException(UB_EXARGS,"not implemented.");
+}
+/*=======================================================*/
+void GbObjectGroup3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3)
+{
+   throw UbException(UB_EXARGS,"not implemented.");
+}
+/*=====================================================*/
+double GbObjectGroup3D::getDistance(GbPoint3D* p)
+{
+   throw UbException(UB_EXARGS,"not implemented.");
+}
+/*=====================================================*/
+
+void GbObjectGroup3D::setCenterX1Coordinate(const double& value)
+{
+   throw UbException(UB_EXARGS,"not implemented.");
+}
+/*=====================================================*/
+void GbObjectGroup3D::setCenterX2Coordinate(const double& value)
+{
+   throw UbException(UB_EXARGS,"not implemented.");
+}
+/*=====================================================*/
+void GbObjectGroup3D::setCenterX3Coordinate(const double& value)
+{
+   throw UbException(UB_EXARGS,"not implemented.");
+}
+/*=====================================================*/
+void GbObjectGroup3D::setRadius(const double& radius)
+{
+   throw UbException(UB_EXARGS,"not implemented.");
+}
+/*=====================================================*/
+double GbObjectGroup3D::getDistance(const double& x1p, const double& x2p, const double& x3p)
+{
+   throw UbException(UB_EXARGS,"not implemented.");
+}
+/*=====================================================*/
+//true, wenn 'in Object' oder 'auf Boundary'!
+bool GbObjectGroup3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
+{
+   return false;
+}
+/*=====================================================*/
+//true, wenn 'in Object' oder 'auf Boundary'!
+bool GbObjectGroup3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
+{
+   return false;
+}
+/*=====================================================*/
+string GbObjectGroup3D::toString()
+{
+	stringstream ss;
+	ss<< "GbObjectGroup3D[";
+	ss <<"mid="<<midPoint->toString()<<", r="<<radius<<"]";
+	return ss.str();
+}
+/*=====================================================*/
+GbLine3D* GbObjectGroup3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
+{
+   return NULL;
+}
+/*=========================================================================*/
+vector<GbTriangle3D*> GbObjectGroup3D::getSurfaceTriangleSet()
+{
+   vector<GbTriangle3D*> allTriangles;
+
+   //loop ueber alle objekte in der group
+   for( std::list< GbObject3D* >::iterator iter = this->geoobjects.begin();
+                                          iter != this->geoobjects.end();
+                                          iter++ )
+   {
+      vector<GbTriangle3D*> triangles;
+      triangles = (*iter)->getSurfaceTriangleSet();
+
+      for( size_t i=0;i<triangles.size(); i++ )
+      {
+         //kopieren...
+         allTriangles.push_back( triangles[i] );
+      }
+   }
+   return allTriangles;
+}
+/*=======================================================*/
+void GbObjectGroup3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles)
+{
+}
+/*=======================================================*/
+void GbObjectGroup3D::write(UbFileOutput* out)
+{
+   out->writeString(this->getCreator()->getTypeID());
+   midPoint->write(out);
+   out->writeDouble(radius);
+   out->writeInteger((int)triangulationMode);
+}
+/*=======================================================*/
+void GbObjectGroup3D::read(UbFileInput* in)
+{
+}
+/*=======================================================*/
+bool GbObjectGroup3D::hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction)
+{
+   return false;
+}
+/*=======================================================*/
+bool GbObjectGroup3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+{
+   return false;
+}
+/*=======================================================*/
+bool GbObjectGroup3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+{
+   return false;
+}
+/*==========================================================*/
+double GbObjectGroup3D::getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+{
+   return 0.0;
+}
+/*==========================================================*/
+double GbObjectGroup3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
+{
+   return 0.0;
+}
+/*=======================================================*/
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbObjectGroup3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbObjectGroup3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbObjectGroup3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbObjectGroup3D.h
index 4620de5f0ed0c84ec8516f08df172d69021bb043..49c00da70586ebf1f52a65011a70e4f321de4696 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbObjectGroup3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbObjectGroup3D.h
@@ -1,159 +1,159 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBOBJECTGROUP3D_H
-#define GBOBJECTGROUP3D_H
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-#ifdef CAB_CTL
-   #include <ctl.h>
-#endif //CAB_CTL
-
-#include <vector>
-#include <cmath>
-
-#include <numerics/geometry3d/GbObject3D.h>
-#include <basics/utilities/UbObserver.h>
-#include <numerics/geometry3d/GbPoint3D.h>
-
-#include <PointerDefinitions.h>
-
-class GbLine3D;
-class GbTriangle3D;
-class GbObject3DCreator;
-
-class GbObjectGroup3D : public GbObject3D, public UbObserver
-{                                              
-public:
-   enum TRIANGULATIONMODE { CUBOIDPROJECTION ,RAYPROJECTION };
-   
-   //////////////////////////////////////////////////////////////////////////
-   // Konstruktoren
-   GbObjectGroup3D(); 
-   GbObjectGroup3D(GbObjectGroup3D *group){}; 
-   ~GbObjectGroup3D();
-
-   GbObjectGroup3D* clone() {return new GbObjectGroup3D(this);}
-   void finalize();
-
-   void addGbObject(GbObject3D* object)
-   {
-      this->geoobjects.push_back(object);
-   }
-
-   double getRadius() const	{	return this->radius;	}
-
-   double getX1Centroid()  { return midPoint->getX1Coordinate();}
-   double getX1Minimum()   { return midPoint->getX1Coordinate()-radius;}
-   double getX1Maximum()   { return midPoint->getX1Coordinate()+radius;}
-   double getX2Centroid()  { return midPoint->getX2Coordinate();}
-   double getX2Minimum()   { return midPoint->getX2Coordinate()-radius;}
-   double getX2Maximum()   { return midPoint->getX2Coordinate()+radius;}
-   double getX3Centroid()  { return midPoint->getX3Coordinate();}
-   double getX3Minimum()   { return midPoint->getX3Coordinate()-radius;}
-   double getX3Maximum()   { return midPoint->getX3Coordinate()+radius;}
-
-   void setCenterX1Coordinate(const double& value);
-   void setCenterX2Coordinate(const double& value);
-   void setCenterX3Coordinate(const double& value);
-   void setCenterCoordinates(const double& x1, const double& x2, const double& x3);
-   void setRadius(const double& radius);
-
-   GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2);
-   double getDistance(GbPoint3D* p); 
-   double getDistance(const double& x1p, const double& x2p, const double& x3p);
-
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3);
-   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary);
-
-   bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   
-   std::vector<GbTriangle3D*> getSurfaceTriangleSet();
-   void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles);
-                                
-   bool hasRaytracing() { return true; }
-   /*|r| must be 1! einheitsvector!!*/
-   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
-
-   bool hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction);
-
-	std::string toString();
-
-   ObObjectCreator* getCreator(){ return NULL; };
-   void write(UbFileOutput* out);
-   void read(UbFileInput* in);       
-
-   void translate(const double& x1, const double& x2, const double& x3) 
-   {
-      this->midPoint->translate(x1, x2, x3); 
-      this->notifyObserversObjectChanged();
-   }
-   void rotate(const double& rx1, const double& rx2, const double& rx3) {/* rotation makes no sense*/ }
-   void scale(const double& sx1, const double& sx2, const double& sx3) { this->radius *= sx1; }
-
-   TRIANGULATIONMODE getTriangulationMode() {return triangulationMode;}
-   void setTriangulationMode(TRIANGULATIONMODE mode) { this->triangulationMode = mode; }
-   
-   //virtuelle Methoden von UbObserver
-   void objectChanged(UbObservable* changedObject)
-   {
-      this->notifyObserversObjectChanged();
-      //std::cout<<"GbSphere:objectChanged() - toDo-);";
-   }
-   void objectWillBeDeleted(UbObservable* objectForDeletion)
-   {
-	   std::cout<<"throw UbException(-GbObjectGroup3D::finalize() - toDo-);";
-   }
-
-   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere, weil man eine
-
-   std::list< GbObject3D* > getGbObject3DList() { return this->geoobjects; }
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void SF_SERIALIZE(Archive & ar)
-   {
-      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
-      ar & midPoint;
-      ar & radius;
-      ar & triangulationMode;
-      ar & geoobjects;
-   }
-#endif //CAB_RCF
-#ifdef CAB_CTL
-   ctl::oStream &write(ctl::oStream &os) const
-   { 
-      midPoint->write(os);
-      return os<<radius; 
-   }
-   ctl::iStream &read(ctl::iStream &is) 
-   { 
-      midPoint->read(is);
-      return is>>radius;
-   }
-#endif //CAB_CTL
-
-private:
-   GbPoint3D* midPoint;
-   double radius;  // Radius des Kreises
-   TRIANGULATIONMODE triangulationMode;
-
-   std::list< GbObject3D* > geoobjects;
-};
-
-#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
-   #if defined(RCF_USE_SF_SERIALIZATION) && (CAB_RCF <= 903) 
-      SF_SERIALIZE_ENUM(GbObjectGroup3D::TRIANGULATIONMODE) //bei klassen ausserhalb der klasse;-)
-   #endif
-   UB_AUTO_RUN_NAMED(   SF::registerType<GbObjectGroup3D>("GbObjectGroup3D")        , SF_GbObjectGroup3D     );
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbObjectGroup3D >()), SF_GbObjectGroup3D_BD1 );
-#endif //RCF_USE_SF_SERIALIZATION
-
-#endif //GbObjectGroup3D_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBOBJECTGROUP3D_H
+#define GBOBJECTGROUP3D_H
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+#ifdef CAB_CTL
+   #include <ctl.h>
+#endif //CAB_CTL
+
+#include <vector>
+#include <cmath>
+
+#include <numerics/geometry3d/GbObject3D.h>
+#include <basics/utilities/UbObserver.h>
+#include <numerics/geometry3d/GbPoint3D.h>
+
+#include <PointerDefinitions.h>
+
+class GbLine3D;
+class GbTriangle3D;
+class GbObject3DCreator;
+
+class GbObjectGroup3D : public GbObject3D, public UbObserver
+{                                              
+public:
+   enum TRIANGULATIONMODE { CUBOIDPROJECTION ,RAYPROJECTION };
+   
+   //////////////////////////////////////////////////////////////////////////
+   // Konstruktoren
+   GbObjectGroup3D(); 
+   GbObjectGroup3D(GbObjectGroup3D *group){}; 
+   ~GbObjectGroup3D();
+
+   GbObjectGroup3D* clone() {return new GbObjectGroup3D(this);}
+   void finalize();
+
+   void addGbObject(GbObject3D* object)
+   {
+      this->geoobjects.push_back(object);
+   }
+
+   double getRadius() const	{	return this->radius;	}
+
+   double getX1Centroid()  { return midPoint->getX1Coordinate();}
+   double getX1Minimum()   { return midPoint->getX1Coordinate()-radius;}
+   double getX1Maximum()   { return midPoint->getX1Coordinate()+radius;}
+   double getX2Centroid()  { return midPoint->getX2Coordinate();}
+   double getX2Minimum()   { return midPoint->getX2Coordinate()-radius;}
+   double getX2Maximum()   { return midPoint->getX2Coordinate()+radius;}
+   double getX3Centroid()  { return midPoint->getX3Coordinate();}
+   double getX3Minimum()   { return midPoint->getX3Coordinate()-radius;}
+   double getX3Maximum()   { return midPoint->getX3Coordinate()+radius;}
+
+   void setCenterX1Coordinate(const double& value);
+   void setCenterX2Coordinate(const double& value);
+   void setCenterX3Coordinate(const double& value);
+   void setCenterCoordinates(const double& x1, const double& x2, const double& x3);
+   void setRadius(const double& radius);
+
+   GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2);
+   double getDistance(GbPoint3D* p); 
+   double getDistance(const double& x1p, const double& x2p, const double& x3p);
+
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3);
+   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary);
+
+   bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   
+   std::vector<GbTriangle3D*> getSurfaceTriangleSet();
+   void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles);
+                                
+   bool hasRaytracing() { return true; }
+   /*|r| must be 1! einheitsvector!!*/
+   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
+
+   bool hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction);
+
+	std::string toString();
+
+   ObObjectCreator* getCreator(){ return NULL; };
+   void write(UbFileOutput* out);
+   void read(UbFileInput* in);       
+
+   void translate(const double& x1, const double& x2, const double& x3) 
+   {
+      this->midPoint->translate(x1, x2, x3); 
+      this->notifyObserversObjectChanged();
+   }
+   void rotate(const double& rx1, const double& rx2, const double& rx3) {/* rotation makes no sense*/ }
+   void scale(const double& sx1, const double& sx2, const double& sx3) { this->radius *= sx1; }
+
+   TRIANGULATIONMODE getTriangulationMode() {return triangulationMode;}
+   void setTriangulationMode(TRIANGULATIONMODE mode) { this->triangulationMode = mode; }
+   
+   //virtuelle Methoden von UbObserver
+   void objectChanged(UbObservable* changedObject)
+   {
+      this->notifyObserversObjectChanged();
+      //std::cout<<"GbSphere:objectChanged() - toDo-);";
+   }
+   void objectWillBeDeleted(UbObservable* objectForDeletion)
+   {
+	   std::cout<<"throw UbException(-GbObjectGroup3D::finalize() - toDo-);";
+   }
+
+   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere, weil man eine
+
+   std::list< GbObject3D* > getGbObject3DList() { return this->geoobjects; }
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void SF_SERIALIZE(Archive & ar)
+   {
+      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
+      ar & midPoint;
+      ar & radius;
+      ar & triangulationMode;
+      ar & geoobjects;
+   }
+#endif //CAB_RCF
+#ifdef CAB_CTL
+   ctl::oStream &write(ctl::oStream &os) const
+   { 
+      midPoint->write(os);
+      return os<<radius; 
+   }
+   ctl::iStream &read(ctl::iStream &is) 
+   { 
+      midPoint->read(is);
+      return is>>radius;
+   }
+#endif //CAB_CTL
+
+private:
+   GbPoint3D* midPoint;
+   double radius;  // Radius des Kreises
+   TRIANGULATIONMODE triangulationMode;
+
+   std::list< GbObject3D* > geoobjects;
+};
+
+#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
+   #if defined(RCF_USE_SF_SERIALIZATION) && (CAB_RCF <= 903) 
+      SF_SERIALIZE_ENUM(GbObjectGroup3D::TRIANGULATIONMODE) //bei klassen ausserhalb der klasse;-)
+   #endif
+   UB_AUTO_RUN_NAMED(   SF::registerType<GbObjectGroup3D>("GbObjectGroup3D")        , SF_GbObjectGroup3D     );
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbObjectGroup3D >()), SF_GbObjectGroup3D_BD1 );
+#endif //RCF_USE_SF_SERIALIZATION
+
+#endif //GbObjectGroup3D_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbPoint3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbPoint3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbPoint3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbPoint3D.cpp
index 980fcf386f20cb0e64c56e0301bbc23995b269e4..e5fec169c8e3e79612f4eee83004d262df200235 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbPoint3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbPoint3D.cpp
@@ -1,146 +1,146 @@
-#include <numerics/geometry3d/GbPoint3D.h>
-//#include <numerics/geometry3d/GbTriangle3D.h>
-#include <numerics/geometry3d/creator/GbPoint3DCreator.h>
-
-using namespace std;
-
-/*=======================================================*/
-ObObjectCreator* GbPoint3D::getCreator()
-{
-   return GbPoint3DCreator::getInstance();
-}
-/*=======================================================*/
-GbPoint3D::GbPoint3D()
-{ 
-   this->x1=0.0; 
-   this->x2=0.0; 
-   this->x3=0.0;
-}                                             
-/*=======================================================*/
-GbPoint3D::GbPoint3D(const double& x1, const double& x2, const double& x3)
-{ 
-   this->x1=x1; 
-   this->x2=x2; 
-   this->x3=x3;
-}
-/*=======================================================*/
-GbPoint3D::GbPoint3D(GbPoint3D* point)
-{
-   this->x1 = point->x1;                                             
-   this->x2 = point->x2;
-   this->x3 = point->x3;
-} 
-/*=======================================================*/
-double GbPoint3D::getDistance(GbPoint3D* p)
-{
-   double dx1 = this->x1 - p->x1;
-   double dx2 = this->x2 - p->x2;
-   double dx3 = this->x3 - p->x3;
-   return std::sqrt(dx1*dx1 + dx2*dx2 + dx3*dx3);
-}
-/*=======================================================*/
-bool GbPoint3D::equals(const GbPoint3D* point) const
-{
-   if(fabs(this->x1-point->x1)>1.E-10) return false;
-   if(fabs(this->x2-point->x2)>1.E-10) return false;
-   if(fabs(this->x3-point->x3)>1.E-10) return false;
-
-   return true;
-}
-/*=======================================================*/
-void GbPoint3D::transform(const double matrix[4][4])
-{
-   double tempX1 = x1;
-   double tempX2 = x2;
-   double tempX3 = x3;
-   x1 = matrix[0][0] * tempX1 + matrix[0][1] * tempX2 + matrix[0][2] * tempX3 + matrix[0][3] * 1.;
-   x2 = matrix[1][0] * tempX1 + matrix[1][1] * tempX2 + matrix[1][2] * tempX3 + matrix[1][3] * 1.;
-   x3 = matrix[2][0] * tempX1 + matrix[2][1] * tempX2 + matrix[2][2] * tempX3 + matrix[2][3] * 1.;
-}
-/*=======================================================*/
-bool GbPoint3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3)
-{
-   return (fabs(x1)<1.E-13 && fabs(x2)<1.E-13 && fabs(x3)<1.E-13 );
-}
-/*=======================================================*/
-bool GbPoint3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)
-{
-   pointIsOnBoundary = (fabs(x1)<1.E-13 && fabs(x2)<1.E-13 && fabs(x3)<1.E-13 );
-   return pointIsOnBoundary;
-}
-/*=======================================================*/
-vector<GbTriangle3D*> GbPoint3D::getSurfaceTriangleSet()
-{            
-   cout<<"GbPoint3D::getSurfaceTriangleSet() - test ... if no exception occurs, everything is fine\n";
-   vector<GbTriangle3D*> triangles;
-   return triangles; //<-empty vector! is okay!
-   
-   //old:
-   //to avoid unnecessary exceptions a point will generate a triangle with
-   //three point with same coordinates
-   //vector<GbTriangle3D*> triangles;
-   //GbPoint3D p1(getX1Coordinate(),getX2Coordinate(),getX3Coordinate());
-   //triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p1),new GbPoint3D(p1)));
-}
-/*=======================================================*/
-GbLine3D* GbPoint3D::createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2)
-{
-   throw UbException(UB_EXARGS,"not implemented");
-} 
-/*=======================================================*/
-string GbPoint3D::toString()
-{
-   stringstream ss;
-   ss<<"GbPoint3D["<<this->x1<<","<<this->x2<<","<<this->x3<<"]";
-   return((ss.str()).c_str());
-}
-/*=======================================================*/
-void GbPoint3D::write(UbFileOutput* out) 
-{                                      
-   out->writeString(this->getCreator()->getTypeID());
-   out->writeDouble(x1);
-   out->writeDouble(x2);
-   out->writeDouble(x3);
-}
-/*=======================================================*/
-void GbPoint3D::read(UbFileInput* in) 
-{  
-   x1=in->readDouble();
-   x2=in->readDouble();
-   x3=in->readDouble();
-}
-/*=======================================================*/
-void GbPoint3D::translate(const double& dx1, const double& dx2, const double& dx3)
-{  
-   this->x1 += dx1;
-   this->x2 += dx2;
-   this->x3 += dx3;
-  // wenn Notify hier dann nicht im Cuboid oder spher translate ?!
-   //sollte eigentlich!
-   //--> hier muss notify aufgerufen werden udn rekuriv dann z.B. Cuboid, etc 
-   
-   //aber da ist halt einfach daemlich, ich asse es auf gellers way... (erstmal)
-   this->notifyObserversObjectChanged(); 
-}
-/*=======================================================*/
-void GbPoint3D::rotate(const double& rx1, const double& rx2, const double& rx3)
-{  
-   double newX1 = cos(rx3)*cos(rx2)*x1-x2*sin(rx3)*cos(rx1)+x2*cos(rx3)*sin(rx2)*sin(rx1)+x3*sin(rx3)*sin(rx1)+x3*cos(rx3)*sin(rx2)*cos(rx1);
-   double newX2 =  sin(rx3)*cos(rx2)*x1+x2*cos(rx3)*cos(rx1)+x2*sin(rx3)*sin(rx2)*sin(rx1)-x3*cos(rx3)*sin(rx1)+x3*sin(rx3)*sin(rx2)*cos(rx1);
-   double newX3 = -sin(rx2)*x1+cos(rx2)*sin(rx1)*x2+cos(rx2)*cos(rx1)*x3;
-
-   this->x1 = newX1;
-   this->x2 = newX2;
-   this->x3 = newX3;
-   this->notifyObserversObjectChanged(); 
-}
-/*=======================================================*/
-void GbPoint3D::scale(const double& sx1, const double& sx2, const double& sx3)
-{  
-   this->x1 *= sx1;
-   this->x2 *= sx2;
-   this->x3 *= sx3;
-   this->notifyObserversObjectChanged(); 
-}
-/*=======================================================*/
-
+#include <numerics/geometry3d/GbPoint3D.h>
+//#include <numerics/geometry3d/GbTriangle3D.h>
+#include <numerics/geometry3d/creator/GbPoint3DCreator.h>
+
+using namespace std;
+
+/*=======================================================*/
+ObObjectCreator* GbPoint3D::getCreator()
+{
+   return GbPoint3DCreator::getInstance();
+}
+/*=======================================================*/
+GbPoint3D::GbPoint3D()
+{ 
+   this->x1=0.0; 
+   this->x2=0.0; 
+   this->x3=0.0;
+}                                             
+/*=======================================================*/
+GbPoint3D::GbPoint3D(const double& x1, const double& x2, const double& x3)
+{ 
+   this->x1=x1; 
+   this->x2=x2; 
+   this->x3=x3;
+}
+/*=======================================================*/
+GbPoint3D::GbPoint3D(GbPoint3D* point)
+{
+   this->x1 = point->x1;                                             
+   this->x2 = point->x2;
+   this->x3 = point->x3;
+} 
+/*=======================================================*/
+double GbPoint3D::getDistance(GbPoint3D* p)
+{
+   double dx1 = this->x1 - p->x1;
+   double dx2 = this->x2 - p->x2;
+   double dx3 = this->x3 - p->x3;
+   return std::sqrt(dx1*dx1 + dx2*dx2 + dx3*dx3);
+}
+/*=======================================================*/
+bool GbPoint3D::equals(const GbPoint3D* point) const
+{
+   if(fabs(this->x1-point->x1)>1.E-10) return false;
+   if(fabs(this->x2-point->x2)>1.E-10) return false;
+   if(fabs(this->x3-point->x3)>1.E-10) return false;
+
+   return true;
+}
+/*=======================================================*/
+void GbPoint3D::transform(const double matrix[4][4])
+{
+   double tempX1 = x1;
+   double tempX2 = x2;
+   double tempX3 = x3;
+   x1 = matrix[0][0] * tempX1 + matrix[0][1] * tempX2 + matrix[0][2] * tempX3 + matrix[0][3] * 1.;
+   x2 = matrix[1][0] * tempX1 + matrix[1][1] * tempX2 + matrix[1][2] * tempX3 + matrix[1][3] * 1.;
+   x3 = matrix[2][0] * tempX1 + matrix[2][1] * tempX2 + matrix[2][2] * tempX3 + matrix[2][3] * 1.;
+}
+/*=======================================================*/
+bool GbPoint3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3)
+{
+   return (fabs(x1)<1.E-13 && fabs(x2)<1.E-13 && fabs(x3)<1.E-13 );
+}
+/*=======================================================*/
+bool GbPoint3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)
+{
+   pointIsOnBoundary = (fabs(x1)<1.E-13 && fabs(x2)<1.E-13 && fabs(x3)<1.E-13 );
+   return pointIsOnBoundary;
+}
+/*=======================================================*/
+vector<GbTriangle3D*> GbPoint3D::getSurfaceTriangleSet()
+{            
+   cout<<"GbPoint3D::getSurfaceTriangleSet() - test ... if no exception occurs, everything is fine\n";
+   vector<GbTriangle3D*> triangles;
+   return triangles; //<-empty vector! is okay!
+   
+   //old:
+   //to avoid unnecessary exceptions a point will generate a triangle with
+   //three point with same coordinates
+   //vector<GbTriangle3D*> triangles;
+   //GbPoint3D p1(getX1Coordinate(),getX2Coordinate(),getX3Coordinate());
+   //triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p1),new GbPoint3D(p1)));
+}
+/*=======================================================*/
+GbLine3D* GbPoint3D::createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2)
+{
+   throw UbException(UB_EXARGS,"not implemented");
+} 
+/*=======================================================*/
+string GbPoint3D::toString()
+{
+   stringstream ss;
+   ss<<"GbPoint3D["<<this->x1<<","<<this->x2<<","<<this->x3<<"]";
+   return((ss.str()).c_str());
+}
+/*=======================================================*/
+void GbPoint3D::write(UbFileOutput* out) 
+{                                      
+   out->writeString(this->getCreator()->getTypeID());
+   out->writeDouble(x1);
+   out->writeDouble(x2);
+   out->writeDouble(x3);
+}
+/*=======================================================*/
+void GbPoint3D::read(UbFileInput* in) 
+{  
+   x1=in->readDouble();
+   x2=in->readDouble();
+   x3=in->readDouble();
+}
+/*=======================================================*/
+void GbPoint3D::translate(const double& dx1, const double& dx2, const double& dx3)
+{  
+   this->x1 += dx1;
+   this->x2 += dx2;
+   this->x3 += dx3;
+  // wenn Notify hier dann nicht im Cuboid oder spher translate ?!
+   //sollte eigentlich!
+   //--> hier muss notify aufgerufen werden udn rekuriv dann z.B. Cuboid, etc 
+   
+   //aber da ist halt einfach daemlich, ich asse es auf gellers way... (erstmal)
+   this->notifyObserversObjectChanged(); 
+}
+/*=======================================================*/
+void GbPoint3D::rotate(const double& rx1, const double& rx2, const double& rx3)
+{  
+   double newX1 = cos(rx3)*cos(rx2)*x1-x2*sin(rx3)*cos(rx1)+x2*cos(rx3)*sin(rx2)*sin(rx1)+x3*sin(rx3)*sin(rx1)+x3*cos(rx3)*sin(rx2)*cos(rx1);
+   double newX2 =  sin(rx3)*cos(rx2)*x1+x2*cos(rx3)*cos(rx1)+x2*sin(rx3)*sin(rx2)*sin(rx1)-x3*cos(rx3)*sin(rx1)+x3*sin(rx3)*sin(rx2)*cos(rx1);
+   double newX3 = -sin(rx2)*x1+cos(rx2)*sin(rx1)*x2+cos(rx2)*cos(rx1)*x3;
+
+   this->x1 = newX1;
+   this->x2 = newX2;
+   this->x3 = newX3;
+   this->notifyObserversObjectChanged(); 
+}
+/*=======================================================*/
+void GbPoint3D::scale(const double& sx1, const double& sx2, const double& sx3)
+{  
+   this->x1 *= sx1;
+   this->x2 *= sx2;
+   this->x3 *= sx3;
+   this->notifyObserversObjectChanged(); 
+}
+/*=======================================================*/
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbPoint3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbPoint3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbPoint3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbPoint3D.h
index 4b3b45f16bf4657f79e45fe2ca4f4e1595c7e56e..611e1a036636dc7c6805c87deb92269d16a9eac6 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbPoint3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbPoint3D.h
@@ -1,120 +1,120 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBPOINT3D_H
-#define GBPOINT3D_H
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-#include <string>
-#include <sstream>
-#include <cmath>
-
-#include <numerics/geometry3d/GbObject3D.h>
-
-#include <PointerDefinitions.h>
-
-class GbTriangle3D;
-class GbObject3DCreator;
-
-#ifdef CAB_CTL
-   #include <ctl.h>
-#endif
-
-class GbPoint3D : public GbObject3D
-{
-public:
-   GbPoint3D();
-   GbPoint3D(const double& x1, const double& x2, const double& x3);
-   GbPoint3D(GbPoint3D *point);                
-   ~GbPoint3D() {}
-
-   GbPoint3D* clone() {return new GbPoint3D(this);}
-   void finalize() {}
-
-   void setCoordinates(const double& x1, const double& x2, const double& x3)
-   {
-       this->x1=x1;
-       this->x2=x2;
-       this->x3=x3;
-       this->notifyObserversObjectChanged();
-   }
-   void setX1(const double& x1) { this->x1=x1; this->notifyObserversObjectChanged(); }
-   void setX2(const double& x2) { this->x2=x2; this->notifyObserversObjectChanged(); }
-   void setX3(const double& x3) { this->x3=x3; this->notifyObserversObjectChanged(); }
-
-   double getX1Coordinate() const  { return this->x1; }
-   double getX2Coordinate() const  { return this->x2; }
-   double getX3Coordinate() const  { return this->x3; }
-
-   void transform(const double matrix[4][4]);
- 
-   double getX1Centroid()  { return this->x1; }
-   double getX1Minimum()   { return this->x1; }
-   double getX1Maximum()   { return this->x1; }
-   double getX2Centroid()  { return this->x2; }
-   double getX2Minimum()   { return this->x2; }
-   double getX2Maximum()   { return this->x2; }
-   double getX3Centroid()  { return this->x3; }
-   double getX3Minimum()   { return this->x3; }
-   double getX3Maximum()   { return this->x3; }        
- 
-   void translate(const double& x1, const double& x2, const double& x3);
-   void rotate(const double& rx1, const double& rx2, const double& rx3);
-   void scale(const double& sx1, const double& sx2, const double& sx3);
-
-   double getDistance(GbPoint3D *p);
-   bool equals(const GbPoint3D* point) const;
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary);
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3);
-   bool isCellInsideGbObject3D(const double& x11,const double& x21,const double& x31,const double& x12,const double& x22,const double& x23) { return false; }
-
-   std::vector<GbTriangle3D*> getSurfaceTriangleSet();
-   GbLine3D* createClippedLine3D(GbPoint3D &point1, GbPoint3D &point2);
-   virtual std::string toString();
-   ObObjectCreator* getCreator();
-   void write(UbFileOutput* out);
-   void read(UbFileInput* in);
-
-   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren
-                                          //, welche sonst hier "ueberdeckt" waere,da es dieselbe methode mit anderen args gibt!
-#ifdef CAB_RCF
-   template<class Archive>
-   void SF_SERIALIZE(Archive & ar)
-   {
-      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
-      ar & x1; 
-      ar & x2; 
-      ar & x3;
-   }
-#endif //CAB_RCF
-
-#ifdef CAB_CTL
-   ctl::oStream &write(ctl::oStream &os) const
-   { 
-      return os<<x1<<x2<<x3; 
-   }
-   ctl::iStream &read(ctl::iStream &is) 
-   { 
-      return is>>x1>>x2>>x3;
-   }
-#endif
-
-   //member
-   double x1;
-   double x2;
-   double x3;      
-};
-
-
-#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
-   UB_AUTO_RUN_NAMED(   SF::registerType<GbPoint3D>("GbPoint3D")              , SF_GbPoint3D      );
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbPoint3D >()), SF_GbPoint3D_BD1 );
-#endif //RCF_USE_SF_SERIALIZATION
-
-#endif
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBPOINT3D_H
+#define GBPOINT3D_H
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+#include <string>
+#include <sstream>
+#include <cmath>
+
+#include <numerics/geometry3d/GbObject3D.h>
+
+#include <PointerDefinitions.h>
+
+class GbTriangle3D;
+class GbObject3DCreator;
+
+#ifdef CAB_CTL
+   #include <ctl.h>
+#endif
+
+class GbPoint3D : public GbObject3D
+{
+public:
+   GbPoint3D();
+   GbPoint3D(const double& x1, const double& x2, const double& x3);
+   GbPoint3D(GbPoint3D *point);                
+   ~GbPoint3D() {}
+
+   GbPoint3D* clone() {return new GbPoint3D(this);}
+   void finalize() {}
+
+   void setCoordinates(const double& x1, const double& x2, const double& x3)
+   {
+       this->x1=x1;
+       this->x2=x2;
+       this->x3=x3;
+       this->notifyObserversObjectChanged();
+   }
+   void setX1(const double& x1) { this->x1=x1; this->notifyObserversObjectChanged(); }
+   void setX2(const double& x2) { this->x2=x2; this->notifyObserversObjectChanged(); }
+   void setX3(const double& x3) { this->x3=x3; this->notifyObserversObjectChanged(); }
+
+   double getX1Coordinate() const  { return this->x1; }
+   double getX2Coordinate() const  { return this->x2; }
+   double getX3Coordinate() const  { return this->x3; }
+
+   void transform(const double matrix[4][4]);
+ 
+   double getX1Centroid()  { return this->x1; }
+   double getX1Minimum()   { return this->x1; }
+   double getX1Maximum()   { return this->x1; }
+   double getX2Centroid()  { return this->x2; }
+   double getX2Minimum()   { return this->x2; }
+   double getX2Maximum()   { return this->x2; }
+   double getX3Centroid()  { return this->x3; }
+   double getX3Minimum()   { return this->x3; }
+   double getX3Maximum()   { return this->x3; }        
+ 
+   void translate(const double& x1, const double& x2, const double& x3);
+   void rotate(const double& rx1, const double& rx2, const double& rx3);
+   void scale(const double& sx1, const double& sx2, const double& sx3);
+
+   double getDistance(GbPoint3D *p);
+   bool equals(const GbPoint3D* point) const;
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary);
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3);
+   bool isCellInsideGbObject3D(const double& x11,const double& x21,const double& x31,const double& x12,const double& x22,const double& x23) { return false; }
+
+   std::vector<GbTriangle3D*> getSurfaceTriangleSet();
+   GbLine3D* createClippedLine3D(GbPoint3D &point1, GbPoint3D &point2);
+   virtual std::string toString();
+   ObObjectCreator* getCreator();
+   void write(UbFileOutput* out);
+   void read(UbFileInput* in);
+
+   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren
+                                          //, welche sonst hier "ueberdeckt" waere,da es dieselbe methode mit anderen args gibt!
+#ifdef CAB_RCF
+   template<class Archive>
+   void SF_SERIALIZE(Archive & ar)
+   {
+      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
+      ar & x1; 
+      ar & x2; 
+      ar & x3;
+   }
+#endif //CAB_RCF
+
+#ifdef CAB_CTL
+   ctl::oStream &write(ctl::oStream &os) const
+   { 
+      return os<<x1<<x2<<x3; 
+   }
+   ctl::iStream &read(ctl::iStream &is) 
+   { 
+      return is>>x1>>x2>>x3;
+   }
+#endif
+
+   //member
+   double x1;
+   double x2;
+   double x3;      
+};
+
+
+#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
+   UB_AUTO_RUN_NAMED(   SF::registerType<GbPoint3D>("GbPoint3D")              , SF_GbPoint3D      );
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbPoint3D >()), SF_GbPoint3D_BD1 );
+#endif //RCF_USE_SF_SERIALIZATION
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbPolygon3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbPolygon3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbPolygon3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbPolygon3D.cpp
index 879c6a9af274e551d306ccb99eb6a1998a7cd723..80f88334741760505fedfe5ed40e836cbb74acdd 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbPolygon3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbPolygon3D.cpp
@@ -1,686 +1,686 @@
-#include <numerics/geometry3d/GbPolygon3D.h>
-#include <numerics/geometry3d/creator/GbPolygon3DCreator.h>
-
-using namespace std;
-
-ObObjectCreator* GbPolygon3D::getCreator()
-{
-   return GbPolygon3DCreator::getInstance();
-}
-
-int GbPolygon3D::counter = 0;
-
-GbPolygon3D::GbPolygon3D()
-{
-   init();
-   counter++;
-   this->ps = new GbSystem3D::PointSet3(0);
-}
-void GbPolygon3D::init()
-{
-   x1s        = 0.0;
-   x2s        = 0.0;
-   x1min      = 0.0;
-   x1max      = 0.0;
-   x2min      = 0.0;
-   x2max      = 0.0;
-   //		points   = NULL;
-   consistent = false;
-   ps         = NULL;
-}
-
-/**
-* Creates an empty 3D polygon with the specified capacity.
-* @param capacity the initial capacity
-*/
-GbPolygon3D::GbPolygon3D(int capacity)
-{
-   init();
-   counter++;
-   this->ps = new GbSystem3D::PointSet3(capacity);
-   //     this.po = new PointObserver(this);
-}
-/**
-* Creates a 3D polygon with the specified points.
-* @param points the initial points of the polygon
-*/
-GbPolygon3D::GbPolygon3D(vector<GbPoint3D>& points)
-{
-   init();
-   counter++;
-   this->ps = new GbSystem3D::PointSet3((int)points.size());
-   this->addPoints(points);
-}
-/**
-* Creates a 3D polygon as clone of the specified 3D polygon.
-* @param polygon the 3D polygon to be cloned
-*/
-GbPolygon3D::GbPolygon3D(GbPolygon3D* polygon)
-{
-   this->init();
-   counter++;
-   this->ps = new GbSystem3D::PointSet3((int)polygon->size());
-   vector<GbPoint3D> temp = polygon->getPoints();
-   this->addPoints( temp  );
-}
-
-GbPolygon3D::~GbPolygon3D()
-{
-   counter--;
-   //if(points)
-   //for(unsigned u=0; u<points->size(); u++)
-   //{
-   //	delete (*points)[u];
-   //}
-   //		delete this->points;
-   delete this->ps;
-}
-
-/*======================================================================*/
-/**
-* Returns the number of points.
-* @return the number of points
-*/
-int GbPolygon3D::size()
-{
-   return(this->ps->size());
-}
-/**
-* Returns the number of times this 3D polygon contains the specified point.
-* @param point the point
-* @return the number of times this 3D polygon contains the specified point
-*/
-int GbPolygon3D::contains(GbPoint3D* point)
-{
-   return(this->ps->contains(point));
-}
-/**
-* Returns the number of times this 3D polygon contains a point equal to the specified point.
-* @param point the point
-* @return the number of times this 3D polygon contains a point equal to the specified point
-*/
-int GbPolygon3D::containsEqual(GbPoint3D* point)
-{
-   return(this->ps->containsEqual(point));
-}
-/**
-* Returns true, if this 3D polygon contains the specified line.
-* @param point1 the first point
-* @param point2 the second point
-* @return true, if this 3D polygon contains the specified line
-*/
-bool GbPolygon3D::containsLine(GbPoint3D* point1, GbPoint3D* point2)
-{
-   return(this->ps->containsLine(point1, point2));
-}
-/**
-* Returns true, if this 3D polygon contains the specified line.
-* @param line the line
-* @return true, if this 3D polygon contains the specified line
-*/
-bool GbPolygon3D::containsLine(GbLine3D* line)
-{
-   return(this->ps->containsLine(line->getPoint1(), line->getPoint2()));
-}
-/**
-* Returns the first point.
-* @return the first point
-*/
-GbPoint3D* GbPolygon3D::getFirstPoint()
-{
-   return(this->ps->getFirstPoint());
-}
-/**
-* Returns the last point.
-* @return the last point
-*/
-GbPoint3D* GbPolygon3D::getLastPoint()
-{
-   return(this->ps->getLastPoint());
-}
-/**
-* Returns the specified point.
-* @param index the index
-* @return the specified point
-* @exception ArrayIndexOutOfBoundsException if the specified index is not valid
-*/
-GbPoint3D* GbPolygon3D::getPoint(const int& index) 
-{
-   if(index < 0 || index > this->ps->size()) throw UbException(UB_EXARGS,"ArrayIndexOutOfBoundsException-GbPolygon3D.getPoint()");
-   return(this->ps->getPoint(index));
-}
-/**
-* Returns the points.
-* @return the points
-*/
-vector<GbPoint3D> GbPolygon3D::getPoints()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->points);
-}
-/**
-* Returns the points within the specified rectangle.
-* @param p1 the 1st point of the rectangle
-* @param p2 the 2nd point of the rectangle
-* @return the points within the specified rectangle
-*/
-vector<GbPoint3D> GbPolygon3D::getPoints(GbPoint3D* p1, GbPoint3D* p2)
-{
-   return(this->getPoints(p1->x1, p1->x2, p1->x3, p2->x1, p2->x2, p2->x3));
-}
-/**
-* Returns the points within the specified rectangle.
-* @param p1x1 the 1st x1 coordinate of the rectangle
-* @param p1x2 the 1st x2 coordinate of the rectangle
-* @param p1x3 the 1st x3 coordinate of the rectangle
-* @param p2x1 the 2nd x1 coordinate of the rectangle
-* @param p2x2 the 2nd x2 coordinate of the rectangle
-* @param p2x3 the 2nd x3 coordinate of the rectangle
-* @return the points within the specified rectangle
-*/
-vector<GbPoint3D> GbPolygon3D::getPoints(const double& p1x1, const double& p1x2, const double& p1x3, const double& p2x1, const double& p2x2, const double& p2x3)
-{
-   double x1min, x1max, x2min, x2max, x3min, x3max;
-
-   if(UbMath::less(p1x1, p2x1)) { x1min = p1x1; x1max = p2x1; }
-   else                           { x1min = p2x1; x1max = p1x1; }
-   if(UbMath::less(p1x2, p2x2)) { x2min = p1x2; x2max = p2x2; }
-   else                           { x2min = p2x2; x2max = p1x2; }
-   if(UbMath::less(p1x3, p2x3)) { x3min = p1x3; x3max = p2x3; }
-   else                           { x3min = p2x3; x3max = p1x3; }
-
-   GbSystem3D::PointSet3 *pts = new GbSystem3D::PointSet3(1);
-
-   if(!this->consistent) this->calculateValues();
-   for(int i=this->size()-1; i>=0; i--)
-   {
-      if(UbMath::lessEqual(x1min, (this->points)[i].x1) && UbMath::greaterEqual(x1max, (this->points)[i].x1) &&
-         UbMath::lessEqual(x2min, (this->points)[i].x2) && UbMath::greaterEqual(x2max, (this->points)[i].x2) &&
-         UbMath::lessEqual(x3min, (this->points)[i].x3) && UbMath::greaterEqual(x3max, (this->points)[i].x3))     pts->add((this->points)[i]);
-   }
-   return(pts->getPoints());
-}
-/**
-* Returns the area of this polygon.
-* The area is positive for positive ordered points, otherwise negative.
-* @return the area of this polygon
-*/
-//double getArea()
-//{
-//   if(!this.consistent) this.calculateValues();
-//   return(this.area);
-//}
-double GbPolygon3D::getX1Centroid()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x1s);
-}
-double GbPolygon3D::getX1Minimum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x1min);
-}
-double GbPolygon3D::getX1Maximum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x1max);
-}
-double GbPolygon3D::getX2Centroid()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x2s);
-}
-double GbPolygon3D::getX2Minimum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x2min);
-}
-double GbPolygon3D::getX2Maximum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x2max);
-}
-double GbPolygon3D::getX3Centroid()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x3s);
-}
-double GbPolygon3D::getX3Minimum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x3min);
-}
-double GbPolygon3D::getX3Maximum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x3max);
-}
-
-/**
-* Adds a point to the end of this polygon. Notifies the observers of this 3D polygon.
-* @param point the point
-*/
-void GbPolygon3D::addPoint(GbPoint3D* point)
-{
-   //if((this instanceof GbPolygon3D) && !(point instanceof GbPoint3D)) throw new IllegalArgumentException("GbPolygon3D.addPoint(): points of 3D polygons have to be 3D points!");
-
-   this->ps->add(point);
-   //point.addObserver(this.po);
-   this->consistent = false;
-   //super.notifyObservers();
-}
-/**
-* Adds a number of points to the end of this polygon. Notifies the observers of this 3D polygon.
-* @param points the points
-*/
-void GbPolygon3D::addPoints(vector<GbPoint3D>& points)
-{
-   //if((this instanceof GbPolygon3D) && (points.getClass().getComponentType() != GbPoint3D.class)) throw new IllegalArgumentException("GbPolygon3D.addPoints(): points of 3D polygons have to be 3D points!");
-
-   this->ps->add(points);
-   //for(int i=0; i<points.length; i++) points[i].addObserver(this.po);
-   this->consistent = false;
-   //super.notifyObservers();
-}
-/**
-* Inserts a point at the specified position within this polygon. Notifies the observers of this 3D polygon.
-* @param point the point
-* @param index the index
-* @exception ArrayIndexOutOfBoundsException if the specified index is not valid
-*/
-//public void insertPoint(GbPoint3D point, int index) throws ArrayIndexOutOfBoundsException
-//{
-//   if((this instanceof GbPolygon3D) && !(point instanceof GbPoint3D)) throw new IllegalArgumentException("GbPolygon3D.insertPoint(): points of 3D polygons have to be 3D points!");
-//   if(index < 0 || index > this.ps.size()) throw new ArrayIndexOutOfBoundsException("GbPolygon3D.insert(): invalid index specified: "+index);
-
-//   this.ps.insert(point, index);
-//   point.addObserver(this.po);
-//   this.consistent = false;
-//   super.notifyObservers();
-//}
-/**
-* Removes all points from this polygon identical to the specified one. Notifies the observers of this 3D polygon.
-* @param point the point
-*/
-//public void deletePoint(GbPoint3D point)
-//{
-//   this.ps.delete(point);
-//   point.removeObserver(this.po);
-//   this.consistent = false;
-//   super.notifyObservers();
-//}
-/**
-* Removes all points from this polygon equal to the specified one. Notifies the observers of this 3D polygon.
-* @param point the point
-*/
-//public void deleteEqualPoint(GbPoint3D point)
-//{
-//   this.ps.deleteEqual(point);
-//   point.removeObserver(this.po);
-//   this.consistent = false;
-//   super.notifyObservers();
-//}
-/**
-* Removes all points from this polygon. Notifies the observers of this 3D polygon.
-*/
-void GbPolygon3D::clear()
-{
-   //		delete this->points;
-   this->ps->clearAndTrim();
-   delete this->ps;
-
-   //for(int i=points.length-1; i>=0; i--) points[i].removeObserver(this.po);
-   this->consistent = false;
-   //super.notifyObservers();
-}
-
-/**
-* Returns true if this 3D polygon equals the specified object.
-* Two polygon are equal, if their points are equal.
-* <BR>Note that the order of points is recognized!
-* @return true if this 3D polygon equals the specified object
-* @see GbPoint3D#equals(java.lang.Object)
-*/
-// bool equals(Object object)
-// {
-//    try
-//    {
-//	GbPolygon2D polygon = (GbPolygon3D) object;
-//int         n       = this.size();
-
-//if(n != polygon.size()) return(false);
-//for(int i=0; i<n; i++) if(!this.getPoint(i).equals(polygon.getPoint(i))) return(false);
-//return(true);
-//    }
-//    catch(Exception e){ return(false); }
-// }
-/**
-* Returns a string representation of this 3D polygon.
-* @return a string representation of this 3D polygon
-*/
-string GbPolygon3D::toString()
-{
-   stringstream ss;
-   ss<<"GbPolygon3D[";
-   ss<<this->size()<<" points";
-
-   //    ss<<", x1s="<<this->x1s;
-   //    ss<<", x2s="<<this->x2s;
-   //ss<<", x3s="<<this->x3s;
-   //    ss<<", x1min="<<this->x1min;
-   //    ss<<", x1max="<<this->x1max;
-   //    ss<<", x2min="<<this->x2min;
-   //    ss<<", x2max="<<this->x2max;
-   //ss<<", x3min="<<this->x3min;
-   //    ss<<", x3max="<<this->x3max;
-   ss<<"]"<<endl;
-   for(int u=0; u<this->size(); u++)
-      ss<<this->ps->getPoint(u)->toString()<<endl;
-
-   return(ss.str());
-}
-/*======================================================================*/
-
-
-/*======================================================================*/
-/*  Calculation                                                         */
-/*                                                                      */
-/*
-* Returns the intersection points of this 3D polygon and the specified 3D line.
-* @param line the 3D line to intersect
-* @return the intersection points of this 3D polygon and the specified 3D line
-*/
-// public GbPoint3D[] calculateIntersectionPoints3D(GbLine3D line)
-// {
-//    GbSystem.PointSet pointSet = new GbSystem.PointSet(0);
-//    GbPoint3D         points[] = this.getPoints();
-//    GbPoint3D         pCrossed = null;
-//    int               n        = points.length;
-//    if(n < 2)         return(pointSet.getPoints());
-
-//    for(int i=1; i<n; i++)
-//    {
-//pCrossed = GbSystem.calculateIntersectionPoint3D(points[i-1], points[i], line.p1, line.p2);
-//if(pCrossed != null) pointSet.add(pCrossed);
-//    }
-//    pCrossed = GbSystem.calculateIntersectionPoint3D(points[n-1], points[0], line.p1, line.p2);
-//    if(pCrossed != null) pointSet.add(pCrossed);
-
-//    return(pointSet.getPoints());
-// }
-
-/*
-* Returns true if the specified 3D point lies within (or on the border of) this 3D polygon.
-* @param point the 3D point to check
-* @return true if the specified 3D point lies within (or on the border of) this 3D polygon
-*/
-// public boolean enclosesPoint3D(GbPoint3D point)
-// {
-//    if(GbSystem.less(point.x1, this.x1min))    return(false);
-//    if(GbSystem.less(point.x2, this.x2min))    return(false);
-//    if(GbSystem.greater(point.x1, this.x1max)) return(false);
-//    if(GbSystem.greater(point.x2, this.x2max)) return(false);
-//    if(this.containsEqual(point) > 0)          return(true);
-
-//    QbList    ltest    = new QbList(GbPoint2D.class, QbList.NOEQUALOBJECTS);
-//    GbPoint3D points[] = this.getPoints();
-//    GbPoint3D ptest;
-//    int       n        = points.length;
-//    if(n < 2) return(false);
-
-//    if(GbSystem.equal(point.x2, this.x2min)) ptest = new GbPoint3D(point.x1, this.x2min-1.0);
-//    else                                     ptest = new GbPoint3D(point.x1, this.x2max+1.0);
-
-//    for(int i=1; i<n; i++)
-//    {
-//try { ltest.append(GbSystem.calculateIntersectionPoint2D(points[i-1], points[i], point, ptest)); }
-//catch(Exception e){}
-//    }
-//    try { ltest.append(GbSystem.calculateIntersectionPoint3D(points[n-1], points[0], point, ptest)); }
-//    catch(Exception e){}
-//    return((ltest.size()%2)==1);
-// }
-
-/*
-* Returns a new 3D polygon clipped by the specified 3D rectangle (result may be null!).
-* @param rectangle the 3D rectangle
-* @return a new 3D polygon clipped by the specified 3D rectangle
-*/
-// GbPolygon3D *createClippedPolygon3D(GbCuboid3D *cube)
-// {
-//return(GbSystem::clipPolygon3D(this->getPoints(), cube->p1->x1, cube->p1->x2, cube->p1->x3, , cube->p2->x1, cube->p2->x2, cube->p2->x3));
-// }
-/*                                          
-* Returns a new 3D polygon clipped by the specified 3D rectangle (result may be null!).
-* @param p1 the 1st point of the rectangle
-* @param p2 the 2nd point of the rectangle
-* @return a new 3D polygon clipped by the specified 3D rectangle
-*/
-// GbPolygon3D *createClippedPolygon3D(GbPoint3D *p1, GbPoint3D *p2)
-// {
-//return(GbSystem::clipPolygon3D(this->getPoints(), p1->x1, p1->x2, p1->x3, p2->x1, p2->x2, p2->x3));
-// }
-/*
-* Returns a new 3D polygon clipped by the specified 3D rectangle (result may be null!).
-* @param p1x1 the 1st x1 coordinate of the rectangle
-* @param p1x2 the 1st x2 coordinate of the rectangle
-* @param p2x1 the 2nd x1 coordinate of the rectangle
-* @param p2x2 the 2nd x2 coordinate of the rectangle
-* @return a new 3D polygon clipped by the specified 3D rectangle
-*/
-// GbPolygon3D *createClippedPolygon3D(double p1x1, double p1x2, double p1x3, double p2x1, double p2x2, double p2x3)
-// {
-//return(GbSystem::clipPolygon3D(this.getPoints(), p1x1, p1x2, p1x3, p2x1, p2x2. p2x3));
-// }
-
-/*
-* Returns true if the specified 3D rectangle lies completely within this 3D polygon.
-* @param rectangle the 3D rectangle to check
-* @return true if the specified 3D rectangle lies completely within this 3D polygon
-*/
-//public boolean enclosesRectangle3D(GbRectangle3D rectangle)
-//{
-//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
-//   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), rectangle.getArea()));
-//}
-/*
-* Returns true if the specified 3D rectangle lies completely within this 3D polygon.
-* @param p1 the 1st point of the rectangle to check
-* @param p2 the 2nd point of the rectangle to check
-* @return true if the specified 3D rectangle lies completely within this 3D polygon
-*/
-//public boolean enclosesRectangle3D(GbPoint3D p1, GbPoint3D p2)
-//{
-//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2);
-//   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2))));
-//}
-/*
-* Returns true if the specified 3D rectangle lies completely within this 3D polygon.
-* @param p1x1 the 1st x1 coordinate of the rectangle to check
-* @param p1x2 the 1st x2 coordinate of the rectangle to check
-* @param p2x1 the 2nd x1 coordinate of the rectangle to check
-* @param p2x2 the 2nd x2 coordinate of the rectangle to check
-* @return true if the specified 3D rectangle lies completely within this 3D polygon
-*/
-//public boolean enclosesRectangle3D(double p1x1, double p1x2, double p2x1, double p2x2)
-//{
-//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1x1, p1x2, p2x1, p2x2);
-//   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1x1-p2x1)*(p1x2-p2x2))));
-//}
-
-/*
-* Returns true if the specified 3D rectangle is crossed by this 3D polygon.
-* @param rectangle the 3D rectangle to check
-* @return true if the specified 3D rectangle is crossed by this 3D polygon
-*/
-//public boolean crossesRectangle3D(GbRectangle3D rectangle)
-//{
-//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
-//   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, rectangle.getArea()));
-//}
-/*
-* Returns true if the specified 3D rectangle is crossed by this 3D polygon.
-* @param p1 the 1st point of the rectangle to check
-* @param p2 the 2nd point of the rectangle to check
-* @return true if the specified 3D rectangle is crossed by this 3D polygon
-*/
-//public boolean crossesRectangle3D(GbPoint3D p1, GbPoint3D p2)
-//{
-//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2);
-//   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2))));
-//}
-/*
-* Returns true if the specified 3D rectangle is crossed by this 3D polygon.
-* @param p1x1 the 1st x1 coordinate of the rectangle to check
-* @param p1x2 the 1st x2 coordinate of the rectangle to check
-* @param p2x1 the 2nd x1 coordinate of the rectangle to check
-* @param p2x2 the 2nd x2 coordinate of the rectangle to check
-* @return true if the specified 3D rectangle is crossed by this 3D polygon
-*/
-//public boolean crossesRectangle3D(double p1x1, double p1x2, double p2x1, double p2x2)
-//{
-//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1x1, p1x2, p2x1, p2x2);
-//   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1x1-p2x1)*(p1x2-p2x2))));
-//}
-
-/*
-* Returns true if the specified 3D rectangle lies (at least partly) within this 3D polygon.
-* @param rectangle the 3D rectangle to check
-* @return true if the specified 3D rectangle lies (at least partly) within this 3D polygon
-*/
-//public boolean enclosesOrCrossesRectangle3D(GbRectangle3D rectangle)
-//{
-//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
-//   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
-//}
-/*
-* Returns true if the specified 3D rectangle lies (at least partly) within this 3D polygon.
-* @param p1 the 1st point of the rectangle to check
-* @param p2 the 2nd point of the rectangle to check
-* @return true if the specified 3D rectangle lies (at least partly) within this 3D polygon
-*/
-//public boolean enclosesOrCrossesRectangle3D(GbPoint3D p1, GbPoint3D p2)
-//{
-//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2);
-//   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
-//}
-/*
-* Returns true if the specified 3D rectangle lies (at least partly) within this 3D polygon.
-* @param p1x1 the 1st x1 coordinate of the rectangle to check
-* @param p1x2 the 1st x2 coordinate of the rectangle to check
-* @param p2x1 the 2nd x1 coordinate of the rectangle to check
-* @param p2x2 the 2nd x2 coordinate of the rectangle to check
-* @return true if the specified 3D rectangle lies (at least partly) within this 3D polygon
-*/
-//public boolean enclosesOrCrossesRectangle3D(double p1x1, double p1x2, double p2x1, double p2x2)
-//{
-//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1x1, p1x2, p2x1, p2x2);
-//   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
-//}
-/*======================================================================*/
-
-void GbPolygon3D::calculateValues()
-{
-   this->x1s        = 0.0;
-   this->x2s        = 0.0;
-   this->x3s        = 0.0;
-   this->x1min      = 0.0;
-   this->x1max      = 0.0;
-   this->x2min      = 0.0;
-   this->x2max      = 0.0;
-   this->x3min      = 0.0;
-   this->x3max      = 0.0;
-   throw UbException(UB_EXARGS,"should be implemented");
-
-   //this->consistent = true;
-
-   //this->points = this->ps->getPoints();
-
-   //int       n     = (int)this->points.size();
-   //if(n < 1) return;
-
-   //GbPoint3D p1 = (this->points)[0];
-   //GbPoint3D p2 = NULL;
-   //double    h1 = 0.0;
-   //double    h2 = 0.0;
-   //double    f=0.0;
-
-   //this->x1s   = p1.x1;
-   //this->x1min = p1.x1;
-   //this->x1max = p1.x1;
-   //this->x2s   = p1.x2;
-   //this->x2min = p1.x2;
-   //this->x2max = p1.x2;
-   //this->x3s   = p1.x2;
-   //this->x3min = p1.x2;
-   //this->x3max = p1.x2;
-
-   //std::cout<<"Should be implemented "<<endl;
-
-   //for(int i=1; i<n; i++)
-   //{
-   //  p2         = (this->points)[i];
-   //  f          = p1.x1*p2.x2 - p1.x2*p2.x1;
-   //  this->area += f;
-   //  h1        += f*(p1.x2 + p2.x2);
-   //  h2        += f*(p1.x1 + p2.x1);
-   //  p1         = p2;
-
-   //  if(p1.x1 < this->x1min) this->x1min = p1.x1;
-   //  if(p1.x1 > this->x1max) this->x1max = p1.x1;
-   //  if(p1.x2 < this->x2min) this->x2min = p1.x2;
-   //  if(p1.x2 > this->x2max) this->x2max = p1.x2;
-   //}
-   //p2         = (this->points)[0];
-   //f          = p1.x1*p2.x2 - p1.x2*p2.x1;
-   //this->area += f;
-   //h1        += f*(p1.x2 + p2.x2);
-   //h2        += f*(p1.x1 + p2.x1);
-
-   //this->area *= 0.5;
-   //h1        /= 6.0;
-   //h2        /= 6.0;
-
-   //if(n > 2)
-   //{
-   //   this->x1s = h2/this->area;
-   //   this->x2s = h1/this->area;
-   //}
-
-   //if(n < 3 || !GbSystem::inClosedInterval(this->x1s, this->x1min, this->x1max)) this->x1s = 0.5*(this->x1min+this->x1max);
-   //if(n < 3 || !GbSystem::inClosedInterval(this->x2s, this->x2min, this->x2max)) this->x2s = 0.5*(this->x2min+this->x2max);
-}
-/*======================================================================*/
-
-
-/*======================================================================*/
-// private class PointObserver implements TiObserver
-// {
-//    GbPolygon3D polygon = null;
-
-//    PointObserver(GbPolygon3D polygon)
-//    {
-//this.polygon = polygon;
-//    }
-
-//    public void objectChanged(Object object)
-//    {
-//if((object instanceof GbPoint3D) && this.polygon.contains((GbPoint3D)object)>0)
-//{
-//   this.polygon.consistent = false;
-//   this.polygon.notifyObservers();
-//}
-//    }
-// }
-/*=======================================================*/
-void GbPolygon3D::write(UbFileOutput* out) 
-{                                      
-   throw UbException(UB_EXARGS,"not implemented");
-}
-/*=======================================================*/
-void GbPolygon3D::read(UbFileInput* in) 
-{  
-   throw UbException(UB_EXARGS,"not implemented");
-}
-/*=======================================================*/
-
+#include <numerics/geometry3d/GbPolygon3D.h>
+#include <numerics/geometry3d/creator/GbPolygon3DCreator.h>
+
+using namespace std;
+
+ObObjectCreator* GbPolygon3D::getCreator()
+{
+   return GbPolygon3DCreator::getInstance();
+}
+
+int GbPolygon3D::counter = 0;
+
+GbPolygon3D::GbPolygon3D()
+{
+   init();
+   counter++;
+   this->ps = new GbSystem3D::PointSet3(0);
+}
+void GbPolygon3D::init()
+{
+   x1s        = 0.0;
+   x2s        = 0.0;
+   x1min      = 0.0;
+   x1max      = 0.0;
+   x2min      = 0.0;
+   x2max      = 0.0;
+   //		points   = NULL;
+   consistent = false;
+   ps         = NULL;
+}
+
+/**
+* Creates an empty 3D polygon with the specified capacity.
+* @param capacity the initial capacity
+*/
+GbPolygon3D::GbPolygon3D(int capacity)
+{
+   init();
+   counter++;
+   this->ps = new GbSystem3D::PointSet3(capacity);
+   //     this.po = new PointObserver(this);
+}
+/**
+* Creates a 3D polygon with the specified points.
+* @param points the initial points of the polygon
+*/
+GbPolygon3D::GbPolygon3D(vector<GbPoint3D>& points)
+{
+   init();
+   counter++;
+   this->ps = new GbSystem3D::PointSet3((int)points.size());
+   this->addPoints(points);
+}
+/**
+* Creates a 3D polygon as clone of the specified 3D polygon.
+* @param polygon the 3D polygon to be cloned
+*/
+GbPolygon3D::GbPolygon3D(GbPolygon3D* polygon)
+{
+   this->init();
+   counter++;
+   this->ps = new GbSystem3D::PointSet3((int)polygon->size());
+   vector<GbPoint3D> temp = polygon->getPoints();
+   this->addPoints( temp  );
+}
+
+GbPolygon3D::~GbPolygon3D()
+{
+   counter--;
+   //if(points)
+   //for(unsigned u=0; u<points->size(); u++)
+   //{
+   //	delete (*points)[u];
+   //}
+   //		delete this->points;
+   delete this->ps;
+}
+
+/*======================================================================*/
+/**
+* Returns the number of points.
+* @return the number of points
+*/
+int GbPolygon3D::size()
+{
+   return(this->ps->size());
+}
+/**
+* Returns the number of times this 3D polygon contains the specified point.
+* @param point the point
+* @return the number of times this 3D polygon contains the specified point
+*/
+int GbPolygon3D::contains(GbPoint3D* point)
+{
+   return(this->ps->contains(point));
+}
+/**
+* Returns the number of times this 3D polygon contains a point equal to the specified point.
+* @param point the point
+* @return the number of times this 3D polygon contains a point equal to the specified point
+*/
+int GbPolygon3D::containsEqual(GbPoint3D* point)
+{
+   return(this->ps->containsEqual(point));
+}
+/**
+* Returns true, if this 3D polygon contains the specified line.
+* @param point1 the first point
+* @param point2 the second point
+* @return true, if this 3D polygon contains the specified line
+*/
+bool GbPolygon3D::containsLine(GbPoint3D* point1, GbPoint3D* point2)
+{
+   return(this->ps->containsLine(point1, point2));
+}
+/**
+* Returns true, if this 3D polygon contains the specified line.
+* @param line the line
+* @return true, if this 3D polygon contains the specified line
+*/
+bool GbPolygon3D::containsLine(GbLine3D* line)
+{
+   return(this->ps->containsLine(line->getPoint1(), line->getPoint2()));
+}
+/**
+* Returns the first point.
+* @return the first point
+*/
+GbPoint3D* GbPolygon3D::getFirstPoint()
+{
+   return(this->ps->getFirstPoint());
+}
+/**
+* Returns the last point.
+* @return the last point
+*/
+GbPoint3D* GbPolygon3D::getLastPoint()
+{
+   return(this->ps->getLastPoint());
+}
+/**
+* Returns the specified point.
+* @param index the index
+* @return the specified point
+* @exception ArrayIndexOutOfBoundsException if the specified index is not valid
+*/
+GbPoint3D* GbPolygon3D::getPoint(const int& index) 
+{
+   if(index < 0 || index > this->ps->size()) throw UbException(UB_EXARGS,"ArrayIndexOutOfBoundsException-GbPolygon3D.getPoint()");
+   return(this->ps->getPoint(index));
+}
+/**
+* Returns the points.
+* @return the points
+*/
+vector<GbPoint3D> GbPolygon3D::getPoints()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->points);
+}
+/**
+* Returns the points within the specified rectangle.
+* @param p1 the 1st point of the rectangle
+* @param p2 the 2nd point of the rectangle
+* @return the points within the specified rectangle
+*/
+vector<GbPoint3D> GbPolygon3D::getPoints(GbPoint3D* p1, GbPoint3D* p2)
+{
+   return(this->getPoints(p1->x1, p1->x2, p1->x3, p2->x1, p2->x2, p2->x3));
+}
+/**
+* Returns the points within the specified rectangle.
+* @param p1x1 the 1st x1 coordinate of the rectangle
+* @param p1x2 the 1st x2 coordinate of the rectangle
+* @param p1x3 the 1st x3 coordinate of the rectangle
+* @param p2x1 the 2nd x1 coordinate of the rectangle
+* @param p2x2 the 2nd x2 coordinate of the rectangle
+* @param p2x3 the 2nd x3 coordinate of the rectangle
+* @return the points within the specified rectangle
+*/
+vector<GbPoint3D> GbPolygon3D::getPoints(const double& p1x1, const double& p1x2, const double& p1x3, const double& p2x1, const double& p2x2, const double& p2x3)
+{
+   double x1min, x1max, x2min, x2max, x3min, x3max;
+
+   if(UbMath::less(p1x1, p2x1)) { x1min = p1x1; x1max = p2x1; }
+   else                           { x1min = p2x1; x1max = p1x1; }
+   if(UbMath::less(p1x2, p2x2)) { x2min = p1x2; x2max = p2x2; }
+   else                           { x2min = p2x2; x2max = p1x2; }
+   if(UbMath::less(p1x3, p2x3)) { x3min = p1x3; x3max = p2x3; }
+   else                           { x3min = p2x3; x3max = p1x3; }
+
+   GbSystem3D::PointSet3 *pts = new GbSystem3D::PointSet3(1);
+
+   if(!this->consistent) this->calculateValues();
+   for(int i=this->size()-1; i>=0; i--)
+   {
+      if(UbMath::lessEqual(x1min, (this->points)[i].x1) && UbMath::greaterEqual(x1max, (this->points)[i].x1) &&
+         UbMath::lessEqual(x2min, (this->points)[i].x2) && UbMath::greaterEqual(x2max, (this->points)[i].x2) &&
+         UbMath::lessEqual(x3min, (this->points)[i].x3) && UbMath::greaterEqual(x3max, (this->points)[i].x3))     pts->add((this->points)[i]);
+   }
+   return(pts->getPoints());
+}
+/**
+* Returns the area of this polygon.
+* The area is positive for positive ordered points, otherwise negative.
+* @return the area of this polygon
+*/
+//double getArea()
+//{
+//   if(!this.consistent) this.calculateValues();
+//   return(this.area);
+//}
+double GbPolygon3D::getX1Centroid()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x1s);
+}
+double GbPolygon3D::getX1Minimum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x1min);
+}
+double GbPolygon3D::getX1Maximum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x1max);
+}
+double GbPolygon3D::getX2Centroid()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x2s);
+}
+double GbPolygon3D::getX2Minimum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x2min);
+}
+double GbPolygon3D::getX2Maximum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x2max);
+}
+double GbPolygon3D::getX3Centroid()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x3s);
+}
+double GbPolygon3D::getX3Minimum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x3min);
+}
+double GbPolygon3D::getX3Maximum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x3max);
+}
+
+/**
+* Adds a point to the end of this polygon. Notifies the observers of this 3D polygon.
+* @param point the point
+*/
+void GbPolygon3D::addPoint(GbPoint3D* point)
+{
+   //if((this instanceof GbPolygon3D) && !(point instanceof GbPoint3D)) throw new IllegalArgumentException("GbPolygon3D.addPoint(): points of 3D polygons have to be 3D points!");
+
+   this->ps->add(point);
+   //point.addObserver(this.po);
+   this->consistent = false;
+   //super.notifyObservers();
+}
+/**
+* Adds a number of points to the end of this polygon. Notifies the observers of this 3D polygon.
+* @param points the points
+*/
+void GbPolygon3D::addPoints(vector<GbPoint3D>& points)
+{
+   //if((this instanceof GbPolygon3D) && (points.getClass().getComponentType() != GbPoint3D.class)) throw new IllegalArgumentException("GbPolygon3D.addPoints(): points of 3D polygons have to be 3D points!");
+
+   this->ps->add(points);
+   //for(int i=0; i<points.length; i++) points[i].addObserver(this.po);
+   this->consistent = false;
+   //super.notifyObservers();
+}
+/**
+* Inserts a point at the specified position within this polygon. Notifies the observers of this 3D polygon.
+* @param point the point
+* @param index the index
+* @exception ArrayIndexOutOfBoundsException if the specified index is not valid
+*/
+//public void insertPoint(GbPoint3D point, int index) throws ArrayIndexOutOfBoundsException
+//{
+//   if((this instanceof GbPolygon3D) && !(point instanceof GbPoint3D)) throw new IllegalArgumentException("GbPolygon3D.insertPoint(): points of 3D polygons have to be 3D points!");
+//   if(index < 0 || index > this.ps.size()) throw new ArrayIndexOutOfBoundsException("GbPolygon3D.insert(): invalid index specified: "+index);
+
+//   this.ps.insert(point, index);
+//   point.addObserver(this.po);
+//   this.consistent = false;
+//   super.notifyObservers();
+//}
+/**
+* Removes all points from this polygon identical to the specified one. Notifies the observers of this 3D polygon.
+* @param point the point
+*/
+//public void deletePoint(GbPoint3D point)
+//{
+//   this.ps.delete(point);
+//   point.removeObserver(this.po);
+//   this.consistent = false;
+//   super.notifyObservers();
+//}
+/**
+* Removes all points from this polygon equal to the specified one. Notifies the observers of this 3D polygon.
+* @param point the point
+*/
+//public void deleteEqualPoint(GbPoint3D point)
+//{
+//   this.ps.deleteEqual(point);
+//   point.removeObserver(this.po);
+//   this.consistent = false;
+//   super.notifyObservers();
+//}
+/**
+* Removes all points from this polygon. Notifies the observers of this 3D polygon.
+*/
+void GbPolygon3D::clear()
+{
+   //		delete this->points;
+   this->ps->clearAndTrim();
+   delete this->ps;
+
+   //for(int i=points.length-1; i>=0; i--) points[i].removeObserver(this.po);
+   this->consistent = false;
+   //super.notifyObservers();
+}
+
+/**
+* Returns true if this 3D polygon equals the specified object.
+* Two polygon are equal, if their points are equal.
+* <BR>Note that the order of points is recognized!
+* @return true if this 3D polygon equals the specified object
+* @see GbPoint3D#equals(java.lang.Object)
+*/
+// bool equals(Object object)
+// {
+//    try
+//    {
+//	GbPolygon2D polygon = (GbPolygon3D) object;
+//int         n       = this.size();
+
+//if(n != polygon.size()) return(false);
+//for(int i=0; i<n; i++) if(!this.getPoint(i).equals(polygon.getPoint(i))) return(false);
+//return(true);
+//    }
+//    catch(Exception e){ return(false); }
+// }
+/**
+* Returns a string representation of this 3D polygon.
+* @return a string representation of this 3D polygon
+*/
+string GbPolygon3D::toString()
+{
+   stringstream ss;
+   ss<<"GbPolygon3D[";
+   ss<<this->size()<<" points";
+
+   //    ss<<", x1s="<<this->x1s;
+   //    ss<<", x2s="<<this->x2s;
+   //ss<<", x3s="<<this->x3s;
+   //    ss<<", x1min="<<this->x1min;
+   //    ss<<", x1max="<<this->x1max;
+   //    ss<<", x2min="<<this->x2min;
+   //    ss<<", x2max="<<this->x2max;
+   //ss<<", x3min="<<this->x3min;
+   //    ss<<", x3max="<<this->x3max;
+   ss<<"]"<<endl;
+   for(int u=0; u<this->size(); u++)
+      ss<<this->ps->getPoint(u)->toString()<<endl;
+
+   return(ss.str());
+}
+/*======================================================================*/
+
+
+/*======================================================================*/
+/*  Calculation                                                         */
+/*                                                                      */
+/*
+* Returns the intersection points of this 3D polygon and the specified 3D line.
+* @param line the 3D line to intersect
+* @return the intersection points of this 3D polygon and the specified 3D line
+*/
+// public GbPoint3D[] calculateIntersectionPoints3D(GbLine3D line)
+// {
+//    GbSystem.PointSet pointSet = new GbSystem.PointSet(0);
+//    GbPoint3D         points[] = this.getPoints();
+//    GbPoint3D         pCrossed = null;
+//    int               n        = points.length;
+//    if(n < 2)         return(pointSet.getPoints());
+
+//    for(int i=1; i<n; i++)
+//    {
+//pCrossed = GbSystem.calculateIntersectionPoint3D(points[i-1], points[i], line.p1, line.p2);
+//if(pCrossed != null) pointSet.add(pCrossed);
+//    }
+//    pCrossed = GbSystem.calculateIntersectionPoint3D(points[n-1], points[0], line.p1, line.p2);
+//    if(pCrossed != null) pointSet.add(pCrossed);
+
+//    return(pointSet.getPoints());
+// }
+
+/*
+* Returns true if the specified 3D point lies within (or on the border of) this 3D polygon.
+* @param point the 3D point to check
+* @return true if the specified 3D point lies within (or on the border of) this 3D polygon
+*/
+// public boolean enclosesPoint3D(GbPoint3D point)
+// {
+//    if(GbSystem.less(point.x1, this.x1min))    return(false);
+//    if(GbSystem.less(point.x2, this.x2min))    return(false);
+//    if(GbSystem.greater(point.x1, this.x1max)) return(false);
+//    if(GbSystem.greater(point.x2, this.x2max)) return(false);
+//    if(this.containsEqual(point) > 0)          return(true);
+
+//    QbList    ltest    = new QbList(GbPoint2D.class, QbList.NOEQUALOBJECTS);
+//    GbPoint3D points[] = this.getPoints();
+//    GbPoint3D ptest;
+//    int       n        = points.length;
+//    if(n < 2) return(false);
+
+//    if(GbSystem.equal(point.x2, this.x2min)) ptest = new GbPoint3D(point.x1, this.x2min-1.0);
+//    else                                     ptest = new GbPoint3D(point.x1, this.x2max+1.0);
+
+//    for(int i=1; i<n; i++)
+//    {
+//try { ltest.append(GbSystem.calculateIntersectionPoint2D(points[i-1], points[i], point, ptest)); }
+//catch(Exception e){}
+//    }
+//    try { ltest.append(GbSystem.calculateIntersectionPoint3D(points[n-1], points[0], point, ptest)); }
+//    catch(Exception e){}
+//    return((ltest.size()%2)==1);
+// }
+
+/*
+* Returns a new 3D polygon clipped by the specified 3D rectangle (result may be null!).
+* @param rectangle the 3D rectangle
+* @return a new 3D polygon clipped by the specified 3D rectangle
+*/
+// GbPolygon3D *createClippedPolygon3D(GbCuboid3D *cube)
+// {
+//return(GbSystem::clipPolygon3D(this->getPoints(), cube->p1->x1, cube->p1->x2, cube->p1->x3, , cube->p2->x1, cube->p2->x2, cube->p2->x3));
+// }
+/*                                          
+* Returns a new 3D polygon clipped by the specified 3D rectangle (result may be null!).
+* @param p1 the 1st point of the rectangle
+* @param p2 the 2nd point of the rectangle
+* @return a new 3D polygon clipped by the specified 3D rectangle
+*/
+// GbPolygon3D *createClippedPolygon3D(GbPoint3D *p1, GbPoint3D *p2)
+// {
+//return(GbSystem::clipPolygon3D(this->getPoints(), p1->x1, p1->x2, p1->x3, p2->x1, p2->x2, p2->x3));
+// }
+/*
+* Returns a new 3D polygon clipped by the specified 3D rectangle (result may be null!).
+* @param p1x1 the 1st x1 coordinate of the rectangle
+* @param p1x2 the 1st x2 coordinate of the rectangle
+* @param p2x1 the 2nd x1 coordinate of the rectangle
+* @param p2x2 the 2nd x2 coordinate of the rectangle
+* @return a new 3D polygon clipped by the specified 3D rectangle
+*/
+// GbPolygon3D *createClippedPolygon3D(double p1x1, double p1x2, double p1x3, double p2x1, double p2x2, double p2x3)
+// {
+//return(GbSystem::clipPolygon3D(this.getPoints(), p1x1, p1x2, p1x3, p2x1, p2x2. p2x3));
+// }
+
+/*
+* Returns true if the specified 3D rectangle lies completely within this 3D polygon.
+* @param rectangle the 3D rectangle to check
+* @return true if the specified 3D rectangle lies completely within this 3D polygon
+*/
+//public boolean enclosesRectangle3D(GbRectangle3D rectangle)
+//{
+//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
+//   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), rectangle.getArea()));
+//}
+/*
+* Returns true if the specified 3D rectangle lies completely within this 3D polygon.
+* @param p1 the 1st point of the rectangle to check
+* @param p2 the 2nd point of the rectangle to check
+* @return true if the specified 3D rectangle lies completely within this 3D polygon
+*/
+//public boolean enclosesRectangle3D(GbPoint3D p1, GbPoint3D p2)
+//{
+//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2);
+//   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2))));
+//}
+/*
+* Returns true if the specified 3D rectangle lies completely within this 3D polygon.
+* @param p1x1 the 1st x1 coordinate of the rectangle to check
+* @param p1x2 the 1st x2 coordinate of the rectangle to check
+* @param p2x1 the 2nd x1 coordinate of the rectangle to check
+* @param p2x2 the 2nd x2 coordinate of the rectangle to check
+* @return true if the specified 3D rectangle lies completely within this 3D polygon
+*/
+//public boolean enclosesRectangle3D(double p1x1, double p1x2, double p2x1, double p2x2)
+//{
+//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1x1, p1x2, p2x1, p2x2);
+//   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1x1-p2x1)*(p1x2-p2x2))));
+//}
+
+/*
+* Returns true if the specified 3D rectangle is crossed by this 3D polygon.
+* @param rectangle the 3D rectangle to check
+* @return true if the specified 3D rectangle is crossed by this 3D polygon
+*/
+//public boolean crossesRectangle3D(GbRectangle3D rectangle)
+//{
+//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
+//   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, rectangle.getArea()));
+//}
+/*
+* Returns true if the specified 3D rectangle is crossed by this 3D polygon.
+* @param p1 the 1st point of the rectangle to check
+* @param p2 the 2nd point of the rectangle to check
+* @return true if the specified 3D rectangle is crossed by this 3D polygon
+*/
+//public boolean crossesRectangle3D(GbPoint3D p1, GbPoint3D p2)
+//{
+//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2);
+//   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2))));
+//}
+/*
+* Returns true if the specified 3D rectangle is crossed by this 3D polygon.
+* @param p1x1 the 1st x1 coordinate of the rectangle to check
+* @param p1x2 the 1st x2 coordinate of the rectangle to check
+* @param p2x1 the 2nd x1 coordinate of the rectangle to check
+* @param p2x2 the 2nd x2 coordinate of the rectangle to check
+* @return true if the specified 3D rectangle is crossed by this 3D polygon
+*/
+//public boolean crossesRectangle3D(double p1x1, double p1x2, double p2x1, double p2x2)
+//{
+//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1x1, p1x2, p2x1, p2x2);
+//   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1x1-p2x1)*(p1x2-p2x2))));
+//}
+
+/*
+* Returns true if the specified 3D rectangle lies (at least partly) within this 3D polygon.
+* @param rectangle the 3D rectangle to check
+* @return true if the specified 3D rectangle lies (at least partly) within this 3D polygon
+*/
+//public boolean enclosesOrCrossesRectangle3D(GbRectangle3D rectangle)
+//{
+//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
+//   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
+//}
+/*
+* Returns true if the specified 3D rectangle lies (at least partly) within this 3D polygon.
+* @param p1 the 1st point of the rectangle to check
+* @param p2 the 2nd point of the rectangle to check
+* @return true if the specified 3D rectangle lies (at least partly) within this 3D polygon
+*/
+//public boolean enclosesOrCrossesRectangle3D(GbPoint3D p1, GbPoint3D p2)
+//{
+//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2);
+//   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
+//}
+/*
+* Returns true if the specified 3D rectangle lies (at least partly) within this 3D polygon.
+* @param p1x1 the 1st x1 coordinate of the rectangle to check
+* @param p1x2 the 1st x2 coordinate of the rectangle to check
+* @param p2x1 the 2nd x1 coordinate of the rectangle to check
+* @param p2x2 the 2nd x2 coordinate of the rectangle to check
+* @return true if the specified 3D rectangle lies (at least partly) within this 3D polygon
+*/
+//public boolean enclosesOrCrossesRectangle3D(double p1x1, double p1x2, double p2x1, double p2x2)
+//{
+//   GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1x1, p1x2, p2x1, p2x2);
+//   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
+//}
+/*======================================================================*/
+
+void GbPolygon3D::calculateValues()
+{
+   this->x1s        = 0.0;
+   this->x2s        = 0.0;
+   this->x3s        = 0.0;
+   this->x1min      = 0.0;
+   this->x1max      = 0.0;
+   this->x2min      = 0.0;
+   this->x2max      = 0.0;
+   this->x3min      = 0.0;
+   this->x3max      = 0.0;
+   throw UbException(UB_EXARGS,"should be implemented");
+
+   //this->consistent = true;
+
+   //this->points = this->ps->getPoints();
+
+   //int       n     = (int)this->points.size();
+   //if(n < 1) return;
+
+   //GbPoint3D p1 = (this->points)[0];
+   //GbPoint3D p2 = NULL;
+   //double    h1 = 0.0;
+   //double    h2 = 0.0;
+   //double    f=0.0;
+
+   //this->x1s   = p1.x1;
+   //this->x1min = p1.x1;
+   //this->x1max = p1.x1;
+   //this->x2s   = p1.x2;
+   //this->x2min = p1.x2;
+   //this->x2max = p1.x2;
+   //this->x3s   = p1.x2;
+   //this->x3min = p1.x2;
+   //this->x3max = p1.x2;
+
+   //std::cout<<"Should be implemented "<<endl;
+
+   //for(int i=1; i<n; i++)
+   //{
+   //  p2         = (this->points)[i];
+   //  f          = p1.x1*p2.x2 - p1.x2*p2.x1;
+   //  this->area += f;
+   //  h1        += f*(p1.x2 + p2.x2);
+   //  h2        += f*(p1.x1 + p2.x1);
+   //  p1         = p2;
+
+   //  if(p1.x1 < this->x1min) this->x1min = p1.x1;
+   //  if(p1.x1 > this->x1max) this->x1max = p1.x1;
+   //  if(p1.x2 < this->x2min) this->x2min = p1.x2;
+   //  if(p1.x2 > this->x2max) this->x2max = p1.x2;
+   //}
+   //p2         = (this->points)[0];
+   //f          = p1.x1*p2.x2 - p1.x2*p2.x1;
+   //this->area += f;
+   //h1        += f*(p1.x2 + p2.x2);
+   //h2        += f*(p1.x1 + p2.x1);
+
+   //this->area *= 0.5;
+   //h1        /= 6.0;
+   //h2        /= 6.0;
+
+   //if(n > 2)
+   //{
+   //   this->x1s = h2/this->area;
+   //   this->x2s = h1/this->area;
+   //}
+
+   //if(n < 3 || !GbSystem::inClosedInterval(this->x1s, this->x1min, this->x1max)) this->x1s = 0.5*(this->x1min+this->x1max);
+   //if(n < 3 || !GbSystem::inClosedInterval(this->x2s, this->x2min, this->x2max)) this->x2s = 0.5*(this->x2min+this->x2max);
+}
+/*======================================================================*/
+
+
+/*======================================================================*/
+// private class PointObserver implements TiObserver
+// {
+//    GbPolygon3D polygon = null;
+
+//    PointObserver(GbPolygon3D polygon)
+//    {
+//this.polygon = polygon;
+//    }
+
+//    public void objectChanged(Object object)
+//    {
+//if((object instanceof GbPoint3D) && this.polygon.contains((GbPoint3D)object)>0)
+//{
+//   this.polygon.consistent = false;
+//   this.polygon.notifyObservers();
+//}
+//    }
+// }
+/*=======================================================*/
+void GbPolygon3D::write(UbFileOutput* out) 
+{                                      
+   throw UbException(UB_EXARGS,"not implemented");
+}
+/*=======================================================*/
+void GbPolygon3D::read(UbFileInput* in) 
+{  
+   throw UbException(UB_EXARGS,"not implemented");
+}
+/*=======================================================*/
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbPolygon3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbPolygon3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbPolygon3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbPolygon3D.h
index 056a826376b2af2f727fda0cf5a4bca04d6ec6fd..736913caf73e76f6d64ef686c98be779a9365ab7 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbPolygon3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbPolygon3D.h
@@ -1,533 +1,533 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBPOLYGON3D_H
-#define GBPOLYGON3D_H
-
-#include <sstream>
-#include <iostream>
-
-
-#include <numerics/geometry3d/GbObject3D.h>
-#include <numerics/geometry3d/GbLine3D.h>
-#include <numerics/geometry3d/GbTriangle3D.h>
-#include <numerics/geometry3d/GbSystem3D.h>
-
-#include <PointerDefinitions.h>
-
-class GbObject3DCreator;
-
-/*=========================================================================*/
-/* GbPolygon2D                                                             */
-/*                                                                         */
-/*
-* This Class provides basic 3D polygon objects.
-*/
-class GbPolygon3D : public GbObject3D
-{
-public:
-   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
-private:
-   /*======================================================================*/
-   double            x1s  ;
-   double            x2s  ;
-   double            x3s  ;
-   double            x1min;
-   double            x1max;
-   double            x2min;
-   double            x2max;
-   double            x3min;
-   double            x3max;
-
-   std::vector<GbPoint3D> points;
-   bool                   consistent;
-
-   GbSystem3D::PointSet3 *ps;
-   //private PointObserver     po         = null;
-
-   void init();
-
-   /*======================================================================*/
-
-
-   /*======================================================================*/
-   /*  Konstruktoren                                                       */
-   /*                                                                      */
-   /*
-   * Creates an empty 2D polygon.
-   */
-public:
-   static int counter;
-   GbPolygon3D();
-   /*
-   * Creates an empty 2D polygon with the specified capacity.
-   * @param capacity the initial capacity
-   */
-   GbPolygon3D(int capacity);
-   /*
-   * Creates a 2D polygon with the specified points.
-   * @param points the initial points of the polygon
-   */
-   GbPolygon3D(std::vector<GbPoint3D> &points);
-   /*
-   * Creates a 2D polygon as clone of the specified 2D polygon.
-   * @param polygon the 2D polygon to be cloned
-   */
-   GbPolygon3D(GbPolygon3D *polygon);
-
-   ~GbPolygon3D();
-
-   /*======================================================================*/
-
-
-   /*======================================================================*/
-   /*  Methoden                                                            */
-   /*                                                                      */
-   /*
-   * Creates a 2D polygon as clone of this 2D polygon.
-   */
-   GbPolygon3D* clone() {   return(new GbPolygon3D(this)); }
-   void finalize()
-   {
-      throw UbException(UB_EXARGS,"toDo");
-   }
-
-   /*
-   * Returns the number of points.
-   * @return the number of points
-   */
-   int size();
-   /*
-   * Returns the number of times this 2D polygon contains the specified point.
-   * @param point the point
-   * @return the number of times this 2D polygon contains the specified point
-   */
-   int contains(GbPoint3D *point);
-   /*
-   * Returns the number of times this 2D polygon contains a point equal to the specified point.
-   * @param point the point
-   * @return the number of times this 2D polygon contains a point equal to the specified point
-   */
-   int containsEqual(GbPoint3D* point);
-   /*
-   * Returns true, if this 2D polygon contains the specified line.
-   * @param point1 the first point
-   * @param point2 the second point
-   * @return true, if this 2D polygon contains the specified line
-   */
-   bool containsLine(GbPoint3D* point1, GbPoint3D* point2);
-   /*
-   * Returns true, if this 2D polygon contains the specified line.
-   * @param line the line
-   * @return true, if this 2D polygon contains the specified line
-   */
-   bool containsLine(GbLine3D* line);
-   /*
-   * Returns the first point.
-   * @return the first point
-   */
-   GbPoint3D* getFirstPoint();
-   /*
-   * Returns the last point.
-   * @return the last point
-   */
-   GbPoint3D* getLastPoint();
-   /*
-   * Returns the specified point.
-   * @param index the index
-   * @return the specified point
-   * @exception ArrayIndexOutOfBoundsException if the specified index is not valid
-   */
-   GbPoint3D* getPoint(const int& index);
-   /*
-   * Returns the points.
-   * @return the points
-   */
-   std::vector<GbPoint3D> getPoints();
-   /*
-   * Returns the points within the specified rectangle.
-   * @param rectangle the 2D rectangle
-   * @return the points within the specified rectangle
-   */
-   //public GbPoint2D[] getPoints(GbRectangle2D rectangle)
-   //{
-   //   return(this.getPoints(rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2));
-   //}
-   /*
-   * Returns the points within the specified rectangle.
-   * @param p1 the 1st point of the rectangle
-   * @param p2 the 2nd point of the rectangle
-   * @return the points within the specified rectangle
-   */
-   std::vector<GbPoint3D> getPoints(GbPoint3D* p1, GbPoint3D* p2);
-   /*
-   * Returns the points within the specified rectangle.
-   * @param p1x1 the 1st x1 coordinate of the rectangle
-   * @param p1x2 the 1st x2 coordinate of the rectangle
-   * @param p2x1 the 2nd x1 coordinate of the rectangle
-   * @param p2x2 the 2nd x2 coordinate of the rectangle
-   * @return the points within the specified rectangle
-   */
-   std::vector<GbPoint3D> getPoints(const double& p1x1, const double& p1x2, const double& p1x3, const double& p2x1, const double& p2x2, const double& p2x3);
-   /*
-   * Returns the area of this polygon.
-   * The area is positive for positive ordered points, otherwise negative.
-   * @return the area of this polygon
-   */
-   //double getArea()
-   //{
-   //   if(!this.consistent) this.calculateValues();
-   //   return(this.area);
-   //}
-   double getX1Centroid();
-   double getX1Minimum();
-   double getX1Maximum();
-   double getX2Centroid();
-   double getX2Minimum();
-   double getX2Maximum();
-   double getX3Centroid();
-   double getX3Minimum();
-   double getX3Maximum();
-
-   /*
-   * Adds a point to the end of this polygon. Notifies the observers of this 2D polygon.
-   * @param point the point
-   */
-   void addPoint(GbPoint3D* point);
-   /*
-   * Adds a number of points to the end of this polygon. Notifies the observers of this 2D polygon.
-   * @param points the points
-   */
-   void addPoints(std::vector<GbPoint3D>& points);
-   /*
-   * Inserts a point at the specified position within this polygon. Notifies the observers of this 2D polygon.
-   * @param point the point
-   * @param index the index
-   * @exception ArrayIndexOutOfBoundsException if the specified index is not valid
-   */
-   //public void insertPoint(GbPoint2D point, int index) throws ArrayIndexOutOfBoundsException
-   //{
-   //   if((this instanceof GbPolygon3D) && !(point instanceof GbPoint3D)) throw new IllegalArgumentException("GbPolygon2D.insertPoint(): points of 3D polygons have to be 3D points!");
-   //   if(index < 0 || index > this.ps.size()) throw new ArrayIndexOutOfBoundsException("GbPolygon2D.insert(): invalid index specified: "+index);
-
-   //   this.ps.insert(point, index);
-   //   point.addObserver(this.po);
-   //   this.consistent = false;
-   //   super.notifyObservers();
-   //}
-   /*
-   * Removes all points from this polygon identical to the specified one. Notifies the observers of this 2D polygon.
-   * @param point the point
-   */
-   //public void deletePoint(GbPoint2D point)
-   //{
-   //   this.ps.delete(point);
-   //   point.removeObserver(this.po);
-   //   this.consistent = false;
-   //   super.notifyObservers();
-   //}
-   /*
-   * Removes all points from this polygon equal to the specified one. Notifies the observers of this 2D polygon.
-   * @param point the point
-   */
-   //public void deleteEqualPoint(GbPoint2D point)
-   //{
-   //   this.ps.deleteEqual(point);
-   //   point.removeObserver(this.po);
-   //   this.consistent = false;
-   //   super.notifyObservers();
-   //}
-   /*
-   * Removes all points from this polygon. Notifies the observers of this 2D polygon.
-   */
-   void clear();
-
-   /*
-   * Returns true if this 2D polygon equals the specified object.
-   * Two polygon are equal, if their points are equal.
-   * <BR>Note that the order of points is recognized!
-   * @return true if this 2D polygon equals the specified object
-   * @see GbPoint2D#equals(java.lang.Object)
-   * @see GbPoint3D#equals(java.lang.Object)
-   */
-   // bool equals(Object object)
-   // {
-   //    try
-   //    {
-   //	GbPolygon2D polygon = (GbPolygon2D) object;
-   //int         n       = this.size();
-
-   //if(n != polygon.size()) return(false);
-   //for(int i=0; i<n; i++) if(!this.getPoint(i).equals(polygon.getPoint(i))) return(false);
-   //return(true);
-   //    }
-   //    catch(Exception e){ return(false); }
-   // }
-   std::vector<GbTriangle3D*> getSurfaceTriangleSet()
-   {
-      std::cout<<"GbPolygon3D::getSurfaceTriangleSet() - not implemented\n";
-      std::vector<GbTriangle3D*> tmp;
-      return tmp;
-   }
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3)
-   {
-      throw UbException(__FILE__, __LINE__, "GbPolygon3D::isPointInObject3D- not implemented");
-   }
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)
-   {
-      throw UbException(__FILE__, __LINE__, "GbPolygon3D::isPointInObject3D- not implemented");
-   }
-   bool isCellInsideGbObject3D(double x11,double x21,double x31,double x12,double x22,double x32) { return false; }
-
-   GbLine3D* createClippedLine3D (GbPoint3D& point1, GbPoint3D &point2)
-   {
-      throw UbException(__FILE__, __LINE__, "GbPolygon3D::createClippedLine3D - not implemented");
-   }                        
-/*
-   * Returns a string representation of this 2D polygon.
-   * @return a string representation of this 2D polygon
-   */
-   std::string toString();
-   ObObjectCreator* getCreator();
-   void write(UbFileOutput* out);
-   void read(UbFileInput* in);
-   /*======================================================================*/
-
-
-   /*======================================================================*/
-   /*  Calculation                                                         */
-   /*                                                                      */
-   /*
-   * Returns the intersection points of this 2D polygon and the specified 2D line.
-   * @param line the 2D line to intersect
-   * @return the intersection points of this 2D polygon and the specified 2D line
-   */
-   // public GbPoint2D[] calculateIntersectionPoints2D(GbLine2D line)
-   // {
-   //    GbSystem.PointSet pointSet = new GbSystem.PointSet(0);
-   //    GbPoint2D         points[] = this.getPoints();
-   //    GbPoint2D         pCrossed = null;
-   //    int               n        = points.length;
-   //    if(n < 2)         return(pointSet.getPoints());
-
-   //    for(int i=1; i<n; i++)
-   //    {
-   //pCrossed = GbSystem.calculateIntersectionPoint2D(points[i-1], points[i], line.p1, line.p2);
-   //if(pCrossed != null) pointSet.add(pCrossed);
-   //    }
-   //    pCrossed = GbSystem.calculateIntersectionPoint2D(points[n-1], points[0], line.p1, line.p2);
-   //    if(pCrossed != null) pointSet.add(pCrossed);
-
-   //    return(pointSet.getPoints());
-   // }
-
-   /*
-   * Returns true if the specified 2D point lies within (or on the border of) this 2D polygon.
-   * @param point the 2D point to check
-   * @return true if the specified 2D point lies within (or on the border of) this 2D polygon
-   */
-   // public boolean enclosesPoint2D(GbPoint2D point)
-   // {
-   //    if(GbSystem.less(point.x1, this.x1min))    return(false);
-   //    if(GbSystem.less(point.x2, this.x2min))    return(false);
-   //    if(GbSystem.greater(point.x1, this.x1max)) return(false);
-   //    if(GbSystem.greater(point.x2, this.x2max)) return(false);
-   //    if(this.containsEqual(point) > 0)          return(true);
-
-   //    QbList    ltest    = new QbList(GbPoint2D.class, QbList.NOEQUALOBJECTS);
-   //    GbPoint2D points[] = this.getPoints();
-   //    GbPoint2D ptest;
-   //    int       n        = points.length;
-   //    if(n < 2) return(false);
-
-   //    if(GbSystem.equal(point.x2, this.x2min)) ptest = new GbPoint2D(point.x1, this.x2min-1.0);
-   //    else                                     ptest = new GbPoint2D(point.x1, this.x2max+1.0);
-
-   //    for(int i=1; i<n; i++)
-   //    {
-   //try { ltest.append(GbSystem.calculateIntersectionPoint2D(points[i-1], points[i], point, ptest)); }
-   //catch(Exception e){}
-   //    }
-   //    try { ltest.append(GbSystem.calculateIntersectionPoint2D(points[n-1], points[0], point, ptest)); }
-   //    catch(Exception e){}
-   //    return((ltest.size()%2)==1);
-   // }
-
-   /*
-   * Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!).
-   * @param rectangle the 2D rectangle
-   * @return a new 2D polygon clipped by the specified 2D rectangle
-   */
-   // GbPolygon3D *createClippedPolygon3D(GbCuboid3D *cube)
-   // {
-   //return(GbSystem::clipPolygon3D(this->getPoints(), cube->p1->x1, cube->p1->x2, cube->p1->x3, , cube->p2->x1, cube->p2->x2, cube->p2->x3));
-   // };
-   /*
-   * Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!).
-   * @param p1 the 1st point of the rectangle
-   * @param p2 the 2nd point of the rectangle
-   * @return a new 2D polygon clipped by the specified 2D rectangle
-   */
-   // GbPolygon3D *createClippedPolygon2D(GbPoint3D *p1, GbPoint3D *p2)
-   // {
-   //return(GbSystem::clipPolygon3D(this->getPoints(), p1->x1, p1->x2, p1->x3, p2->x1, p2->x2, p2->x3));
-   // };
-   /*
-   * Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!).
-   * @param p1x1 the 1st x1 coordinate of the rectangle
-   * @param p1x2 the 1st x2 coordinate of the rectangle
-   * @param p2x1 the 2nd x1 coordinate of the rectangle
-   * @param p2x2 the 2nd x2 coordinate of the rectangle
-   * @return a new 2D polygon clipped by the specified 2D rectangle
-   */
-   // GbPolygon3D *createClippedPolygon3D(double p1x1, double p1x2, double p1x3, double p2x1, double p2x2, double p2x3)
-   // {
-   //return(GbSystem::clipPolygon3D(this.getPoints(), p1x1, p1x2, p1x3, p2x1, p2x2. p2x3));
-   // };
-
-   /*
-   * Returns true if the specified 2D rectangle lies completely within this 2D polygon.
-   * @param rectangle the 2D rectangle to check
-   * @return true if the specified 2D rectangle lies completely within this 2D polygon
-   */
-   //public boolean enclosesRectangle2D(GbRectangle2D rectangle)
-   //{
-   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
-   //   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), rectangle.getArea()));
-   //}
-   /*
-   * Returns true if the specified 2D rectangle lies completely within this 2D polygon.
-   * @param p1 the 1st point of the rectangle to check
-   * @param p2 the 2nd point of the rectangle to check
-   * @return true if the specified 2D rectangle lies completely within this 2D polygon
-   */
-   //public boolean enclosesRectangle2D(GbPoint2D p1, GbPoint2D p2)
-   //{
-   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2);
-   //   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2))));
-   //}
-   /*
-   * Returns true if the specified 2D rectangle lies completely within this 2D polygon.
-   * @param p1x1 the 1st x1 coordinate of the rectangle to check
-   * @param p1x2 the 1st x2 coordinate of the rectangle to check
-   * @param p2x1 the 2nd x1 coordinate of the rectangle to check
-   * @param p2x2 the 2nd x2 coordinate of the rectangle to check
-   * @return true if the specified 2D rectangle lies completely within this 2D polygon
-   */
-   //public boolean enclosesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2)
-   //{
-   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1x1, p1x2, p2x1, p2x2);
-   //   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1x1-p2x1)*(p1x2-p2x2))));
-   //}
-
-   /*
-   * Returns true if the specified 2D rectangle is crossed by this 2D polygon.
-   * @param rectangle the 2D rectangle to check
-   * @return true if the specified 2D rectangle is crossed by this 2D polygon
-   */
-   //public boolean crossesRectangle2D(GbRectangle2D rectangle)
-   //{
-   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
-   //   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, rectangle.getArea()));
-   //}
-   /*
-   * Returns true if the specified 2D rectangle is crossed by this 2D polygon.
-   * @param p1 the 1st point of the rectangle to check
-   * @param p2 the 2nd point of the rectangle to check
-   * @return true if the specified 2D rectangle is crossed by this 2D polygon
-   */
-   //public boolean crossesRectangle2D(GbPoint2D p1, GbPoint2D p2)
-   //{
-   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2);
-   //   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2))));
-   //}
-   /*
-   * Returns true if the specified 2D rectangle is crossed by this 2D polygon.
-   * @param p1x1 the 1st x1 coordinate of the rectangle to check
-   * @param p1x2 the 1st x2 coordinate of the rectangle to check
-   * @param p2x1 the 2nd x1 coordinate of the rectangle to check
-   * @param p2x2 the 2nd x2 coordinate of the rectangle to check
-   * @return true if the specified 2D rectangle is crossed by this 2D polygon
-   */
-   //public boolean crossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2)
-   //{
-   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1x1, p1x2, p2x1, p2x2);
-   //   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1x1-p2x1)*(p1x2-p2x2))));
-   //}
-
-   /*
-   * Returns true if the specified 2D rectangle lies (at least partly) within this 2D polygon.
-   * @param rectangle the 2D rectangle to check
-   * @return true if the specified 2D rectangle lies (at least partly) within this 2D polygon
-   */
-   //public boolean enclosesOrCrossesRectangle2D(GbRectangle2D rectangle)
-   //{
-   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
-   //   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
-   //}
-   /*
-   * Returns true if the specified 2D rectangle lies (at least partly) within this 2D polygon.
-   * @param p1 the 1st point of the rectangle to check
-   * @param p2 the 2nd point of the rectangle to check
-   * @return true if the specified 2D rectangle lies (at least partly) within this 2D polygon
-   */
-   //public boolean enclosesOrCrossesRectangle2D(GbPoint2D p1, GbPoint2D p2)
-   //{
-   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2);
-   //   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
-   //}
-   /*
-   * Returns true if the specified 2D rectangle lies (at least partly) within this 2D polygon.
-   * @param p1x1 the 1st x1 coordinate of the rectangle to check
-   * @param p1x2 the 1st x2 coordinate of the rectangle to check
-   * @param p2x1 the 2nd x1 coordinate of the rectangle to check
-   * @param p2x2 the 2nd x2 coordinate of the rectangle to check
-   * @return true if the specified 2D rectangle lies (at least partly) within this 2D polygon
-   */
-   //public boolean enclosesOrCrossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2)
-   //{
-   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1x1, p1x2, p2x1, p2x2);
-   //   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
-   //}
-   /*======================================================================*/
-
-
-   /*======================================================================*/
-   /*  Private Methoden                                                    */
-   /*                                                                      */
-   void calculateValues();
-   /*======================================================================*/
-
-
-   /*======================================================================*/
-   // private class PointObserver implements TiObserver
-   // {
-   //    GbPolygon2D polygon = null;
-
-   //    PointObserver(GbPolygon2D polygon)
-   //    {
-   //this.polygon = polygon;
-   //    }
-
-   //    public void objectChanged(Object object)
-   //    {
-   //if((object instanceof GbPoint2D) && this.polygon.contains((GbPoint2D)object)>0)
-   //{
-   //   this.polygon.consistent = false;
-   //   this.polygon.notifyObservers();
-   //}
-   //    }
-   // }
-   /*======================================================================*/
-};
-/*=========================================================================*/
-#endif
-
-
-
-
-
-
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBPOLYGON3D_H
+#define GBPOLYGON3D_H
+
+#include <sstream>
+#include <iostream>
+
+
+#include <numerics/geometry3d/GbObject3D.h>
+#include <numerics/geometry3d/GbLine3D.h>
+#include <numerics/geometry3d/GbTriangle3D.h>
+#include <numerics/geometry3d/GbSystem3D.h>
+
+#include <PointerDefinitions.h>
+
+class GbObject3DCreator;
+
+/*=========================================================================*/
+/* GbPolygon2D                                                             */
+/*                                                                         */
+/*
+* This Class provides basic 3D polygon objects.
+*/
+class GbPolygon3D : public GbObject3D
+{
+public:
+   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
+private:
+   /*======================================================================*/
+   double            x1s  ;
+   double            x2s  ;
+   double            x3s  ;
+   double            x1min;
+   double            x1max;
+   double            x2min;
+   double            x2max;
+   double            x3min;
+   double            x3max;
+
+   std::vector<GbPoint3D> points;
+   bool                   consistent;
+
+   GbSystem3D::PointSet3 *ps;
+   //private PointObserver     po         = null;
+
+   void init();
+
+   /*======================================================================*/
+
+
+   /*======================================================================*/
+   /*  Konstruktoren                                                       */
+   /*                                                                      */
+   /*
+   * Creates an empty 2D polygon.
+   */
+public:
+   static int counter;
+   GbPolygon3D();
+   /*
+   * Creates an empty 2D polygon with the specified capacity.
+   * @param capacity the initial capacity
+   */
+   GbPolygon3D(int capacity);
+   /*
+   * Creates a 2D polygon with the specified points.
+   * @param points the initial points of the polygon
+   */
+   GbPolygon3D(std::vector<GbPoint3D> &points);
+   /*
+   * Creates a 2D polygon as clone of the specified 2D polygon.
+   * @param polygon the 2D polygon to be cloned
+   */
+   GbPolygon3D(GbPolygon3D *polygon);
+
+   ~GbPolygon3D();
+
+   /*======================================================================*/
+
+
+   /*======================================================================*/
+   /*  Methoden                                                            */
+   /*                                                                      */
+   /*
+   * Creates a 2D polygon as clone of this 2D polygon.
+   */
+   GbPolygon3D* clone() {   return(new GbPolygon3D(this)); }
+   void finalize()
+   {
+      throw UbException(UB_EXARGS,"toDo");
+   }
+
+   /*
+   * Returns the number of points.
+   * @return the number of points
+   */
+   int size();
+   /*
+   * Returns the number of times this 2D polygon contains the specified point.
+   * @param point the point
+   * @return the number of times this 2D polygon contains the specified point
+   */
+   int contains(GbPoint3D *point);
+   /*
+   * Returns the number of times this 2D polygon contains a point equal to the specified point.
+   * @param point the point
+   * @return the number of times this 2D polygon contains a point equal to the specified point
+   */
+   int containsEqual(GbPoint3D* point);
+   /*
+   * Returns true, if this 2D polygon contains the specified line.
+   * @param point1 the first point
+   * @param point2 the second point
+   * @return true, if this 2D polygon contains the specified line
+   */
+   bool containsLine(GbPoint3D* point1, GbPoint3D* point2);
+   /*
+   * Returns true, if this 2D polygon contains the specified line.
+   * @param line the line
+   * @return true, if this 2D polygon contains the specified line
+   */
+   bool containsLine(GbLine3D* line);
+   /*
+   * Returns the first point.
+   * @return the first point
+   */
+   GbPoint3D* getFirstPoint();
+   /*
+   * Returns the last point.
+   * @return the last point
+   */
+   GbPoint3D* getLastPoint();
+   /*
+   * Returns the specified point.
+   * @param index the index
+   * @return the specified point
+   * @exception ArrayIndexOutOfBoundsException if the specified index is not valid
+   */
+   GbPoint3D* getPoint(const int& index);
+   /*
+   * Returns the points.
+   * @return the points
+   */
+   std::vector<GbPoint3D> getPoints();
+   /*
+   * Returns the points within the specified rectangle.
+   * @param rectangle the 2D rectangle
+   * @return the points within the specified rectangle
+   */
+   //public GbPoint2D[] getPoints(GbRectangle2D rectangle)
+   //{
+   //   return(this.getPoints(rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2));
+   //}
+   /*
+   * Returns the points within the specified rectangle.
+   * @param p1 the 1st point of the rectangle
+   * @param p2 the 2nd point of the rectangle
+   * @return the points within the specified rectangle
+   */
+   std::vector<GbPoint3D> getPoints(GbPoint3D* p1, GbPoint3D* p2);
+   /*
+   * Returns the points within the specified rectangle.
+   * @param p1x1 the 1st x1 coordinate of the rectangle
+   * @param p1x2 the 1st x2 coordinate of the rectangle
+   * @param p2x1 the 2nd x1 coordinate of the rectangle
+   * @param p2x2 the 2nd x2 coordinate of the rectangle
+   * @return the points within the specified rectangle
+   */
+   std::vector<GbPoint3D> getPoints(const double& p1x1, const double& p1x2, const double& p1x3, const double& p2x1, const double& p2x2, const double& p2x3);
+   /*
+   * Returns the area of this polygon.
+   * The area is positive for positive ordered points, otherwise negative.
+   * @return the area of this polygon
+   */
+   //double getArea()
+   //{
+   //   if(!this.consistent) this.calculateValues();
+   //   return(this.area);
+   //}
+   double getX1Centroid();
+   double getX1Minimum();
+   double getX1Maximum();
+   double getX2Centroid();
+   double getX2Minimum();
+   double getX2Maximum();
+   double getX3Centroid();
+   double getX3Minimum();
+   double getX3Maximum();
+
+   /*
+   * Adds a point to the end of this polygon. Notifies the observers of this 2D polygon.
+   * @param point the point
+   */
+   void addPoint(GbPoint3D* point);
+   /*
+   * Adds a number of points to the end of this polygon. Notifies the observers of this 2D polygon.
+   * @param points the points
+   */
+   void addPoints(std::vector<GbPoint3D>& points);
+   /*
+   * Inserts a point at the specified position within this polygon. Notifies the observers of this 2D polygon.
+   * @param point the point
+   * @param index the index
+   * @exception ArrayIndexOutOfBoundsException if the specified index is not valid
+   */
+   //public void insertPoint(GbPoint2D point, int index) throws ArrayIndexOutOfBoundsException
+   //{
+   //   if((this instanceof GbPolygon3D) && !(point instanceof GbPoint3D)) throw new IllegalArgumentException("GbPolygon2D.insertPoint(): points of 3D polygons have to be 3D points!");
+   //   if(index < 0 || index > this.ps.size()) throw new ArrayIndexOutOfBoundsException("GbPolygon2D.insert(): invalid index specified: "+index);
+
+   //   this.ps.insert(point, index);
+   //   point.addObserver(this.po);
+   //   this.consistent = false;
+   //   super.notifyObservers();
+   //}
+   /*
+   * Removes all points from this polygon identical to the specified one. Notifies the observers of this 2D polygon.
+   * @param point the point
+   */
+   //public void deletePoint(GbPoint2D point)
+   //{
+   //   this.ps.delete(point);
+   //   point.removeObserver(this.po);
+   //   this.consistent = false;
+   //   super.notifyObservers();
+   //}
+   /*
+   * Removes all points from this polygon equal to the specified one. Notifies the observers of this 2D polygon.
+   * @param point the point
+   */
+   //public void deleteEqualPoint(GbPoint2D point)
+   //{
+   //   this.ps.deleteEqual(point);
+   //   point.removeObserver(this.po);
+   //   this.consistent = false;
+   //   super.notifyObservers();
+   //}
+   /*
+   * Removes all points from this polygon. Notifies the observers of this 2D polygon.
+   */
+   void clear();
+
+   /*
+   * Returns true if this 2D polygon equals the specified object.
+   * Two polygon are equal, if their points are equal.
+   * <BR>Note that the order of points is recognized!
+   * @return true if this 2D polygon equals the specified object
+   * @see GbPoint2D#equals(java.lang.Object)
+   * @see GbPoint3D#equals(java.lang.Object)
+   */
+   // bool equals(Object object)
+   // {
+   //    try
+   //    {
+   //	GbPolygon2D polygon = (GbPolygon2D) object;
+   //int         n       = this.size();
+
+   //if(n != polygon.size()) return(false);
+   //for(int i=0; i<n; i++) if(!this.getPoint(i).equals(polygon.getPoint(i))) return(false);
+   //return(true);
+   //    }
+   //    catch(Exception e){ return(false); }
+   // }
+   std::vector<GbTriangle3D*> getSurfaceTriangleSet()
+   {
+      std::cout<<"GbPolygon3D::getSurfaceTriangleSet() - not implemented\n";
+      std::vector<GbTriangle3D*> tmp;
+      return tmp;
+   }
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3)
+   {
+      throw UbException(__FILE__, __LINE__, "GbPolygon3D::isPointInObject3D- not implemented");
+   }
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)
+   {
+      throw UbException(__FILE__, __LINE__, "GbPolygon3D::isPointInObject3D- not implemented");
+   }
+   bool isCellInsideGbObject3D(double x11,double x21,double x31,double x12,double x22,double x32) { return false; }
+
+   GbLine3D* createClippedLine3D (GbPoint3D& point1, GbPoint3D &point2)
+   {
+      throw UbException(__FILE__, __LINE__, "GbPolygon3D::createClippedLine3D - not implemented");
+   }                        
+/*
+   * Returns a string representation of this 2D polygon.
+   * @return a string representation of this 2D polygon
+   */
+   std::string toString();
+   ObObjectCreator* getCreator();
+   void write(UbFileOutput* out);
+   void read(UbFileInput* in);
+   /*======================================================================*/
+
+
+   /*======================================================================*/
+   /*  Calculation                                                         */
+   /*                                                                      */
+   /*
+   * Returns the intersection points of this 2D polygon and the specified 2D line.
+   * @param line the 2D line to intersect
+   * @return the intersection points of this 2D polygon and the specified 2D line
+   */
+   // public GbPoint2D[] calculateIntersectionPoints2D(GbLine2D line)
+   // {
+   //    GbSystem.PointSet pointSet = new GbSystem.PointSet(0);
+   //    GbPoint2D         points[] = this.getPoints();
+   //    GbPoint2D         pCrossed = null;
+   //    int               n        = points.length;
+   //    if(n < 2)         return(pointSet.getPoints());
+
+   //    for(int i=1; i<n; i++)
+   //    {
+   //pCrossed = GbSystem.calculateIntersectionPoint2D(points[i-1], points[i], line.p1, line.p2);
+   //if(pCrossed != null) pointSet.add(pCrossed);
+   //    }
+   //    pCrossed = GbSystem.calculateIntersectionPoint2D(points[n-1], points[0], line.p1, line.p2);
+   //    if(pCrossed != null) pointSet.add(pCrossed);
+
+   //    return(pointSet.getPoints());
+   // }
+
+   /*
+   * Returns true if the specified 2D point lies within (or on the border of) this 2D polygon.
+   * @param point the 2D point to check
+   * @return true if the specified 2D point lies within (or on the border of) this 2D polygon
+   */
+   // public boolean enclosesPoint2D(GbPoint2D point)
+   // {
+   //    if(GbSystem.less(point.x1, this.x1min))    return(false);
+   //    if(GbSystem.less(point.x2, this.x2min))    return(false);
+   //    if(GbSystem.greater(point.x1, this.x1max)) return(false);
+   //    if(GbSystem.greater(point.x2, this.x2max)) return(false);
+   //    if(this.containsEqual(point) > 0)          return(true);
+
+   //    QbList    ltest    = new QbList(GbPoint2D.class, QbList.NOEQUALOBJECTS);
+   //    GbPoint2D points[] = this.getPoints();
+   //    GbPoint2D ptest;
+   //    int       n        = points.length;
+   //    if(n < 2) return(false);
+
+   //    if(GbSystem.equal(point.x2, this.x2min)) ptest = new GbPoint2D(point.x1, this.x2min-1.0);
+   //    else                                     ptest = new GbPoint2D(point.x1, this.x2max+1.0);
+
+   //    for(int i=1; i<n; i++)
+   //    {
+   //try { ltest.append(GbSystem.calculateIntersectionPoint2D(points[i-1], points[i], point, ptest)); }
+   //catch(Exception e){}
+   //    }
+   //    try { ltest.append(GbSystem.calculateIntersectionPoint2D(points[n-1], points[0], point, ptest)); }
+   //    catch(Exception e){}
+   //    return((ltest.size()%2)==1);
+   // }
+
+   /*
+   * Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!).
+   * @param rectangle the 2D rectangle
+   * @return a new 2D polygon clipped by the specified 2D rectangle
+   */
+   // GbPolygon3D *createClippedPolygon3D(GbCuboid3D *cube)
+   // {
+   //return(GbSystem::clipPolygon3D(this->getPoints(), cube->p1->x1, cube->p1->x2, cube->p1->x3, , cube->p2->x1, cube->p2->x2, cube->p2->x3));
+   // };
+   /*
+   * Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!).
+   * @param p1 the 1st point of the rectangle
+   * @param p2 the 2nd point of the rectangle
+   * @return a new 2D polygon clipped by the specified 2D rectangle
+   */
+   // GbPolygon3D *createClippedPolygon2D(GbPoint3D *p1, GbPoint3D *p2)
+   // {
+   //return(GbSystem::clipPolygon3D(this->getPoints(), p1->x1, p1->x2, p1->x3, p2->x1, p2->x2, p2->x3));
+   // };
+   /*
+   * Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!).
+   * @param p1x1 the 1st x1 coordinate of the rectangle
+   * @param p1x2 the 1st x2 coordinate of the rectangle
+   * @param p2x1 the 2nd x1 coordinate of the rectangle
+   * @param p2x2 the 2nd x2 coordinate of the rectangle
+   * @return a new 2D polygon clipped by the specified 2D rectangle
+   */
+   // GbPolygon3D *createClippedPolygon3D(double p1x1, double p1x2, double p1x3, double p2x1, double p2x2, double p2x3)
+   // {
+   //return(GbSystem::clipPolygon3D(this.getPoints(), p1x1, p1x2, p1x3, p2x1, p2x2. p2x3));
+   // };
+
+   /*
+   * Returns true if the specified 2D rectangle lies completely within this 2D polygon.
+   * @param rectangle the 2D rectangle to check
+   * @return true if the specified 2D rectangle lies completely within this 2D polygon
+   */
+   //public boolean enclosesRectangle2D(GbRectangle2D rectangle)
+   //{
+   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
+   //   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), rectangle.getArea()));
+   //}
+   /*
+   * Returns true if the specified 2D rectangle lies completely within this 2D polygon.
+   * @param p1 the 1st point of the rectangle to check
+   * @param p2 the 2nd point of the rectangle to check
+   * @return true if the specified 2D rectangle lies completely within this 2D polygon
+   */
+   //public boolean enclosesRectangle2D(GbPoint2D p1, GbPoint2D p2)
+   //{
+   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2);
+   //   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2))));
+   //}
+   /*
+   * Returns true if the specified 2D rectangle lies completely within this 2D polygon.
+   * @param p1x1 the 1st x1 coordinate of the rectangle to check
+   * @param p1x2 the 1st x2 coordinate of the rectangle to check
+   * @param p2x1 the 2nd x1 coordinate of the rectangle to check
+   * @param p2x2 the 2nd x2 coordinate of the rectangle to check
+   * @return true if the specified 2D rectangle lies completely within this 2D polygon
+   */
+   //public boolean enclosesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2)
+   //{
+   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1x1, p1x2, p2x1, p2x2);
+   //   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1x1-p2x1)*(p1x2-p2x2))));
+   //}
+
+   /*
+   * Returns true if the specified 2D rectangle is crossed by this 2D polygon.
+   * @param rectangle the 2D rectangle to check
+   * @return true if the specified 2D rectangle is crossed by this 2D polygon
+   */
+   //public boolean crossesRectangle2D(GbRectangle2D rectangle)
+   //{
+   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
+   //   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, rectangle.getArea()));
+   //}
+   /*
+   * Returns true if the specified 2D rectangle is crossed by this 2D polygon.
+   * @param p1 the 1st point of the rectangle to check
+   * @param p2 the 2nd point of the rectangle to check
+   * @return true if the specified 2D rectangle is crossed by this 2D polygon
+   */
+   //public boolean crossesRectangle2D(GbPoint2D p1, GbPoint2D p2)
+   //{
+   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2);
+   //   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2))));
+   //}
+   /*
+   * Returns true if the specified 2D rectangle is crossed by this 2D polygon.
+   * @param p1x1 the 1st x1 coordinate of the rectangle to check
+   * @param p1x2 the 1st x2 coordinate of the rectangle to check
+   * @param p2x1 the 2nd x1 coordinate of the rectangle to check
+   * @param p2x2 the 2nd x2 coordinate of the rectangle to check
+   * @return true if the specified 2D rectangle is crossed by this 2D polygon
+   */
+   //public boolean crossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2)
+   //{
+   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1x1, p1x2, p2x1, p2x2);
+   //   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1x1-p2x1)*(p1x2-p2x2))));
+   //}
+
+   /*
+   * Returns true if the specified 2D rectangle lies (at least partly) within this 2D polygon.
+   * @param rectangle the 2D rectangle to check
+   * @return true if the specified 2D rectangle lies (at least partly) within this 2D polygon
+   */
+   //public boolean enclosesOrCrossesRectangle2D(GbRectangle2D rectangle)
+   //{
+   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
+   //   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
+   //}
+   /*
+   * Returns true if the specified 2D rectangle lies (at least partly) within this 2D polygon.
+   * @param p1 the 1st point of the rectangle to check
+   * @param p2 the 2nd point of the rectangle to check
+   * @return true if the specified 2D rectangle lies (at least partly) within this 2D polygon
+   */
+   //public boolean enclosesOrCrossesRectangle2D(GbPoint2D p1, GbPoint2D p2)
+   //{
+   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2);
+   //   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
+   //}
+   /*
+   * Returns true if the specified 2D rectangle lies (at least partly) within this 2D polygon.
+   * @param p1x1 the 1st x1 coordinate of the rectangle to check
+   * @param p1x2 the 1st x2 coordinate of the rectangle to check
+   * @param p2x1 the 2nd x1 coordinate of the rectangle to check
+   * @param p2x2 the 2nd x2 coordinate of the rectangle to check
+   * @return true if the specified 2D rectangle lies (at least partly) within this 2D polygon
+   */
+   //public boolean enclosesOrCrossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2)
+   //{
+   //   GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1x1, p1x2, p2x1, p2x2);
+   //   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
+   //}
+   /*======================================================================*/
+
+
+   /*======================================================================*/
+   /*  Private Methoden                                                    */
+   /*                                                                      */
+   void calculateValues();
+   /*======================================================================*/
+
+
+   /*======================================================================*/
+   // private class PointObserver implements TiObserver
+   // {
+   //    GbPolygon2D polygon = null;
+
+   //    PointObserver(GbPolygon2D polygon)
+   //    {
+   //this.polygon = polygon;
+   //    }
+
+   //    public void objectChanged(Object object)
+   //    {
+   //if((object instanceof GbPoint2D) && this.polygon.contains((GbPoint2D)object)>0)
+   //{
+   //   this.polygon.consistent = false;
+   //   this.polygon.notifyObservers();
+   //}
+   //    }
+   // }
+   /*======================================================================*/
+};
+/*=========================================================================*/
+#endif
+
+
+
+
+
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbQuadFaceMesh3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbQuadFaceMesh3D.cpp
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/GbQuadFaceMesh3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbQuadFaceMesh3D.cpp
index c6b8df7927fe730d7a1271cfec5b327c641d2173..43a72e0c9683016a9eae930716947c3a26ed03cb 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbQuadFaceMesh3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbQuadFaceMesh3D.cpp
@@ -1,362 +1,362 @@
-#include <numerics/geometry3d/GbQuadFaceMesh3D.h>
-#include <numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h>
-
-#include <numerics/geometry3d/GbHalfSpace3D.h>
-#include <numerics/geometry3d/GbCuboid3D.h>
-
- 
-using namespace std;
-
-GbQuadFaceMesh3D::GbQuadFaceMesh3D() : GbObject3D()
-{
-   this->name             = "new GbMesh";
-   this->nodes            = new vector<Vertex>;           
-   this->quads            = new vector<QuadFace>;
-   this->consistent       = false;                                 
-}
-
-GbQuadFaceMesh3D::GbQuadFaceMesh3D(string name, vector<Vertex> *nodes, vector<QuadFace> *quads) : GbObject3D()
-{
-   if(name.size()==0 ) throw UbException(UB_EXARGS,"no name specified");
-   if(!nodes         ) throw UbException(UB_EXARGS,"no nodes specified");
-   if(!quads         ) throw UbException(UB_EXARGS,"no quads specified");
-                                                         
-   this->name             = name;
-   this->nodes            = nodes;           
-   this->quads            = quads;     
-   this->consistent       = false;                                 
-}
-/*=============================================================================================*/
-
-GbQuadFaceMesh3D::~GbQuadFaceMesh3D()
-{
-	if(nodes)
-	{
-	//	for(unsigned u=0; u<nodes->size(); u++) delete (*nodes)[u];
-      delete nodes;
-	}
-   if(quads)
-   {
-      delete quads;
-   }
-}
-/*======================================================================*/
-ObObjectCreator* GbQuadFaceMesh3D::getCreator()
-{
-   return GbQuadFaceMesh3DCreator::getInstance();
-}
-/*======================================================================*/
-
-void GbQuadFaceMesh3D::init()
-{
-   nodes      = NULL;
-   quads      = NULL;
-   x1min      = 0.0;
-   x1max      = 0.0;
-   x2min      = 0.0;
-   x2max      = 0.0;
-   x3min      = 0.0;
-   x3max      = 0.0;
-   consistent = false;
-}                                     
-   /**
-    * Returns a string representation of this triangular mesh.
-    * @return a string representation of this triangular mesh
-    */
-string GbQuadFaceMesh3D::toString()
-{
-	stringstream ss;
-	ss<<"GbQuadFaceMesh3D[";
-	ss<<(int)this->quads->size()<<"-Quadangles, "<<(int)this->nodes->size()<<"-Nodes, "<<endl;
-	//ss<<"\""<<this->name<<", Area=sollt mal berechnet werden ;-)"<<"\"";
-   //ss<<", x1min="<<this->x1min;
-   //ss<<", x1max="<<this->x1max;
-   //ss<<", x2min="<<this->x2min;
-   //ss<<", x2max="<<this->x2max;
-   //ss<<", x3min="<<this->x3min;
-   //ss<<", x3max="<<this->x3max;
-   ss<<"]";
-   return(ss.str());
-}
-/**
- * Returns the name of this triangular mesh.
- * @return the name of this triangular mesh
- */
-string GbQuadFaceMesh3D::getName(){ return(this->name); }
-
-/**
- * Returns the nodes of this triangular mesh.
- * @return the nodes of this triangular mesh
- */
-vector<GbQuadFaceMesh3D::Vertex>* GbQuadFaceMesh3D::getNodes()   {  return(this->nodes);   }
-/**
- * Returns the quads of this triangular mesh.
- * @return the quads of this triangular mesh
- */
-vector<GbQuadFaceMesh3D::QuadFace>* GbQuadFaceMesh3D::getQuads()  { return(this->quads);  }
-/**
- * Returns the center x1 coordinate of this triangular mesh.
- * @return the center x1 coordinate of this triangular mesh
- */
-double GbQuadFaceMesh3D::getX1Centroid()
-{
-   if(!this->consistent) this->calculateValues();
-   return(0.5*(this->x1min+this->x1max));
-}
-/**
- * Returns the center x2 coordinate of this triangular mesh.
- * @return the center x2 coordinate of this triangular mesh
- */
-double GbQuadFaceMesh3D::getX2Centroid()
-{
-   if(!this->consistent) this->calculateValues();
-   return(0.5*(this->x2min+this->x2max));
-}
-/**
-* Returns the center x3 coordinate of this triangular mesh.
-	* @return the center x3 coordinate of this triangular mesh
-	*/
-double GbQuadFaceMesh3D::getX3Centroid()
-{
-	if(!this->consistent) this->calculateValues();
-	return(0.5*(this->x3min+this->x3max));
-}
-
-/**
- * Returns the minimum x1 coordinate of this triangular mesh.
- * @return the minimum x1 coordinate of this triangular mesh
- */
-double GbQuadFaceMesh3D::getX1Minimum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x1min);
-}
-/**
- * Returns the maximum x1 coordinate of this triangular mesh.
- * @return the maximum x1 coordinate of this triangular mesh
- */
-double GbQuadFaceMesh3D::getX1Maximum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x1max);
-}
-/**
- * Returns the minimum x2 coordinate of this triangular mesh.
- * @return the minimum x2 coordinate of this triangular mesh
- */
-double GbQuadFaceMesh3D::getX2Minimum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x2min);
-}
-/**
- * Returns the maximum x2 coordinate of this triangular mesh.
- * @return the maximum x2 coordinate of this triangular mesh
- */
-double GbQuadFaceMesh3D::getX2Maximum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x2max);
-}
-/**
- * Returns the minimum x3 coordinate of this triangular mesh.
- * @return the minimum x3 coordinate of this triangular mesh
- */
-double GbQuadFaceMesh3D::getX3Minimum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x3min);
-}
-/**
- * Returns the maximum x3 coordinate of this triangular mesh.
- * @return the maximum x3 coordinate of this triangular mesh
- */
-double GbQuadFaceMesh3D::getX3Maximum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x3max);
-}
-
-void GbQuadFaceMesh3D::calculateValues()
-{
-   double x1, x2, x3;
-
-	this->x1min = (*this->nodes)[0].x;
-   this->x1max = (*this->nodes)[0].x;
-   this->x2min = (*this->nodes)[0].y;
-   this->x2max = (*this->nodes)[0].y;
-   this->x3min = (*this->nodes)[0].z;
-   this->x3max = (*this->nodes)[0].z;
-
-   for(int i=1; i<(int)this->nodes->size(); i++)
-   {
-		x1 = (*this->nodes)[i].x;
-		x2 = (*this->nodes)[i].y;
-		x3 = (*this->nodes)[i].z;
-		if(x1 < this->x1min) this->x1min = x1;
-		if(x1 > this->x1max) this->x1max = x1;
-		if(x2 < this->x2min) this->x2min = x2;
-		if(x2 > this->x2max) this->x2max = x2;
-		if(x3 < this->x3min) this->x3min = x3;
-		if(x3 > this->x3max) this->x3max = x3;
-   }
-   this->consistent = true;
-}
-
-
-/*======================================================================*/
-vector<GbTriangle3D*> GbQuadFaceMesh3D::getSurfaceTriangleSet()
-{
-   vector<GbTriangle3D*> triangles(0);
-   return triangles;
-	 //throw UbException(__FILE__, __LINE__, "GbQuadFaceMesh3D::getSurfaceTriangelSet - not implemented"); 
-}
-//vector<GbQuad3D*> GbQuadFaceMesh3D::getSurfaceQuadSet()
-//{
-//   throw UbException(__FILE__, __LINE__, "GbQuadFaceMesh3D::getSurfaceQuadSet - not implemented"); 
-//   //vector<GbQuadangle3D*> tris;
-//   //GbQuadangle3D* quad;
-//   //GbPoint3D* p1;
-//   //GbPoint3D* p2;
-//   //GbPoint3D* p3;
-//   //int size = (int)this->quads->size();
-//   //for(int u=0; u<size;u++)
-//   //{
-//   //   quad = (*this->quads)[u];
-//   //   p1 = new GbPoint3D(quad->getPoint1());
-//   //   p2 = new GbPoint3D(quad->getPoint2());
-//   //   p3 = new GbPoint3D(quad->getPoint3());
-//   //   tris.push_back(new GbQuadangle3D(p1, p2, p3));
-//   //}
-//   //return tris;
-//}
-/*======================================================================*/
-/*
-* Function to determine if the point is inside the polyhedron defined as a 3D object
-* using the Halfspace algorithm
-* @param xp the x-coordinate of the point
-* @param yp the y-coordinate of the point
-* @param zp the z-coordinate of the point
-* @return true if point is inside else return false
-*/
-bool GbQuadFaceMesh3D::isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp)
-{ 
-   throw UbException(UB_EXARGS,"not implemented"); 
-   //vector<GbQuadangle3D*> *Quadangles = this->quads;
-   //int Quadanglesize = (int)Quadangles->size();
-   //GbPoint3D Point(xp,yp,zp);
-   //for (int i=0; i<Quadanglesize; i++)
-   //{
-   //   GbPoint3D* point1 = (*Quadangles)[i]->getPoint1();
-   //   GbPoint3D* point2 = (*Quadangles)[i]->getPoint2();
-   //   GbPoint3D* point3 = (*Quadangles)[i]->getPoint3();
-
-   //   GbHalfSpace3D halfspace(point1, point2, point3);
-   //   if (halfspace.ptInside(&Point)) return false;
-   //}
-   //return true;
-}
-/*======================================================================*/
-/*======================================================================*/
-bool GbQuadFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3)
-{
-
-   double xmin=this->getX1Minimum();	double xmax=this->getX1Maximum();
-   double ymin=this->getX2Minimum();	double ymax=this->getX2Maximum();
-   double zmin=this->getX3Minimum();	double zmax=this->getX3Maximum();
-   double dX = (xmax-xmin)/100.;
-   double dY = (ymax-ymin)/100.;
-   double dZ = (zmax-zmin)/100.;
-   GbCuboid3D boundingCube(xmin-dX, ymin-dY, zmin-dZ, xmax+dX, ymax+dY, zmax+dZ);
-   if(!boundingCube.isPointInGbObject3D(x1, x2, x3)) 
-   {
-      boundingCube.finalize();
-      return false;
-   }
-   boundingCube.finalize();
-
-   // Halfspace algorithm, Area of spherical polygons algorithm or Ray crossing algorithm
-   GbVector3D bMin(boundingCube.getPoint1());
-   GbVector3D bMax(boundingCube.getPoint2());
-   bMin = bMax.Subtract(bMin);
-   //int radius = (int)bMin.Length();
-
-   //if(((GbQuadFaceMesh3D*)this->geoObject3D)->isPointInObject3DHalfSpace(x1,x2,x3) )
-   //if(((GbQuadFaceMesh3D*)this->geoObject3D)->isPointInObject3Darea(x11,x12,x13,numQuadangles))
-   //if(this->isPointInObject3DRayCrossing(x1,x2,x3,radius,(int)this->nodes->size(),(int)this->quads->size()))
-   //   return true;
-   //else 
-      return false;
-}
-/*======================================================================*/
-bool GbQuadFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)
-{
-    throw UbException(UB_EXARGS,"not implemented");
-}
-/*======================================================================*/
-GbLine3D* GbQuadFaceMesh3D::createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2)
-{
-   throw UbException(UB_EXARGS,"not implemented");
-}
-
-/*======================================================================*/
-void GbQuadFaceMesh3D::writeAVSMesh(UbFileOutput *out, bool normals) 
-{
-   cout<<" - write_ucd ("<<out->getFileName()<<") -> ";
-   if(!out)
-   {
-      cout<<"GbQuadFaceMesh3D::writeAVSMesh() - File konnte nicht geschrieben werden: "<<endl;
-      return;
-   }
-   out->writeLine("# UCD-File created by GbQuadFaceMesh3D");
-
-   int quadsize = (int)this->quads->size();
-   int nodesize = (int)this->nodes->size();
-
-   out->writeInteger(nodesize);
-   out->writeInteger(quadsize);
-
-   out->writeInteger(0);
-   out->writeInteger(0);
-   out->writeInteger(0);
-   out->writeLine();
-   int nr=1;
-   Vertex node;
-   QuadFace face;
-   for(int i=0;i<nodesize; i++)
-   {
-    node = (*nodes)[i]; 
-    out->writeInteger(nr++);
-    out->writeDouble(node.x);
-    out->writeDouble(node.y);
-    out->writeDouble(node.z);
-    out->writeLine();
-   }
-
-   nr=1;
-   for(int i=0;i<quadsize; i++)
-   {
-      face = (*quads)[i]; 
-      out->writeInteger(nr++);
-      out->writeInteger(2);
-      out->writeString("quad");
-      out->writeInteger(face.vertex1+1);
-      out->writeInteger(face.vertex2+1);
-      out->writeInteger(face.vertex3+1);
-      out->writeInteger(face.vertex4+1);
-      out->writeLine();
-   }
-
-   //out->writeInteger(0);	out->writeInteger(1);	out->writeLine();
-   //out->writeInteger(1);	out->writeInteger(1);	out->writeLine();
-   //out->writeLine("TEST,no_unit");
-   //nr=1;
-   //for(int i=0;i<quadsize; i++)
-   //{
-   //	out->writeInteger(nr++);
-   //	out->writeInteger(10);
-   //	out->writeLine();
-   //}
-   cout<<"done\n";
-}
-
+#include <numerics/geometry3d/GbQuadFaceMesh3D.h>
+#include <numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h>
+
+#include <numerics/geometry3d/GbHalfSpace3D.h>
+#include <numerics/geometry3d/GbCuboid3D.h>
+
+ 
+using namespace std;
+
+GbQuadFaceMesh3D::GbQuadFaceMesh3D() : GbObject3D()
+{
+   this->name             = "new GbMesh";
+   this->nodes            = new vector<Vertex>;           
+   this->quads            = new vector<QuadFace>;
+   this->consistent       = false;                                 
+}
+
+GbQuadFaceMesh3D::GbQuadFaceMesh3D(string name, vector<Vertex> *nodes, vector<QuadFace> *quads) : GbObject3D()
+{
+   if(name.size()==0 ) throw UbException(UB_EXARGS,"no name specified");
+   if(!nodes         ) throw UbException(UB_EXARGS,"no nodes specified");
+   if(!quads         ) throw UbException(UB_EXARGS,"no quads specified");
+                                                         
+   this->name             = name;
+   this->nodes            = nodes;           
+   this->quads            = quads;     
+   this->consistent       = false;                                 
+}
+/*=============================================================================================*/
+
+GbQuadFaceMesh3D::~GbQuadFaceMesh3D()
+{
+	if(nodes)
+	{
+	//	for(unsigned u=0; u<nodes->size(); u++) delete (*nodes)[u];
+      delete nodes;
+	}
+   if(quads)
+   {
+      delete quads;
+   }
+}
+/*======================================================================*/
+ObObjectCreator* GbQuadFaceMesh3D::getCreator()
+{
+   return GbQuadFaceMesh3DCreator::getInstance();
+}
+/*======================================================================*/
+
+void GbQuadFaceMesh3D::init()
+{
+   nodes      = NULL;
+   quads      = NULL;
+   x1min      = 0.0;
+   x1max      = 0.0;
+   x2min      = 0.0;
+   x2max      = 0.0;
+   x3min      = 0.0;
+   x3max      = 0.0;
+   consistent = false;
+}                                     
+   /**
+    * Returns a string representation of this triangular mesh.
+    * @return a string representation of this triangular mesh
+    */
+string GbQuadFaceMesh3D::toString()
+{
+	stringstream ss;
+	ss<<"GbQuadFaceMesh3D[";
+	ss<<(int)this->quads->size()<<"-Quadangles, "<<(int)this->nodes->size()<<"-Nodes, "<<endl;
+	//ss<<"\""<<this->name<<", Area=sollt mal berechnet werden ;-)"<<"\"";
+   //ss<<", x1min="<<this->x1min;
+   //ss<<", x1max="<<this->x1max;
+   //ss<<", x2min="<<this->x2min;
+   //ss<<", x2max="<<this->x2max;
+   //ss<<", x3min="<<this->x3min;
+   //ss<<", x3max="<<this->x3max;
+   ss<<"]";
+   return(ss.str());
+}
+/**
+ * Returns the name of this triangular mesh.
+ * @return the name of this triangular mesh
+ */
+string GbQuadFaceMesh3D::getName(){ return(this->name); }
+
+/**
+ * Returns the nodes of this triangular mesh.
+ * @return the nodes of this triangular mesh
+ */
+vector<GbQuadFaceMesh3D::Vertex>* GbQuadFaceMesh3D::getNodes()   {  return(this->nodes);   }
+/**
+ * Returns the quads of this triangular mesh.
+ * @return the quads of this triangular mesh
+ */
+vector<GbQuadFaceMesh3D::QuadFace>* GbQuadFaceMesh3D::getQuads()  { return(this->quads);  }
+/**
+ * Returns the center x1 coordinate of this triangular mesh.
+ * @return the center x1 coordinate of this triangular mesh
+ */
+double GbQuadFaceMesh3D::getX1Centroid()
+{
+   if(!this->consistent) this->calculateValues();
+   return(0.5*(this->x1min+this->x1max));
+}
+/**
+ * Returns the center x2 coordinate of this triangular mesh.
+ * @return the center x2 coordinate of this triangular mesh
+ */
+double GbQuadFaceMesh3D::getX2Centroid()
+{
+   if(!this->consistent) this->calculateValues();
+   return(0.5*(this->x2min+this->x2max));
+}
+/**
+* Returns the center x3 coordinate of this triangular mesh.
+	* @return the center x3 coordinate of this triangular mesh
+	*/
+double GbQuadFaceMesh3D::getX3Centroid()
+{
+	if(!this->consistent) this->calculateValues();
+	return(0.5*(this->x3min+this->x3max));
+}
+
+/**
+ * Returns the minimum x1 coordinate of this triangular mesh.
+ * @return the minimum x1 coordinate of this triangular mesh
+ */
+double GbQuadFaceMesh3D::getX1Minimum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x1min);
+}
+/**
+ * Returns the maximum x1 coordinate of this triangular mesh.
+ * @return the maximum x1 coordinate of this triangular mesh
+ */
+double GbQuadFaceMesh3D::getX1Maximum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x1max);
+}
+/**
+ * Returns the minimum x2 coordinate of this triangular mesh.
+ * @return the minimum x2 coordinate of this triangular mesh
+ */
+double GbQuadFaceMesh3D::getX2Minimum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x2min);
+}
+/**
+ * Returns the maximum x2 coordinate of this triangular mesh.
+ * @return the maximum x2 coordinate of this triangular mesh
+ */
+double GbQuadFaceMesh3D::getX2Maximum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x2max);
+}
+/**
+ * Returns the minimum x3 coordinate of this triangular mesh.
+ * @return the minimum x3 coordinate of this triangular mesh
+ */
+double GbQuadFaceMesh3D::getX3Minimum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x3min);
+}
+/**
+ * Returns the maximum x3 coordinate of this triangular mesh.
+ * @return the maximum x3 coordinate of this triangular mesh
+ */
+double GbQuadFaceMesh3D::getX3Maximum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x3max);
+}
+
+void GbQuadFaceMesh3D::calculateValues()
+{
+   double x1, x2, x3;
+
+	this->x1min = (*this->nodes)[0].x;
+   this->x1max = (*this->nodes)[0].x;
+   this->x2min = (*this->nodes)[0].y;
+   this->x2max = (*this->nodes)[0].y;
+   this->x3min = (*this->nodes)[0].z;
+   this->x3max = (*this->nodes)[0].z;
+
+   for(int i=1; i<(int)this->nodes->size(); i++)
+   {
+		x1 = (*this->nodes)[i].x;
+		x2 = (*this->nodes)[i].y;
+		x3 = (*this->nodes)[i].z;
+		if(x1 < this->x1min) this->x1min = x1;
+		if(x1 > this->x1max) this->x1max = x1;
+		if(x2 < this->x2min) this->x2min = x2;
+		if(x2 > this->x2max) this->x2max = x2;
+		if(x3 < this->x3min) this->x3min = x3;
+		if(x3 > this->x3max) this->x3max = x3;
+   }
+   this->consistent = true;
+}
+
+
+/*======================================================================*/
+vector<GbTriangle3D*> GbQuadFaceMesh3D::getSurfaceTriangleSet()
+{
+   vector<GbTriangle3D*> triangles(0);
+   return triangles;
+	 //throw UbException(__FILE__, __LINE__, "GbQuadFaceMesh3D::getSurfaceTriangelSet - not implemented"); 
+}
+//vector<GbQuad3D*> GbQuadFaceMesh3D::getSurfaceQuadSet()
+//{
+//   throw UbException(__FILE__, __LINE__, "GbQuadFaceMesh3D::getSurfaceQuadSet - not implemented"); 
+//   //vector<GbQuadangle3D*> tris;
+//   //GbQuadangle3D* quad;
+//   //GbPoint3D* p1;
+//   //GbPoint3D* p2;
+//   //GbPoint3D* p3;
+//   //int size = (int)this->quads->size();
+//   //for(int u=0; u<size;u++)
+//   //{
+//   //   quad = (*this->quads)[u];
+//   //   p1 = new GbPoint3D(quad->getPoint1());
+//   //   p2 = new GbPoint3D(quad->getPoint2());
+//   //   p3 = new GbPoint3D(quad->getPoint3());
+//   //   tris.push_back(new GbQuadangle3D(p1, p2, p3));
+//   //}
+//   //return tris;
+//}
+/*======================================================================*/
+/*
+* Function to determine if the point is inside the polyhedron defined as a 3D object
+* using the Halfspace algorithm
+* @param xp the x-coordinate of the point
+* @param yp the y-coordinate of the point
+* @param zp the z-coordinate of the point
+* @return true if point is inside else return false
+*/
+bool GbQuadFaceMesh3D::isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp)
+{ 
+   throw UbException(UB_EXARGS,"not implemented"); 
+   //vector<GbQuadangle3D*> *Quadangles = this->quads;
+   //int Quadanglesize = (int)Quadangles->size();
+   //GbPoint3D Point(xp,yp,zp);
+   //for (int i=0; i<Quadanglesize; i++)
+   //{
+   //   GbPoint3D* point1 = (*Quadangles)[i]->getPoint1();
+   //   GbPoint3D* point2 = (*Quadangles)[i]->getPoint2();
+   //   GbPoint3D* point3 = (*Quadangles)[i]->getPoint3();
+
+   //   GbHalfSpace3D halfspace(point1, point2, point3);
+   //   if (halfspace.ptInside(&Point)) return false;
+   //}
+   //return true;
+}
+/*======================================================================*/
+/*======================================================================*/
+bool GbQuadFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3)
+{
+
+   double xmin=this->getX1Minimum();	double xmax=this->getX1Maximum();
+   double ymin=this->getX2Minimum();	double ymax=this->getX2Maximum();
+   double zmin=this->getX3Minimum();	double zmax=this->getX3Maximum();
+   double dX = (xmax-xmin)/100.;
+   double dY = (ymax-ymin)/100.;
+   double dZ = (zmax-zmin)/100.;
+   GbCuboid3D boundingCube(xmin-dX, ymin-dY, zmin-dZ, xmax+dX, ymax+dY, zmax+dZ);
+   if(!boundingCube.isPointInGbObject3D(x1, x2, x3)) 
+   {
+      boundingCube.finalize();
+      return false;
+   }
+   boundingCube.finalize();
+
+   // Halfspace algorithm, Area of spherical polygons algorithm or Ray crossing algorithm
+   GbVector3D bMin(boundingCube.getPoint1());
+   GbVector3D bMax(boundingCube.getPoint2());
+   bMin = bMax.Subtract(bMin);
+   //int radius = (int)bMin.Length();
+
+   //if(((GbQuadFaceMesh3D*)this->geoObject3D)->isPointInObject3DHalfSpace(x1,x2,x3) )
+   //if(((GbQuadFaceMesh3D*)this->geoObject3D)->isPointInObject3Darea(x11,x12,x13,numQuadangles))
+   //if(this->isPointInObject3DRayCrossing(x1,x2,x3,radius,(int)this->nodes->size(),(int)this->quads->size()))
+   //   return true;
+   //else 
+      return false;
+}
+/*======================================================================*/
+bool GbQuadFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)
+{
+    throw UbException(UB_EXARGS,"not implemented");
+}
+/*======================================================================*/
+GbLine3D* GbQuadFaceMesh3D::createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2)
+{
+   throw UbException(UB_EXARGS,"not implemented");
+}
+
+/*======================================================================*/
+void GbQuadFaceMesh3D::writeAVSMesh(UbFileOutput *out, bool normals) 
+{
+   cout<<" - write_ucd ("<<out->getFileName()<<") -> ";
+   if(!out)
+   {
+      cout<<"GbQuadFaceMesh3D::writeAVSMesh() - File konnte nicht geschrieben werden: "<<endl;
+      return;
+   }
+   out->writeLine("# UCD-File created by GbQuadFaceMesh3D");
+
+   int quadsize = (int)this->quads->size();
+   int nodesize = (int)this->nodes->size();
+
+   out->writeInteger(nodesize);
+   out->writeInteger(quadsize);
+
+   out->writeInteger(0);
+   out->writeInteger(0);
+   out->writeInteger(0);
+   out->writeLine();
+   int nr=1;
+   Vertex node;
+   QuadFace face;
+   for(int i=0;i<nodesize; i++)
+   {
+    node = (*nodes)[i]; 
+    out->writeInteger(nr++);
+    out->writeDouble(node.x);
+    out->writeDouble(node.y);
+    out->writeDouble(node.z);
+    out->writeLine();
+   }
+
+   nr=1;
+   for(int i=0;i<quadsize; i++)
+   {
+      face = (*quads)[i]; 
+      out->writeInteger(nr++);
+      out->writeInteger(2);
+      out->writeString("quad");
+      out->writeInteger(face.vertex1+1);
+      out->writeInteger(face.vertex2+1);
+      out->writeInteger(face.vertex3+1);
+      out->writeInteger(face.vertex4+1);
+      out->writeLine();
+   }
+
+   //out->writeInteger(0);	out->writeInteger(1);	out->writeLine();
+   //out->writeInteger(1);	out->writeInteger(1);	out->writeLine();
+   //out->writeLine("TEST,no_unit");
+   //nr=1;
+   //for(int i=0;i<quadsize; i++)
+   //{
+   //	out->writeInteger(nr++);
+   //	out->writeInteger(10);
+   //	out->writeLine();
+   //}
+   cout<<"done\n";
+}
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbQuadFaceMesh3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbQuadFaceMesh3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbQuadFaceMesh3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbQuadFaceMesh3D.h
index 16e5a611f844379cce07b10b1410257a51c37405..7a993abd74f20aa782b558aeda86f3877f8eae6f 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbQuadFaceMesh3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbQuadFaceMesh3D.h
@@ -1,123 +1,123 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBQUADFACEMESH3D_H
-#define GBQUADFACEMESH3D_H
-
-#include <sstream>
-#include <iostream>
-
-
-#include <numerics/geometry3d/GbObject3D.h>                
-#include <basics/utilities/UbException.h>  
-
-#include <PointerDefinitions.h>
-
-class UbFileOutput;
-class UbFileInput;
-/*=========================================================================*/
-/* GbQuadFaceMesh3D                                                                  */
-/*                                                                         */
-/**
- * This Class provides the triangular meshes.
- * Note, that up to now no methods for checking consistency are included.
- * in this context this class describes facettes from an 3D-object !!!
-*/
-class GbQuadFaceMesh3D : public GbObject3D 
-{   
-public:
-  // nested class start
-   class Vertex
-   {
-   public:
-      Vertex(){}
-      Vertex(float x, float y, float z)
-      {
-         this->x=x;
-         this->y=y;
-         this->z=z;
-      }
-      float x, y, z;
-   };
-
-   class QuadFace
-   {
-   public:
-      QuadFace() {}
-      QuadFace(int v1, int v2, int v3, int v4)
-      {
-         this->vertex1=v1;
-         this->vertex2=v2;
-         this->vertex3=v3;
-         this->vertex4=v4;
-      }
-
-      int vertex1, vertex2, vertex3, vertex4;
-   };
- // nested class end
-
-public:
-   GbQuadFaceMesh3D();
-	GbQuadFaceMesh3D(std::string name, std::vector<Vertex> *nodes, std::vector<QuadFace> *quads);
-	virtual ~GbQuadFaceMesh3D();   
-   GbQuadFaceMesh3D* clone() { throw UbException(UB_EXARGS,"clone() - not implemented"); }
-   void finalize()           { throw UbException(UB_EXARGS,"finalize() - not implemented");}
-
-   std::string toString();
-   std::string getName();
-   std::vector<Vertex>*  getNodes();
-   std::vector<QuadFace>* getQuads();
-   double getX1Centroid();
-   double getX2Centroid();
-   double getX3Centroid();
-   double getX1Minimum();
-   double getX1Maximum();
-   double getX2Minimum();
-   double getX2Maximum();
-   double getX3Minimum();
-   double getX3Maximum();
-   void calculateValues();
-
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3);
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary);
-
-   bool isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp);    //based on Halfspace algorithm
-   //bool isPointInObject3DSpherical(const double& xp, const double& yp, const double& zp, int numQuads);    //based on Spherical polygon area method        
-   //bool isPointInObject3DRayCrossing(const double& xp, const double& yp, const double& zp, int radius, int numVertices, int numQuads);  //based on Ray tracing algorithm
-   
-   //char SegPlaneInt(GbQuad3D *quad, GbVector3D  &PointQ, GbVector3D &PointR, GbVector3D &Point, int *m);
-   //char SegQuadCross(GbQuad3D *quad, GbVector3D  &PointQ, GbVector3D &PointR);
-   //till here !!!
-
-   virtual GbLine3D* createClippedLine3D (GbPoint3D &point1,GbPoint3D &point2);
-   //virtual std::vector<GbQuad3D*> getSurfaceQuadSet();
-	virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet();
-   virtual ObObjectCreator* getCreator();
-
-   virtual void write(UbFileOutput* out) { std::cout<<"GbQuadFaceMesh3D::write - sorry not implemented\n"; }
-   virtual void read(UbFileInput* in)    { std::cout<<"GbQuadFaceMesh3D::read  - sorry not implemented\n"; }
-
-   void writeAVSMesh(UbFileOutput *out, bool normals=false);
-
-   /*======================================================================*/
-   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
-private:
-   void init();
-   /*======================================================================*/
-   std::string name;
-   std::vector<Vertex>   *nodes;
-   std::vector<QuadFace> *quads;
-   double      x1min;
-   double      x1max;
-   double      x2min;
-   double      x2max;
-   double      x3min;
-   double      x3max;
-   bool        consistent;
-};
-/*=========================================================================*/
-
-#endif
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBQUADFACEMESH3D_H
+#define GBQUADFACEMESH3D_H
+
+#include <sstream>
+#include <iostream>
+
+
+#include <numerics/geometry3d/GbObject3D.h>                
+#include <basics/utilities/UbException.h>  
+
+#include <PointerDefinitions.h>
+
+class UbFileOutput;
+class UbFileInput;
+/*=========================================================================*/
+/* GbQuadFaceMesh3D                                                                  */
+/*                                                                         */
+/**
+ * This Class provides the triangular meshes.
+ * Note, that up to now no methods for checking consistency are included.
+ * in this context this class describes facettes from an 3D-object !!!
+*/
+class GbQuadFaceMesh3D : public GbObject3D 
+{   
+public:
+  // nested class start
+   class Vertex
+   {
+   public:
+      Vertex(){}
+      Vertex(float x, float y, float z)
+      {
+         this->x=x;
+         this->y=y;
+         this->z=z;
+      }
+      float x, y, z;
+   };
+
+   class QuadFace
+   {
+   public:
+      QuadFace() {}
+      QuadFace(int v1, int v2, int v3, int v4)
+      {
+         this->vertex1=v1;
+         this->vertex2=v2;
+         this->vertex3=v3;
+         this->vertex4=v4;
+      }
+
+      int vertex1, vertex2, vertex3, vertex4;
+   };
+ // nested class end
+
+public:
+   GbQuadFaceMesh3D();
+	GbQuadFaceMesh3D(std::string name, std::vector<Vertex> *nodes, std::vector<QuadFace> *quads);
+	virtual ~GbQuadFaceMesh3D();   
+   GbQuadFaceMesh3D* clone() { throw UbException(UB_EXARGS,"clone() - not implemented"); }
+   void finalize()           { throw UbException(UB_EXARGS,"finalize() - not implemented");}
+
+   std::string toString();
+   std::string getName();
+   std::vector<Vertex>*  getNodes();
+   std::vector<QuadFace>* getQuads();
+   double getX1Centroid();
+   double getX2Centroid();
+   double getX3Centroid();
+   double getX1Minimum();
+   double getX1Maximum();
+   double getX2Minimum();
+   double getX2Maximum();
+   double getX3Minimum();
+   double getX3Maximum();
+   void calculateValues();
+
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3);
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary);
+
+   bool isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp);    //based on Halfspace algorithm
+   //bool isPointInObject3DSpherical(const double& xp, const double& yp, const double& zp, int numQuads);    //based on Spherical polygon area method        
+   //bool isPointInObject3DRayCrossing(const double& xp, const double& yp, const double& zp, int radius, int numVertices, int numQuads);  //based on Ray tracing algorithm
+   
+   //char SegPlaneInt(GbQuad3D *quad, GbVector3D  &PointQ, GbVector3D &PointR, GbVector3D &Point, int *m);
+   //char SegQuadCross(GbQuad3D *quad, GbVector3D  &PointQ, GbVector3D &PointR);
+   //till here !!!
+
+   virtual GbLine3D* createClippedLine3D (GbPoint3D &point1,GbPoint3D &point2);
+   //virtual std::vector<GbQuad3D*> getSurfaceQuadSet();
+	virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet();
+   virtual ObObjectCreator* getCreator();
+
+   virtual void write(UbFileOutput* out) { std::cout<<"GbQuadFaceMesh3D::write - sorry not implemented\n"; }
+   virtual void read(UbFileInput* in)    { std::cout<<"GbQuadFaceMesh3D::read  - sorry not implemented\n"; }
+
+   void writeAVSMesh(UbFileOutput *out, bool normals=false);
+
+   /*======================================================================*/
+   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
+private:
+   void init();
+   /*======================================================================*/
+   std::string name;
+   std::vector<Vertex>   *nodes;
+   std::vector<QuadFace> *quads;
+   double      x1min;
+   double      x1max;
+   double      x2min;
+   double      x2max;
+   double      x3min;
+   double      x3max;
+   bool        consistent;
+};
+/*=========================================================================*/
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbSphere3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbSphere3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbSphere3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbSphere3D.cpp
index 56ce83ec83a7f10d8fbb7205e9e2ae8b12bfc918..40603c33a0d80408ee05a656603cd24f32625c5e 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbSphere3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbSphere3D.cpp
@@ -1,922 +1,922 @@
-#include <numerics/geometry3d/GbSphere3D.h>
-#include <numerics/geometry3d/GbSystem3D.h>
-#include <numerics/geometry3d/GbPoint3D.h>
-#include <numerics/geometry3d/GbLine3D.h>
-#include <numerics/geometry3d/GbTriangle3D.h>
-
-#include <numerics/geometry3d/creator/GbSphere3DCreator.h>
-
-using namespace std;
-
-ObObjectCreator* GbSphere3D::getCreator()
-{
-   return GbSphere3DCreator::getInstance();
-}
-/*=====================================================*/
-GbSphere3D::GbSphere3D()
-  : GbObject3D(), UbObserver()
-{
-   this->setName("sphere");
-   radius=0;
-   midPoint=new GbPoint3D(0,0,0);
-}
-/*=====================================================*/
-GbSphere3D::GbSphere3D(const double& x1,const double& x2, const double& x3, const double& radius)
-  : GbObject3D(), UbObserver()
-{
-   this->setName("sphere");
-   midPoint = new GbPoint3D(x1,x2,x3);
-   midPoint->addObserver(this);
-
-   this->radius   = radius;
-   triangulationMode = RAYPROJECTION;
-   //triangulationMode = CUBOIDPROJECTION;
-}
-/*=====================================================*/
-GbSphere3D::GbSphere3D(const GbSphere3D& sphere)
-  : GbObject3D(), UbObserver()
-{
-   this->setName("sphere");
-
-   this->midPoint    = sphere.midPoint->clone();
-   this->radius      = sphere.radius;
-   triangulationMode = RAYPROJECTION;
-
-   this->midPoint->addObserver(this);
-}
-/*=====================================================*/
-GbSphere3D::GbSphere3D(GbSphere3D* sphere)
-   : GbObject3D(), UbObserver()
-{
-   this->setName(sphere->getName());
-   midPoint = sphere->midPoint->clone();
-   midPoint->addObserver(this);
-
-   this->radius   = sphere->getRadius();
-   triangulationMode = RAYPROJECTION;
-}
-/*=====================================================*/
-GbSphere3D::~GbSphere3D()
-{
-   if(this->midPoint) this->midPoint->removeObserver(this);
-}
-/*=====================================================*/
-void GbSphere3D::finalize()
-{
-   if(this->midPoint)
-   {
-      this->midPoint->removeObserver(this);
-      this->midPoint->finalize();
-      delete this->midPoint;
-      this->midPoint = NULL;
-   }
-
-   if(this->midPoint) this->midPoint->removeObserver(this);
-}
-/*=====================================================*/
-bool GbSphere3D::intersects(SPtr<GbSphere3D> sphere)
-{
-    return this->getDistance(sphere->midPoint) < radius + sphere->radius;
-}
-/*=======================================================*/
-void GbSphere3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3)
-{
-   this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() );
-}
-
-void GbSphere3D::setCenterCoordinates(const UbTupleDouble3& position)
-{
-    this->setCenterCoordinates(val<1>(position), val<2>(position), val<3>(position));
-}
-
-/*=====================================================*/
-double GbSphere3D::getDistance(GbPoint3D* p)
-{
-   return this->getDistance(p->getX1Centroid(),p->getX2Coordinate(),p->getX3Coordinate());
-}
-/*=====================================================*/
-void GbSphere3D::setCenterX1Coordinate(const double& value)
-{
-   if(this->midPoint) this->midPoint->setX1(value);
-   else throw UbException(UB_EXARGS,"Sphere has no midPoint");
-   //kein notifyObserver(), da der knoten notifyObserver() ausfuehrt und die GbSphere dieses event
-   //abfaengt und dann selbst notifyObservers ausfuehrt ;-)
-}
-/*=====================================================*/
-void GbSphere3D::setCenterX2Coordinate(const double& value)
-{
-   if(this->midPoint) this->midPoint->setX2(value);
-   else  throw UbException(UB_EXARGS,"Sphere has no midPoint");
-   //kein notifyObserver(), da der knoten notifyObserver() ausfuehrt und die GbSphere dieses event
-   //abfaengt und dann selbst notifyObservers ausfuehrt ;-)
-}
-/*=====================================================*/
-void GbSphere3D::setCenterX3Coordinate(const double& value)
-{
-   if(this->midPoint) this->midPoint->setX3(value);
-   else  throw UbException(UB_EXARGS,"sphere has no midPoint");
-   //kein notifyObserver(), da der knoten notifyObserver() ausfuehrt und die GbSphere dieses event
-   //abfaengt und dann selbst notifyObservers ausfuehrt ;-)
-}
-/*=====================================================*/
-void GbSphere3D::setRadius(const double& radius)
-{
-   if (radius != this->radius)
-   {
-   this->radius=radius;
-   this->notifyObserversObjectChanged();
-}
-}
-/*=====================================================*/
-double GbSphere3D::getDistance(const double& x1p, const double& x2p, const double& x3p)
-{
-   double deltaX1 = x1p - midPoint->getX1Coordinate();
-   double deltaX2 = x2p - midPoint->getX2Coordinate();
-   double deltaX3 = x3p - midPoint->getX3Coordinate();
-   return sqrt(deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3)-this->radius;
-}
-/*=====================================================*/
-//true, wenn 'in Object' oder 'auf Boundary'!
-bool GbSphere3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
-{
-   double deltaX1 = x1p - midPoint->getX1Coordinate();
-   double deltaX2 = x2p - midPoint->getX2Coordinate();
-   double deltaX3 = x3p - midPoint->getX3Coordinate();
-
-   return UbMath::lessEqual(deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3, this->radius*this->radius);
-}
-/*=====================================================*/
-//true, wenn 'in Object' oder 'auf Boundary'!
-bool GbSphere3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
-{
-   double deltaX1 = x1p - midPoint->getX1Coordinate();
-   double deltaX2 = x2p - midPoint->getX2Coordinate();
-   double deltaX3 = x3p - midPoint->getX3Coordinate();
-
-   double distanceSquare = deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3;
-   double radiusSquare   = this->radius*this->radius;
-
-   pointIsOnBoundary = UbMath::equal(distanceSquare,radiusSquare);
-
-   return UbMath::lessEqual(distanceSquare,radiusSquare);
-}
-/*=====================================================*/
-//bool GbSphere3D::crossCellCrossSection(double x11,double x21,double x12,double x22, double ra)
-//{
-//   if(this->isPointInCrossection(x11, x12) || this->isPointInCrossection(x21, x22) || this->isPointInCrossection(x11, x22) || this->isPointInCrossection(x21, x12))
-//   {
-//		if(!this->isPointInCrossection(x11, x12) || !this->isPointInCrossection(x21, x22) || !this->isPointInCrossection(x11, x22) || !this->isPointInCrossection(x21, x12)) return true;
-//   }
-//   return false;
-//}
-//
-///*=====================================================*/
-//bool GbSphere3D::cellCrossAndInsideCrossSection(double x11,double x21,double x12,double x22, double ra)
-//{
-//   if(this->isPointInCrossection(x11, x12) || this->isPointInCrossection(x21, x22) || this->isPointInCrossection(x11, x22) || this->isPointInCrossection(x21, x12))  return true;
-//   return false;
-//}
-/*=====================================================*/
-string GbSphere3D::toString()
-{
-	stringstream ss;
-	ss<< "GbSphere3D[";
-	ss <<"mid="<<midPoint->toString()<<", r="<<radius<<"]";
-	return ss.str();
-}
-/*=====================================================*/
-GbLine3D* GbSphere3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
-{
-   double factor = 100.0; //um rundungsfehler beim wurzelterm zu minimieren
-   double xa = factor*point1.getX1Coordinate();
-   double ya = factor*point1.getX2Coordinate();
-   double za = factor*point1.getX3Coordinate();
-   double xb = factor*point2.getX1Coordinate();
-   double yb = factor*point2.getX2Coordinate();
-   double zb = factor*point2.getX3Coordinate();
-   double xm = factor*this->midPoint->getX1Coordinate();
-   double ym = factor*this->midPoint->getX2Coordinate();
-   double zm = factor*this->midPoint->getX3Coordinate();
-   double r  = factor*this->radius;
-
-   double xa2 = xa*xa;
-   double ya2 = ya*ya;
-   double za2 = za*za;
-   double xb2 = xb*xb;
-   double yb2 = yb*yb;
-   double zb2 = zb*zb;
-   double xm2 = xm*xm;
-   double ym2 = ym*ym;
-   double zm2 = zm*zm;
-   double r2  = r*r;
-
-   double wurzel =   2.0*xa*xb*ym2-2.0*ya*yb*r2+2.0*ya*ym*xb2+2.0*yb*ym*za2
-                    +2.0*ya*ym*zb2+2.0*xb*xm*za2+2.0*za*zb*ym2+2.0*xb*xm*ya2+2.0*xa*xm*yb2
-                    +2.0*yb*ym*xa2+2.0*zb*zm*ya2+2.0*xa*xm*zb2+2.0*za*zm*xb2+2.0*za*zm*yb2
-                    +2.0*xa*xb*zm2-2.0*xa*xb*r2-2.0*za*zb*r2+2.0*za*zb*xm2-2.0*ya*yb*xa*xm
-                    +2.0*ya*yb*xa*xb+2.0*zb*zm*xa2-2.0*ya*yb*xb*xm+2.0*ya*yb*xm2-2.0*ya*yb*zb*zm
-                    +2.0*ya*yb*zm2+2.0*zb*zm*yb*ym-2.0*zb*zm*ya*ym+2.0*zb*zm*xb*xm-2.0*xa*xm*yb*ym
-                    +2.0*xa*xm*za*zm+2.0*xa*xm*ya*ym-2.0*yb*ym*za*zm+2.0*yb*ym*xb*xm+2.0*za*zm*ya*ym
-                    -2.0*za*zm*xb*xm-2.0*ya*ym*xb*xm+2.0*za*zb*xa*xb-2.0*za*zb*xa*xm-2.0*za*zb*xb*xm
-                    +2.0*za*zb*ya*yb-2.0*za*zb*ya*ym-2.0*za*zb*yb*ym-2.0*ya*yb*za*zm-xa2*zb2
-                    -xa2*yb2-zb2*ya2-za2*xb2-za2*yb2-xb2*ya2-2.0*zb*zm*xa*xm
-                    -2.0*xa*xb*za*zm-2.0*xa*xb*zb*zm-2.0*xa*xb*ya*ym-2.0*xa*xb*yb*ym+za2*r2
-                    -za2*xm2-za2*ym2+zb2*r2-zb2*xm2-zb2*ym2+xa2*r2-xa2*zm2
-                    -xa2*ym2+xb2*r2-xb2*zm2-xb2*ym2+ya2*r2-ya2*zm2-ya2*xm2
-                    +yb2*r2-yb2*zm2-yb2*xm2;
-   double nenner  = -2.0*za*zb-2.0*ya*yb-2.0*xa*xb+za2+zb2+xa2+xb2+ya2+yb2;
-   double zaehler =  2.0*zb*zm-2.0*xa*xm+2.0*yb*ym-2.0*za*zm+xa2-2.0*ya*ym
-                    +2.0*xb*xm-zb2+za2-xb2+ya2-yb2;
-
-   vector<GbPoint3D*> schnittpunkte;
-
-   if(fabs(nenner)>1.E-13 && UbMath::greaterEqual(wurzel,0.0))
-   {
-      double t1 = (zaehler+2.0*sqrt(wurzel))/nenner;
-      double t2 = (zaehler-2.0*sqrt(wurzel))/nenner;
-
-      if(UbMath::inClosedInterval(t1,-1.0,1.0))
-      {
-         double x = ( xa*(0.5-0.5*t1)+xb*(0.5+0.5*t1) )/factor;
-         double y = ( ya*(0.5-0.5*t1)+yb*(0.5+0.5*t1) )/factor;
-         double z = ( za*(0.5-0.5*t1)+zb*(0.5+0.5*t1) )/factor;
-
-         schnittpunkte.push_back(new GbPoint3D(x,y,z));
-      }
-      if(fabs(t2-t1)>1.E-13 && UbMath::inClosedInterval(t2,-1.0,1.0))
-      {
-         double x = ( xa*(0.5-0.5*t2)+xb*(0.5+0.5*t2) )/factor;
-         double y = ( ya*(0.5-0.5*t2)+yb*(0.5+0.5*t2) )/factor;
-         double z = ( za*(0.5-0.5*t2)+zb*(0.5+0.5*t2) )/factor;
-
-         schnittpunkte.push_back(new GbPoint3D(x,y,z));
-      }
-   }
-
-   int nofSchnittpunkte = (int)schnittpunkte.size();
-   if(nofSchnittpunkte==1)
-   {
-      if     (this->isPointInGbObject3D(&point1)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point1));
-      else if(this->isPointInGbObject3D(&point2)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point2));
-      else //line beruehrt kugel! -> clippedLine reduziert sich zu einem Punkt!
-      {
-         if(std::fabs(this->getDistance(schnittpunkte[0])-this->radius)<1.E-13)
-            throw UbException(UB_EXARGS,"Beide LinenPunkte ausserhalb des Kreises, der berechnete Punkt ist jedoch KEIN Beruhrungspunkt der Sphere...");
-         return new GbLine3D(schnittpunkte[0],new GbPoint3D(*(schnittpunkte[0])));
-      }
-   }
-   else if(nofSchnittpunkte==2) return new GbLine3D(schnittpunkte[0],schnittpunkte[1]);
-
-   return NULL;
-}
-/*=========================================================================*/
-vector<GbTriangle3D*> GbSphere3D::getSurfaceTriangleSet()
-{
-   if(triangulationMode==RAYPROJECTION)
-   {
-      double x1m = midPoint->getX1Coordinate();
-      double x2m = midPoint->getX2Coordinate();
-      double x3m = midPoint->getX3Coordinate();
-
-      vector<GbTriangle3D*> triangles;
-
-      int segments =30;
-      double deltaPhi = UbMath::PI/(double)segments;
-      double phiX1a,phiX1b,phiX3a,phiX3b;
-      double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d;
-
-      for(phiX3a=0.5*UbMath::PI; phiX3a>-1.5*UbMath::PI; phiX3a-=deltaPhi)
-      {
-         for(phiX1a=0.0; phiX1a<UbMath::PI; phiX1a+=deltaPhi)
-         {
-            phiX1b = phiX1a+deltaPhi;
-            phiX3b = phiX3a+deltaPhi;
-
-            x1a =  x1m+radius*cos(phiX3a)*std::cos(phiX1a);
-            x2a =  x2m+radius*cos(phiX3a)*std::sin(phiX1a);
-            x3a =  x3m+radius*sin(phiX3a);
-            x1b =  x1m+radius*cos(phiX3a)*std::cos(phiX1b);
-            x2b =  x2m+radius*cos(phiX3a)*std::sin(phiX1b);
-            x3b =  x3m+radius*sin(phiX3a);
-            x1c =  x1m+radius*cos(phiX3b)*std::cos(phiX1b);
-            x2c =  x2m+radius*cos(phiX3b)*std::sin(phiX1b);
-            x3c =  x3m+radius*sin(phiX3b);
-            x1d =  x1m+radius*cos(phiX3b)*std::cos(phiX1a);
-            x2d =  x2m+radius*cos(phiX3b)*std::sin(phiX1a);
-            x3d =  x3m+radius*sin(phiX3b);
-
-            if(UbMath::greater(phiX3b,-0.5*UbMath::PI)  && UbMath::less(phiX3a,0.5*UbMath::PI))
-            {
-               triangles.push_back(new GbTriangle3D(new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1b,x2b,x3b),new GbPoint3D(x1c,x2c,x3c)));
-               triangles.push_back(new GbTriangle3D(new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1c,x2c,x3c),new GbPoint3D(x1d,x2d,x3d)));
-            }
-            else
-            {
-               triangles.push_back(new GbTriangle3D(new GbPoint3D(x1d,x2d,x3d),new GbPoint3D(x1c,x2c,x3c),new GbPoint3D(x1a,x2a,x3a)));
-               triangles.push_back(new GbTriangle3D(new GbPoint3D(x1c,x2c,x3c),new GbPoint3D(x1b,x2b,x3b),new GbPoint3D(x1a,x2a,x3a)));
-            }
-         }
-      }
-      return triangles;
-   }
-   else if(triangulationMode==CUBOIDPROJECTION)
-   {
-      vector<GbTriangle3D*> triangles;
-      vector<GbPoint3D*>   points;
-      double x1min = this->getX1Minimum();
-      double x2min = this->getX2Minimum();
-      double x3min = this->getX3Minimum();
-      double x1max = this->getX1Maximum();
-      double x2max = this->getX2Maximum();
-      double x3max = this->getX3Maximum();
-      double ax1 = x1min;    double bx2 = x2min;   double cx1 = x1min;
-      double ax2 = x2min;    double bx3 = x3min;   double cx3 = x3min;
-
-      int anzahl = 20;
-      double dx1 = (x1max-x1min)/(double)(anzahl-1);
-      double dx2 = (x2max-x2min)/(double)(anzahl-1);
-      double dx3 = (x3max-x3min)/(double)(anzahl-1);
-
-      for (int u=0; u<anzahl; u++)
-      {
-         ax2 = x2min;
-         bx2 = x2min;
-         cx3 = x3min;
-         for (int v=0; v<anzahl; v++)
-         {
-            GbPoint3D p1 = GbPoint3D(ax1, ax2, x3max);
-            GbPoint3D p2 = GbPoint3D(ax1, ax2, x3min);
-            GbPoint3D p3 = GbPoint3D(cx1, x2min, cx3);
-            GbPoint3D p4 = GbPoint3D(cx1, x2max, cx3);
-            GbPoint3D p5 = GbPoint3D(x1min, bx2, bx3);
-            GbPoint3D p6 = GbPoint3D(x1max, bx2, bx3);
-
-            GbLine3D* clippedline1 = this->createClippedLine3D(*this->midPoint, p1);
-            GbLine3D* clippedline2 = this->createClippedLine3D(*this->midPoint, p2);
-            GbLine3D* clippedline3 = this->createClippedLine3D(*this->midPoint, p3);
-            GbLine3D* clippedline4 = this->createClippedLine3D(*this->midPoint, p4);
-            GbLine3D* clippedline5 = this->createClippedLine3D(*this->midPoint, p5);
-            GbLine3D* clippedline6 = this->createClippedLine3D(*this->midPoint, p6);
-            points.push_back(new GbPoint3D(clippedline1->getPoint1()));
-            points.push_back(new GbPoint3D(clippedline2->getPoint1()));
-            points.push_back(new GbPoint3D(clippedline3->getPoint1()));
-            points.push_back(new GbPoint3D(clippedline4->getPoint1()));
-            points.push_back(new GbPoint3D(clippedline5->getPoint1()));
-            points.push_back(new GbPoint3D(clippedline6->getPoint1()));
-            clippedline1->deletePoints();    delete clippedline1;
-            clippedline2->deletePoints();    delete clippedline2;
-            clippedline3->deletePoints();    delete clippedline3;
-            clippedline4->deletePoints();    delete clippedline4;
-            clippedline5->deletePoints();    delete clippedline5;
-            clippedline6->deletePoints();    delete clippedline6;
-            ax2 +=dx2;
-            cx3 +=dx3;
-            bx2 +=dx2;
-         }
-         ax1 +=dx1;
-         cx1 +=dx1;
-         bx3 +=dx3;
-      }
-
-      int anz = anzahl*anzahl*6;
-      GbPoint3D* point1 = NULL;
-      GbPoint3D* point2 = NULL;
-      GbPoint3D* point3 = NULL;
-      int anzahl2 = anzahl*6;
-      int anzahl3 = anzahl2+6;
-      for (int u=0; u<anz-anzahl3; u++)
-      {
-         point1 = new GbPoint3D(points[u+6]);
-         point2 = new GbPoint3D(points[u]);
-         point3 = new GbPoint3D(points[u+anzahl2]);
-         if(u%2 == 0) triangles.push_back(new GbTriangle3D(point1, point2, point3));
-         else         triangles.push_back(new GbTriangle3D(point2, point1, point3));
-
-         point1 = new GbPoint3D(points[u+6]);
-         point2 = new GbPoint3D(points[u+anzahl2]);
-         point3 = new GbPoint3D(points[u+anzahl3]);
-         if(u%2 == 0) triangles.push_back(new GbTriangle3D(point1, point2, point3));
-         else         triangles.push_back(new GbTriangle3D(point2, point1, point3));
-      }
-      for (int u=0; u<anz; u++) delete points[u];
-
-      return triangles;
-   }
-   else throw UbException(UB_EXARGS,"undefined triangulationmode");
-}
-/*=======================================================*/
-void GbSphere3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles)
-{
-   //wenn ich viele Kugeln bei der PE rausschreibe sollten die vektoren nicht geresized werden
-   //nodes.resize(0);
-   //triangles.resize(0);
-
-   if(triangulationMode==RAYPROJECTION)
-   {
-      float x1m = (float)midPoint->getX1Coordinate();
-      float x2m = (float)midPoint->getX2Coordinate();
-      float x3m = (float)midPoint->getX3Coordinate();
-
-      int segments =30;
-      float deltaPhi = (float)UbMath::PI/(float)segments;
-      float phiX1a,phiX1b,phiX3a,phiX3b;
-      float x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d;
-      int nodeNr = nodes.size();
-      for(phiX3a=(float)(0.5*UbMath::PI); phiX3a > (float)(-1.5*UbMath::PI); phiX3a-=deltaPhi)
-      {
-         for(phiX1a=0.0; phiX1a<UbMath::PI; phiX1a+=deltaPhi)
-         {
-            phiX1b = phiX1a+deltaPhi;
-            phiX3b = phiX3a+deltaPhi;
-
-            x1a =  x1m+(float)(radius*cos(phiX3a)*std::cos(phiX1a));
-            x2a =  x2m+(float)(radius*cos(phiX3a)*std::sin(phiX1a));
-            x3a =  x3m+(float)(radius*sin(phiX3a));
-            x1b =  x1m+(float)(radius*cos(phiX3a)*std::cos(phiX1b));
-            x2b =  x2m+(float)(radius*cos(phiX3a)*std::sin(phiX1b));
-            x3b =  x3m+(float)(radius*sin(phiX3a));
-            x1c =  x1m+(float)(radius*cos(phiX3b)*std::cos(phiX1b));
-            x2c =  x2m+(float)(radius*cos(phiX3b)*std::sin(phiX1b));
-            x3c =  x3m+(float)(radius*sin(phiX3b));
-            x1d =  x1m+(float)(radius*cos(phiX3b)*std::cos(phiX1a));
-            x2d =  x2m+(float)(radius*cos(phiX3b)*std::sin(phiX1a));
-            x3d =  x3m+(float)(radius*sin(phiX3b));
-
-            if(UbMath::greater(phiX3b,-0.5*UbMath::PI) && UbMath::less(phiX3a,0.5*UbMath::PI))
-            {
-               nodes.push_back( makeUbTuple(x1a,x2a,x3a) );
-               nodes.push_back( makeUbTuple(x1b,x2b,x3b) );
-               nodes.push_back( makeUbTuple(x1c,x2c,x3c) );
-
-               nodes.push_back( makeUbTuple(x1a,x2a,x3a) );
-               nodes.push_back( makeUbTuple(x1c,x2c,x3c) );
-               nodes.push_back( makeUbTuple(x1d,x2d,x3d) );
-            }
-            else
-            {
-               nodes.push_back( makeUbTuple(x1d,x2d,x3d) );
-               nodes.push_back( makeUbTuple(x1c,x2c,x3c) );
-               nodes.push_back( makeUbTuple(x1a,x2a,x3a) );
-
-               nodes.push_back( makeUbTuple(x1c,x2c,x3c) );
-               nodes.push_back( makeUbTuple(x1b,x2b,x3b) );
-               nodes.push_back( makeUbTuple(x1a,x2a,x3a) );
-            }
-            triangles.push_back( makeUbTuple(nodeNr, nodeNr+1, nodeNr+2) );
-            triangles.push_back( makeUbTuple(nodeNr+3, nodeNr+4, nodeNr+5) );
-            nodeNr+=6;
-         }
-      }
-   }
-   else if(triangulationMode==CUBOIDPROJECTION)
-   {
-      vector<GbPoint3D*>   points;
-      double x1min = this->getX1Minimum();
-      double x2min = this->getX2Minimum();
-      double x3min = this->getX3Minimum();
-      double x1max = this->getX1Maximum();
-      double x2max = this->getX2Maximum();
-      double x3max = this->getX3Maximum();
-      double ax1 = x1min;    double bx2 = x2min;   double cx1 = x1min;
-      double ax2 = x2min;    double bx3 = x3min;   double cx3 = x3min;
-
-      int anzahl = 20;
-      double dx1 = (x1max-x1min)/(double)(anzahl-1);
-      double dx2 = (x2max-x2min)/(double)(anzahl-1);
-      double dx3 = (x3max-x3min)/(double)(anzahl-1);
-
-      for (int u=0; u<anzahl; u++)
-      {
-         ax2 = x2min;
-         bx2 = x2min;
-         cx3 = x3min;
-         for (int v=0; v<anzahl; v++)
-         {
-            GbPoint3D p1 = GbPoint3D(ax1, ax2, x3max);
-            GbPoint3D p2 = GbPoint3D(ax1, ax2, x3min);
-            GbPoint3D p3 = GbPoint3D(cx1, x2min, cx3);
-            GbPoint3D p4 = GbPoint3D(cx1, x2max, cx3);
-            GbPoint3D p5 = GbPoint3D(x1min, bx2, bx3);
-            GbPoint3D p6 = GbPoint3D(x1max, bx2, bx3);
-
-            GbLine3D* clippedline1 = this->createClippedLine3D(*this->midPoint, p1);
-            GbLine3D* clippedline2 = this->createClippedLine3D(*this->midPoint, p2);
-            GbLine3D* clippedline3 = this->createClippedLine3D(*this->midPoint, p3);
-            GbLine3D* clippedline4 = this->createClippedLine3D(*this->midPoint, p4);
-            GbLine3D* clippedline5 = this->createClippedLine3D(*this->midPoint, p5);
-            GbLine3D* clippedline6 = this->createClippedLine3D(*this->midPoint, p6);
-            points.push_back(new GbPoint3D(clippedline1->getPoint1()));
-            points.push_back(new GbPoint3D(clippedline2->getPoint1()));
-            points.push_back(new GbPoint3D(clippedline3->getPoint1()));
-            points.push_back(new GbPoint3D(clippedline4->getPoint1()));
-            points.push_back(new GbPoint3D(clippedline5->getPoint1()));
-            points.push_back(new GbPoint3D(clippedline6->getPoint1()));
-            clippedline1->deletePoints();    delete clippedline1;
-            clippedline2->deletePoints();    delete clippedline2;
-            clippedline3->deletePoints();    delete clippedline3;
-            clippedline4->deletePoints();    delete clippedline4;
-            clippedline5->deletePoints();    delete clippedline5;
-            clippedline6->deletePoints();    delete clippedline6;
-            ax2 +=dx2;
-            cx3 +=dx3;
-            bx2 +=dx2;
-         }
-         ax1 +=dx1;
-         cx1 +=dx1;
-         bx3 +=dx3;
-      }
-
-      int anz = anzahl*anzahl*6;
-      int anzahl2 = anzahl*6;
-      int anzahl3 = anzahl2+6;
-      int nodeNr = 0;
-      for (int u=0; u<anz-anzahl3; u++)
-      {
-         nodes.push_back( makeUbTuple((float)points[u+6]->x1      , (float)points[u+6]->x2      , (float)points[u+6]->x3) );
-         nodes.push_back( makeUbTuple((float)points[u]->x1        , (float)points[u]->x2        , (float)points[u]->x3) );
-         nodes.push_back( makeUbTuple((float)points[u+anzahl2]->x1, (float)points[u+anzahl2]->x2, (float)points[u+anzahl2]->x3) );
-
-         if(u%2 == 0) triangles.push_back( makeUbTuple(nodeNr  , nodeNr+1, nodeNr+2) );
-         else         triangles.push_back( makeUbTuple(nodeNr  , nodeNr+1, nodeNr+2) );
-
-         nodes.push_back( makeUbTuple((float)points[u+6]->x1      , (float)points[u+6]->x2      , (float)points[u+6]->x3) );
-         nodes.push_back( makeUbTuple((float)points[u+anzahl2]->x1, (float)points[u+anzahl2]->x2, (float)points[u+anzahl2]->x3) );
-         nodes.push_back( makeUbTuple((float)points[u+anzahl3]->x1, (float)points[u+anzahl3]->x2, (float)points[u+anzahl3]->x3) );
-         if(u%2 == 0) triangles.push_back( makeUbTuple(nodeNr+3, nodeNr+4, nodeNr+5) );
-         else         triangles.push_back( makeUbTuple(nodeNr+3, nodeNr+4, nodeNr+5) );
-
-         nodeNr+=6;
-      }
-      for(int u=0; u<anz; u++) delete points[u];
-   }
-   else throw UbException(UB_EXARGS,"undefined triangulationmode");
-}
-/*=======================================================*/
-void GbSphere3D::transform(const double matrix[4][4])
-{
-   midPoint->transform(matrix);
-   this->setRadius(this->getRadius()*matrix[0][0]);
-   this->notifyObserversObjectChanged();
-}
-/*=======================================================*/
-void GbSphere3D::write(UbFileOutput* out)
-{
-   out->writeString(this->getCreator()->getTypeID());
-   midPoint->write(out);
-   out->writeDouble(radius);
-   out->writeInteger((int)triangulationMode);
-}
-/*=======================================================*/
-void GbSphere3D::read(UbFileInput* in)
-{
-   if(midPoint)
-   {
-      midPoint->removeObserver(this);
-      midPoint->finalize();
-      delete midPoint;
-   }
-   midPoint = new GbPoint3D;
-   in->readString();
-   midPoint->read(in);
-   midPoint->addObserver(this);
-   radius = in->readDouble();
-   triangulationMode = (TRIANGULATIONMODE)in->readInteger();
-}
-/*=======================================================*/
-bool GbSphere3D::hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction)
-{
-	GbVector3D vecOrigin(origin.getX1Coordinate(),origin.getX2Coordinate(), origin.getX3Coordinate()) ;
-	GbVector3D vecDirection(direction.getX1Coordinate(),direction.getX2Coordinate(), direction.getX3Coordinate());
-	GbVector3D vecSfereCenter(getX1Centroid(), getX2Centroid(), getX3Centroid());
-	GbVector3D diff = vecOrigin - vecSfereCenter;
-   float a = (float)(vecDirection.Dot(vecDirection));
-   float b = (float)(2.0 * vecDirection.Dot(diff));
-   float c = (float)(diff.Dot(diff) - this->getRadius()*this->getRadius());
-
-	// use 'abc'-formula for finding root t_1,2 = (-b +/- sqrt(b^2-4ac))/(2a)
-	float inRoot = (float)(b*b - 4.0*a*c);
-	if (inRoot < 0) return false;
-	float root = sqrt(inRoot);
-
-	float dist = (float)((-b - root)/(2.0*a));
-
-	double infinity = DBL_MAX;
-	double eps = 1E-4;
-
-   if (dist > infinity)
-		return false;
-
-	if (dist < eps)
-	{
-		dist = (float)((-b + root)/(2.0*a));
-		if (dist < eps || dist > infinity)
-			return false;
-	}
-	return true;
-}
-/*=======================================================*/
-bool GbSphere3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-//Merksatz: cell oder deren Volumen schneidet oder beinhaltet komplette oder Teile der SphereUmrandung
-//returns true:
-//  - cell cuts  sphere3D
-//  - cell boxes sphere3D
-//returns false:
-//  - cell completely inside sphere3D ( = sphere3D boxes cell)
-//  - cell und sphere3D haben kein gemeinsames Volumen
-{
-   double midX[] = {  this->getX1Centroid()
-                    , this->getX2Centroid()
-                    , this->getX3Centroid() };
-
-   double Bmin[] = {  UbMath::min(x1a, x1b)
-                    , UbMath::min(x2a, x2b)
-                    , UbMath::min(x3a, x3b) };
-
-   double Bmax[] = {  UbMath::max(x1a, x1b)
-                    , UbMath::max(x2a, x2b)
-                    , UbMath::max(x3a, x3b) };
-
-   /* Solid Box - Hollow Sphere */
-   double dmin = 0.0;
-   double dmax = 0.0;
-   double r2   = radius*radius;
-
-   for( int i=0; i<3; i++ )
-   {
-      double a = pow( midX[i] - Bmin[i], 2.0 );
-      double b = pow( midX[i] - Bmax[i], 2.0 );
-      dmax += UbMath::max( a, b );
-      if     ( UbMath::less   ( midX[i], Bmin[i] ) ) dmin += a;
-      else if( UbMath::greater( midX[i], Bmax[i] ) ) dmin += b;
-   }
-   if(   UbMath::lessEqual(dmin, r2   )
-      && UbMath::lessEqual(r2  , dmax ) )
-   {
-      return true;
-   }
-   return false;
-}
-/*=======================================================*/
-bool GbSphere3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-//returns true:
-//  - cell completely inside sphere3D ( = sphere3D boxes cell)
-//  - cell cuts  sphere3D
-//  - cell boxes sphere3D
-//returns false:
-//  - cell und sphere3D haben kein gemeinsames Volumen
-{
-   //URL: http://tog.acm.org/GraphicsGems/gems/BoxSphere.c (mode=4, beides solids!!!)
-   // solid - solid
-   //this routine tests for intersection between an 3-dimensional
-   //axis-aligned box and an 3-dimensional sphere.
-
-   //true:
-   //  - wenn Schnitt
-   //  - Cell komplett innerhalb GbSphere3D
-   //  - Cell umhuellt GbSphere3D
-
-
-   double midX1 = this->getX1Centroid();
-   double midX2 = this->getX2Centroid();
-   double midX3 = this->getX3Centroid();
-
-   double dmin  = 0.0;
-
-   if     ( UbMath::less   ( midX1, x1a ) ) dmin += std::pow( midX1 - x1a, 2.0 );
-   else if( UbMath::greater( midX1, x1b ) ) dmin += std::pow( midX1 - x1b, 2.0 );
-
-   if     ( UbMath::less   ( midX2, x2a ) ) dmin += std::pow( midX2 - x2a, 2.0 );
-   else if( UbMath::greater( midX2, x2b ) ) dmin += std::pow( midX2 - x2b, 2.0 );
-
-   if     ( UbMath::less   ( midX3, x3a ) ) dmin += std::pow( midX3 - x3a, 2.0 );
-   else if( UbMath::greater( midX3, x3b ) ) dmin += std::pow( midX3 - x3b, 2.0 );
-
-   if( UbMath::lessEqual( dmin, radius*radius ) )
-   {
-      return true;
-   }
-
-   return false;
-}
-/*==========================================================*/
-double GbSphere3D::getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-{
-	double deltaX1 = (x1b-x1a);
-	double deltaX2 = (x2b-x2a);
-	double deltaX3 = (x3b-x3a);
-	  
-	if( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) )       return 1.0*deltaX1*deltaX2*deltaX3; 
-	if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) )   return 0.0;
-
-	double tempResult = 0.0;
-
-	int iMax = 10;
-	int jMax = 10;
-	int kMax = 10;
-
-	for(         int i=0; i<iMax; i++){
-		for(     int j=0; j<jMax; j++){
-			for( int k=0; k<kMax; k++){
-				
-				tempResult += getCellVolumeInsideGbObject3DHelperFunction(
-					x1a+((double) i   )*deltaX1/((double)iMax), x2a+((double) j   )*deltaX2/((double)jMax), x3a+((double) k   )*deltaX3/((double)kMax),
-					x1a+((double)(i+1))*deltaX1/((double)iMax), x2a+((double)(j+1))*deltaX2/((double)jMax), x3a+((double)(k+1))*deltaX3/((double)kMax) );
-			}
-		}
-	}
-
-
-	double resultWithOneCell = getCellVolumeInsideGbObject3DHelperFunction( x1a, x2a, x3a, x1b, x2b, x3b );
-
-	//cout << tempResult << " vs. " << resultWithOneCell << endl;
-
-	return tempResult;
-
-}
-/*==========================================================*/
-double GbSphere3D::getCellVolumeInsideGbObject3DHelperFunction(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-{
-
-	double deltaX1 = x1b-x1a;
-   double deltaX2 = x2b-x2a;
-   double deltaX3 = x3b-x3a;
-
-   if(   this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) )     return 1.0*deltaX1*deltaX2*deltaX3;
-   if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) )   return 0.0;
-
-   double alpha=0.0;
-   double internX1,internX2,internX3;
-
-   for(int x1vers=0;x1vers<2;x1vers++){
-      for(int x2vers=0;x2vers<2;x2vers++){
-         for(int x3vers=0;x3vers<2;x3vers++){
-            internX1 = x1a + (x1b-x1a)*x1vers;
-            internX2 = x2a + (x2b-x2a)*x2vers;
-            internX3 = x3a + (x3b-x3a)*x3vers;
-
-            if( UbMath::lessEqual(this->getDistance(internX1,internX2,internX3),alpha) )
-               alpha = this->getDistance(internX1,internX2,internX3);
-            //cout<<zelltyp<<" "<<kugel->getDistance(internX1,internX2,internX3)<<" "<<alpha<<endl;
-         }//end first for
-      }//end second for
-   }//end third for
-
-   alpha = (-1)*alpha;
-
-
-
-   double n[3];
-   n[0] = 0.5*(x1b+x1a) - this->getX1Centroid();
-   n[1] = 0.5*(x2b+x2a) - this->getX2Centroid();
-   n[2] = 0.5*(x3b+x3a) - this->getX3Centroid();
-
-   //cout << "Koordinaten:  "<<x1<<" "<<x2<<" "<<x3<<endl;
-   //cout << "Deltas:       "<<deltaX1<<" "<<deltaX2<<" "<<deltaX3<<endl;
-   //cout << "Halbe Zelle:  "<<halfcelldelta<<endl;
-
-   //cout<<"Centroid:  "<<kugel->getX1Centroid()<<" "<<kugel->getX2Centroid()<<" "<<kugel->getX3Centroid()<<endl;
-
-   //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl;
-
-   double normLength;
-   normLength = sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]);
-   n[0] /= normLength;
-   n[1] /= normLength;
-   n[2] /= normLength;
-
-   if( UbMath::less(n[0],0.0) ) n[0] = -n[0];
-   if( UbMath::less(n[1],0.0) ) n[1] = -n[1];
-   if( UbMath::less(n[2],0.0) ) n[2] = -n[2];
-
-   //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl;
-
-   double dummy;
-   if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;}
-   if( UbMath::greater(n[1],n[2])) {dummy=n[2]; n[2]=n[1]; n[1]=dummy;}
-   if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;}
-
-   //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl;
-
-   double n1,n2,n3;
-   n1=n[0];
-   n2=n[1];
-   n3=n[2];
-
-	double maxVol =  deltaX1*deltaX2*deltaX3;
-
-	double result = 0.0, preresult = 0.0;
-
-   if( UbMath::lessEqual( maxVol, 0.000001 ) )
-      return 0.0;
-
-   // 1D Check
-   if ( UbMath::lessEqual(n1,0.001)&&UbMath::lessEqual(n2,0.001) )
-	{
-		result = alpha*deltaX1*deltaX2;
-   }
-   // 2D Check
-   else if ( UbMath::lessEqual(n1,0.001) )
-	{
-		preresult = (2*n2*n3);
-		result = (alpha*alpha)/preresult;
-		
-		if( UbMath::greater(alpha,n2*deltaX2) )
-		{
-			result += -(alpha-n2*deltaX2)*(alpha-n2*deltaX2)/preresult;
-		}
-		if( UbMath::greater(alpha,n3*deltaX3) )
-		{
-			result += -(alpha-n3*deltaX3)*(alpha-n3*deltaX3)/preresult;
-		}
-		if( UbMath::greater(alpha,n2*deltaX2+n3*deltaX3) )
-		{
-			result +=  (alpha-n2*deltaX2-n3*deltaX3)*(alpha-n2*deltaX2-n3*deltaX3)/preresult;
-		}
-
-		// tiefenrichtung mit einmultiplizieren...
-		result *= deltaX1;
-	}	
-   // 3D Check
-   else	
-	{ 	
-		preresult =6*n1*n2*n3;
-
-		result = alpha*alpha*alpha;
-
-		if ( UbMath::greaterEqual(alpha,n1*deltaX1))
-		{
-			result+=-((alpha-n1*deltaX1)*(alpha-n1*deltaX1)*(alpha-n1*deltaX1));
-		}
-		if (UbMath::greaterEqual(alpha,n2*deltaX2))
-		{
-			result+=-((alpha-n2*deltaX2)*(alpha-n2*deltaX2)*(alpha-n2*deltaX2));
-		}
-		if (UbMath::greaterEqual(alpha,n3*deltaX3))
-		{
-			result+=-((alpha-n3*deltaX3)*(alpha-n3*deltaX3)*(alpha-n3*deltaX3));
-		}
-		if (UbMath::greaterEqual(alpha,(n1*deltaX1+n2*deltaX2)))
-		{
-			result+=((alpha-(n1*deltaX1+n2*deltaX2))*(alpha-(n1*deltaX1+n2*deltaX2))*(alpha-(n1*deltaX1+n2*deltaX2)));
-		}
-		if (UbMath::greaterEqual(alpha,(n1*deltaX1+n3*deltaX3)))
-		{
-			result+=((alpha-(n1*deltaX1+n3*deltaX3))*(alpha-(n1*deltaX1+n3*deltaX3))*(alpha-(n1*deltaX1+n3*deltaX3)));
-		}
-		if (UbMath::greaterEqual(alpha,(n2*deltaX2+n3*deltaX3)))
-		{
-			result+=((alpha-(n2*deltaX2+n3*deltaX3))*(alpha-(n2*deltaX2+n3*deltaX3))*(alpha-(n2*deltaX2+n3*deltaX3)));
-		}
-
-		//NEW
-		if (UbMath::greaterEqual(alpha,(n1*deltaX1+n2*deltaX2+n3*deltaX3)))
-		{
-			result+= -((alpha-(n1*deltaX1+n2*deltaX2+n3*deltaX3))*(alpha-(n1*deltaX1+n2*deltaX2+n3*deltaX3))*(alpha-(n1*deltaX1+n2*deltaX2+n3*deltaX3)));
-		}
-
-		result = result / preresult;
-
-   }
-   return(result) ;
-
-   //cout << "alpha ist " << alpha << endl;
-   //cout << "fillLevel ist " << eps << endl;
-}
-/*==========================================================*/
-double GbSphere3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
-{
-   double lx1  = midPoint->x1 - x1;
-   double lx2  = midPoint->x2 - x2;
-   double lx3  = midPoint->x3 - x3;
-   double l_sq = lx1*lx1 + lx2*lx2 + lx3*lx3;  //l = abstand Punkt(x1,x2,x3)<->kreismittelpunkt
-
-   double s    = lx1*rx1 + lx2*rx2 + lx3*rx3;  //s= l*ray_dir)
-   double r_sq = this->radius * this->radius;  // r² =r*r
-   //if (d<0 (fuer die Richtung falls sie gegen das Kreis dann haben wir ein negativer Zahl)
-   //     && l² > r² (point outside ))
-   //wenn s<0->Punkt liegt rechts vom mittelpunkt, wenn nun punkt ausserhalb des kreises liegt, kann es keinen SP mehr geben
-   if( s<-1.E-10 && l_sq>r_sq+1.E-10 )
-      return -1.0;
-   //Pythagor on Triangle Rectangle (point, center of the cercle, intersection of the direction on point and m)
-   // l² = m² + d²
-   double m_sq = l_sq - s*s;
-   // if (m² > r² (dann gibt es kein schnittpunt zwischen direction und circle))
-   if( m_sq > r_sq+1.E-10 )  return -1.0;
-   // Pythagoras on Triangle Rectangle in cercle (direction , m, r)
-   // r² = m² + h²
-
-   //patch: rundungsfehler bei kleinen delta!!!
-   //-> wenn wurzel minimal null->
-   double wurzelTerm = r_sq - m_sq;
-   if(wurzelTerm<0.0)
-   {
-      if(wurzelTerm<-1E-10) return -1.0; //definitiv kein SP
-      else                  return s;   //im rundungsfehler-bereich. SP liegt dierkt auf sphere umrandung
-   }
-
-   //if point outside of the circle
-   if(l_sq>r_sq) return s-sqrt(wurzelTerm);
-
-   return s+sqrt(wurzelTerm);
-}
-/*=======================================================*/
+#include <numerics/geometry3d/GbSphere3D.h>
+#include <numerics/geometry3d/GbSystem3D.h>
+#include <numerics/geometry3d/GbPoint3D.h>
+#include <numerics/geometry3d/GbLine3D.h>
+#include <numerics/geometry3d/GbTriangle3D.h>
+
+#include <numerics/geometry3d/creator/GbSphere3DCreator.h>
+
+using namespace std;
+
+ObObjectCreator* GbSphere3D::getCreator()
+{
+   return GbSphere3DCreator::getInstance();
+}
+/*=====================================================*/
+GbSphere3D::GbSphere3D()
+  : GbObject3D(), UbObserver()
+{
+   this->setName("sphere");
+   radius=0;
+   midPoint=new GbPoint3D(0,0,0);
+}
+/*=====================================================*/
+GbSphere3D::GbSphere3D(const double& x1,const double& x2, const double& x3, const double& radius)
+  : GbObject3D(), UbObserver()
+{
+   this->setName("sphere");
+   midPoint = new GbPoint3D(x1,x2,x3);
+   midPoint->addObserver(this);
+
+   this->radius   = radius;
+   triangulationMode = RAYPROJECTION;
+   //triangulationMode = CUBOIDPROJECTION;
+}
+/*=====================================================*/
+GbSphere3D::GbSphere3D(const GbSphere3D& sphere)
+  : GbObject3D(), UbObserver()
+{
+   this->setName("sphere");
+
+   this->midPoint    = sphere.midPoint->clone();
+   this->radius      = sphere.radius;
+   triangulationMode = RAYPROJECTION;
+
+   this->midPoint->addObserver(this);
+}
+/*=====================================================*/
+GbSphere3D::GbSphere3D(GbSphere3D* sphere)
+   : GbObject3D(), UbObserver()
+{
+   this->setName(sphere->getName());
+   midPoint = sphere->midPoint->clone();
+   midPoint->addObserver(this);
+
+   this->radius   = sphere->getRadius();
+   triangulationMode = RAYPROJECTION;
+}
+/*=====================================================*/
+GbSphere3D::~GbSphere3D()
+{
+   if(this->midPoint) this->midPoint->removeObserver(this);
+}
+/*=====================================================*/
+void GbSphere3D::finalize()
+{
+   if(this->midPoint)
+   {
+      this->midPoint->removeObserver(this);
+      this->midPoint->finalize();
+      delete this->midPoint;
+      this->midPoint = NULL;
+   }
+
+   if(this->midPoint) this->midPoint->removeObserver(this);
+}
+/*=====================================================*/
+bool GbSphere3D::intersects(SPtr<GbSphere3D> sphere)
+{
+    return this->getDistance(sphere->midPoint) < radius + sphere->radius;
+}
+/*=======================================================*/
+void GbSphere3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3)
+{
+   this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() );
+}
+
+void GbSphere3D::setCenterCoordinates(const UbTupleDouble3& position)
+{
+    this->setCenterCoordinates(val<1>(position), val<2>(position), val<3>(position));
+}
+
+/*=====================================================*/
+double GbSphere3D::getDistance(GbPoint3D* p)
+{
+   return this->getDistance(p->getX1Centroid(),p->getX2Coordinate(),p->getX3Coordinate());
+}
+/*=====================================================*/
+void GbSphere3D::setCenterX1Coordinate(const double& value)
+{
+   if(this->midPoint) this->midPoint->setX1(value);
+   else throw UbException(UB_EXARGS,"Sphere has no midPoint");
+   //kein notifyObserver(), da der knoten notifyObserver() ausfuehrt und die GbSphere dieses event
+   //abfaengt und dann selbst notifyObservers ausfuehrt ;-)
+}
+/*=====================================================*/
+void GbSphere3D::setCenterX2Coordinate(const double& value)
+{
+   if(this->midPoint) this->midPoint->setX2(value);
+   else  throw UbException(UB_EXARGS,"Sphere has no midPoint");
+   //kein notifyObserver(), da der knoten notifyObserver() ausfuehrt und die GbSphere dieses event
+   //abfaengt und dann selbst notifyObservers ausfuehrt ;-)
+}
+/*=====================================================*/
+void GbSphere3D::setCenterX3Coordinate(const double& value)
+{
+   if(this->midPoint) this->midPoint->setX3(value);
+   else  throw UbException(UB_EXARGS,"sphere has no midPoint");
+   //kein notifyObserver(), da der knoten notifyObserver() ausfuehrt und die GbSphere dieses event
+   //abfaengt und dann selbst notifyObservers ausfuehrt ;-)
+}
+/*=====================================================*/
+void GbSphere3D::setRadius(const double& radius)
+{
+   if (radius != this->radius)
+   {
+   this->radius=radius;
+   this->notifyObserversObjectChanged();
+}
+}
+/*=====================================================*/
+double GbSphere3D::getDistance(const double& x1p, const double& x2p, const double& x3p)
+{
+   double deltaX1 = x1p - midPoint->getX1Coordinate();
+   double deltaX2 = x2p - midPoint->getX2Coordinate();
+   double deltaX3 = x3p - midPoint->getX3Coordinate();
+   return sqrt(deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3)-this->radius;
+}
+/*=====================================================*/
+//true, wenn 'in Object' oder 'auf Boundary'!
+bool GbSphere3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
+{
+   double deltaX1 = x1p - midPoint->getX1Coordinate();
+   double deltaX2 = x2p - midPoint->getX2Coordinate();
+   double deltaX3 = x3p - midPoint->getX3Coordinate();
+
+   return UbMath::lessEqual(deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3, this->radius*this->radius);
+}
+/*=====================================================*/
+//true, wenn 'in Object' oder 'auf Boundary'!
+bool GbSphere3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
+{
+   double deltaX1 = x1p - midPoint->getX1Coordinate();
+   double deltaX2 = x2p - midPoint->getX2Coordinate();
+   double deltaX3 = x3p - midPoint->getX3Coordinate();
+
+   double distanceSquare = deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3;
+   double radiusSquare   = this->radius*this->radius;
+
+   pointIsOnBoundary = UbMath::equal(distanceSquare,radiusSquare);
+
+   return UbMath::lessEqual(distanceSquare,radiusSquare);
+}
+/*=====================================================*/
+//bool GbSphere3D::crossCellCrossSection(double x11,double x21,double x12,double x22, double ra)
+//{
+//   if(this->isPointInCrossection(x11, x12) || this->isPointInCrossection(x21, x22) || this->isPointInCrossection(x11, x22) || this->isPointInCrossection(x21, x12))
+//   {
+//		if(!this->isPointInCrossection(x11, x12) || !this->isPointInCrossection(x21, x22) || !this->isPointInCrossection(x11, x22) || !this->isPointInCrossection(x21, x12)) return true;
+//   }
+//   return false;
+//}
+//
+///*=====================================================*/
+//bool GbSphere3D::cellCrossAndInsideCrossSection(double x11,double x21,double x12,double x22, double ra)
+//{
+//   if(this->isPointInCrossection(x11, x12) || this->isPointInCrossection(x21, x22) || this->isPointInCrossection(x11, x22) || this->isPointInCrossection(x21, x12))  return true;
+//   return false;
+//}
+/*=====================================================*/
+string GbSphere3D::toString()
+{
+	stringstream ss;
+	ss<< "GbSphere3D[";
+	ss <<"mid="<<midPoint->toString()<<", r="<<radius<<"]";
+	return ss.str();
+}
+/*=====================================================*/
+GbLine3D* GbSphere3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
+{
+   double factor = 100.0; //um rundungsfehler beim wurzelterm zu minimieren
+   double xa = factor*point1.getX1Coordinate();
+   double ya = factor*point1.getX2Coordinate();
+   double za = factor*point1.getX3Coordinate();
+   double xb = factor*point2.getX1Coordinate();
+   double yb = factor*point2.getX2Coordinate();
+   double zb = factor*point2.getX3Coordinate();
+   double xm = factor*this->midPoint->getX1Coordinate();
+   double ym = factor*this->midPoint->getX2Coordinate();
+   double zm = factor*this->midPoint->getX3Coordinate();
+   double r  = factor*this->radius;
+
+   double xa2 = xa*xa;
+   double ya2 = ya*ya;
+   double za2 = za*za;
+   double xb2 = xb*xb;
+   double yb2 = yb*yb;
+   double zb2 = zb*zb;
+   double xm2 = xm*xm;
+   double ym2 = ym*ym;
+   double zm2 = zm*zm;
+   double r2  = r*r;
+
+   double wurzel =   2.0*xa*xb*ym2-2.0*ya*yb*r2+2.0*ya*ym*xb2+2.0*yb*ym*za2
+                    +2.0*ya*ym*zb2+2.0*xb*xm*za2+2.0*za*zb*ym2+2.0*xb*xm*ya2+2.0*xa*xm*yb2
+                    +2.0*yb*ym*xa2+2.0*zb*zm*ya2+2.0*xa*xm*zb2+2.0*za*zm*xb2+2.0*za*zm*yb2
+                    +2.0*xa*xb*zm2-2.0*xa*xb*r2-2.0*za*zb*r2+2.0*za*zb*xm2-2.0*ya*yb*xa*xm
+                    +2.0*ya*yb*xa*xb+2.0*zb*zm*xa2-2.0*ya*yb*xb*xm+2.0*ya*yb*xm2-2.0*ya*yb*zb*zm
+                    +2.0*ya*yb*zm2+2.0*zb*zm*yb*ym-2.0*zb*zm*ya*ym+2.0*zb*zm*xb*xm-2.0*xa*xm*yb*ym
+                    +2.0*xa*xm*za*zm+2.0*xa*xm*ya*ym-2.0*yb*ym*za*zm+2.0*yb*ym*xb*xm+2.0*za*zm*ya*ym
+                    -2.0*za*zm*xb*xm-2.0*ya*ym*xb*xm+2.0*za*zb*xa*xb-2.0*za*zb*xa*xm-2.0*za*zb*xb*xm
+                    +2.0*za*zb*ya*yb-2.0*za*zb*ya*ym-2.0*za*zb*yb*ym-2.0*ya*yb*za*zm-xa2*zb2
+                    -xa2*yb2-zb2*ya2-za2*xb2-za2*yb2-xb2*ya2-2.0*zb*zm*xa*xm
+                    -2.0*xa*xb*za*zm-2.0*xa*xb*zb*zm-2.0*xa*xb*ya*ym-2.0*xa*xb*yb*ym+za2*r2
+                    -za2*xm2-za2*ym2+zb2*r2-zb2*xm2-zb2*ym2+xa2*r2-xa2*zm2
+                    -xa2*ym2+xb2*r2-xb2*zm2-xb2*ym2+ya2*r2-ya2*zm2-ya2*xm2
+                    +yb2*r2-yb2*zm2-yb2*xm2;
+   double nenner  = -2.0*za*zb-2.0*ya*yb-2.0*xa*xb+za2+zb2+xa2+xb2+ya2+yb2;
+   double zaehler =  2.0*zb*zm-2.0*xa*xm+2.0*yb*ym-2.0*za*zm+xa2-2.0*ya*ym
+                    +2.0*xb*xm-zb2+za2-xb2+ya2-yb2;
+
+   vector<GbPoint3D*> schnittpunkte;
+
+   if(fabs(nenner)>1.E-13 && UbMath::greaterEqual(wurzel,0.0))
+   {
+      double t1 = (zaehler+2.0*sqrt(wurzel))/nenner;
+      double t2 = (zaehler-2.0*sqrt(wurzel))/nenner;
+
+      if(UbMath::inClosedInterval(t1,-1.0,1.0))
+      {
+         double x = ( xa*(0.5-0.5*t1)+xb*(0.5+0.5*t1) )/factor;
+         double y = ( ya*(0.5-0.5*t1)+yb*(0.5+0.5*t1) )/factor;
+         double z = ( za*(0.5-0.5*t1)+zb*(0.5+0.5*t1) )/factor;
+
+         schnittpunkte.push_back(new GbPoint3D(x,y,z));
+      }
+      if(fabs(t2-t1)>1.E-13 && UbMath::inClosedInterval(t2,-1.0,1.0))
+      {
+         double x = ( xa*(0.5-0.5*t2)+xb*(0.5+0.5*t2) )/factor;
+         double y = ( ya*(0.5-0.5*t2)+yb*(0.5+0.5*t2) )/factor;
+         double z = ( za*(0.5-0.5*t2)+zb*(0.5+0.5*t2) )/factor;
+
+         schnittpunkte.push_back(new GbPoint3D(x,y,z));
+      }
+   }
+
+   int nofSchnittpunkte = (int)schnittpunkte.size();
+   if(nofSchnittpunkte==1)
+   {
+      if     (this->isPointInGbObject3D(&point1)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point1));
+      else if(this->isPointInGbObject3D(&point2)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point2));
+      else //line beruehrt kugel! -> clippedLine reduziert sich zu einem Punkt!
+      {
+         if(std::fabs(this->getDistance(schnittpunkte[0])-this->radius)<1.E-13)
+            throw UbException(UB_EXARGS,"Beide LinenPunkte ausserhalb des Kreises, der berechnete Punkt ist jedoch KEIN Beruhrungspunkt der Sphere...");
+         return new GbLine3D(schnittpunkte[0],new GbPoint3D(*(schnittpunkte[0])));
+      }
+   }
+   else if(nofSchnittpunkte==2) return new GbLine3D(schnittpunkte[0],schnittpunkte[1]);
+
+   return NULL;
+}
+/*=========================================================================*/
+vector<GbTriangle3D*> GbSphere3D::getSurfaceTriangleSet()
+{
+   if(triangulationMode==RAYPROJECTION)
+   {
+      double x1m = midPoint->getX1Coordinate();
+      double x2m = midPoint->getX2Coordinate();
+      double x3m = midPoint->getX3Coordinate();
+
+      vector<GbTriangle3D*> triangles;
+
+      int segments =30;
+      double deltaPhi = UbMath::PI/(double)segments;
+      double phiX1a,phiX1b,phiX3a,phiX3b;
+      double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d;
+
+      for(phiX3a=0.5*UbMath::PI; phiX3a>-1.5*UbMath::PI; phiX3a-=deltaPhi)
+      {
+         for(phiX1a=0.0; phiX1a<UbMath::PI; phiX1a+=deltaPhi)
+         {
+            phiX1b = phiX1a+deltaPhi;
+            phiX3b = phiX3a+deltaPhi;
+
+            x1a =  x1m+radius*cos(phiX3a)*std::cos(phiX1a);
+            x2a =  x2m+radius*cos(phiX3a)*std::sin(phiX1a);
+            x3a =  x3m+radius*sin(phiX3a);
+            x1b =  x1m+radius*cos(phiX3a)*std::cos(phiX1b);
+            x2b =  x2m+radius*cos(phiX3a)*std::sin(phiX1b);
+            x3b =  x3m+radius*sin(phiX3a);
+            x1c =  x1m+radius*cos(phiX3b)*std::cos(phiX1b);
+            x2c =  x2m+radius*cos(phiX3b)*std::sin(phiX1b);
+            x3c =  x3m+radius*sin(phiX3b);
+            x1d =  x1m+radius*cos(phiX3b)*std::cos(phiX1a);
+            x2d =  x2m+radius*cos(phiX3b)*std::sin(phiX1a);
+            x3d =  x3m+radius*sin(phiX3b);
+
+            if(UbMath::greater(phiX3b,-0.5*UbMath::PI)  && UbMath::less(phiX3a,0.5*UbMath::PI))
+            {
+               triangles.push_back(new GbTriangle3D(new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1b,x2b,x3b),new GbPoint3D(x1c,x2c,x3c)));
+               triangles.push_back(new GbTriangle3D(new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1c,x2c,x3c),new GbPoint3D(x1d,x2d,x3d)));
+            }
+            else
+            {
+               triangles.push_back(new GbTriangle3D(new GbPoint3D(x1d,x2d,x3d),new GbPoint3D(x1c,x2c,x3c),new GbPoint3D(x1a,x2a,x3a)));
+               triangles.push_back(new GbTriangle3D(new GbPoint3D(x1c,x2c,x3c),new GbPoint3D(x1b,x2b,x3b),new GbPoint3D(x1a,x2a,x3a)));
+            }
+         }
+      }
+      return triangles;
+   }
+   else if(triangulationMode==CUBOIDPROJECTION)
+   {
+      vector<GbTriangle3D*> triangles;
+      vector<GbPoint3D*>   points;
+      double x1min = this->getX1Minimum();
+      double x2min = this->getX2Minimum();
+      double x3min = this->getX3Minimum();
+      double x1max = this->getX1Maximum();
+      double x2max = this->getX2Maximum();
+      double x3max = this->getX3Maximum();
+      double ax1 = x1min;    double bx2 = x2min;   double cx1 = x1min;
+      double ax2 = x2min;    double bx3 = x3min;   double cx3 = x3min;
+
+      int anzahl = 20;
+      double dx1 = (x1max-x1min)/(double)(anzahl-1);
+      double dx2 = (x2max-x2min)/(double)(anzahl-1);
+      double dx3 = (x3max-x3min)/(double)(anzahl-1);
+
+      for (int u=0; u<anzahl; u++)
+      {
+         ax2 = x2min;
+         bx2 = x2min;
+         cx3 = x3min;
+         for (int v=0; v<anzahl; v++)
+         {
+            GbPoint3D p1 = GbPoint3D(ax1, ax2, x3max);
+            GbPoint3D p2 = GbPoint3D(ax1, ax2, x3min);
+            GbPoint3D p3 = GbPoint3D(cx1, x2min, cx3);
+            GbPoint3D p4 = GbPoint3D(cx1, x2max, cx3);
+            GbPoint3D p5 = GbPoint3D(x1min, bx2, bx3);
+            GbPoint3D p6 = GbPoint3D(x1max, bx2, bx3);
+
+            GbLine3D* clippedline1 = this->createClippedLine3D(*this->midPoint, p1);
+            GbLine3D* clippedline2 = this->createClippedLine3D(*this->midPoint, p2);
+            GbLine3D* clippedline3 = this->createClippedLine3D(*this->midPoint, p3);
+            GbLine3D* clippedline4 = this->createClippedLine3D(*this->midPoint, p4);
+            GbLine3D* clippedline5 = this->createClippedLine3D(*this->midPoint, p5);
+            GbLine3D* clippedline6 = this->createClippedLine3D(*this->midPoint, p6);
+            points.push_back(new GbPoint3D(clippedline1->getPoint1()));
+            points.push_back(new GbPoint3D(clippedline2->getPoint1()));
+            points.push_back(new GbPoint3D(clippedline3->getPoint1()));
+            points.push_back(new GbPoint3D(clippedline4->getPoint1()));
+            points.push_back(new GbPoint3D(clippedline5->getPoint1()));
+            points.push_back(new GbPoint3D(clippedline6->getPoint1()));
+            clippedline1->deletePoints();    delete clippedline1;
+            clippedline2->deletePoints();    delete clippedline2;
+            clippedline3->deletePoints();    delete clippedline3;
+            clippedline4->deletePoints();    delete clippedline4;
+            clippedline5->deletePoints();    delete clippedline5;
+            clippedline6->deletePoints();    delete clippedline6;
+            ax2 +=dx2;
+            cx3 +=dx3;
+            bx2 +=dx2;
+         }
+         ax1 +=dx1;
+         cx1 +=dx1;
+         bx3 +=dx3;
+      }
+
+      int anz = anzahl*anzahl*6;
+      GbPoint3D* point1 = NULL;
+      GbPoint3D* point2 = NULL;
+      GbPoint3D* point3 = NULL;
+      int anzahl2 = anzahl*6;
+      int anzahl3 = anzahl2+6;
+      for (int u=0; u<anz-anzahl3; u++)
+      {
+         point1 = new GbPoint3D(points[u+6]);
+         point2 = new GbPoint3D(points[u]);
+         point3 = new GbPoint3D(points[u+anzahl2]);
+         if(u%2 == 0) triangles.push_back(new GbTriangle3D(point1, point2, point3));
+         else         triangles.push_back(new GbTriangle3D(point2, point1, point3));
+
+         point1 = new GbPoint3D(points[u+6]);
+         point2 = new GbPoint3D(points[u+anzahl2]);
+         point3 = new GbPoint3D(points[u+anzahl3]);
+         if(u%2 == 0) triangles.push_back(new GbTriangle3D(point1, point2, point3));
+         else         triangles.push_back(new GbTriangle3D(point2, point1, point3));
+      }
+      for (int u=0; u<anz; u++) delete points[u];
+
+      return triangles;
+   }
+   else throw UbException(UB_EXARGS,"undefined triangulationmode");
+}
+/*=======================================================*/
+void GbSphere3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles)
+{
+   //wenn ich viele Kugeln bei der PE rausschreibe sollten die vektoren nicht geresized werden
+   //nodes.resize(0);
+   //triangles.resize(0);
+
+   if(triangulationMode==RAYPROJECTION)
+   {
+      float x1m = (float)midPoint->getX1Coordinate();
+      float x2m = (float)midPoint->getX2Coordinate();
+      float x3m = (float)midPoint->getX3Coordinate();
+
+      int segments =30;
+      float deltaPhi = (float)UbMath::PI/(float)segments;
+      float phiX1a,phiX1b,phiX3a,phiX3b;
+      float x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d;
+      int nodeNr = nodes.size();
+      for(phiX3a=(float)(0.5*UbMath::PI); phiX3a > (float)(-1.5*UbMath::PI); phiX3a-=deltaPhi)
+      {
+         for(phiX1a=0.0; phiX1a<UbMath::PI; phiX1a+=deltaPhi)
+         {
+            phiX1b = phiX1a+deltaPhi;
+            phiX3b = phiX3a+deltaPhi;
+
+            x1a =  x1m+(float)(radius*cos(phiX3a)*std::cos(phiX1a));
+            x2a =  x2m+(float)(radius*cos(phiX3a)*std::sin(phiX1a));
+            x3a =  x3m+(float)(radius*sin(phiX3a));
+            x1b =  x1m+(float)(radius*cos(phiX3a)*std::cos(phiX1b));
+            x2b =  x2m+(float)(radius*cos(phiX3a)*std::sin(phiX1b));
+            x3b =  x3m+(float)(radius*sin(phiX3a));
+            x1c =  x1m+(float)(radius*cos(phiX3b)*std::cos(phiX1b));
+            x2c =  x2m+(float)(radius*cos(phiX3b)*std::sin(phiX1b));
+            x3c =  x3m+(float)(radius*sin(phiX3b));
+            x1d =  x1m+(float)(radius*cos(phiX3b)*std::cos(phiX1a));
+            x2d =  x2m+(float)(radius*cos(phiX3b)*std::sin(phiX1a));
+            x3d =  x3m+(float)(radius*sin(phiX3b));
+
+            if(UbMath::greater(phiX3b,-0.5*UbMath::PI) && UbMath::less(phiX3a,0.5*UbMath::PI))
+            {
+               nodes.push_back( makeUbTuple(x1a,x2a,x3a) );
+               nodes.push_back( makeUbTuple(x1b,x2b,x3b) );
+               nodes.push_back( makeUbTuple(x1c,x2c,x3c) );
+
+               nodes.push_back( makeUbTuple(x1a,x2a,x3a) );
+               nodes.push_back( makeUbTuple(x1c,x2c,x3c) );
+               nodes.push_back( makeUbTuple(x1d,x2d,x3d) );
+            }
+            else
+            {
+               nodes.push_back( makeUbTuple(x1d,x2d,x3d) );
+               nodes.push_back( makeUbTuple(x1c,x2c,x3c) );
+               nodes.push_back( makeUbTuple(x1a,x2a,x3a) );
+
+               nodes.push_back( makeUbTuple(x1c,x2c,x3c) );
+               nodes.push_back( makeUbTuple(x1b,x2b,x3b) );
+               nodes.push_back( makeUbTuple(x1a,x2a,x3a) );
+            }
+            triangles.push_back( makeUbTuple(nodeNr, nodeNr+1, nodeNr+2) );
+            triangles.push_back( makeUbTuple(nodeNr+3, nodeNr+4, nodeNr+5) );
+            nodeNr+=6;
+         }
+      }
+   }
+   else if(triangulationMode==CUBOIDPROJECTION)
+   {
+      vector<GbPoint3D*>   points;
+      double x1min = this->getX1Minimum();
+      double x2min = this->getX2Minimum();
+      double x3min = this->getX3Minimum();
+      double x1max = this->getX1Maximum();
+      double x2max = this->getX2Maximum();
+      double x3max = this->getX3Maximum();
+      double ax1 = x1min;    double bx2 = x2min;   double cx1 = x1min;
+      double ax2 = x2min;    double bx3 = x3min;   double cx3 = x3min;
+
+      int anzahl = 20;
+      double dx1 = (x1max-x1min)/(double)(anzahl-1);
+      double dx2 = (x2max-x2min)/(double)(anzahl-1);
+      double dx3 = (x3max-x3min)/(double)(anzahl-1);
+
+      for (int u=0; u<anzahl; u++)
+      {
+         ax2 = x2min;
+         bx2 = x2min;
+         cx3 = x3min;
+         for (int v=0; v<anzahl; v++)
+         {
+            GbPoint3D p1 = GbPoint3D(ax1, ax2, x3max);
+            GbPoint3D p2 = GbPoint3D(ax1, ax2, x3min);
+            GbPoint3D p3 = GbPoint3D(cx1, x2min, cx3);
+            GbPoint3D p4 = GbPoint3D(cx1, x2max, cx3);
+            GbPoint3D p5 = GbPoint3D(x1min, bx2, bx3);
+            GbPoint3D p6 = GbPoint3D(x1max, bx2, bx3);
+
+            GbLine3D* clippedline1 = this->createClippedLine3D(*this->midPoint, p1);
+            GbLine3D* clippedline2 = this->createClippedLine3D(*this->midPoint, p2);
+            GbLine3D* clippedline3 = this->createClippedLine3D(*this->midPoint, p3);
+            GbLine3D* clippedline4 = this->createClippedLine3D(*this->midPoint, p4);
+            GbLine3D* clippedline5 = this->createClippedLine3D(*this->midPoint, p5);
+            GbLine3D* clippedline6 = this->createClippedLine3D(*this->midPoint, p6);
+            points.push_back(new GbPoint3D(clippedline1->getPoint1()));
+            points.push_back(new GbPoint3D(clippedline2->getPoint1()));
+            points.push_back(new GbPoint3D(clippedline3->getPoint1()));
+            points.push_back(new GbPoint3D(clippedline4->getPoint1()));
+            points.push_back(new GbPoint3D(clippedline5->getPoint1()));
+            points.push_back(new GbPoint3D(clippedline6->getPoint1()));
+            clippedline1->deletePoints();    delete clippedline1;
+            clippedline2->deletePoints();    delete clippedline2;
+            clippedline3->deletePoints();    delete clippedline3;
+            clippedline4->deletePoints();    delete clippedline4;
+            clippedline5->deletePoints();    delete clippedline5;
+            clippedline6->deletePoints();    delete clippedline6;
+            ax2 +=dx2;
+            cx3 +=dx3;
+            bx2 +=dx2;
+         }
+         ax1 +=dx1;
+         cx1 +=dx1;
+         bx3 +=dx3;
+      }
+
+      int anz = anzahl*anzahl*6;
+      int anzahl2 = anzahl*6;
+      int anzahl3 = anzahl2+6;
+      int nodeNr = 0;
+      for (int u=0; u<anz-anzahl3; u++)
+      {
+         nodes.push_back( makeUbTuple((float)points[u+6]->x1      , (float)points[u+6]->x2      , (float)points[u+6]->x3) );
+         nodes.push_back( makeUbTuple((float)points[u]->x1        , (float)points[u]->x2        , (float)points[u]->x3) );
+         nodes.push_back( makeUbTuple((float)points[u+anzahl2]->x1, (float)points[u+anzahl2]->x2, (float)points[u+anzahl2]->x3) );
+
+         if(u%2 == 0) triangles.push_back( makeUbTuple(nodeNr  , nodeNr+1, nodeNr+2) );
+         else         triangles.push_back( makeUbTuple(nodeNr  , nodeNr+1, nodeNr+2) );
+
+         nodes.push_back( makeUbTuple((float)points[u+6]->x1      , (float)points[u+6]->x2      , (float)points[u+6]->x3) );
+         nodes.push_back( makeUbTuple((float)points[u+anzahl2]->x1, (float)points[u+anzahl2]->x2, (float)points[u+anzahl2]->x3) );
+         nodes.push_back( makeUbTuple((float)points[u+anzahl3]->x1, (float)points[u+anzahl3]->x2, (float)points[u+anzahl3]->x3) );
+         if(u%2 == 0) triangles.push_back( makeUbTuple(nodeNr+3, nodeNr+4, nodeNr+5) );
+         else         triangles.push_back( makeUbTuple(nodeNr+3, nodeNr+4, nodeNr+5) );
+
+         nodeNr+=6;
+      }
+      for(int u=0; u<anz; u++) delete points[u];
+   }
+   else throw UbException(UB_EXARGS,"undefined triangulationmode");
+}
+/*=======================================================*/
+void GbSphere3D::transform(const double matrix[4][4])
+{
+   midPoint->transform(matrix);
+   this->setRadius(this->getRadius()*matrix[0][0]);
+   this->notifyObserversObjectChanged();
+}
+/*=======================================================*/
+void GbSphere3D::write(UbFileOutput* out)
+{
+   out->writeString(this->getCreator()->getTypeID());
+   midPoint->write(out);
+   out->writeDouble(radius);
+   out->writeInteger((int)triangulationMode);
+}
+/*=======================================================*/
+void GbSphere3D::read(UbFileInput* in)
+{
+   if(midPoint)
+   {
+      midPoint->removeObserver(this);
+      midPoint->finalize();
+      delete midPoint;
+   }
+   midPoint = new GbPoint3D;
+   in->readString();
+   midPoint->read(in);
+   midPoint->addObserver(this);
+   radius = in->readDouble();
+   triangulationMode = (TRIANGULATIONMODE)in->readInteger();
+}
+/*=======================================================*/
+bool GbSphere3D::hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction)
+{
+	GbVector3D vecOrigin(origin.getX1Coordinate(),origin.getX2Coordinate(), origin.getX3Coordinate()) ;
+	GbVector3D vecDirection(direction.getX1Coordinate(),direction.getX2Coordinate(), direction.getX3Coordinate());
+	GbVector3D vecSfereCenter(getX1Centroid(), getX2Centroid(), getX3Centroid());
+	GbVector3D diff = vecOrigin - vecSfereCenter;
+   float a = (float)(vecDirection.Dot(vecDirection));
+   float b = (float)(2.0 * vecDirection.Dot(diff));
+   float c = (float)(diff.Dot(diff) - this->getRadius()*this->getRadius());
+
+	// use 'abc'-formula for finding root t_1,2 = (-b +/- sqrt(b^2-4ac))/(2a)
+	float inRoot = (float)(b*b - 4.0*a*c);
+	if (inRoot < 0) return false;
+	float root = sqrt(inRoot);
+
+	float dist = (float)((-b - root)/(2.0*a));
+
+	double infinity = DBL_MAX;
+	double eps = 1E-4;
+
+   if (dist > infinity)
+		return false;
+
+	if (dist < eps)
+	{
+		dist = (float)((-b + root)/(2.0*a));
+		if (dist < eps || dist > infinity)
+			return false;
+	}
+	return true;
+}
+/*=======================================================*/
+bool GbSphere3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+//Merksatz: cell oder deren Volumen schneidet oder beinhaltet komplette oder Teile der SphereUmrandung
+//returns true:
+//  - cell cuts  sphere3D
+//  - cell boxes sphere3D
+//returns false:
+//  - cell completely inside sphere3D ( = sphere3D boxes cell)
+//  - cell und sphere3D haben kein gemeinsames Volumen
+{
+   double midX[] = {  this->getX1Centroid()
+                    , this->getX2Centroid()
+                    , this->getX3Centroid() };
+
+   double Bmin[] = {  UbMath::min(x1a, x1b)
+                    , UbMath::min(x2a, x2b)
+                    , UbMath::min(x3a, x3b) };
+
+   double Bmax[] = {  UbMath::max(x1a, x1b)
+                    , UbMath::max(x2a, x2b)
+                    , UbMath::max(x3a, x3b) };
+
+   /* Solid Box - Hollow Sphere */
+   double dmin = 0.0;
+   double dmax = 0.0;
+   double r2   = radius*radius;
+
+   for( int i=0; i<3; i++ )
+   {
+      double a = pow( midX[i] - Bmin[i], 2.0 );
+      double b = pow( midX[i] - Bmax[i], 2.0 );
+      dmax += UbMath::max( a, b );
+      if     ( UbMath::less   ( midX[i], Bmin[i] ) ) dmin += a;
+      else if( UbMath::greater( midX[i], Bmax[i] ) ) dmin += b;
+   }
+   if(   UbMath::lessEqual(dmin, r2   )
+      && UbMath::lessEqual(r2  , dmax ) )
+   {
+      return true;
+   }
+   return false;
+}
+/*=======================================================*/
+bool GbSphere3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+//returns true:
+//  - cell completely inside sphere3D ( = sphere3D boxes cell)
+//  - cell cuts  sphere3D
+//  - cell boxes sphere3D
+//returns false:
+//  - cell und sphere3D haben kein gemeinsames Volumen
+{
+   //URL: http://tog.acm.org/GraphicsGems/gems/BoxSphere.c (mode=4, beides solids!!!)
+   // solid - solid
+   //this routine tests for intersection between an 3-dimensional
+   //axis-aligned box and an 3-dimensional sphere.
+
+   //true:
+   //  - wenn Schnitt
+   //  - Cell komplett innerhalb GbSphere3D
+   //  - Cell umhuellt GbSphere3D
+
+
+   double midX1 = this->getX1Centroid();
+   double midX2 = this->getX2Centroid();
+   double midX3 = this->getX3Centroid();
+
+   double dmin  = 0.0;
+
+   if     ( UbMath::less   ( midX1, x1a ) ) dmin += std::pow( midX1 - x1a, 2.0 );
+   else if( UbMath::greater( midX1, x1b ) ) dmin += std::pow( midX1 - x1b, 2.0 );
+
+   if     ( UbMath::less   ( midX2, x2a ) ) dmin += std::pow( midX2 - x2a, 2.0 );
+   else if( UbMath::greater( midX2, x2b ) ) dmin += std::pow( midX2 - x2b, 2.0 );
+
+   if     ( UbMath::less   ( midX3, x3a ) ) dmin += std::pow( midX3 - x3a, 2.0 );
+   else if( UbMath::greater( midX3, x3b ) ) dmin += std::pow( midX3 - x3b, 2.0 );
+
+   if( UbMath::lessEqual( dmin, radius*radius ) )
+   {
+      return true;
+   }
+
+   return false;
+}
+/*==========================================================*/
+double GbSphere3D::getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+{
+	double deltaX1 = (x1b-x1a);
+	double deltaX2 = (x2b-x2a);
+	double deltaX3 = (x3b-x3a);
+	  
+	if( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) )       return 1.0*deltaX1*deltaX2*deltaX3; 
+	if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) )   return 0.0;
+
+	double tempResult = 0.0;
+
+	int iMax = 10;
+	int jMax = 10;
+	int kMax = 10;
+
+	for(         int i=0; i<iMax; i++){
+		for(     int j=0; j<jMax; j++){
+			for( int k=0; k<kMax; k++){
+				
+				tempResult += getCellVolumeInsideGbObject3DHelperFunction(
+					x1a+((double) i   )*deltaX1/((double)iMax), x2a+((double) j   )*deltaX2/((double)jMax), x3a+((double) k   )*deltaX3/((double)kMax),
+					x1a+((double)(i+1))*deltaX1/((double)iMax), x2a+((double)(j+1))*deltaX2/((double)jMax), x3a+((double)(k+1))*deltaX3/((double)kMax) );
+			}
+		}
+	}
+
+
+	double resultWithOneCell = getCellVolumeInsideGbObject3DHelperFunction( x1a, x2a, x3a, x1b, x2b, x3b );
+
+	//cout << tempResult << " vs. " << resultWithOneCell << endl;
+
+	return tempResult;
+
+}
+/*==========================================================*/
+double GbSphere3D::getCellVolumeInsideGbObject3DHelperFunction(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+{
+
+	double deltaX1 = x1b-x1a;
+   double deltaX2 = x2b-x2a;
+   double deltaX3 = x3b-x3a;
+
+   if(   this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) )     return 1.0*deltaX1*deltaX2*deltaX3;
+   if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) )   return 0.0;
+
+   double alpha=0.0;
+   double internX1,internX2,internX3;
+
+   for(int x1vers=0;x1vers<2;x1vers++){
+      for(int x2vers=0;x2vers<2;x2vers++){
+         for(int x3vers=0;x3vers<2;x3vers++){
+            internX1 = x1a + (x1b-x1a)*x1vers;
+            internX2 = x2a + (x2b-x2a)*x2vers;
+            internX3 = x3a + (x3b-x3a)*x3vers;
+
+            if( UbMath::lessEqual(this->getDistance(internX1,internX2,internX3),alpha) )
+               alpha = this->getDistance(internX1,internX2,internX3);
+            //cout<<zelltyp<<" "<<kugel->getDistance(internX1,internX2,internX3)<<" "<<alpha<<endl;
+         }//end first for
+      }//end second for
+   }//end third for
+
+   alpha = (-1)*alpha;
+
+
+
+   double n[3];
+   n[0] = 0.5*(x1b+x1a) - this->getX1Centroid();
+   n[1] = 0.5*(x2b+x2a) - this->getX2Centroid();
+   n[2] = 0.5*(x3b+x3a) - this->getX3Centroid();
+
+   //cout << "Koordinaten:  "<<x1<<" "<<x2<<" "<<x3<<endl;
+   //cout << "Deltas:       "<<deltaX1<<" "<<deltaX2<<" "<<deltaX3<<endl;
+   //cout << "Halbe Zelle:  "<<halfcelldelta<<endl;
+
+   //cout<<"Centroid:  "<<kugel->getX1Centroid()<<" "<<kugel->getX2Centroid()<<" "<<kugel->getX3Centroid()<<endl;
+
+   //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl;
+
+   double normLength;
+   normLength = sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]);
+   n[0] /= normLength;
+   n[1] /= normLength;
+   n[2] /= normLength;
+
+   if( UbMath::less(n[0],0.0) ) n[0] = -n[0];
+   if( UbMath::less(n[1],0.0) ) n[1] = -n[1];
+   if( UbMath::less(n[2],0.0) ) n[2] = -n[2];
+
+   //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl;
+
+   double dummy;
+   if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;}
+   if( UbMath::greater(n[1],n[2])) {dummy=n[2]; n[2]=n[1]; n[1]=dummy;}
+   if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;}
+
+   //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl;
+
+   double n1,n2,n3;
+   n1=n[0];
+   n2=n[1];
+   n3=n[2];
+
+	double maxVol =  deltaX1*deltaX2*deltaX3;
+
+	double result = 0.0, preresult = 0.0;
+
+   if( UbMath::lessEqual( maxVol, 0.000001 ) )
+      return 0.0;
+
+   // 1D Check
+   if ( UbMath::lessEqual(n1,0.001)&&UbMath::lessEqual(n2,0.001) )
+	{
+		result = alpha*deltaX1*deltaX2;
+   }
+   // 2D Check
+   else if ( UbMath::lessEqual(n1,0.001) )
+	{
+		preresult = (2*n2*n3);
+		result = (alpha*alpha)/preresult;
+		
+		if( UbMath::greater(alpha,n2*deltaX2) )
+		{
+			result += -(alpha-n2*deltaX2)*(alpha-n2*deltaX2)/preresult;
+		}
+		if( UbMath::greater(alpha,n3*deltaX3) )
+		{
+			result += -(alpha-n3*deltaX3)*(alpha-n3*deltaX3)/preresult;
+		}
+		if( UbMath::greater(alpha,n2*deltaX2+n3*deltaX3) )
+		{
+			result +=  (alpha-n2*deltaX2-n3*deltaX3)*(alpha-n2*deltaX2-n3*deltaX3)/preresult;
+		}
+
+		// tiefenrichtung mit einmultiplizieren...
+		result *= deltaX1;
+	}	
+   // 3D Check
+   else	
+	{ 	
+		preresult =6*n1*n2*n3;
+
+		result = alpha*alpha*alpha;
+
+		if ( UbMath::greaterEqual(alpha,n1*deltaX1))
+		{
+			result+=-((alpha-n1*deltaX1)*(alpha-n1*deltaX1)*(alpha-n1*deltaX1));
+		}
+		if (UbMath::greaterEqual(alpha,n2*deltaX2))
+		{
+			result+=-((alpha-n2*deltaX2)*(alpha-n2*deltaX2)*(alpha-n2*deltaX2));
+		}
+		if (UbMath::greaterEqual(alpha,n3*deltaX3))
+		{
+			result+=-((alpha-n3*deltaX3)*(alpha-n3*deltaX3)*(alpha-n3*deltaX3));
+		}
+		if (UbMath::greaterEqual(alpha,(n1*deltaX1+n2*deltaX2)))
+		{
+			result+=((alpha-(n1*deltaX1+n2*deltaX2))*(alpha-(n1*deltaX1+n2*deltaX2))*(alpha-(n1*deltaX1+n2*deltaX2)));
+		}
+		if (UbMath::greaterEqual(alpha,(n1*deltaX1+n3*deltaX3)))
+		{
+			result+=((alpha-(n1*deltaX1+n3*deltaX3))*(alpha-(n1*deltaX1+n3*deltaX3))*(alpha-(n1*deltaX1+n3*deltaX3)));
+		}
+		if (UbMath::greaterEqual(alpha,(n2*deltaX2+n3*deltaX3)))
+		{
+			result+=((alpha-(n2*deltaX2+n3*deltaX3))*(alpha-(n2*deltaX2+n3*deltaX3))*(alpha-(n2*deltaX2+n3*deltaX3)));
+		}
+
+		//NEW
+		if (UbMath::greaterEqual(alpha,(n1*deltaX1+n2*deltaX2+n3*deltaX3)))
+		{
+			result+= -((alpha-(n1*deltaX1+n2*deltaX2+n3*deltaX3))*(alpha-(n1*deltaX1+n2*deltaX2+n3*deltaX3))*(alpha-(n1*deltaX1+n2*deltaX2+n3*deltaX3)));
+		}
+
+		result = result / preresult;
+
+   }
+   return(result) ;
+
+   //cout << "alpha ist " << alpha << endl;
+   //cout << "fillLevel ist " << eps << endl;
+}
+/*==========================================================*/
+double GbSphere3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
+{
+   double lx1  = midPoint->x1 - x1;
+   double lx2  = midPoint->x2 - x2;
+   double lx3  = midPoint->x3 - x3;
+   double l_sq = lx1*lx1 + lx2*lx2 + lx3*lx3;  //l = abstand Punkt(x1,x2,x3)<->kreismittelpunkt
+
+   double s    = lx1*rx1 + lx2*rx2 + lx3*rx3;  //s= l*ray_dir)
+   double r_sq = this->radius * this->radius;  // r² =r*r
+   //if (d<0 (fuer die Richtung falls sie gegen das Kreis dann haben wir ein negativer Zahl)
+   //     && l² > r² (point outside ))
+   //wenn s<0->Punkt liegt rechts vom mittelpunkt, wenn nun punkt ausserhalb des kreises liegt, kann es keinen SP mehr geben
+   if( s<-1.E-10 && l_sq>r_sq+1.E-10 )
+      return -1.0;
+   //Pythagor on Triangle Rectangle (point, center of the cercle, intersection of the direction on point and m)
+   // l² = m² + d²
+   double m_sq = l_sq - s*s;
+   // if (m² > r² (dann gibt es kein schnittpunt zwischen direction und circle))
+   if( m_sq > r_sq+1.E-10 )  return -1.0;
+   // Pythagoras on Triangle Rectangle in cercle (direction , m, r)
+   // r² = m² + h²
+
+   //patch: rundungsfehler bei kleinen delta!!!
+   //-> wenn wurzel minimal null->
+   double wurzelTerm = r_sq - m_sq;
+   if(wurzelTerm<0.0)
+   {
+      if(wurzelTerm<-1E-10) return -1.0; //definitiv kein SP
+      else                  return s;   //im rundungsfehler-bereich. SP liegt dierkt auf sphere umrandung
+   }
+
+   //if point outside of the circle
+   if(l_sq>r_sq) return s-sqrt(wurzelTerm);
+
+   return s+sqrt(wurzelTerm);
+}
+/*=======================================================*/
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbSphere3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbSphere3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbSphere3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbSphere3D.h
index 78e288d36cfae9711e9cc0dd7b92733d79536a79..c8e4eee5f94257a21b972f41949ebf5fe5a21955 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbSphere3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbSphere3D.h
@@ -1,164 +1,164 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBSPHERE3D_H
-#define GBSPHERE3D_H
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-#ifdef CAB_CTL
-   #include <ctl.h>
-#endif //CAB_CTL
-
-#include <vector>
-#include <cmath>
-
-#include <basics/utilities/UbObserver.h>
-
-#include <numerics/geometry3d/GbObject3D.h>
-#include <numerics/geometry3d/GbPoint3D.h>
-
-#include <PointerDefinitions.h>
-
-class GbLine3D;
-class GbTriangle3D;
-class GbObject3DCreator;
-
-class GbSphere3D : public GbObject3D, public UbObserver
-{                                              
-public:
-   enum TRIANGULATIONMODE { CUBOIDPROJECTION ,RAYPROJECTION };
-   
-   //////////////////////////////////////////////////////////////////////////
-   // Konstruktoren
-   GbSphere3D(); 
-   GbSphere3D(const double& x1,const double& x2, const double& x3, const double& radius);            
-   GbSphere3D(const GbSphere3D& sphere);            
-   GbSphere3D(GbSphere3D* sphere); //<-unschoen!
-   
-   ~GbSphere3D();
-
-   GbSphere3D* clone() { return new GbSphere3D(*this);}
-   void finalize();
-
-
-   bool intersects(SPtr<GbSphere3D> sphere);
-
-   double getRadius() const	{	return this->radius;	}
-
-   double getX1Centroid()  { return midPoint->getX1Coordinate();}
-   double getX1Minimum()   { return midPoint->getX1Coordinate()-radius;}
-   double getX1Maximum()   { return midPoint->getX1Coordinate()+radius;}
-   double getX2Centroid()  { return midPoint->getX2Coordinate();}
-   double getX2Minimum()   { return midPoint->getX2Coordinate()-radius;}
-   double getX2Maximum()   { return midPoint->getX2Coordinate()+radius;}
-   double getX3Centroid()  { return midPoint->getX3Coordinate();}
-   double getX3Minimum()   { return midPoint->getX3Coordinate()-radius;}
-   double getX3Maximum()   { return midPoint->getX3Coordinate()+radius;}
-
-   void setCenterX1Coordinate(const double& value);
-   void setCenterX2Coordinate(const double& value);
-   void setCenterX3Coordinate(const double& value);
-   void setCenterCoordinates(const double& x1, const double& x2, const double& x3);
-   virtual void setCenterCoordinates(const UbTupleDouble3& position);
-   void setRadius(const double& radius);
-
-   GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2);
-   double getDistance(GbPoint3D* p); 
-   double getDistance(const double& x1p, const double& x2p, const double& x3p);
-
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3);
-   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary);
-
-   bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   double getCellVolumeInsideGbObject3DHelperFunction(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-
-   std::vector<GbTriangle3D*> getSurfaceTriangleSet();
-   void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles);
-
-   bool hasRaytracing() { return true; }
-   /*|r| must be 1! einheitsvector!!*/
-   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
-
-   bool hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction);
-
-	std::string toString();
-
-   ObObjectCreator* getCreator();
-   void write(UbFileOutput* out);
-   void read(UbFileInput* in);       
-
-   void translate(const double& x1, const double& x2, const double& x3) 
-   {
-      this->midPoint->translate(x1, x2, x3); 
-      this->notifyObserversObjectChanged();
-   }
-   void rotate(const double& rx1, const double& rx2, const double& rx3) {/* rotation makes no sense*/ }
-   void scale(const double& sx1, const double& sx2, const double& sx3) 
-   { 
-      this->radius *= sx1; 
-      this->notifyObserversObjectChanged();
-   }
-
-   void transform(const double matrix[4][4]);
-
-   TRIANGULATIONMODE getTriangulationMode() {return triangulationMode;}
-   void setTriangulationMode(TRIANGULATIONMODE mode) { this->triangulationMode = mode; }
-   
-   //virtuelle Methoden von UbObserver
-   void objectChanged(UbObservable* changedObject)
-   {
-      this->notifyObserversObjectChanged();
-      //std::cout<<"GbSphere:objectChanged() - toDo-);";
-   }
-   void objectWillBeDeleted(UbObservable* objectForDeletion)
-   {
-	   throw UbException(UB_EXARGS,"not implemented");
-   }
-
-   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere, weil man eine
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void SF_SERIALIZE(Archive & ar)
-   {
-      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
-      ar & midPoint;
-      ar & radius;
-      ar & triangulationMode;
-   }
-#endif //CAB_RCF
-#ifdef CAB_CTL
-   ctl::oStream &write(ctl::oStream &os) const
-   { 
-      midPoint->write(os);
-      return os<<radius; 
-   }
-   ctl::iStream &read(ctl::iStream &is) 
-   { 
-      midPoint->read(is);
-      return is>>radius;
-   }
-#endif //CAB_CTL
-
-private:
-   GbPoint3D* midPoint;
-   double radius;  // Radius des Kreises
-   TRIANGULATIONMODE triangulationMode;
-};
-
-#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
-   #if CAB_RCF <= 903 
-      SF_SERIALIZE_ENUM(GbSphere3D::TRIANGULATIONMODE) //bei klassen ausserhalb der klasse;-)
-   #endif
-   UB_AUTO_RUN_NAMED(   SF::registerType<GbSphere3D>("GbSphere3D")             , SF_GbSphere3D     );
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbSphere3D >()), SF_GbSphere3D_BD1 );
-#endif //RCF_USE_SF_SERIALIZATION
-
-#endif //GBSPHERE3D_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBSPHERE3D_H
+#define GBSPHERE3D_H
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+#ifdef CAB_CTL
+   #include <ctl.h>
+#endif //CAB_CTL
+
+#include <vector>
+#include <cmath>
+
+#include <basics/utilities/UbObserver.h>
+
+#include <numerics/geometry3d/GbObject3D.h>
+#include <numerics/geometry3d/GbPoint3D.h>
+
+#include <PointerDefinitions.h>
+
+class GbLine3D;
+class GbTriangle3D;
+class GbObject3DCreator;
+
+class GbSphere3D : public GbObject3D, public UbObserver
+{                                              
+public:
+   enum TRIANGULATIONMODE { CUBOIDPROJECTION ,RAYPROJECTION };
+   
+   //////////////////////////////////////////////////////////////////////////
+   // Konstruktoren
+   GbSphere3D(); 
+   GbSphere3D(const double& x1,const double& x2, const double& x3, const double& radius);            
+   GbSphere3D(const GbSphere3D& sphere);            
+   GbSphere3D(GbSphere3D* sphere); //<-unschoen!
+   
+   ~GbSphere3D();
+
+   GbSphere3D* clone() { return new GbSphere3D(*this);}
+   void finalize();
+
+
+   bool intersects(SPtr<GbSphere3D> sphere);
+
+   double getRadius() const	{	return this->radius;	}
+
+   double getX1Centroid()  { return midPoint->getX1Coordinate();}
+   double getX1Minimum()   { return midPoint->getX1Coordinate()-radius;}
+   double getX1Maximum()   { return midPoint->getX1Coordinate()+radius;}
+   double getX2Centroid()  { return midPoint->getX2Coordinate();}
+   double getX2Minimum()   { return midPoint->getX2Coordinate()-radius;}
+   double getX2Maximum()   { return midPoint->getX2Coordinate()+radius;}
+   double getX3Centroid()  { return midPoint->getX3Coordinate();}
+   double getX3Minimum()   { return midPoint->getX3Coordinate()-radius;}
+   double getX3Maximum()   { return midPoint->getX3Coordinate()+radius;}
+
+   void setCenterX1Coordinate(const double& value);
+   void setCenterX2Coordinate(const double& value);
+   void setCenterX3Coordinate(const double& value);
+   void setCenterCoordinates(const double& x1, const double& x2, const double& x3);
+   virtual void setCenterCoordinates(const UbTupleDouble3& position);
+   void setRadius(const double& radius);
+
+   GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2);
+   double getDistance(GbPoint3D* p); 
+   double getDistance(const double& x1p, const double& x2p, const double& x3p);
+
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3);
+   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary);
+
+   bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   double getCellVolumeInsideGbObject3DHelperFunction(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+
+   std::vector<GbTriangle3D*> getSurfaceTriangleSet();
+   void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles);
+
+   bool hasRaytracing() { return true; }
+   /*|r| must be 1! einheitsvector!!*/
+   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
+
+   bool hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction);
+
+	std::string toString();
+
+   ObObjectCreator* getCreator();
+   void write(UbFileOutput* out);
+   void read(UbFileInput* in);       
+
+   void translate(const double& x1, const double& x2, const double& x3) 
+   {
+      this->midPoint->translate(x1, x2, x3); 
+      this->notifyObserversObjectChanged();
+   }
+   void rotate(const double& rx1, const double& rx2, const double& rx3) {/* rotation makes no sense*/ }
+   void scale(const double& sx1, const double& sx2, const double& sx3) 
+   { 
+      this->radius *= sx1; 
+      this->notifyObserversObjectChanged();
+   }
+
+   void transform(const double matrix[4][4]);
+
+   TRIANGULATIONMODE getTriangulationMode() {return triangulationMode;}
+   void setTriangulationMode(TRIANGULATIONMODE mode) { this->triangulationMode = mode; }
+   
+   //virtuelle Methoden von UbObserver
+   void objectChanged(UbObservable* changedObject)
+   {
+      this->notifyObserversObjectChanged();
+      //std::cout<<"GbSphere:objectChanged() - toDo-);";
+   }
+   void objectWillBeDeleted(UbObservable* objectForDeletion)
+   {
+	   throw UbException(UB_EXARGS,"not implemented");
+   }
+
+   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere, weil man eine
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void SF_SERIALIZE(Archive & ar)
+   {
+      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
+      ar & midPoint;
+      ar & radius;
+      ar & triangulationMode;
+   }
+#endif //CAB_RCF
+#ifdef CAB_CTL
+   ctl::oStream &write(ctl::oStream &os) const
+   { 
+      midPoint->write(os);
+      return os<<radius; 
+   }
+   ctl::iStream &read(ctl::iStream &is) 
+   { 
+      midPoint->read(is);
+      return is>>radius;
+   }
+#endif //CAB_CTL
+
+private:
+   GbPoint3D* midPoint;
+   double radius;  // Radius des Kreises
+   TRIANGULATIONMODE triangulationMode;
+};
+
+#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
+   #if CAB_RCF <= 903 
+      SF_SERIALIZE_ENUM(GbSphere3D::TRIANGULATIONMODE) //bei klassen ausserhalb der klasse;-)
+   #endif
+   UB_AUTO_RUN_NAMED(   SF::registerType<GbSphere3D>("GbSphere3D")             , SF_GbSphere3D     );
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbSphere3D >()), SF_GbSphere3D_BD1 );
+#endif //RCF_USE_SF_SERIALIZATION
+
+#endif //GBSPHERE3D_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbSystem3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbSystem3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbSystem3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbSystem3D.cpp
index 529d3222c8b643631e6e33fe2499c5df873313e2..7a224f8bf343a6f9ba593729f59776219800cef3 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbSystem3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbSystem3D.cpp
@@ -1,1187 +1,1187 @@
-#include <numerics/geometry3d/GbSystem3D.h>
-
-#include <numerics/geometry3d/GbPolygon3D.h>
-#include <numerics/geometry3d/GbCuboid3D.h>
-
-using namespace std;
-
-double GbSystem3D::getDistance(const GbPoint3D& p11, const GbPoint3D& p12)
-{
-   double dx1 = p11.x1 - p12.x1;
-   double dx2 = p11.x2 - p12.x2;
-   double dx3 = p11.x3 - p12.x3;
-   return std::sqrt(dx1*dx1+dx2*dx2+dx3*dx3);
-}
-
-GbPoint3D* GbSystem3D::calculateIntersectionPoint3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22)
-{
-   if(UbMath::less2(p11.x1, p12.x1, p21.x1, p22.x1))    return NULL;
-   if(UbMath::less2(p11.x2, p12.x2, p21.x2, p22.x2))    return NULL;
-   if(UbMath::less2(p11.x3, p12.x3, p21.x3, p22.x3))    return NULL;
-   if(UbMath::greater2(p11.x1, p12.x1, p21.x1, p22.x1)) return NULL;
-   if(UbMath::greater2(p11.x2, p12.x2, p21.x2, p22.x2)) return NULL;
-   if(UbMath::greater2(p11.x3, p12.x3, p21.x3, p22.x3)) return NULL;
-
-   double a11 = p12.x1 - p11.x1;                       //..HOW PARAMETERS ARE USED.........
-   double a12 = p12.x2 - p11.x2;                       //
-   double a13 = p12.x3 - p11.x3;                       //  p11 and p12 represent line 1
-   double a21 = p21.x1 - p22.x1;                       //  p21 and p22 represent line 2
-   double a22 = p21.x2 - p22.x2;                       //
-   double a23 = p21.x3 - p22.x3;                       //..................................
-   double b1  = p21.x1 - p11.x1;
-   double b2  = p21.x2 - p11.x2;
-   double b3  = p21.x3 - p11.x3;
-   double d1  = a11*a22 - a12*a21;
-   double d2  = a11*a23 - a13*a21;
-   double d3  = a12*a23 - a13*a22;
-   double t;
-
-   if(UbMath::zero(d1) && UbMath::zero(d2) && UbMath::zero(d3)) return NULL;
-   if(UbMath::zero(d1))
-   {
-   	if(!UbMath::zero(d2)) t = (a23*b1-a21*b3)/d2;
-      else          t = (a23*b2-a22*b3)/d3;
-   }
-   else if(UbMath::zero(d2))
-   {
-   	if(!UbMath::zero(d1)) t = (a22*b1-a21*b2)/d1;
-      else          t = (a23*b2-a22*b3)/d3;
-   }
-   else if(UbMath::zero(d3))
-   {
-   	if(!UbMath::zero(d1)) t = (a22*b1-a21*b2)/d1;
-      else          t = (a23*b1-a21*b3)/d2;
-   }
-   else return NULL;
-
-   double x1 = p11.x1 + t*a11;
-   double x2 = p11.x2 + t*a12;
-   double x3 = p11.x3 + t*a13;
-
-   if(UbMath::inClosedInterval(x1, p11.x1, p12.x1) && UbMath::inClosedInterval(x1, p21.x1, p22.x1) &&
-      UbMath::inClosedInterval(x2, p11.x2, p12.x2) && UbMath::inClosedInterval(x2, p21.x2, p22.x2) &&
-      UbMath::inClosedInterval(x3, p11.x3, p12.x3) && UbMath::inClosedInterval(x3, p21.x3, p22.x3)    ) return new GbPoint3D(x1, x2, x3);
-
-   return NULL;
-}
-/*=================================================================*/
-//Line1: p11 -> p12 and Line2: p21 -> p22
-bool GbSystem3D::hasIntersectionPoint3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22)
-{
-   if(UbMath::less2(p11.x1, p12.x1, p21.x1, p22.x1))    return false; 
-   if(UbMath::less2(p11.x2, p12.x2, p21.x2, p22.x2))    return false; 
-   if(UbMath::less2(p11.x3, p12.x3, p21.x3, p22.x3))    return false; 
-   if(UbMath::greater2(p11.x1, p12.x1, p21.x1, p22.x1)) return false; 
-   if(UbMath::greater2(p11.x2, p12.x2, p21.x2, p22.x2)) return false; 
-   if(UbMath::greater2(p11.x3, p12.x3, p21.x3, p22.x3)) return false; 
-
-   double a11 = p12.x1 - p11.x1;                       //..HOW PARAMETERS ARE USED.........
-   double a12 = p12.x2 - p11.x2;                       //
-   double a13 = p12.x3 - p11.x3;                       //  p11 and p12 represent line 1
-   double a21 = p21.x1 - p22.x1;                       //  p21 and p22 represent line 2
-   double a22 = p21.x2 - p22.x2;                       //
-   double a23 = p21.x3 - p22.x3;                       //..................................
-   double b1  = p21.x1 - p11.x1;
-   double b2  = p21.x2 - p11.x2;
-   double b3  = p21.x3 - p11.x3;
-   double d1  = a11*a22 - a12*a21;
-   double d2  = a11*a23 - a13*a21;
-   double d3  = a12*a23 - a13*a22;
-   double t;
-
-   if(UbMath::zero(d1) && UbMath::zero(d2) && UbMath::zero(d3)) return false; 
-   if(UbMath::zero(d1))
-   {
-      if(!UbMath::zero(d2)) t = (a23*b1-a21*b3)/d2;
-      else          t = (a23*b2-a22*b3)/d3;
-   }
-   else if(UbMath::zero(d2))
-   {
-      if(!UbMath::zero(d1)) t = (a22*b1-a21*b2)/d1;
-	   else          t = (a23*b2-a22*b3)/d3;
-   }
-   else if(UbMath::zero(d3))
-   {
-      if(!UbMath::zero(d1)) t = (a22*b1-a21*b2)/d1;
-      else          t = (a23*b1-a21*b3)/d2;
-   }
-   else return false; 
-
-   double x1 = p11.x1 + t*a11;
-   double x2 = p11.x2 + t*a12;
-   double x3 = p11.x3 + t*a13;
-
-   if(UbMath::inClosedInterval(x1, p11.x1, p12.x1) && UbMath::inClosedInterval(x1, p21.x1, p22.x1) &&
-	   UbMath::inClosedInterval(x2, p11.x2, p12.x2) && UbMath::inClosedInterval(x2, p21.x2, p22.x2) &&
-	   UbMath::inClosedInterval(x3, p11.x3, p12.x3) && UbMath::inClosedInterval(x3, p21.x3, p22.x3)) return true; 
-   return false; 
-}
- /*======================================================================*/
-//
-//
-//   /*======================================================================*/
-//   /*  Private Methoden (Parallelism)                                      */
-//   /*                                                                      */
-bool GbSystem3D::isParallelIn3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22)
-{
-   double a11 = p12.x1 - p11.x1;                       //..HOW PARAMETERS ARE USED.........
-   double a12 = p12.x2 - p11.x2;                       //
-   double a13 = p12.x3 - p11.x3;                       //  p11 and p12 represent line 1
-   double a21 = p21.x1 - p22.x1;                       //  p21 and p22 represent line 2
-   double a22 = p21.x2 - p22.x2;                       //
-   double a23 = p21.x3 - p22.x3;                       //..................................
-
-   return (UbMath::zero(a11*a22 - a12*a21) && UbMath::zero(a11*a23 - a13*a21) && UbMath::zero(a12*a23 - a13*a22));
-}
-/*======================================================================*/
-
-
-/*======================================================================*/
-/*  General Clipping Methods                                            */
-//......................................................................*/
-//
-//  Method       Parameters                                       Result      Remarks
-//  ---------    ---------------------------------------------    ---------   -------------------
-//  clip###2D   (2D objects to be clipped, 2+2 clipping values)   2D object   clipping x1, x2
-//  clip###3D   (3D objects to be clipped, 2+2 clipping values)   3D object   clipping x1, x2
-//  clip###3D   (3D objects to be clipped, 3+3 clipping values)   3D object   clipping x1, x2, x3
-//  clip###3D   (3D objects to be clipped, 1+1 clipping values)   3D object   clipping x3
-//
-/*======================================================================*/
-/*  Private Methoden (Clipping Lines)                                   */
-/*                                                                      */
-GbLine3D* GbSystem3D::createClipLine3D(GbPoint3D &pA, GbPoint3D &pB, double x1a, double x2a, double x3a, double x1b, double x2b, double x3b)
-{
-   GbPoint3D *p1 = new GbPoint3D(pA);
-   GbPoint3D *p2 = new GbPoint3D(pB);
-
-   if(UbMath::greater(x1a, x1b)) { double x1 = x1a; x1a = x1b; x1b = x1; }
-   if(UbMath::greater(x2a, x2b)) { double x2 = x2a; x2a = x2b; x2b = x2; }
-   if(UbMath::greater(x3a, x3b)) { double x3 = x3a; x3a = x3b; x3b = x3; }
-
-   double f;
-
-   /*-------------------------------------------------------------------*/
-   /*  Schneiden an vorderer Kante                                      */
-   /*                                                                   */
-   if(UbMath::less(p1->x3, x3a))
-   {
-      if(UbMath::less(p2->x3, x3a)) { delete p1; delete p2; return NULL; }
-
-      f       = (x3a-p1->x3)/(p1->x3-p2->x3);
-      p1->x1 += (p1->x1-p2->x1)*f;
-      p1->x2 += (p1->x2-p2->x2)*f;
-      p1->x3  = x3a;
-   }
-   else if(UbMath::less(p2->x3, x3a))
-   {
-      f      = (x3a-p2->x3)/(p2->x3-p1->x3);
-      p2->x1 += (p2->x1-p1->x1)*f;
-      p2->x2 += (p2->x2-p1->x2)*f;
-      p2->x3  = x3a;
-   }     
-   /*-------------------------------------------------------------------*/
-   /*  Schneiden an unterer Kante                                       */
-   /*                                                                   */
-   if(UbMath::less(p1->x2, x2a))
-   {
-      if(UbMath::less(p2->x2, x2a)) { delete p1; delete p2; return NULL;
-      }
-
-      f      = (x2a-p1->x2)/(p1->x2-p2->x2);
-      p1->x1 += (p1->x1-p2->x1)*f;
-      p1->x3 += (p1->x3-p2->x3)*f;
-      p1->x2  = x2a;
-   }
-   else if(UbMath::less(p2->x2, x2a))
-   {
-      f      = (x2a-p2->x2)/(p2->x2-p1->x2);
-      p2->x1 += (p2->x1-p1->x1)*f;
-      p2->x3 += (p2->x3-p1->x3)*f;
-      p2->x2  = x2a;
-   }
-   /*-------------------------------------------------------------------*/
-   /*  Schneiden an rechter Kante                                       */
-   /*                                                                   */
-   if(UbMath::greater(p1->x1, x1b))
-   {
-      if(UbMath::greater(p2->x1, x1b))  { delete p1;delete p2; return NULL;}
-
-      f      = (x1b-p1->x1)/(p1->x1-p2->x1);
-      p1->x2 += (p1->x2-p2->x2)*f;
-      p1->x3 += (p1->x3-p2->x3)*f;
-      p1->x1  = x1b;
-   }
-   else if(UbMath::greater(p2->x1, x1b))
-   {
-      f      = (x1b-p2->x1)/(p2->x1-p1->x1);
-      p2->x2 += (p2->x2-p1->x2)*f;
-      p2->x3 += (p2->x3-p1->x3)*f;
-      p2->x1  = x1b;
-   }
-   /*-------------------------------------------------------------------*/
-   /*  Schneiden an hinterer Kante                                      */
-   /*                                                                   */
-   if(UbMath::greater(p1->x3, x3b))
-   {
-      if(UbMath::greater(p2->x3, x3b))  { delete p1;delete p2; return NULL;}
-
-      f      = (x3b-p1->x3)/(p1->x3-p2->x3);
-      p1->x1 += (p1->x1-p2->x1)*f;
-      p1->x2 += (p1->x2-p2->x2)*f;
-      p1->x3  = x3b;
-   }
-   else if(UbMath::greater(p2->x3, x3b))
-   {
-      f      = (x3b-p2->x3)/(p2->x3-p1->x3);
-      p2->x1 += (p2->x1-p1->x1)*f;
-      p2->x2 += (p2->x2-p1->x2)*f;
-      p2->x3  = x3b;
-   }
-   /*-------------------------------------------------------------------*/
-   /*  Schneiden an oberer Kante                                        */
-   /*                                                                   */
-   if(UbMath::greater(p1->x2, x2b))
-   {
-      if(UbMath::greater(p2->x2, x2b))  { delete p1;delete p2; return NULL;}
-
-      f      = (x2b-p1->x2)/(p1->x2-p2->x2);
-      p1->x1 += (p1->x1-p2->x1)*f;
-      p1->x3 += (p1->x3-p2->x3)*f;
-      p1->x2  = x2b;
-   }
-   else if(UbMath::greater(p2->x2, x2b))
-   {
-      f      = (x2b-p2->x2)/(p2->x2-p1->x2);
-      p2->x1 += (p2->x1-p1->x1)*f;
-      p2->x3 += (p2->x3-p1->x3)*f;
-      p2->x2  = x2b;
-   }
-   /*-------------------------------------------------------------------*/
-   /*  Schneiden an linker Kante                                        */
-   /*                                                                   */
-   if(UbMath::less(p1->x1, x1a))
-   {
-      if(UbMath::less(p2->x1, x1a))  { delete p1;delete p2; return NULL;}
-
-      f      = (x1a-p1->x1)/(p1->x1-p2->x1);
-      p1->x2 += (p1->x2-p2->x2)*f;
-      p1->x3 += (p1->x3-p2->x3)*f;
-      p1->x1  = x1a;
-   }
-   else if(UbMath::less(p2->x1, x1a))
-   {
-      f      = (x1a-p2->x1)/(p2->x1-p1->x1);
-      p2->x2 += (p2->x2-p1->x2)*f;
-      p2->x3 += (p2->x3-p1->x3)*f;
-      p2->x1  = x1a;
-   }
-   /*-------------------------------------------------------------------*/
-   return new GbLine3D(p1, p2);
-}
-//   /*======================================================================*/
-//   /*  Private Methoden (Clipping Rectangles)                              */
-//   /*                                                                      */
-//   final static GbPolygon3D clipPolygon3D(GbPoint3D points[], double x11, double x12, double x21, double x22)
-//   {
-//      GbPoint3D last = null;
-//      PointSet3 ps   = new PointSet3(points);
-//      boolean   flag = false;
-//      int       n    = points.length;
-//      int       i;
-//      double    f;
-//
-//      if(n == 0)              return(null);
-//      if(greater(x11, x21)) { double ax = x11; x11 = x21; x21 = ax; }
-//      if(greater(x12, x22)) { double ay = x12; x12 = x22; x22 = ay; }
-//
-//      /*-------------------------------------------------------------------*/
-//      /*  Schneiden an unterer Kante                                       */
-//      /*                                                                   */
-//      if(less(ps.getX2Minimum(), x12))
-//      {
-//	 ps.clear();
-//	 last = points[0];
-//	 if(less((*points)[0]->x2, x12)) flag = false;
-//	 else
-//	 {
-//	    ps.add(points[0]);
-//	    flag = true;
-//	 }
-//	 for(i=1; i<n; i++)
-//	 {
-//	    if(less((*points)[i]->x2, x12))
-//	    {
-//	       if(flag)
-//	       {
-//	          f = (x12-(*points)[i]->x2)/((*points)[i]->x2-last->x2);
-//	          ps.add(new GbPoint3D((*points)[i]->x1 + ((*points)[i]->x1-last->x1)*f, x12, (*points)[i]->x3 + ((*points)[i]->x3-last->x3)*f));
-//	       }
-//	       flag = false;
-//	    }
-//	    else
-//	    {
-//	       if(!flag)
-//	       {
-//	          f = (x12-(*points)[i]->x2)/((*points)[i]->x2-last->x2);
-//	          ps.add(new GbPoint3D((*points)[i]->x1 + ((*points)[i]->x1-last->x1)*f, x12, (*points)[i]->x3 + ((*points)[i]->x3-last->x3)*f));
-//	       }
-//	       ps.add((*points)[i]);
-//	       flag = true;
-//	    }
-//	    last = points[i];
-//	 }
-//	 if(!((less(points[0].x2, x12)) ^ flag))
-//	 {
-//	    f = (x12-points[0].x2)/(points[0].x2-last->x2);
-//	    ps.add(new GbPoint3D(points[0].x1 + (points[0].x1-last->x1)*f, x12, points[0].x3 + (points[0].x3-last->x3)*f));
-//	 }
-//
-//	 points = ps.getPoints();
-//	 n      = points.length;
-//
-//	 if(n == 0) return(null);
-//      }
-//      /*-------------------------------------------------------------------*/
-//      /*  Schneiden an rechter Kante                                       */
-//      /*                                                                   */
-//      if(greater(ps.getX1Maximum(), x21))
-//      {
-//	 ps.clear();
-//	 last = points[0];
-//	 if(greater(points[0].x1, x21)) flag = false;
-//	 else
-//	 {
-//	    ps.add(points[0]);
-//	    flag = true;
-//	 }
-//	 for(i=1; i<n; i++)
-//	 {
-//	    if(greater((*points)[i]->x1, x21))
-//	    {
-//	       if(flag)
-//	       {
-//	          f = (x21-(*points)[i]->x1)/((*points)[i]->x1-last->x1);
-//	          ps.add(new GbPoint3D(x21, (*points)[i]->x2 + ((*points)[i]->x2-last->x2)*f, (*points)[i]->x3 + ((*points)[i]->x3-last->x3)*f));
-//	       }
-//	       flag = false;
-//	    }
-//	    else
-//	    {
-//	       if(!flag)
-//	       {
-//	          f = (x21-(*points)[i]->x1)/((*points)[i]->x1-last->x1);
-//	          ps.add(new GbPoint3D(x21, (*points)[i]->x2 + ((*points)[i]->x2-last->x2)*f, (*points)[i]->x3 + ((*points)[i]->x3-last->x3)*f));
-//	       }
-//	       ps.add(points[i]);
-//	       flag = true;
-//	    }
-//	    last = points[i];
-//	 }
-//	 if(!((greater(points[0].x1, x21)) ^ flag))
-//	 {
-//	    f = (x21-points[0].x1)/(points[0].x1-last.x1);
-//	    ps.add(new GbPoint3D(x21, points[0].x2 + (points[0].x2-last.x2)*f, points[0].x3 + (points[0].x3-last.x3)*f));
-//	 }
-//
-//	 points = ps.getPoints();
-//	 n      = points.length;
-//
-//	 if(n == 0) return(null);
-//      }
-//      /*-------------------------------------------------------------------*/
-//      /*  Schneiden an oberer Kante                                        */
-//      /*                                                                   */
-//      if(greater(ps.getX2Maximum(), x22))
-//      {
-//	 ps.clear();
-//	 last = points[0];
-//	 if(greater(points[0].x2, x22)) flag = false;
-//	 else
-//	 {
-//	    ps.add(points[0]);
-//	    flag = true;
-//	 }
-//	 for(i=1; i<n; i++)
-//	 {
-//	    if(greater((*points)[i]->x2, x22))
-//	    {
-//	       if(flag)
-//	       {
-//	          f = (x22-(*points)[i]->x2)/(points[i].x2-last.x2);
-//	          ps.add(new GbPoint3D(points[i].x1 + (points[i].x1-last.x1)*f, x22, points[i].x3 + (points[i].x3-last.x3)*f));
-//	       }
-//	       flag = false;
-//	    }
-//	    else
-//	    {
-//	       if(!flag)
-//	       {
-//	          f = (x22-points[i].x2)/(points[i].x2-last.x2);
-//	          ps.add(new GbPoint3D(points[i].x1 + (points[i].x1-last.x1)*f, x22, points[i].x3 + (points[i].x3-last.x3)*f));
-//	       }
-//	       ps.add(points[i]);
-//	       flag = true;
-//	    }
-//	    last = points[i];
-//	 }
-//	 if(!((greater(points[0].x2, x22)) ^ flag))
-//	 {
-//	    f = (x22-points[0].x2)/(points[0].x2-last.x2);
-//	    ps.add(new GbPoint3D(points[0].x1 + (points[0].x1-last.x1)*f, x22, points[0].x3 + (points[0].x3-last.x3)*f));
-//	 }
-//
-//	 points = ps.getPoints();
-//	 n      = points.length;
-//
-//	 if(n == 0) return(null);
-//      }
-//      /*-------------------------------------------------------------------*/
-//      /*  Schneiden an linker Kante                                        */
-//      /*                                                                   */
-//      if(less(ps.getX1Minimum(), x11))
-//      {
-//	 ps.clear();
-//	 last = points[0];
-//	 if(less(points[0].x1, x11)) flag = false;
-//	 else
-//	 {
-//	    ps.add(points[0]);
-//	    flag = true;
-//	 }
-//	 for(i=1; i<n; i++)
-//	 {
-//	    if(less(points[i].x1, x11))
-//	    {
-//	       if(flag)
-//	       {
-//	          f = (x11-points[i].x1)/(points[i].x1-last.x1);
-//	          ps.add(new GbPoint3D(x11, points[i].x2 + (points[i].x2-last.x2)*f, points[i].x3 + (points[i].x3-last.x3)*f));
-//	       }
-//	       flag = false;
-//	    }
-//	    else
-//	    {
-//	       if(!flag)
-//	       {
-//	          f = (x11-points[i].x1)/(points[i].x1-last.x1);
-//	          ps.add(new GbPoint3D(x11, points[i].x2 + (points[i].x2-last.x2)*f, points[i].x3 + (points[i].x3-last.x3)*f));
-//	       }
-//	       ps.add(points[i]);
-//	       flag = true;
-//	    }
-//	    last = points[i];
-//	 }
-//	 if(!((less(points[0].x1, x11)) ^ flag))
-//	 {
-//	    f = (x11-points[0].x1)/(points[0].x1-last.x1);
-//	    ps.add(new GbPoint3D(x11, points[0].x2 + (points[0].x2-last.x2)*f, points[0].x3 + (points[0].x3-last.x3)*f));
-//	 }
-//
-//	 points = ps.getPoints();
-//	 n      = points.length;
-//
-//	 if(n == 0) return(null);
-//      }
-//      /*-------------------------------------------------------------------*/
-//      GbPolygon3D polygon = new GbPolygon3D(points);
-//
-//      if(n > 2)
-//      {
-//	 for(i=2; i<n; i++) if(zero(i_TA(points[i-2], points[i-1], points[i]))) polygon.deletePoint(points[i-1]);
-//	 if(zero(i_TA(points[n-2], points[n-1], points[0]))) polygon.deletePoint(points[n-1]);
-//	 if(zero(i_TA(points[n-1], points[0],   points[1]))) polygon.deletePoint(points[0]);
-//      }
-//      return(polygon);
-//   }
-//   final static GbPolygon3D clipPolygon3D(GbPoint3D points[], double x13, double x23)
-//   {
-//      GbPoint3D last = null;
-//      PointSet3 ps   = new PointSet3(points);
-//      boolean   flag = false;
-//      int       n    = points.length;
-//      int       i;
-//      double    f;
-//
-//      if(n == 0)              return(null);
-//      if(greater(x13, x23)) { double az = x13; x13 = x23; x23 = az; }
-//
-//      /*-------------------------------------------------------------------*/
-//      /*  Schneiden an vorderer Kante                                      */
-//      /*                                                                   */
-//      if(less(ps.getX3Minimum(), x13))
-//      {
-//	 ps.clear();
-//	 last = points[0];
-//	 if(less(points[0].x3, x13)) flag = false;
-//	 else
-//	 {
-//	    ps.add(points[0]);
-//	    flag = true;
-//	 }
-//	 for(i=1; i<n; i++)
-//	 {
-//	    if(less(points[i].x3, x13))
-//	    {
-//	       if(flag)
-//	       {
-//	          f = (x13-points[i].x3)/(points[i].x3-last.x3);
-//	          ps.add(new GbPoint3D(points[i].x1 + (points[i].x1-last.x1)*f, points[i].x2 + (points[i].x2-last.x2)*f, x13));
-//	       }
-//	       flag = false;
-//	    }
-//	    else
-//	    {
-//	       if(!flag)
-//	       {
-//	          f = (x13-points[i].x3)/(points[i].x3-last.x3);
-//	          ps.add(new GbPoint3D(points[i].x1 + (points[i].x1-last.x1)*f, points[i].x2 + (points[i].x2-last.x2)*f, x13));
-//	       }
-//	       ps.add(points[i]);
-//	       flag = true;
-//	    }
-//	    last = points[i];
-//	 }
-//	 if(!((less(points[0].x3, x13)) ^ flag))
-//	 {
-//	    f = (x13-points[0].x3)/(points[0].x3-last.x3);
-//	    ps.add(new GbPoint3D(points[0].x1 + (points[0].x1-last.x1)*f, points[0].x2 + (points[0].x2-last.x2)*f, x13));
-//	 }
-//
-//	 points = ps.getPoints();
-//	 n      = points.length;
-//
-//	 if(n == 0) return(null);
-//      }
-//      /*-------------------------------------------------------------------*/
-//      /*  Schneiden an hinterer Kante                                      */
-//      /*                                                                   */
-//      if(greater(ps.getX3Maximum(), x23))
-//      {
-//	 ps.clear();
-//	 last = points[0];
-//	 if(greater(points[0].x3, x23)) flag = false;
-//	 else
-//	 {
-//	    ps.add(points[0]);
-//	    flag = true;
-//	 }
-//	 for(i=1; i<n; i++)
-//	 {
-//	    if(greater(points[i].x3, x23))
-//	    {
-//	       if(flag)
-//	       {
-//	          f = (x23-points[i].x3)/(points[i].x3-last.x3);
-//	          ps.add(new GbPoint3D(points[i].x1 + (points[i].x1-last.x1)*f, points[i].x2 + (points[i].x2-last.x2)*f, x23));
-//	       }
-//	       flag = false;
-//	    }
-//	    else
-//	    {
-//	       if(!flag)
-//	       {
-//	          f = (x23-points[i].x3)/(points[i].x3-last.x3);
-//	          ps.add(new GbPoint3D(points[i].x1 + ((*points)[i]->x1-last.x1)*f, (*points)[i]->x2 + ((*points)[i]->x2-last.x2)*f, x23));
-//	       }
-//	       ps.add(points[i]);
-//	       flag = true;
-//	    }
-//	    last = points[i];
-//	 }
-//	 if(!((greater(points[0].x3, x23)) ^ flag))
-//	 {
-//	    f = (x23-points[0].x3)/(points[0].x3-last.x3);
-//	    ps.add(new GbPoint3D(points[0].x1 + (points[0].x1-last.x1)*f, points[0].x2 + (points[0].x2-last.x2)*f, x23));
-//	 }
-//
-//	 points = ps.getPoints();
-//	 n      = points.length;
-//
-//	 if(n == 0) return(null);
-//      }
-//      /*-------------------------------------------------------------------*/
-//      GbPolygon3D polygon = new GbPolygon3D(points);
-//
-//      return(polygon);
-//   }
-GbPolygon3D* GbSystem3D::clipPolygon3D(vector<GbPoint3D> points, double x11, double x12, double x13, double x21, double x22, double x23)
-{
-   GbPoint3D last;
-   PointSet3 ps(points);
-   bool   flag = false;
-   int    n    = (int)points.size();
-	int       i;
-   double    f;
-
-   if(n == 0)              return NULL;
-   if(UbMath::greater(x11, x21)) { double ax = x11; x11 = x21; x21 = ax; }
-   if(UbMath::greater(x12, x22)) { double ay = x12; x12 = x22; x22 = ay; }
-   if(UbMath::greater(x13, x23)) { double az = x13; x13 = x23; x23 = az; }
-
-   /*-------------------------------------------------------------------*/
-   /*  Schneiden an vorderer Kante                                      */
-   /*                                                                   */
-   if(UbMath::less(ps.getX3Minimum(), x13))
-   {
-		ps.clear();
-		last = (points)[0];
-		if(UbMath::less((points)[0].x3, x13)) flag = false;
-		else
-		{
-			ps.add((points)[0]);
-			flag = true;
-		}
-		for(i=1; i<n; i++)
-		{
-			if(UbMath::less((points)[i].x3, x13))
-			{
-				if(flag)
-				{
-					f = (x13-(points)[i].x3)/((points)[i].x3-last.x3);
-					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, (points)[i].x2 + ((points)[i].x2-last.x2)*f, x13));
-				}
-				flag = false;
-			}
-			else
-			{
-				if(!flag)
-				{
-					f = (x13-(points)[i].x3)/((points)[i].x3-last.x3);
-					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, (points)[i].x2 + ((points)[i].x2-last.x2)*f, x13));
-				}
-				ps.add((points)[i]);
-				flag = true;
-			}
-			last = (points)[i];
-		}
-		if(!((UbMath::less((points)[0].x3, x13)) ^ flag))
-		{
-			f = (x13-(points)[0].x3)/((points)[0].x3-last.x3);
-			ps.add(GbPoint3D((points)[0].x1 + ((points)[0].x1-last.x1)*f, (points)[0].x2 + ((points)[0].x2-last.x2)*f, x13));
-		}
-
-		points = ps.getPoints();
-		n      = (int)points.size();
-
-		if(n == 0) return NULL;
-   }
-	
-	/*-------------------------------------------------------------------*/
-   /*  Schneiden an unterer Kante                                       */
-   /*                                                                   */
-   if(UbMath::less(ps.getX2Minimum(), x12))
-   {
-		ps.clear();
-		last = (points)[0];
-		if(UbMath::less((points)[0].x2, x12)) flag = false;
-		else
-		{
-			ps.add((points)[0]);
-			flag = true;
-		}
-		for(i=1; i<n; i++)
-		{
-			if(UbMath::less((points)[i].x2, x12))
-			{
-				if(flag)
-				{
-					f = (x12-(points)[i].x2)/((points)[i].x2-last.x2);
-					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, x12, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
-				}
-				flag = false;
-			}
-		   else
-			{
-				if(!flag)
-				{
-					f = (x12-(points)[i].x2)/((points)[i].x2-last.x2);
-					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, x12, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
-				}
-				ps.add((points)[i]);
-				flag = true;
-			}
-			last = (points)[i];
-		}
-		if(!((UbMath::less((points)[0].x2, x12)) ^ flag))
-		{
-			f = (x12-(points)[0].x2)/((points)[0].x2-last.x2);
-			ps.add(GbPoint3D((points)[0].x1 + ((points)[0].x1-last.x1)*f, x12, (points)[0].x3 + ((points)[0].x3-last.x3)*f));
-		}
-
-		points = ps.getPoints();
-		n      = (int)points.size();
-
-		if(n == 0) return NULL;
-   }
-   /*-------------------------------------------------------------------*/
-   /*  Schneiden an rechter Kante                                       */
-   /*                                                                   */
-	
-	if(UbMath::greater(ps.getX1Maximum(), x21))
-   {
-		ps.clear();
-		last = (points)[0];
-		if(UbMath::greater((points)[0].x1, x21)) flag = false;
-		else
-		{
-			ps.add((points)[0]);
-			flag = true;
-		}
-		for(i=1; i<n; i++)
-		{
-			if(UbMath::greater((points)[i].x1, x21))
-			{
-				if(flag)
-				{
-					f = (x21-(points)[i].x1)/((points)[i].x1-last.x1);
-					ps.add(GbPoint3D(x21, (points)[i].x2 + ((points)[i].x2-last.x2)*f, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
-				}
-				flag = false;
-			}
-			else
-			{
-				if(!flag)
-				{
-					f = (x21-(points)[i].x1)/((points)[i].x1-last.x1);
-					ps.add(GbPoint3D(x21, (points)[i].x2 + ((points)[i].x2-last.x2)*f, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
-				}
-				ps.add((points)[i]);
-				flag = true;
-			}
-			last = (points)[i];
-		}
-		if(!((UbMath::greater((points)[0].x1, x21)) ^ flag))
-		{
-			f = (x21-(points)[0].x1)/((points)[0].x1-last.x1);
-			ps.add(GbPoint3D(x21, (points)[0].x2 + ((points)[0].x2-last.x2)*f, (points)[0].x3 + ((points)[0].x3-last.x3)*f));
-		}
-
-		points = ps.getPoints();
-		n      = (int)points.size();
-
-		if(n == 0) return NULL;
-   }
-   /*-------------------------------------------------------------------*/
-   /*  Schneiden an hinterer Kante                                      */
-   /*                                                                   */
-   if(UbMath::greater(ps.getX3Maximum(), x23))
-   {
-		ps.clear();
-		last = (points)[0];
-		if(UbMath::greater((points)[0].x3, x23)) flag = false;
-		else
-		{
-			ps.add((points)[0]);
-			flag = true;
-		}
-		for(i=1; i<n; i++)
-		{
-			if(UbMath::greater((points)[i].x3, x23))
-			{
-				if(flag)
-				{
-					f = (x23-(points)[i].x3)/((points)[i].x3-last.x3);
-					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, (points)[i].x2 + ((points)[i].x2-last.x2)*f, x23));
-				}
-				flag = false;
-			}
-			else
-			{
-				if(!flag)
-				{
-					f = (x23-(points)[i].x3)/((points)[i].x3-last.x3);
-					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, (points)[i].x2 + ((points)[i].x2-last.x2)*f, x23));
-				}
-				ps.add((points)[i]);
-				flag = true;
-			}
-			last = (points)[i];
-		}
-		if(!((UbMath::greater((points)[0].x3, x23)) ^ flag))
-		{
-			f = (x23-(points)[0].x3)/((points)[0].x3-last.x3);
-			ps.add(GbPoint3D((points)[0].x1 + ((points)[0].x1-last.x1)*f, (points)[0].x2 + ((points)[0].x2-last.x2)*f, x23));
-		}
-
-		points = ps.getPoints();
-		n      = (int)points.size();
-
-		if(n == 0) return NULL;
-	}
-   /*-------------------------------------------------------------------*/
-   /*  Schneiden an oberer Kante                                        */
-   /*                                                                   */
-
-	if(UbMath::greater(ps.getX2Maximum(), x22))
-   {
-		ps.clear();
-		last = (points)[0];
-		if(UbMath::greater((points)[0].x2, x22)) flag = false;
-		else
-		{
-			ps.add((points)[0]);
-			flag = true;
-		}
-		for(i=1; i<n; i++)
-		{
-			if(UbMath::greater((points)[i].x2, x22))
-			{
-				if(flag)
-				{
-					f = (x22-(points)[i].x2)/((points)[i].x2-last.x2);
-					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, x22, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
-				}
-				flag = false;
-			}
-			else
-			{
-				if(!flag)
-				{
-					f = (x22-(points)[i].x2)/((points)[i].x2-last.x2);
-					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, x22, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
-				}
-				ps.add((points)[i]);
-				flag = true;
-			}
-			last = (points)[i];
-		}
-		if(!((UbMath::greater((points)[0].x2, x22)) ^ flag))
-		{
-			f = (x22-(points)[0].x2)/((points)[0].x2-last.x2);
-			ps.add(GbPoint3D((points)[0].x1 + ((points)[0].x1-last.x1)*f, x22, (points)[0].x3 + ((points)[0].x3-last.x3)*f));
-		}
-
-		points = ps.getPoints();
-		n      = (int)points.size();
-
-		if(n == 0) return NULL;
-   }
-   /*-------------------------------------------------------------------*/
-   /*  Schneiden an linker Kante                                        */
-   /*                                                                   */
-	if(UbMath::less(ps.getX1Minimum(), x11))
-   {
-		ps.clear();
-		last = (points)[0];
-		if(UbMath::less((points)[0].x1, x11)) flag = false;
-		else
-		{
-			ps.add((points)[0]);
-			flag = true;
-		}
-		for(i=1; i<n; i++)
-		{
-			if(UbMath::less((points)[i].x1, x11))
-			{
-				if(flag)
-				{
-					f = (x11-(points)[i].x1)/((points)[i].x1-last.x1);
-					ps.add(GbPoint3D(x11, (points)[i].x2 + ((points)[i].x2-last.x2)*f, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
-
-				}
-				flag = false;
-			}
-			else
-			{
-				if(!flag)
-				{
-					f = (x11-(points)[i].x1)/((points)[i].x1-last.x1);
-					ps.add(GbPoint3D(x11, (points)[i].x2 + ((points)[i].x2-last.x2)*f, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
-				}
-				ps.add((points)[i]);
-				flag = true;
-			}
-			last = (points)[i];
-		}
-		if(!((UbMath::less((points)[0].x1, x11)) ^ flag))
-		{
-			f = (x11-(points)[0].x1)/((points)[0].x1-last.x1);
-			ps.add(GbPoint3D(x11, (points)[0].x2 + ((points)[0].x2-last.x2)*f, (points)[0].x3 + ((points)[0].x3-last.x3)*f));
-		}
-
-		points = ps.getPoints();
-		n      = (int)points.size();
-		
-		if(n == 0) return NULL;
-   }
-   /*-------------------------------------------------------------------*/
-	return new GbPolygon3D(points);
-}
-/*=========================================================================*/
-GbCuboid3D* GbSystem3D::clipRectangle3D(GbPoint3D& p1, GbPoint3D& p2, double x11, double x12, double x13, double x21, double x22, double x23)
-{
-   double r11 = p1.x1;
-   double r12 = p1.x2;
-   double r13 = p1.x3;
-   double r21 = p2.x1;
-   double r22 = p2.x2;
-   double r23 = p2.x3;
-
-   if(UbMath::greater(x11, x21)) { double ax = x11; x11 = x21; x21 = ax; }
-   if(UbMath::greater(x12, x22)) { double ay = x12; x12 = x22; x22 = ay; }
-   if(UbMath::greater(x13, x23)) { double az = x13; x13 = x23; x23 = az; }
-   if(UbMath::greater(r11, r21)) { double bx = r11; r11 = r21; r21 = bx; }
-   if(UbMath::greater(r12, r22)) { double by = r12; r12 = r22; r22 = by; }
-   if(UbMath::greater(r13, r23)) { double bz = r13; r13 = r23; r23 = bz; }
-
-   double m11 = UbMath::greater(x11, r11) ? x11 : r11;
-   double m12 = UbMath::greater(x12, r12) ? x12 : r12;
-   double m13 = UbMath::greater(x13, r13) ? x13 : r13;
-   double m21 = UbMath::greater(x21, r21) ? r21 : x21;
-   double m22 = UbMath::greater(x22, r22) ? r22 : x22;
-   double m23 = UbMath::greater(x23, r23) ? r23 : x23;
-
-   if(UbMath::lessEqual(m11, m21) && UbMath::lessEqual(m12, m22) && UbMath::lessEqual(m13, m23)) 
-      return(new GbCuboid3D(new GbPoint3D(m11, m12, m13), new GbPoint3D(m21, m22, m23)));
-   else  
-      return(NULL);
-}
-
-/*=========================================================================*/
-/*=========================================================================*/
-/*=========================================================================*/
-
-
-GbSystem3D::PointSet3::PointSet3(int n)
-{
-   this->init();
-   this->points.reserve(n); //reserves n elements! but the size of the vector ist still "0"
-}
-/*=======================================================*/
-GbSystem3D::PointSet3::PointSet3(const vector<GbPoint3D>& points)
-{
-   this->init();
-   this->add(points);
-}
-/*=======================================================*/
-void GbSystem3D::PointSet3::add(const GbPoint3D& point)
-{
-   //is point equal to last point in points then return
-   if(!this->points.empty() && point.equals(&this->points.back())) return;    //WHY???
-
-   //push point to vector
-   this->points.push_back(point);
-
-   this->consistent = false;
-}
-/*=======================================================*/
-void GbSystem3D::PointSet3::addUnequal(const GbPoint3D& point)
-{
-   if(this->containsEqual(point) > 0) return;
-   
-   this->points.push_back(point);
-   this->consistent = false;
-}
-/*=======================================================*/
-void GbSystem3D::PointSet3::add(const vector<GbPoint3D>& pointVector)
-{
-   for(int pos=0; pos<(int)pointVector.size(); pos++ )
-      this->points.push_back(pointVector[pos]);
-
-   this->consistent = false;
-}
-/*=======================================================*/
-void GbSystem3D::PointSet3::insert(const GbPoint3D& point, int index)
-{
-   if(index<0 || index>=(int)this->points.size()) 
-      throw UbException(UB_EXARGS,"index out of range");
-
-   //get iterator for index-position
-   vector<GbPoint3D>::iterator pos=this->points.begin();
-   for(int i=1; i<=index; i++) ++pos;
-
-   //insert point
-   this->points.insert(pos,point);
-
-   this->consistent    = false;
-}
-/*=======================================================*/
-//void delete(GbPoint3D point)
-//{
-//   for(int i=this.size-1; i>=0; i--) if(this.points[i] == point) this.delete(i);
-//}
-/*=======================================================*/
-//void delete(int index)
-//{
-//   int j = this.size - index - 1;
-//   if(j > 0) System.arraycopy(this.points, index + 1, this.points, index, j);
-//   this.consistent = false;
-//   this.size--;
-//}
-/*=======================================================*/
-void GbSystem3D::PointSet3::clear()
-{
-   //clears points (size==0 but capacity is the old one)
-   this->points.clear();
-   this->consistent = false;
-}
-/*=======================================================*/
-void GbSystem3D::PointSet3::clearAndTrim()
-{
-   //clears points (size==0 AND capacity==0)
-   this->points.resize(0);
-   this->consistent = false;
-}
-/*=======================================================*/
-double GbSystem3D::PointSet3::getX1Minimum()
-{
-   if(!this->consistent) this->calculateValues();
-   return this->x1min;
-}
-/*=======================================================*/
-double GbSystem3D::PointSet3::getX1Maximum()
-{
-   if(!this->consistent) this->calculateValues();
-   return this->x1max;
-}
-/*=======================================================*/
-double GbSystem3D::PointSet3::getX2Minimum()
-{
-   if(!this->consistent) this->calculateValues();
-   return this->x2min;
-}
-/*=======================================================*/
-double GbSystem3D::PointSet3::getX2Maximum()
-{
-   if(!this->consistent) this->calculateValues();
-   return this->x2max;
-}
-/*=======================================================*/
-double GbSystem3D::PointSet3::getX3Minimum()
-{
-   if(!this->consistent) this->calculateValues();
-   return this->x3min;
-}
-/*=======================================================*/
-double GbSystem3D::PointSet3::getX3Maximum()
-{
-   if(!this->consistent) this->calculateValues();
-   return this->x3max;
-}
-/*=======================================================*/
-int GbSystem3D::PointSet3::contains(GbPoint3D* point)
-{
-   //returns number of points which has the same adress (this should be 0 or 1!!!)
-   int n=0;
-
-   for(int pos=(int)this->points.size()-1; pos>=0; pos--) 
-      if(&this->points[pos]==point) n++;
-
-   return n;
-}
-/*=======================================================*/
-int GbSystem3D::PointSet3::containsEqual(const GbPoint3D& point)
-{
-   //returns number of points which have the same coordinates with point (could be 0,1 or even more)
-   int n=0;
-
-   for(int pos=(int)this->points.size()-1; pos>=0; pos--) 
-      if(this->points[pos].equals(&point)) n++;
-
-   return n;
-}
-/*=======================================================*/
-bool GbSystem3D::PointSet3::containsLine(GbPoint3D *point1, GbPoint3D *point2)
-{
-   //returns true if pointset has two in "this->points"vector  neighboured points 
-   //wich have the same adress as point1 or point2
-   vector<GbPoint3D>::iterator pos1=this->points.begin();
-   vector<GbPoint3D>::iterator pos2;
-
-   for(pos2=pos1++; pos2!=this->points.end(); ++pos2) 
-   {
-      if     (&(*pos1)==point1 && &(*pos2)==point2) return true;
-      else if(&(*pos1)==point2 && &(*pos2)==point1) return true;
-
-      pos1=pos2;
-   }
-
-   return false;
-}
-/*=======================================================*/
-bool GbSystem3D::PointSet3::containsEqualLine(const GbPoint3D& point1, const GbPoint3D& point2)
-{
-   //returns true if pointset has two in "this->points"vector  neighboured points 
-   //wich have the same coordinates as point1 or point2
-   vector<GbPoint3D>::iterator pos1=this->points.begin();
-   vector<GbPoint3D>::iterator pos2;
-
-   for(pos2=pos1++; pos2!=this->points.end(); ++pos2) 
-   {
-      if     ((*pos1).equals(&point1) && (*pos2).equals(&point2)) return true;
-      else if((*pos1).equals(&point2) && (*pos2).equals(&point1)) return true;
-
-      pos1=pos2;
-   }
-
-   return false;
-}
-/*=======================================================*/
-GbPoint3D* GbSystem3D::PointSet3::getPoint(int index)
-{
-   if(index<0 || index>=(int)this->points.size()) throw UbException(UB_EXARGS,"index out of range");
-   return &(this->points)[index];
-}
-/*=======================================================*/
-GbPoint3D* GbSystem3D::PointSet3::getFirstPoint()
-{
-   return &(this->points.front());
-}
-/*=======================================================*/
-GbPoint3D* GbSystem3D::PointSet3::getLastPoint() 
-{ 
-   return &(this->points.back()); 
-}
-/*=======================================================*/
-int GbSystem3D::PointSet3::size()
-{ 
-   return (int)this->points.size();      
-}
-/*=======================================================*/
-vector<GbPoint3D> GbSystem3D::PointSet3::getPoints()
-{
-   //is this right? it's another effect as at GbPoint3D* getNode(index)!!!
-   //or do we want to have the next uncommented getPoints() funktion
-   return this->points;
-}
-///*=======================================================*/
-//vector<GbPoint3D*> GbSystem3D::PointSet3::getPoints()
-//{
-//   vector<GbPoint3D*> tmp;
-//   for(int pos=0; pos<(int)this->points.size();pos++) tmp.push_back(&this->points[pos]);
-//   
-//   return tmp;
-//}
-/*=======================================================*/
-void GbSystem3D::PointSet3::calculateValues()
-{
-   if(this->points.empty()) 
-   {
-      this->x1min = this->x2min = this->x3min = 0.0;
-      this->x1max = this->x2max = this->x3max = 0.0;
-   }
-   else
-   {
-      this->x1min = (this->points)[0].x1;
-      this->x1max = (this->points)[0].x1;
-      this->x2min = (this->points)[0].x2;
-      this->x2max = (this->points)[0].x2;
-      this->x3min = (this->points)[0].x3;
-      this->x3max = (this->points)[0].x3;
-
-      for(int i=(int)this->points.size()-1; i>0; --i)
-      {
-         if((this->points)[i].x1 < this->x1min) this->x1min = (this->points)[i].x1;
-         if((this->points)[i].x1 > this->x1max) this->x1max = (this->points)[i].x1;
-         if((this->points)[i].x2 < this->x2min) this->x2min = (this->points)[i].x2;
-         if((this->points)[i].x2 > this->x2max) this->x2max = (this->points)[i].x2;
-         if((this->points)[i].x3 < this->x3min) this->x3min = (this->points)[i].x3;
-         if((this->points)[i].x3 > this->x3max) this->x3max = (this->points)[i].x3;
-      }
-   }
-   this->consistent = true;
-}
-
-
-
+#include <numerics/geometry3d/GbSystem3D.h>
+
+#include <numerics/geometry3d/GbPolygon3D.h>
+#include <numerics/geometry3d/GbCuboid3D.h>
+
+using namespace std;
+
+double GbSystem3D::getDistance(const GbPoint3D& p11, const GbPoint3D& p12)
+{
+   double dx1 = p11.x1 - p12.x1;
+   double dx2 = p11.x2 - p12.x2;
+   double dx3 = p11.x3 - p12.x3;
+   return std::sqrt(dx1*dx1+dx2*dx2+dx3*dx3);
+}
+
+GbPoint3D* GbSystem3D::calculateIntersectionPoint3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22)
+{
+   if(UbMath::less2(p11.x1, p12.x1, p21.x1, p22.x1))    return NULL;
+   if(UbMath::less2(p11.x2, p12.x2, p21.x2, p22.x2))    return NULL;
+   if(UbMath::less2(p11.x3, p12.x3, p21.x3, p22.x3))    return NULL;
+   if(UbMath::greater2(p11.x1, p12.x1, p21.x1, p22.x1)) return NULL;
+   if(UbMath::greater2(p11.x2, p12.x2, p21.x2, p22.x2)) return NULL;
+   if(UbMath::greater2(p11.x3, p12.x3, p21.x3, p22.x3)) return NULL;
+
+   double a11 = p12.x1 - p11.x1;                       //..HOW PARAMETERS ARE USED.........
+   double a12 = p12.x2 - p11.x2;                       //
+   double a13 = p12.x3 - p11.x3;                       //  p11 and p12 represent line 1
+   double a21 = p21.x1 - p22.x1;                       //  p21 and p22 represent line 2
+   double a22 = p21.x2 - p22.x2;                       //
+   double a23 = p21.x3 - p22.x3;                       //..................................
+   double b1  = p21.x1 - p11.x1;
+   double b2  = p21.x2 - p11.x2;
+   double b3  = p21.x3 - p11.x3;
+   double d1  = a11*a22 - a12*a21;
+   double d2  = a11*a23 - a13*a21;
+   double d3  = a12*a23 - a13*a22;
+   double t;
+
+   if(UbMath::zero(d1) && UbMath::zero(d2) && UbMath::zero(d3)) return NULL;
+   if(UbMath::zero(d1))
+   {
+   	if(!UbMath::zero(d2)) t = (a23*b1-a21*b3)/d2;
+      else          t = (a23*b2-a22*b3)/d3;
+   }
+   else if(UbMath::zero(d2))
+   {
+   	if(!UbMath::zero(d1)) t = (a22*b1-a21*b2)/d1;
+      else          t = (a23*b2-a22*b3)/d3;
+   }
+   else if(UbMath::zero(d3))
+   {
+   	if(!UbMath::zero(d1)) t = (a22*b1-a21*b2)/d1;
+      else          t = (a23*b1-a21*b3)/d2;
+   }
+   else return NULL;
+
+   double x1 = p11.x1 + t*a11;
+   double x2 = p11.x2 + t*a12;
+   double x3 = p11.x3 + t*a13;
+
+   if(UbMath::inClosedInterval(x1, p11.x1, p12.x1) && UbMath::inClosedInterval(x1, p21.x1, p22.x1) &&
+      UbMath::inClosedInterval(x2, p11.x2, p12.x2) && UbMath::inClosedInterval(x2, p21.x2, p22.x2) &&
+      UbMath::inClosedInterval(x3, p11.x3, p12.x3) && UbMath::inClosedInterval(x3, p21.x3, p22.x3)    ) return new GbPoint3D(x1, x2, x3);
+
+   return NULL;
+}
+/*=================================================================*/
+//Line1: p11 -> p12 and Line2: p21 -> p22
+bool GbSystem3D::hasIntersectionPoint3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22)
+{
+   if(UbMath::less2(p11.x1, p12.x1, p21.x1, p22.x1))    return false; 
+   if(UbMath::less2(p11.x2, p12.x2, p21.x2, p22.x2))    return false; 
+   if(UbMath::less2(p11.x3, p12.x3, p21.x3, p22.x3))    return false; 
+   if(UbMath::greater2(p11.x1, p12.x1, p21.x1, p22.x1)) return false; 
+   if(UbMath::greater2(p11.x2, p12.x2, p21.x2, p22.x2)) return false; 
+   if(UbMath::greater2(p11.x3, p12.x3, p21.x3, p22.x3)) return false; 
+
+   double a11 = p12.x1 - p11.x1;                       //..HOW PARAMETERS ARE USED.........
+   double a12 = p12.x2 - p11.x2;                       //
+   double a13 = p12.x3 - p11.x3;                       //  p11 and p12 represent line 1
+   double a21 = p21.x1 - p22.x1;                       //  p21 and p22 represent line 2
+   double a22 = p21.x2 - p22.x2;                       //
+   double a23 = p21.x3 - p22.x3;                       //..................................
+   double b1  = p21.x1 - p11.x1;
+   double b2  = p21.x2 - p11.x2;
+   double b3  = p21.x3 - p11.x3;
+   double d1  = a11*a22 - a12*a21;
+   double d2  = a11*a23 - a13*a21;
+   double d3  = a12*a23 - a13*a22;
+   double t;
+
+   if(UbMath::zero(d1) && UbMath::zero(d2) && UbMath::zero(d3)) return false; 
+   if(UbMath::zero(d1))
+   {
+      if(!UbMath::zero(d2)) t = (a23*b1-a21*b3)/d2;
+      else          t = (a23*b2-a22*b3)/d3;
+   }
+   else if(UbMath::zero(d2))
+   {
+      if(!UbMath::zero(d1)) t = (a22*b1-a21*b2)/d1;
+	   else          t = (a23*b2-a22*b3)/d3;
+   }
+   else if(UbMath::zero(d3))
+   {
+      if(!UbMath::zero(d1)) t = (a22*b1-a21*b2)/d1;
+      else          t = (a23*b1-a21*b3)/d2;
+   }
+   else return false; 
+
+   double x1 = p11.x1 + t*a11;
+   double x2 = p11.x2 + t*a12;
+   double x3 = p11.x3 + t*a13;
+
+   if(UbMath::inClosedInterval(x1, p11.x1, p12.x1) && UbMath::inClosedInterval(x1, p21.x1, p22.x1) &&
+	   UbMath::inClosedInterval(x2, p11.x2, p12.x2) && UbMath::inClosedInterval(x2, p21.x2, p22.x2) &&
+	   UbMath::inClosedInterval(x3, p11.x3, p12.x3) && UbMath::inClosedInterval(x3, p21.x3, p22.x3)) return true; 
+   return false; 
+}
+ /*======================================================================*/
+//
+//
+//   /*======================================================================*/
+//   /*  Private Methoden (Parallelism)                                      */
+//   /*                                                                      */
+bool GbSystem3D::isParallelIn3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22)
+{
+   double a11 = p12.x1 - p11.x1;                       //..HOW PARAMETERS ARE USED.........
+   double a12 = p12.x2 - p11.x2;                       //
+   double a13 = p12.x3 - p11.x3;                       //  p11 and p12 represent line 1
+   double a21 = p21.x1 - p22.x1;                       //  p21 and p22 represent line 2
+   double a22 = p21.x2 - p22.x2;                       //
+   double a23 = p21.x3 - p22.x3;                       //..................................
+
+   return (UbMath::zero(a11*a22 - a12*a21) && UbMath::zero(a11*a23 - a13*a21) && UbMath::zero(a12*a23 - a13*a22));
+}
+/*======================================================================*/
+
+
+/*======================================================================*/
+/*  General Clipping Methods                                            */
+//......................................................................*/
+//
+//  Method       Parameters                                       Result      Remarks
+//  ---------    ---------------------------------------------    ---------   -------------------
+//  clip###2D   (2D objects to be clipped, 2+2 clipping values)   2D object   clipping x1, x2
+//  clip###3D   (3D objects to be clipped, 2+2 clipping values)   3D object   clipping x1, x2
+//  clip###3D   (3D objects to be clipped, 3+3 clipping values)   3D object   clipping x1, x2, x3
+//  clip###3D   (3D objects to be clipped, 1+1 clipping values)   3D object   clipping x3
+//
+/*======================================================================*/
+/*  Private Methoden (Clipping Lines)                                   */
+/*                                                                      */
+GbLine3D* GbSystem3D::createClipLine3D(GbPoint3D &pA, GbPoint3D &pB, double x1a, double x2a, double x3a, double x1b, double x2b, double x3b)
+{
+   GbPoint3D *p1 = new GbPoint3D(pA);
+   GbPoint3D *p2 = new GbPoint3D(pB);
+
+   if(UbMath::greater(x1a, x1b)) { double x1 = x1a; x1a = x1b; x1b = x1; }
+   if(UbMath::greater(x2a, x2b)) { double x2 = x2a; x2a = x2b; x2b = x2; }
+   if(UbMath::greater(x3a, x3b)) { double x3 = x3a; x3a = x3b; x3b = x3; }
+
+   double f;
+
+   /*-------------------------------------------------------------------*/
+   /*  Schneiden an vorderer Kante                                      */
+   /*                                                                   */
+   if(UbMath::less(p1->x3, x3a))
+   {
+      if(UbMath::less(p2->x3, x3a)) { delete p1; delete p2; return NULL; }
+
+      f       = (x3a-p1->x3)/(p1->x3-p2->x3);
+      p1->x1 += (p1->x1-p2->x1)*f;
+      p1->x2 += (p1->x2-p2->x2)*f;
+      p1->x3  = x3a;
+   }
+   else if(UbMath::less(p2->x3, x3a))
+   {
+      f      = (x3a-p2->x3)/(p2->x3-p1->x3);
+      p2->x1 += (p2->x1-p1->x1)*f;
+      p2->x2 += (p2->x2-p1->x2)*f;
+      p2->x3  = x3a;
+   }     
+   /*-------------------------------------------------------------------*/
+   /*  Schneiden an unterer Kante                                       */
+   /*                                                                   */
+   if(UbMath::less(p1->x2, x2a))
+   {
+      if(UbMath::less(p2->x2, x2a)) { delete p1; delete p2; return NULL;
+      }
+
+      f      = (x2a-p1->x2)/(p1->x2-p2->x2);
+      p1->x1 += (p1->x1-p2->x1)*f;
+      p1->x3 += (p1->x3-p2->x3)*f;
+      p1->x2  = x2a;
+   }
+   else if(UbMath::less(p2->x2, x2a))
+   {
+      f      = (x2a-p2->x2)/(p2->x2-p1->x2);
+      p2->x1 += (p2->x1-p1->x1)*f;
+      p2->x3 += (p2->x3-p1->x3)*f;
+      p2->x2  = x2a;
+   }
+   /*-------------------------------------------------------------------*/
+   /*  Schneiden an rechter Kante                                       */
+   /*                                                                   */
+   if(UbMath::greater(p1->x1, x1b))
+   {
+      if(UbMath::greater(p2->x1, x1b))  { delete p1;delete p2; return NULL;}
+
+      f      = (x1b-p1->x1)/(p1->x1-p2->x1);
+      p1->x2 += (p1->x2-p2->x2)*f;
+      p1->x3 += (p1->x3-p2->x3)*f;
+      p1->x1  = x1b;
+   }
+   else if(UbMath::greater(p2->x1, x1b))
+   {
+      f      = (x1b-p2->x1)/(p2->x1-p1->x1);
+      p2->x2 += (p2->x2-p1->x2)*f;
+      p2->x3 += (p2->x3-p1->x3)*f;
+      p2->x1  = x1b;
+   }
+   /*-------------------------------------------------------------------*/
+   /*  Schneiden an hinterer Kante                                      */
+   /*                                                                   */
+   if(UbMath::greater(p1->x3, x3b))
+   {
+      if(UbMath::greater(p2->x3, x3b))  { delete p1;delete p2; return NULL;}
+
+      f      = (x3b-p1->x3)/(p1->x3-p2->x3);
+      p1->x1 += (p1->x1-p2->x1)*f;
+      p1->x2 += (p1->x2-p2->x2)*f;
+      p1->x3  = x3b;
+   }
+   else if(UbMath::greater(p2->x3, x3b))
+   {
+      f      = (x3b-p2->x3)/(p2->x3-p1->x3);
+      p2->x1 += (p2->x1-p1->x1)*f;
+      p2->x2 += (p2->x2-p1->x2)*f;
+      p2->x3  = x3b;
+   }
+   /*-------------------------------------------------------------------*/
+   /*  Schneiden an oberer Kante                                        */
+   /*                                                                   */
+   if(UbMath::greater(p1->x2, x2b))
+   {
+      if(UbMath::greater(p2->x2, x2b))  { delete p1;delete p2; return NULL;}
+
+      f      = (x2b-p1->x2)/(p1->x2-p2->x2);
+      p1->x1 += (p1->x1-p2->x1)*f;
+      p1->x3 += (p1->x3-p2->x3)*f;
+      p1->x2  = x2b;
+   }
+   else if(UbMath::greater(p2->x2, x2b))
+   {
+      f      = (x2b-p2->x2)/(p2->x2-p1->x2);
+      p2->x1 += (p2->x1-p1->x1)*f;
+      p2->x3 += (p2->x3-p1->x3)*f;
+      p2->x2  = x2b;
+   }
+   /*-------------------------------------------------------------------*/
+   /*  Schneiden an linker Kante                                        */
+   /*                                                                   */
+   if(UbMath::less(p1->x1, x1a))
+   {
+      if(UbMath::less(p2->x1, x1a))  { delete p1;delete p2; return NULL;}
+
+      f      = (x1a-p1->x1)/(p1->x1-p2->x1);
+      p1->x2 += (p1->x2-p2->x2)*f;
+      p1->x3 += (p1->x3-p2->x3)*f;
+      p1->x1  = x1a;
+   }
+   else if(UbMath::less(p2->x1, x1a))
+   {
+      f      = (x1a-p2->x1)/(p2->x1-p1->x1);
+      p2->x2 += (p2->x2-p1->x2)*f;
+      p2->x3 += (p2->x3-p1->x3)*f;
+      p2->x1  = x1a;
+   }
+   /*-------------------------------------------------------------------*/
+   return new GbLine3D(p1, p2);
+}
+//   /*======================================================================*/
+//   /*  Private Methoden (Clipping Rectangles)                              */
+//   /*                                                                      */
+//   final static GbPolygon3D clipPolygon3D(GbPoint3D points[], double x11, double x12, double x21, double x22)
+//   {
+//      GbPoint3D last = null;
+//      PointSet3 ps   = new PointSet3(points);
+//      boolean   flag = false;
+//      int       n    = points.length;
+//      int       i;
+//      double    f;
+//
+//      if(n == 0)              return(null);
+//      if(greater(x11, x21)) { double ax = x11; x11 = x21; x21 = ax; }
+//      if(greater(x12, x22)) { double ay = x12; x12 = x22; x22 = ay; }
+//
+//      /*-------------------------------------------------------------------*/
+//      /*  Schneiden an unterer Kante                                       */
+//      /*                                                                   */
+//      if(less(ps.getX2Minimum(), x12))
+//      {
+//	 ps.clear();
+//	 last = points[0];
+//	 if(less((*points)[0]->x2, x12)) flag = false;
+//	 else
+//	 {
+//	    ps.add(points[0]);
+//	    flag = true;
+//	 }
+//	 for(i=1; i<n; i++)
+//	 {
+//	    if(less((*points)[i]->x2, x12))
+//	    {
+//	       if(flag)
+//	       {
+//	          f = (x12-(*points)[i]->x2)/((*points)[i]->x2-last->x2);
+//	          ps.add(new GbPoint3D((*points)[i]->x1 + ((*points)[i]->x1-last->x1)*f, x12, (*points)[i]->x3 + ((*points)[i]->x3-last->x3)*f));
+//	       }
+//	       flag = false;
+//	    }
+//	    else
+//	    {
+//	       if(!flag)
+//	       {
+//	          f = (x12-(*points)[i]->x2)/((*points)[i]->x2-last->x2);
+//	          ps.add(new GbPoint3D((*points)[i]->x1 + ((*points)[i]->x1-last->x1)*f, x12, (*points)[i]->x3 + ((*points)[i]->x3-last->x3)*f));
+//	       }
+//	       ps.add((*points)[i]);
+//	       flag = true;
+//	    }
+//	    last = points[i];
+//	 }
+//	 if(!((less(points[0].x2, x12)) ^ flag))
+//	 {
+//	    f = (x12-points[0].x2)/(points[0].x2-last->x2);
+//	    ps.add(new GbPoint3D(points[0].x1 + (points[0].x1-last->x1)*f, x12, points[0].x3 + (points[0].x3-last->x3)*f));
+//	 }
+//
+//	 points = ps.getPoints();
+//	 n      = points.length;
+//
+//	 if(n == 0) return(null);
+//      }
+//      /*-------------------------------------------------------------------*/
+//      /*  Schneiden an rechter Kante                                       */
+//      /*                                                                   */
+//      if(greater(ps.getX1Maximum(), x21))
+//      {
+//	 ps.clear();
+//	 last = points[0];
+//	 if(greater(points[0].x1, x21)) flag = false;
+//	 else
+//	 {
+//	    ps.add(points[0]);
+//	    flag = true;
+//	 }
+//	 for(i=1; i<n; i++)
+//	 {
+//	    if(greater((*points)[i]->x1, x21))
+//	    {
+//	       if(flag)
+//	       {
+//	          f = (x21-(*points)[i]->x1)/((*points)[i]->x1-last->x1);
+//	          ps.add(new GbPoint3D(x21, (*points)[i]->x2 + ((*points)[i]->x2-last->x2)*f, (*points)[i]->x3 + ((*points)[i]->x3-last->x3)*f));
+//	       }
+//	       flag = false;
+//	    }
+//	    else
+//	    {
+//	       if(!flag)
+//	       {
+//	          f = (x21-(*points)[i]->x1)/((*points)[i]->x1-last->x1);
+//	          ps.add(new GbPoint3D(x21, (*points)[i]->x2 + ((*points)[i]->x2-last->x2)*f, (*points)[i]->x3 + ((*points)[i]->x3-last->x3)*f));
+//	       }
+//	       ps.add(points[i]);
+//	       flag = true;
+//	    }
+//	    last = points[i];
+//	 }
+//	 if(!((greater(points[0].x1, x21)) ^ flag))
+//	 {
+//	    f = (x21-points[0].x1)/(points[0].x1-last.x1);
+//	    ps.add(new GbPoint3D(x21, points[0].x2 + (points[0].x2-last.x2)*f, points[0].x3 + (points[0].x3-last.x3)*f));
+//	 }
+//
+//	 points = ps.getPoints();
+//	 n      = points.length;
+//
+//	 if(n == 0) return(null);
+//      }
+//      /*-------------------------------------------------------------------*/
+//      /*  Schneiden an oberer Kante                                        */
+//      /*                                                                   */
+//      if(greater(ps.getX2Maximum(), x22))
+//      {
+//	 ps.clear();
+//	 last = points[0];
+//	 if(greater(points[0].x2, x22)) flag = false;
+//	 else
+//	 {
+//	    ps.add(points[0]);
+//	    flag = true;
+//	 }
+//	 for(i=1; i<n; i++)
+//	 {
+//	    if(greater((*points)[i]->x2, x22))
+//	    {
+//	       if(flag)
+//	       {
+//	          f = (x22-(*points)[i]->x2)/(points[i].x2-last.x2);
+//	          ps.add(new GbPoint3D(points[i].x1 + (points[i].x1-last.x1)*f, x22, points[i].x3 + (points[i].x3-last.x3)*f));
+//	       }
+//	       flag = false;
+//	    }
+//	    else
+//	    {
+//	       if(!flag)
+//	       {
+//	          f = (x22-points[i].x2)/(points[i].x2-last.x2);
+//	          ps.add(new GbPoint3D(points[i].x1 + (points[i].x1-last.x1)*f, x22, points[i].x3 + (points[i].x3-last.x3)*f));
+//	       }
+//	       ps.add(points[i]);
+//	       flag = true;
+//	    }
+//	    last = points[i];
+//	 }
+//	 if(!((greater(points[0].x2, x22)) ^ flag))
+//	 {
+//	    f = (x22-points[0].x2)/(points[0].x2-last.x2);
+//	    ps.add(new GbPoint3D(points[0].x1 + (points[0].x1-last.x1)*f, x22, points[0].x3 + (points[0].x3-last.x3)*f));
+//	 }
+//
+//	 points = ps.getPoints();
+//	 n      = points.length;
+//
+//	 if(n == 0) return(null);
+//      }
+//      /*-------------------------------------------------------------------*/
+//      /*  Schneiden an linker Kante                                        */
+//      /*                                                                   */
+//      if(less(ps.getX1Minimum(), x11))
+//      {
+//	 ps.clear();
+//	 last = points[0];
+//	 if(less(points[0].x1, x11)) flag = false;
+//	 else
+//	 {
+//	    ps.add(points[0]);
+//	    flag = true;
+//	 }
+//	 for(i=1; i<n; i++)
+//	 {
+//	    if(less(points[i].x1, x11))
+//	    {
+//	       if(flag)
+//	       {
+//	          f = (x11-points[i].x1)/(points[i].x1-last.x1);
+//	          ps.add(new GbPoint3D(x11, points[i].x2 + (points[i].x2-last.x2)*f, points[i].x3 + (points[i].x3-last.x3)*f));
+//	       }
+//	       flag = false;
+//	    }
+//	    else
+//	    {
+//	       if(!flag)
+//	       {
+//	          f = (x11-points[i].x1)/(points[i].x1-last.x1);
+//	          ps.add(new GbPoint3D(x11, points[i].x2 + (points[i].x2-last.x2)*f, points[i].x3 + (points[i].x3-last.x3)*f));
+//	       }
+//	       ps.add(points[i]);
+//	       flag = true;
+//	    }
+//	    last = points[i];
+//	 }
+//	 if(!((less(points[0].x1, x11)) ^ flag))
+//	 {
+//	    f = (x11-points[0].x1)/(points[0].x1-last.x1);
+//	    ps.add(new GbPoint3D(x11, points[0].x2 + (points[0].x2-last.x2)*f, points[0].x3 + (points[0].x3-last.x3)*f));
+//	 }
+//
+//	 points = ps.getPoints();
+//	 n      = points.length;
+//
+//	 if(n == 0) return(null);
+//      }
+//      /*-------------------------------------------------------------------*/
+//      GbPolygon3D polygon = new GbPolygon3D(points);
+//
+//      if(n > 2)
+//      {
+//	 for(i=2; i<n; i++) if(zero(i_TA(points[i-2], points[i-1], points[i]))) polygon.deletePoint(points[i-1]);
+//	 if(zero(i_TA(points[n-2], points[n-1], points[0]))) polygon.deletePoint(points[n-1]);
+//	 if(zero(i_TA(points[n-1], points[0],   points[1]))) polygon.deletePoint(points[0]);
+//      }
+//      return(polygon);
+//   }
+//   final static GbPolygon3D clipPolygon3D(GbPoint3D points[], double x13, double x23)
+//   {
+//      GbPoint3D last = null;
+//      PointSet3 ps   = new PointSet3(points);
+//      boolean   flag = false;
+//      int       n    = points.length;
+//      int       i;
+//      double    f;
+//
+//      if(n == 0)              return(null);
+//      if(greater(x13, x23)) { double az = x13; x13 = x23; x23 = az; }
+//
+//      /*-------------------------------------------------------------------*/
+//      /*  Schneiden an vorderer Kante                                      */
+//      /*                                                                   */
+//      if(less(ps.getX3Minimum(), x13))
+//      {
+//	 ps.clear();
+//	 last = points[0];
+//	 if(less(points[0].x3, x13)) flag = false;
+//	 else
+//	 {
+//	    ps.add(points[0]);
+//	    flag = true;
+//	 }
+//	 for(i=1; i<n; i++)
+//	 {
+//	    if(less(points[i].x3, x13))
+//	    {
+//	       if(flag)
+//	       {
+//	          f = (x13-points[i].x3)/(points[i].x3-last.x3);
+//	          ps.add(new GbPoint3D(points[i].x1 + (points[i].x1-last.x1)*f, points[i].x2 + (points[i].x2-last.x2)*f, x13));
+//	       }
+//	       flag = false;
+//	    }
+//	    else
+//	    {
+//	       if(!flag)
+//	       {
+//	          f = (x13-points[i].x3)/(points[i].x3-last.x3);
+//	          ps.add(new GbPoint3D(points[i].x1 + (points[i].x1-last.x1)*f, points[i].x2 + (points[i].x2-last.x2)*f, x13));
+//	       }
+//	       ps.add(points[i]);
+//	       flag = true;
+//	    }
+//	    last = points[i];
+//	 }
+//	 if(!((less(points[0].x3, x13)) ^ flag))
+//	 {
+//	    f = (x13-points[0].x3)/(points[0].x3-last.x3);
+//	    ps.add(new GbPoint3D(points[0].x1 + (points[0].x1-last.x1)*f, points[0].x2 + (points[0].x2-last.x2)*f, x13));
+//	 }
+//
+//	 points = ps.getPoints();
+//	 n      = points.length;
+//
+//	 if(n == 0) return(null);
+//      }
+//      /*-------------------------------------------------------------------*/
+//      /*  Schneiden an hinterer Kante                                      */
+//      /*                                                                   */
+//      if(greater(ps.getX3Maximum(), x23))
+//      {
+//	 ps.clear();
+//	 last = points[0];
+//	 if(greater(points[0].x3, x23)) flag = false;
+//	 else
+//	 {
+//	    ps.add(points[0]);
+//	    flag = true;
+//	 }
+//	 for(i=1; i<n; i++)
+//	 {
+//	    if(greater(points[i].x3, x23))
+//	    {
+//	       if(flag)
+//	       {
+//	          f = (x23-points[i].x3)/(points[i].x3-last.x3);
+//	          ps.add(new GbPoint3D(points[i].x1 + (points[i].x1-last.x1)*f, points[i].x2 + (points[i].x2-last.x2)*f, x23));
+//	       }
+//	       flag = false;
+//	    }
+//	    else
+//	    {
+//	       if(!flag)
+//	       {
+//	          f = (x23-points[i].x3)/(points[i].x3-last.x3);
+//	          ps.add(new GbPoint3D(points[i].x1 + ((*points)[i]->x1-last.x1)*f, (*points)[i]->x2 + ((*points)[i]->x2-last.x2)*f, x23));
+//	       }
+//	       ps.add(points[i]);
+//	       flag = true;
+//	    }
+//	    last = points[i];
+//	 }
+//	 if(!((greater(points[0].x3, x23)) ^ flag))
+//	 {
+//	    f = (x23-points[0].x3)/(points[0].x3-last.x3);
+//	    ps.add(new GbPoint3D(points[0].x1 + (points[0].x1-last.x1)*f, points[0].x2 + (points[0].x2-last.x2)*f, x23));
+//	 }
+//
+//	 points = ps.getPoints();
+//	 n      = points.length;
+//
+//	 if(n == 0) return(null);
+//      }
+//      /*-------------------------------------------------------------------*/
+//      GbPolygon3D polygon = new GbPolygon3D(points);
+//
+//      return(polygon);
+//   }
+GbPolygon3D* GbSystem3D::clipPolygon3D(vector<GbPoint3D> points, double x11, double x12, double x13, double x21, double x22, double x23)
+{
+   GbPoint3D last;
+   PointSet3 ps(points);
+   bool   flag = false;
+   int    n    = (int)points.size();
+	int       i;
+   double    f;
+
+   if(n == 0)              return NULL;
+   if(UbMath::greater(x11, x21)) { double ax = x11; x11 = x21; x21 = ax; }
+   if(UbMath::greater(x12, x22)) { double ay = x12; x12 = x22; x22 = ay; }
+   if(UbMath::greater(x13, x23)) { double az = x13; x13 = x23; x23 = az; }
+
+   /*-------------------------------------------------------------------*/
+   /*  Schneiden an vorderer Kante                                      */
+   /*                                                                   */
+   if(UbMath::less(ps.getX3Minimum(), x13))
+   {
+		ps.clear();
+		last = (points)[0];
+		if(UbMath::less((points)[0].x3, x13)) flag = false;
+		else
+		{
+			ps.add((points)[0]);
+			flag = true;
+		}
+		for(i=1; i<n; i++)
+		{
+			if(UbMath::less((points)[i].x3, x13))
+			{
+				if(flag)
+				{
+					f = (x13-(points)[i].x3)/((points)[i].x3-last.x3);
+					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, (points)[i].x2 + ((points)[i].x2-last.x2)*f, x13));
+				}
+				flag = false;
+			}
+			else
+			{
+				if(!flag)
+				{
+					f = (x13-(points)[i].x3)/((points)[i].x3-last.x3);
+					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, (points)[i].x2 + ((points)[i].x2-last.x2)*f, x13));
+				}
+				ps.add((points)[i]);
+				flag = true;
+			}
+			last = (points)[i];
+		}
+		if(!((UbMath::less((points)[0].x3, x13)) ^ flag))
+		{
+			f = (x13-(points)[0].x3)/((points)[0].x3-last.x3);
+			ps.add(GbPoint3D((points)[0].x1 + ((points)[0].x1-last.x1)*f, (points)[0].x2 + ((points)[0].x2-last.x2)*f, x13));
+		}
+
+		points = ps.getPoints();
+		n      = (int)points.size();
+
+		if(n == 0) return NULL;
+   }
+	
+	/*-------------------------------------------------------------------*/
+   /*  Schneiden an unterer Kante                                       */
+   /*                                                                   */
+   if(UbMath::less(ps.getX2Minimum(), x12))
+   {
+		ps.clear();
+		last = (points)[0];
+		if(UbMath::less((points)[0].x2, x12)) flag = false;
+		else
+		{
+			ps.add((points)[0]);
+			flag = true;
+		}
+		for(i=1; i<n; i++)
+		{
+			if(UbMath::less((points)[i].x2, x12))
+			{
+				if(flag)
+				{
+					f = (x12-(points)[i].x2)/((points)[i].x2-last.x2);
+					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, x12, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
+				}
+				flag = false;
+			}
+		   else
+			{
+				if(!flag)
+				{
+					f = (x12-(points)[i].x2)/((points)[i].x2-last.x2);
+					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, x12, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
+				}
+				ps.add((points)[i]);
+				flag = true;
+			}
+			last = (points)[i];
+		}
+		if(!((UbMath::less((points)[0].x2, x12)) ^ flag))
+		{
+			f = (x12-(points)[0].x2)/((points)[0].x2-last.x2);
+			ps.add(GbPoint3D((points)[0].x1 + ((points)[0].x1-last.x1)*f, x12, (points)[0].x3 + ((points)[0].x3-last.x3)*f));
+		}
+
+		points = ps.getPoints();
+		n      = (int)points.size();
+
+		if(n == 0) return NULL;
+   }
+   /*-------------------------------------------------------------------*/
+   /*  Schneiden an rechter Kante                                       */
+   /*                                                                   */
+	
+	if(UbMath::greater(ps.getX1Maximum(), x21))
+   {
+		ps.clear();
+		last = (points)[0];
+		if(UbMath::greater((points)[0].x1, x21)) flag = false;
+		else
+		{
+			ps.add((points)[0]);
+			flag = true;
+		}
+		for(i=1; i<n; i++)
+		{
+			if(UbMath::greater((points)[i].x1, x21))
+			{
+				if(flag)
+				{
+					f = (x21-(points)[i].x1)/((points)[i].x1-last.x1);
+					ps.add(GbPoint3D(x21, (points)[i].x2 + ((points)[i].x2-last.x2)*f, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
+				}
+				flag = false;
+			}
+			else
+			{
+				if(!flag)
+				{
+					f = (x21-(points)[i].x1)/((points)[i].x1-last.x1);
+					ps.add(GbPoint3D(x21, (points)[i].x2 + ((points)[i].x2-last.x2)*f, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
+				}
+				ps.add((points)[i]);
+				flag = true;
+			}
+			last = (points)[i];
+		}
+		if(!((UbMath::greater((points)[0].x1, x21)) ^ flag))
+		{
+			f = (x21-(points)[0].x1)/((points)[0].x1-last.x1);
+			ps.add(GbPoint3D(x21, (points)[0].x2 + ((points)[0].x2-last.x2)*f, (points)[0].x3 + ((points)[0].x3-last.x3)*f));
+		}
+
+		points = ps.getPoints();
+		n      = (int)points.size();
+
+		if(n == 0) return NULL;
+   }
+   /*-------------------------------------------------------------------*/
+   /*  Schneiden an hinterer Kante                                      */
+   /*                                                                   */
+   if(UbMath::greater(ps.getX3Maximum(), x23))
+   {
+		ps.clear();
+		last = (points)[0];
+		if(UbMath::greater((points)[0].x3, x23)) flag = false;
+		else
+		{
+			ps.add((points)[0]);
+			flag = true;
+		}
+		for(i=1; i<n; i++)
+		{
+			if(UbMath::greater((points)[i].x3, x23))
+			{
+				if(flag)
+				{
+					f = (x23-(points)[i].x3)/((points)[i].x3-last.x3);
+					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, (points)[i].x2 + ((points)[i].x2-last.x2)*f, x23));
+				}
+				flag = false;
+			}
+			else
+			{
+				if(!flag)
+				{
+					f = (x23-(points)[i].x3)/((points)[i].x3-last.x3);
+					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, (points)[i].x2 + ((points)[i].x2-last.x2)*f, x23));
+				}
+				ps.add((points)[i]);
+				flag = true;
+			}
+			last = (points)[i];
+		}
+		if(!((UbMath::greater((points)[0].x3, x23)) ^ flag))
+		{
+			f = (x23-(points)[0].x3)/((points)[0].x3-last.x3);
+			ps.add(GbPoint3D((points)[0].x1 + ((points)[0].x1-last.x1)*f, (points)[0].x2 + ((points)[0].x2-last.x2)*f, x23));
+		}
+
+		points = ps.getPoints();
+		n      = (int)points.size();
+
+		if(n == 0) return NULL;
+	}
+   /*-------------------------------------------------------------------*/
+   /*  Schneiden an oberer Kante                                        */
+   /*                                                                   */
+
+	if(UbMath::greater(ps.getX2Maximum(), x22))
+   {
+		ps.clear();
+		last = (points)[0];
+		if(UbMath::greater((points)[0].x2, x22)) flag = false;
+		else
+		{
+			ps.add((points)[0]);
+			flag = true;
+		}
+		for(i=1; i<n; i++)
+		{
+			if(UbMath::greater((points)[i].x2, x22))
+			{
+				if(flag)
+				{
+					f = (x22-(points)[i].x2)/((points)[i].x2-last.x2);
+					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, x22, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
+				}
+				flag = false;
+			}
+			else
+			{
+				if(!flag)
+				{
+					f = (x22-(points)[i].x2)/((points)[i].x2-last.x2);
+					ps.add(GbPoint3D((points)[i].x1 + ((points)[i].x1-last.x1)*f, x22, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
+				}
+				ps.add((points)[i]);
+				flag = true;
+			}
+			last = (points)[i];
+		}
+		if(!((UbMath::greater((points)[0].x2, x22)) ^ flag))
+		{
+			f = (x22-(points)[0].x2)/((points)[0].x2-last.x2);
+			ps.add(GbPoint3D((points)[0].x1 + ((points)[0].x1-last.x1)*f, x22, (points)[0].x3 + ((points)[0].x3-last.x3)*f));
+		}
+
+		points = ps.getPoints();
+		n      = (int)points.size();
+
+		if(n == 0) return NULL;
+   }
+   /*-------------------------------------------------------------------*/
+   /*  Schneiden an linker Kante                                        */
+   /*                                                                   */
+	if(UbMath::less(ps.getX1Minimum(), x11))
+   {
+		ps.clear();
+		last = (points)[0];
+		if(UbMath::less((points)[0].x1, x11)) flag = false;
+		else
+		{
+			ps.add((points)[0]);
+			flag = true;
+		}
+		for(i=1; i<n; i++)
+		{
+			if(UbMath::less((points)[i].x1, x11))
+			{
+				if(flag)
+				{
+					f = (x11-(points)[i].x1)/((points)[i].x1-last.x1);
+					ps.add(GbPoint3D(x11, (points)[i].x2 + ((points)[i].x2-last.x2)*f, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
+
+				}
+				flag = false;
+			}
+			else
+			{
+				if(!flag)
+				{
+					f = (x11-(points)[i].x1)/((points)[i].x1-last.x1);
+					ps.add(GbPoint3D(x11, (points)[i].x2 + ((points)[i].x2-last.x2)*f, (points)[i].x3 + ((points)[i].x3-last.x3)*f));
+				}
+				ps.add((points)[i]);
+				flag = true;
+			}
+			last = (points)[i];
+		}
+		if(!((UbMath::less((points)[0].x1, x11)) ^ flag))
+		{
+			f = (x11-(points)[0].x1)/((points)[0].x1-last.x1);
+			ps.add(GbPoint3D(x11, (points)[0].x2 + ((points)[0].x2-last.x2)*f, (points)[0].x3 + ((points)[0].x3-last.x3)*f));
+		}
+
+		points = ps.getPoints();
+		n      = (int)points.size();
+		
+		if(n == 0) return NULL;
+   }
+   /*-------------------------------------------------------------------*/
+	return new GbPolygon3D(points);
+}
+/*=========================================================================*/
+GbCuboid3D* GbSystem3D::clipRectangle3D(GbPoint3D& p1, GbPoint3D& p2, double x11, double x12, double x13, double x21, double x22, double x23)
+{
+   double r11 = p1.x1;
+   double r12 = p1.x2;
+   double r13 = p1.x3;
+   double r21 = p2.x1;
+   double r22 = p2.x2;
+   double r23 = p2.x3;
+
+   if(UbMath::greater(x11, x21)) { double ax = x11; x11 = x21; x21 = ax; }
+   if(UbMath::greater(x12, x22)) { double ay = x12; x12 = x22; x22 = ay; }
+   if(UbMath::greater(x13, x23)) { double az = x13; x13 = x23; x23 = az; }
+   if(UbMath::greater(r11, r21)) { double bx = r11; r11 = r21; r21 = bx; }
+   if(UbMath::greater(r12, r22)) { double by = r12; r12 = r22; r22 = by; }
+   if(UbMath::greater(r13, r23)) { double bz = r13; r13 = r23; r23 = bz; }
+
+   double m11 = UbMath::greater(x11, r11) ? x11 : r11;
+   double m12 = UbMath::greater(x12, r12) ? x12 : r12;
+   double m13 = UbMath::greater(x13, r13) ? x13 : r13;
+   double m21 = UbMath::greater(x21, r21) ? r21 : x21;
+   double m22 = UbMath::greater(x22, r22) ? r22 : x22;
+   double m23 = UbMath::greater(x23, r23) ? r23 : x23;
+
+   if(UbMath::lessEqual(m11, m21) && UbMath::lessEqual(m12, m22) && UbMath::lessEqual(m13, m23)) 
+      return(new GbCuboid3D(new GbPoint3D(m11, m12, m13), new GbPoint3D(m21, m22, m23)));
+   else  
+      return(NULL);
+}
+
+/*=========================================================================*/
+/*=========================================================================*/
+/*=========================================================================*/
+
+
+GbSystem3D::PointSet3::PointSet3(int n)
+{
+   this->init();
+   this->points.reserve(n); //reserves n elements! but the size of the vector ist still "0"
+}
+/*=======================================================*/
+GbSystem3D::PointSet3::PointSet3(const vector<GbPoint3D>& points)
+{
+   this->init();
+   this->add(points);
+}
+/*=======================================================*/
+void GbSystem3D::PointSet3::add(const GbPoint3D& point)
+{
+   //is point equal to last point in points then return
+   if(!this->points.empty() && point.equals(&this->points.back())) return;    //WHY???
+
+   //push point to vector
+   this->points.push_back(point);
+
+   this->consistent = false;
+}
+/*=======================================================*/
+void GbSystem3D::PointSet3::addUnequal(const GbPoint3D& point)
+{
+   if(this->containsEqual(point) > 0) return;
+   
+   this->points.push_back(point);
+   this->consistent = false;
+}
+/*=======================================================*/
+void GbSystem3D::PointSet3::add(const vector<GbPoint3D>& pointVector)
+{
+   for(int pos=0; pos<(int)pointVector.size(); pos++ )
+      this->points.push_back(pointVector[pos]);
+
+   this->consistent = false;
+}
+/*=======================================================*/
+void GbSystem3D::PointSet3::insert(const GbPoint3D& point, int index)
+{
+   if(index<0 || index>=(int)this->points.size()) 
+      throw UbException(UB_EXARGS,"index out of range");
+
+   //get iterator for index-position
+   vector<GbPoint3D>::iterator pos=this->points.begin();
+   for(int i=1; i<=index; i++) ++pos;
+
+   //insert point
+   this->points.insert(pos,point);
+
+   this->consistent    = false;
+}
+/*=======================================================*/
+//void delete(GbPoint3D point)
+//{
+//   for(int i=this.size-1; i>=0; i--) if(this.points[i] == point) this.delete(i);
+//}
+/*=======================================================*/
+//void delete(int index)
+//{
+//   int j = this.size - index - 1;
+//   if(j > 0) System.arraycopy(this.points, index + 1, this.points, index, j);
+//   this.consistent = false;
+//   this.size--;
+//}
+/*=======================================================*/
+void GbSystem3D::PointSet3::clear()
+{
+   //clears points (size==0 but capacity is the old one)
+   this->points.clear();
+   this->consistent = false;
+}
+/*=======================================================*/
+void GbSystem3D::PointSet3::clearAndTrim()
+{
+   //clears points (size==0 AND capacity==0)
+   this->points.resize(0);
+   this->consistent = false;
+}
+/*=======================================================*/
+double GbSystem3D::PointSet3::getX1Minimum()
+{
+   if(!this->consistent) this->calculateValues();
+   return this->x1min;
+}
+/*=======================================================*/
+double GbSystem3D::PointSet3::getX1Maximum()
+{
+   if(!this->consistent) this->calculateValues();
+   return this->x1max;
+}
+/*=======================================================*/
+double GbSystem3D::PointSet3::getX2Minimum()
+{
+   if(!this->consistent) this->calculateValues();
+   return this->x2min;
+}
+/*=======================================================*/
+double GbSystem3D::PointSet3::getX2Maximum()
+{
+   if(!this->consistent) this->calculateValues();
+   return this->x2max;
+}
+/*=======================================================*/
+double GbSystem3D::PointSet3::getX3Minimum()
+{
+   if(!this->consistent) this->calculateValues();
+   return this->x3min;
+}
+/*=======================================================*/
+double GbSystem3D::PointSet3::getX3Maximum()
+{
+   if(!this->consistent) this->calculateValues();
+   return this->x3max;
+}
+/*=======================================================*/
+int GbSystem3D::PointSet3::contains(GbPoint3D* point)
+{
+   //returns number of points which has the same adress (this should be 0 or 1!!!)
+   int n=0;
+
+   for(int pos=(int)this->points.size()-1; pos>=0; pos--) 
+      if(&this->points[pos]==point) n++;
+
+   return n;
+}
+/*=======================================================*/
+int GbSystem3D::PointSet3::containsEqual(const GbPoint3D& point)
+{
+   //returns number of points which have the same coordinates with point (could be 0,1 or even more)
+   int n=0;
+
+   for(int pos=(int)this->points.size()-1; pos>=0; pos--) 
+      if(this->points[pos].equals(&point)) n++;
+
+   return n;
+}
+/*=======================================================*/
+bool GbSystem3D::PointSet3::containsLine(GbPoint3D *point1, GbPoint3D *point2)
+{
+   //returns true if pointset has two in "this->points"vector  neighboured points 
+   //wich have the same adress as point1 or point2
+   vector<GbPoint3D>::iterator pos1=this->points.begin();
+   vector<GbPoint3D>::iterator pos2;
+
+   for(pos2=pos1++; pos2!=this->points.end(); ++pos2) 
+   {
+      if     (&(*pos1)==point1 && &(*pos2)==point2) return true;
+      else if(&(*pos1)==point2 && &(*pos2)==point1) return true;
+
+      pos1=pos2;
+   }
+
+   return false;
+}
+/*=======================================================*/
+bool GbSystem3D::PointSet3::containsEqualLine(const GbPoint3D& point1, const GbPoint3D& point2)
+{
+   //returns true if pointset has two in "this->points"vector  neighboured points 
+   //wich have the same coordinates as point1 or point2
+   vector<GbPoint3D>::iterator pos1=this->points.begin();
+   vector<GbPoint3D>::iterator pos2;
+
+   for(pos2=pos1++; pos2!=this->points.end(); ++pos2) 
+   {
+      if     ((*pos1).equals(&point1) && (*pos2).equals(&point2)) return true;
+      else if((*pos1).equals(&point2) && (*pos2).equals(&point1)) return true;
+
+      pos1=pos2;
+   }
+
+   return false;
+}
+/*=======================================================*/
+GbPoint3D* GbSystem3D::PointSet3::getPoint(int index)
+{
+   if(index<0 || index>=(int)this->points.size()) throw UbException(UB_EXARGS,"index out of range");
+   return &(this->points)[index];
+}
+/*=======================================================*/
+GbPoint3D* GbSystem3D::PointSet3::getFirstPoint()
+{
+   return &(this->points.front());
+}
+/*=======================================================*/
+GbPoint3D* GbSystem3D::PointSet3::getLastPoint() 
+{ 
+   return &(this->points.back()); 
+}
+/*=======================================================*/
+int GbSystem3D::PointSet3::size()
+{ 
+   return (int)this->points.size();      
+}
+/*=======================================================*/
+vector<GbPoint3D> GbSystem3D::PointSet3::getPoints()
+{
+   //is this right? it's another effect as at GbPoint3D* getNode(index)!!!
+   //or do we want to have the next uncommented getPoints() funktion
+   return this->points;
+}
+///*=======================================================*/
+//vector<GbPoint3D*> GbSystem3D::PointSet3::getPoints()
+//{
+//   vector<GbPoint3D*> tmp;
+//   for(int pos=0; pos<(int)this->points.size();pos++) tmp.push_back(&this->points[pos]);
+//   
+//   return tmp;
+//}
+/*=======================================================*/
+void GbSystem3D::PointSet3::calculateValues()
+{
+   if(this->points.empty()) 
+   {
+      this->x1min = this->x2min = this->x3min = 0.0;
+      this->x1max = this->x2max = this->x3max = 0.0;
+   }
+   else
+   {
+      this->x1min = (this->points)[0].x1;
+      this->x1max = (this->points)[0].x1;
+      this->x2min = (this->points)[0].x2;
+      this->x2max = (this->points)[0].x2;
+      this->x3min = (this->points)[0].x3;
+      this->x3max = (this->points)[0].x3;
+
+      for(int i=(int)this->points.size()-1; i>0; --i)
+      {
+         if((this->points)[i].x1 < this->x1min) this->x1min = (this->points)[i].x1;
+         if((this->points)[i].x1 > this->x1max) this->x1max = (this->points)[i].x1;
+         if((this->points)[i].x2 < this->x2min) this->x2min = (this->points)[i].x2;
+         if((this->points)[i].x2 > this->x2max) this->x2max = (this->points)[i].x2;
+         if((this->points)[i].x3 < this->x3min) this->x3min = (this->points)[i].x3;
+         if((this->points)[i].x3 > this->x3max) this->x3max = (this->points)[i].x3;
+      }
+   }
+   this->consistent = true;
+}
+
+
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbSystem3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbSystem3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbSystem3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbSystem3D.h
index 11f5fafbb764f450af78c37e3170f0cededa4fa6..d0e842a525cda97a04a17cbaca5a51e2e658b5cf 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbSystem3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbSystem3D.h
@@ -1,396 +1,396 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBSYSTEM3D_H
-#define GBSYSTEM3D_H
-
-#include <iostream>
-#include <cmath>
-#include <vector>
-
-#include <basics/utilities/UbMath.h>
-#include <numerics/geometry3d/GbPoint3D.h>
-#include <numerics/geometry3d/GbObject3D.h>
-#include <basics/writer/WbWriter.h>
-
-class GbPolygon3D;
-class GbCuboid3D;
-class GbLine3D;
-
-namespace GbSystem3D
-{
-   extern double       getDistance(const GbPoint3D& p11, const GbPoint3D& p12);
-   extern GbPoint3D*   calculateIntersectionPoint3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22);
-   extern GbPolygon3D* clipPolygon3D(std::vector<GbPoint3D> points, double x11, double x12, double x13, double x21, double x22, double x23);
-   extern GbLine3D*    createClipLine3D(GbPoint3D& p1, GbPoint3D& p2, double x11, double x12, double x13, double x21, double x22, double x23);
-   extern bool         hasIntersectionPoint3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22);
-   extern bool         isParallelIn3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22);
-   extern GbCuboid3D*  clipRectangle3D(GbPoint3D& p1, GbPoint3D& p2, double x11, double x12, double x13, double x21, double x22, double x23);
-
-   /*========================================================================================*/
-   inline static std::string writeGeoObject(GbObject3D* gbobject, const std::string& filename, WbWriter* writer)
-   {
-      std::vector<UbTupleFloat3> nodes;
-      std::vector<UbTupleInt3>   triangles;
-      gbobject->addSurfaceTriangleSet(nodes, triangles);
-
-      std::string outFilename = writer->writeTriangles(filename,nodes,triangles);
-      return outFilename;
-   }
-   //the same as before
-   /*========================================================================================*/
-   inline static std::string writeGeoObject(SPtr<GbObject3D> gbobject, const std::string& filename, WbWriter* writer)
-   {
-      std::vector<UbTupleFloat3> nodes;
-      std::vector<UbTupleInt3>   triangles;
-      gbobject->addSurfaceTriangleSet(nodes, triangles);
-
-      std::string outFilename = writer->writeTriangles(filename,nodes,triangles);
-      return outFilename;
-   }
-   /*========================================================================================*/
-   inline static std::vector< std::string > writeGeoObject(GbObject3D*  gbobject, const std::string& filename, std::vector< WbWriter* > writer )
-   {
-      std::vector<UbTupleFloat3> nodes;
-      std::vector<UbTupleInt3>   triangles;
-      gbobject->addSurfaceTriangleSet(nodes, triangles);
-
-      std::vector< std::string > outFilenames;
-      for(std::size_t i=0; i<writer.size(); ++i)
-         outFilenames.push_back( writer[i]->writeTriangles(filename,nodes,triangles) );
-      return outFilenames;
-   }
-   /*========================================================================================*/
-   inline static std::string writeGeoObjects(std::vector< GbObject3D* > gbobjects, const std::string& filename, WbWriter* writer)
-   {
-      std::vector<UbTupleFloat3> nodes;
-      std::vector<UbTupleInt3>   triangles;
-
-      for(std::size_t i=0; i<gbobjects.size(); ++i)
-      {
-         //std::cout<<i<<", "<<gbobjects[i]<<std::endl;
-         gbobjects[i]->addSurfaceTriangleSet(nodes, triangles);
-      }
-
-      std::string outFilename = writer->writeTriangles(filename,nodes,triangles);
-      return outFilename;
-   }
-   /*========================================================================================*/
-
-   //////////////////////////////////////////////////////////////////////////
-   class PointSet3
-   {
-   public:
-      PointSet3(int n);
-      PointSet3(const std::vector<GbPoint3D>& points);
-      ~PointSet3(){}
-      void   add(const GbPoint3D& point);
-      void   addUnequal(const GbPoint3D& point);
-      void   add(const std::vector<GbPoint3D>& p);
-      int    contains(GbPoint3D* point);
-      void   insert(const GbPoint3D& point, int index);
-      void   clear();
-      void   clearAndTrim();
-      int    containsEqual(const GbPoint3D& point);
-      bool   containsLine(GbPoint3D* point1, GbPoint3D* point2);
-      bool   containsEqualLine(const GbPoint3D& point1, const GbPoint3D& point2);
-      double getX1Minimum();
-      double getX1Maximum();
-      double getX2Minimum();
-      double getX2Maximum();
-      double getX3Minimum();
-      double getX3Maximum();
-      void   calculateValues();
-      int    size();
-      GbPoint3D* getPoint(int index);
-      GbPoint3D* getFirstPoint();
-      GbPoint3D* getLastPoint() ;
-      std::vector<GbPoint3D> getPoints();
-
-   private:
-      double    x1min;
-      double    x1max;
-      double    x2min;
-      double    x2max;
-      double    x3min;
-      double    x3max;
-      bool      consistent;
-      std::vector<GbPoint3D> points;
-
-      void init()
-      {
-         consistent = false;
-         x1min = x2min = x3min = 0.0;
-         x1max = x2max = x3max = 0.0;
-      }
-   };
-   /*=================================================================*/
-   class OldPointSet3
-   {
-   private:
-      int       sizet;
-      double    x1min;
-      double    x1max;
-      double    x2min;
-      double    x2max;
-      double    x3min;
-      double    x3max;
-      bool      consistent;
-      std::vector<GbPoint3D> points;
-
-      void init()
-      {
-         sizet      = 0;
-         x1min      = 0.0;
-         x1max      = 0.0;
-         x2min      = 0.0;
-         x2max      = 0.0;
-         x3min		  = 0.0;
-         x3max      = 0.0;
-         consistent = false;
-         //points   = NULL;
-      };
-
-   public:
-      OldPointSet3(int n)
-      {
-         this->init();
-         this->points.resize(n);
-      }
-      OldPointSet3(std::vector<GbPoint3D> &points)
-      {
-         this->init();
-         this->points.resize(0);//, NULL);
-         this->add(points);
-      };
-      ~OldPointSet3()
-      {
-         //			delete points;
-      };
-      void add(GbPoint3D point)
-         {
-            if(this->sizet>0 && point.equals(&(this->points)[this->sizet-1])) return;
-            if(this->sizet == (int)this->points.size())
-            {
-               std::vector<GbPoint3D> a;
-               a.resize(1+(this->sizet<<1));
-               for(int u=0; u<this->sizet; u++)  { (a)[u] = (points)[u];	}
-               this->points = a;
-            }
-            (this->points)[this->sizet] = point;
-            this->consistent				= false;
-            this->sizet++;
-         }
-         void addUnequal(GbPoint3D *point)
-         {
-            if(this->containsEqual(point) > 0) return;
-            if(this->sizet == (int)this->points.size())
-            {
-               std::vector<GbPoint3D> a;
-               a.resize(1+(this->sizet<<1));
-               for(int u=0; u<this->sizet; u++)  { (a)[u] = (points)[u];	}
-               this->points = a;
-            }
-            (this->points)[this->sizet] = point;
-            this->consistent        = false;
-            this->sizet++;
-         }
-         void add(std::vector<GbPoint3D> &p)
-         {
-            if(this->sizet+p.size() >= this->points.size())
-            {
-               std::vector<GbPoint3D> a;
-               a.resize(this->sizet+p.size());
-               for(int u=0; u<(int)this->points.size(); u++)  { (a)[u] = (this->points)[u];	}
-               this->points = a;
-            }
-            int u = this->sizet;// (int)this->points->size();
-            for(int b=0; b<(int)p.size(); b++)			(this->points)[u++] = (p)[b];
-            //u = this->sizet;
-            //for(int b=0; b<(int)p->size(); b++)
-            //	cout<<(this->points)[u++].toString()<<endl;
-            this->consistent  = false;
-            this->sizet      += (int)p.size();
-         };
-         //		void insert(GbPoint3D *point, int index)
-         //      {
-         //	 if(this.size == this.points.length)
-         //	 {
-         //	    GbPoint3D a[] = new GbPoint3D[1+(this.size<<1)];
-         //	    System.arraycopy(this.points, 0, a, 0, this.size);
-         //	    this.points = a;
-         //	 }
-         //	 System.arraycopy(this.points, index, this.points, index+1, this.size-index);
-         //	 this.points[index] = point;
-         //	 this.consistent    = false;
-         //	 this.size++;
-         //      }
-         //      void delete(GbPoint3D point)
-         //      {
-         //	 for(int i=this.size-1; i>=0; i--) if(this.points[i] == point) this.delete(i);
-         //      }
-         //      void delete(int index)
-         //      {
-         //	 int j = this.size - index - 1;
-         //	 if(j > 0) System.arraycopy(this.points, index + 1, this.points, index, j);
-         //	 this.consistent = false;
-         //	 this.size--;
-         //      }
-         void clear()
-         {
-            this->sizet    = 0;
-            this->consistent = false;
-         }
-         void clearAndTrim()
-         {
-            this->sizet       = 0;
-            this->points.resize(0);
-            this->consistent = false;
-         }
-
-         double getX1Minimum()
-         {
-            if(!this->consistent) this->calculateValues();
-            return(this->x1min);
-         }
-         double getX1Maximum()
-         {
-            if(!this->consistent) this->calculateValues();
-            return(this->x1max);
-         }
-         double getX2Minimum()
-         {
-            if(!this->consistent) this->calculateValues();
-            return(this->x2min);
-         }
-         double getX2Maximum()
-         {
-            if(!this->consistent) this->calculateValues();
-            return(this->x2max);
-         }
-         double getX3Minimum()
-         {
-            if(!this->consistent) this->calculateValues();
-            return(this->x3min);
-         }
-         double getX3Maximum()
-         {
-            if(!this->consistent) this->calculateValues();
-            return(this->x3max);
-         }
-         void calculateValues()
-         {
-            this->x1min      = 0.0;
-            this->x1max      = 0.0;
-            this->x2min      = 0.0;
-            this->x2max      = 0.0;
-            this->x3min      = 0.0;
-            this->x3max      = 0.0;
-            this->consistent = true;
-
-            if(this->sizet == 0) return;
-
-            this->x1min = (this->points)[0].x1;
-            this->x1max = (this->points)[0].x1;
-            this->x2min = (this->points)[0].x2;
-            this->x2max = (this->points)[0].x2;
-            this->x3min = (this->points)[0].x3;
-            this->x3max = (this->points)[0].x3;
-
-            for(int i=this->sizet-1; i>0; i--)
-            {
-               if((this->points)[i].x1 < this->x1min) this->x1min = (this->points)[i].x1;
-               if((this->points)[i].x1 > this->x1max) this->x1max = (this->points)[i].x1;
-               if((this->points)[i].x2 < this->x2min) this->x2min = (this->points)[i].x2;
-               if((this->points)[i].x2 > this->x2max) this->x2max = (this->points)[i].x2;
-               if((this->points)[i].x3 < this->x3min) this->x3min = (this->points)[i].x3;
-               if((this->points)[i].x3 > this->x3max) this->x3max = (this->points)[i].x3;
-            }
-         };
-
-         int contains(GbPoint3D *point)
-         {
-            int n = 0;
-            for(int i=this->sizet-1; i>=0; i--) if(&(this->points)[i] == point) n++;
-            return(n);
-         };
-         int containsEqual(GbPoint3D *point)
-         {
-            int n = 0;
-            for(int i=this->sizet-1; i>=0; i--) if((this->points)[i].equals(point)) n++;
-            return(n);
-         }
-         bool containsLine(GbPoint3D *point1, GbPoint3D *point2)
-         {
-            for(int i=this->sizet-1; i>=0; i--) if(&(this->points)[i] == point1)
-            {
-               if(i == 0)
-               {
-                  if(&(this->points)[i+1]           == point2) return(true);
-                  if(&(this->points)[this->sizet-1] == point2) return(true);
-               }
-               else if(i == this->sizet-1)
-               {
-                  if(&(this->points)[0]   == point2) return(true);
-                  if(&(this->points)[i-1] == point2) return(true);
-               }
-               else
-               {
-                  if(&(this->points)[i+1] == point2) return(true);
-                  if(&(this->points)[i-1] == point2) return(true);
-               }
-            }
-            return(false);
-         };
-         //      boolean containsEqualLine(GbPoint2D point1, GbPoint2D point2)
-         //      {
-         //	 for(int i=this.size-1; i>=0; i--) if(this.points[i].equals(point1))
-         //	 {
-         //	    if(i == 0)
-         //	    {
-         //	       if(this.points[i+1].equals(point2))         return(true);
-         //	       if(this.points[this.size-1].equals(point2)) return(true);
-         //	    }
-         //	    else if(i == this.size-1)
-         //	    {
-         //	       if(this.points[0].equals(point2))   return(true);
-         //	       if(this.points[i-1].equals(point2)) return(true);
-         //	    }
-         //	    else
-         //	    {
-         //	       if(this.points[i+1].equals(point2)) return(true);
-         //	       if(this.points[i-1].equals(point2)) return(true);
-         //	    }
-         //	 }
-         //	 return(false);
-         //      }
-         GbPoint3D *getPoint(int index)
-         {
-            return(&(this->points)[index]);
-         }
-         GbPoint3D *getFirstPoint()
-         {
-            return(&(this->points)[0]);
-         }
-         GbPoint3D *getLastPoint() { return(&(this->points)[this->sizet-1]); }
-         int size()                { return(this->sizet);      }
-         std::vector<GbPoint3D> getPoints()
-         {
-            points.resize(sizet);
-            return points;
-            //int l = this->sizet;
-            //if(l > 1 && (this->points)[0].equals(&(this->points)[l-1])) l--;
-
-            //vector<GbPoint3D*> *a = new vector<GbPoint3D*>;
-            //a->resize(l, NULL);
-            //for(int u=0; u<l; u++)  { (*a)[u] = &((points)[u]);	}
-            //return(a);
-         }
-      };
-      /*=================================================================*/
-}
-
-#endif //GBSYSTEM3D_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBSYSTEM3D_H
+#define GBSYSTEM3D_H
+
+#include <iostream>
+#include <cmath>
+#include <vector>
+
+#include <basics/utilities/UbMath.h>
+#include <numerics/geometry3d/GbPoint3D.h>
+#include <numerics/geometry3d/GbObject3D.h>
+#include <basics/writer/WbWriter.h>
+
+class GbPolygon3D;
+class GbCuboid3D;
+class GbLine3D;
+
+namespace GbSystem3D
+{
+   extern double       getDistance(const GbPoint3D& p11, const GbPoint3D& p12);
+   extern GbPoint3D*   calculateIntersectionPoint3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22);
+   extern GbPolygon3D* clipPolygon3D(std::vector<GbPoint3D> points, double x11, double x12, double x13, double x21, double x22, double x23);
+   extern GbLine3D*    createClipLine3D(GbPoint3D& p1, GbPoint3D& p2, double x11, double x12, double x13, double x21, double x22, double x23);
+   extern bool         hasIntersectionPoint3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22);
+   extern bool         isParallelIn3D(GbPoint3D& p11, GbPoint3D& p12, GbPoint3D& p21, GbPoint3D& p22);
+   extern GbCuboid3D*  clipRectangle3D(GbPoint3D& p1, GbPoint3D& p2, double x11, double x12, double x13, double x21, double x22, double x23);
+
+   /*========================================================================================*/
+   inline static std::string writeGeoObject(GbObject3D* gbobject, const std::string& filename, WbWriter* writer)
+   {
+      std::vector<UbTupleFloat3> nodes;
+      std::vector<UbTupleInt3>   triangles;
+      gbobject->addSurfaceTriangleSet(nodes, triangles);
+
+      std::string outFilename = writer->writeTriangles(filename,nodes,triangles);
+      return outFilename;
+   }
+   //the same as before
+   /*========================================================================================*/
+   inline static std::string writeGeoObject(SPtr<GbObject3D> gbobject, const std::string& filename, WbWriter* writer)
+   {
+      std::vector<UbTupleFloat3> nodes;
+      std::vector<UbTupleInt3>   triangles;
+      gbobject->addSurfaceTriangleSet(nodes, triangles);
+
+      std::string outFilename = writer->writeTriangles(filename,nodes,triangles);
+      return outFilename;
+   }
+   /*========================================================================================*/
+   inline static std::vector< std::string > writeGeoObject(GbObject3D*  gbobject, const std::string& filename, std::vector< WbWriter* > writer )
+   {
+      std::vector<UbTupleFloat3> nodes;
+      std::vector<UbTupleInt3>   triangles;
+      gbobject->addSurfaceTriangleSet(nodes, triangles);
+
+      std::vector< std::string > outFilenames;
+      for(std::size_t i=0; i<writer.size(); ++i)
+         outFilenames.push_back( writer[i]->writeTriangles(filename,nodes,triangles) );
+      return outFilenames;
+   }
+   /*========================================================================================*/
+   inline static std::string writeGeoObjects(std::vector< GbObject3D* > gbobjects, const std::string& filename, WbWriter* writer)
+   {
+      std::vector<UbTupleFloat3> nodes;
+      std::vector<UbTupleInt3>   triangles;
+
+      for(std::size_t i=0; i<gbobjects.size(); ++i)
+      {
+         //std::cout<<i<<", "<<gbobjects[i]<<std::endl;
+         gbobjects[i]->addSurfaceTriangleSet(nodes, triangles);
+      }
+
+      std::string outFilename = writer->writeTriangles(filename,nodes,triangles);
+      return outFilename;
+   }
+   /*========================================================================================*/
+
+   //////////////////////////////////////////////////////////////////////////
+   class PointSet3
+   {
+   public:
+      PointSet3(int n);
+      PointSet3(const std::vector<GbPoint3D>& points);
+      ~PointSet3(){}
+      void   add(const GbPoint3D& point);
+      void   addUnequal(const GbPoint3D& point);
+      void   add(const std::vector<GbPoint3D>& p);
+      int    contains(GbPoint3D* point);
+      void   insert(const GbPoint3D& point, int index);
+      void   clear();
+      void   clearAndTrim();
+      int    containsEqual(const GbPoint3D& point);
+      bool   containsLine(GbPoint3D* point1, GbPoint3D* point2);
+      bool   containsEqualLine(const GbPoint3D& point1, const GbPoint3D& point2);
+      double getX1Minimum();
+      double getX1Maximum();
+      double getX2Minimum();
+      double getX2Maximum();
+      double getX3Minimum();
+      double getX3Maximum();
+      void   calculateValues();
+      int    size();
+      GbPoint3D* getPoint(int index);
+      GbPoint3D* getFirstPoint();
+      GbPoint3D* getLastPoint() ;
+      std::vector<GbPoint3D> getPoints();
+
+   private:
+      double    x1min;
+      double    x1max;
+      double    x2min;
+      double    x2max;
+      double    x3min;
+      double    x3max;
+      bool      consistent;
+      std::vector<GbPoint3D> points;
+
+      void init()
+      {
+         consistent = false;
+         x1min = x2min = x3min = 0.0;
+         x1max = x2max = x3max = 0.0;
+      }
+   };
+   /*=================================================================*/
+   class OldPointSet3
+   {
+   private:
+      int       sizet;
+      double    x1min;
+      double    x1max;
+      double    x2min;
+      double    x2max;
+      double    x3min;
+      double    x3max;
+      bool      consistent;
+      std::vector<GbPoint3D> points;
+
+      void init()
+      {
+         sizet      = 0;
+         x1min      = 0.0;
+         x1max      = 0.0;
+         x2min      = 0.0;
+         x2max      = 0.0;
+         x3min		  = 0.0;
+         x3max      = 0.0;
+         consistent = false;
+         //points   = NULL;
+      };
+
+   public:
+      OldPointSet3(int n)
+      {
+         this->init();
+         this->points.resize(n);
+      }
+      OldPointSet3(std::vector<GbPoint3D> &points)
+      {
+         this->init();
+         this->points.resize(0);//, NULL);
+         this->add(points);
+      };
+      ~OldPointSet3()
+      {
+         //			delete points;
+      };
+      void add(GbPoint3D point)
+         {
+            if(this->sizet>0 && point.equals(&(this->points)[this->sizet-1])) return;
+            if(this->sizet == (int)this->points.size())
+            {
+               std::vector<GbPoint3D> a;
+               a.resize(1+(this->sizet<<1));
+               for(int u=0; u<this->sizet; u++)  { (a)[u] = (points)[u];	}
+               this->points = a;
+            }
+            (this->points)[this->sizet] = point;
+            this->consistent				= false;
+            this->sizet++;
+         }
+         void addUnequal(GbPoint3D *point)
+         {
+            if(this->containsEqual(point) > 0) return;
+            if(this->sizet == (int)this->points.size())
+            {
+               std::vector<GbPoint3D> a;
+               a.resize(1+(this->sizet<<1));
+               for(int u=0; u<this->sizet; u++)  { (a)[u] = (points)[u];	}
+               this->points = a;
+            }
+            (this->points)[this->sizet] = point;
+            this->consistent        = false;
+            this->sizet++;
+         }
+         void add(std::vector<GbPoint3D> &p)
+         {
+            if(this->sizet+p.size() >= this->points.size())
+            {
+               std::vector<GbPoint3D> a;
+               a.resize(this->sizet+p.size());
+               for(int u=0; u<(int)this->points.size(); u++)  { (a)[u] = (this->points)[u];	}
+               this->points = a;
+            }
+            int u = this->sizet;// (int)this->points->size();
+            for(int b=0; b<(int)p.size(); b++)			(this->points)[u++] = (p)[b];
+            //u = this->sizet;
+            //for(int b=0; b<(int)p->size(); b++)
+            //	cout<<(this->points)[u++].toString()<<endl;
+            this->consistent  = false;
+            this->sizet      += (int)p.size();
+         };
+         //		void insert(GbPoint3D *point, int index)
+         //      {
+         //	 if(this.size == this.points.length)
+         //	 {
+         //	    GbPoint3D a[] = new GbPoint3D[1+(this.size<<1)];
+         //	    System.arraycopy(this.points, 0, a, 0, this.size);
+         //	    this.points = a;
+         //	 }
+         //	 System.arraycopy(this.points, index, this.points, index+1, this.size-index);
+         //	 this.points[index] = point;
+         //	 this.consistent    = false;
+         //	 this.size++;
+         //      }
+         //      void delete(GbPoint3D point)
+         //      {
+         //	 for(int i=this.size-1; i>=0; i--) if(this.points[i] == point) this.delete(i);
+         //      }
+         //      void delete(int index)
+         //      {
+         //	 int j = this.size - index - 1;
+         //	 if(j > 0) System.arraycopy(this.points, index + 1, this.points, index, j);
+         //	 this.consistent = false;
+         //	 this.size--;
+         //      }
+         void clear()
+         {
+            this->sizet    = 0;
+            this->consistent = false;
+         }
+         void clearAndTrim()
+         {
+            this->sizet       = 0;
+            this->points.resize(0);
+            this->consistent = false;
+         }
+
+         double getX1Minimum()
+         {
+            if(!this->consistent) this->calculateValues();
+            return(this->x1min);
+         }
+         double getX1Maximum()
+         {
+            if(!this->consistent) this->calculateValues();
+            return(this->x1max);
+         }
+         double getX2Minimum()
+         {
+            if(!this->consistent) this->calculateValues();
+            return(this->x2min);
+         }
+         double getX2Maximum()
+         {
+            if(!this->consistent) this->calculateValues();
+            return(this->x2max);
+         }
+         double getX3Minimum()
+         {
+            if(!this->consistent) this->calculateValues();
+            return(this->x3min);
+         }
+         double getX3Maximum()
+         {
+            if(!this->consistent) this->calculateValues();
+            return(this->x3max);
+         }
+         void calculateValues()
+         {
+            this->x1min      = 0.0;
+            this->x1max      = 0.0;
+            this->x2min      = 0.0;
+            this->x2max      = 0.0;
+            this->x3min      = 0.0;
+            this->x3max      = 0.0;
+            this->consistent = true;
+
+            if(this->sizet == 0) return;
+
+            this->x1min = (this->points)[0].x1;
+            this->x1max = (this->points)[0].x1;
+            this->x2min = (this->points)[0].x2;
+            this->x2max = (this->points)[0].x2;
+            this->x3min = (this->points)[0].x3;
+            this->x3max = (this->points)[0].x3;
+
+            for(int i=this->sizet-1; i>0; i--)
+            {
+               if((this->points)[i].x1 < this->x1min) this->x1min = (this->points)[i].x1;
+               if((this->points)[i].x1 > this->x1max) this->x1max = (this->points)[i].x1;
+               if((this->points)[i].x2 < this->x2min) this->x2min = (this->points)[i].x2;
+               if((this->points)[i].x2 > this->x2max) this->x2max = (this->points)[i].x2;
+               if((this->points)[i].x3 < this->x3min) this->x3min = (this->points)[i].x3;
+               if((this->points)[i].x3 > this->x3max) this->x3max = (this->points)[i].x3;
+            }
+         };
+
+         int contains(GbPoint3D *point)
+         {
+            int n = 0;
+            for(int i=this->sizet-1; i>=0; i--) if(&(this->points)[i] == point) n++;
+            return(n);
+         };
+         int containsEqual(GbPoint3D *point)
+         {
+            int n = 0;
+            for(int i=this->sizet-1; i>=0; i--) if((this->points)[i].equals(point)) n++;
+            return(n);
+         }
+         bool containsLine(GbPoint3D *point1, GbPoint3D *point2)
+         {
+            for(int i=this->sizet-1; i>=0; i--) if(&(this->points)[i] == point1)
+            {
+               if(i == 0)
+               {
+                  if(&(this->points)[i+1]           == point2) return(true);
+                  if(&(this->points)[this->sizet-1] == point2) return(true);
+               }
+               else if(i == this->sizet-1)
+               {
+                  if(&(this->points)[0]   == point2) return(true);
+                  if(&(this->points)[i-1] == point2) return(true);
+               }
+               else
+               {
+                  if(&(this->points)[i+1] == point2) return(true);
+                  if(&(this->points)[i-1] == point2) return(true);
+               }
+            }
+            return(false);
+         };
+         //      boolean containsEqualLine(GbPoint2D point1, GbPoint2D point2)
+         //      {
+         //	 for(int i=this.size-1; i>=0; i--) if(this.points[i].equals(point1))
+         //	 {
+         //	    if(i == 0)
+         //	    {
+         //	       if(this.points[i+1].equals(point2))         return(true);
+         //	       if(this.points[this.size-1].equals(point2)) return(true);
+         //	    }
+         //	    else if(i == this.size-1)
+         //	    {
+         //	       if(this.points[0].equals(point2))   return(true);
+         //	       if(this.points[i-1].equals(point2)) return(true);
+         //	    }
+         //	    else
+         //	    {
+         //	       if(this.points[i+1].equals(point2)) return(true);
+         //	       if(this.points[i-1].equals(point2)) return(true);
+         //	    }
+         //	 }
+         //	 return(false);
+         //      }
+         GbPoint3D *getPoint(int index)
+         {
+            return(&(this->points)[index]);
+         }
+         GbPoint3D *getFirstPoint()
+         {
+            return(&(this->points)[0]);
+         }
+         GbPoint3D *getLastPoint() { return(&(this->points)[this->sizet-1]); }
+         int size()                { return(this->sizet);      }
+         std::vector<GbPoint3D> getPoints()
+         {
+            points.resize(sizet);
+            return points;
+            //int l = this->sizet;
+            //if(l > 1 && (this->points)[0].equals(&(this->points)[l-1])) l--;
+
+            //vector<GbPoint3D*> *a = new vector<GbPoint3D*>;
+            //a->resize(l, NULL);
+            //for(int u=0; u<l; u++)  { (*a)[u] = &((points)[u]);	}
+            //return(a);
+         }
+      };
+      /*=================================================================*/
+}
+
+#endif //GBSYSTEM3D_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbTriFaceMesh3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbTriFaceMesh3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbTriFaceMesh3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbTriFaceMesh3D.cpp
index f376db99ee63db4ff277a2fcc7c8110098bc830f..0beb2b12b55b91372281f4a0cd1a8832752a337c 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbTriFaceMesh3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbTriFaceMesh3D.cpp
@@ -1,1227 +1,1227 @@
-
-#include <numerics/geometry3d/GbTriFaceMesh3D.h>
-
-#include <numerics/geometry3d/GbCuboid3D.h>
-#include <numerics/geometry3d/GbHalfSpace3D.h>
-#include <numerics/geometry3d/CoordinateTransformation3D.h>
-#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h>
-#include <basics/utilities/UbRandom.h>
-#include <basics/utilities/UbTiming.h>
-#include <basics/utilities/UbLogger.h>
-
-#include <numerics/geometry3d/KdTree/KdTree.h>
-#include <numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h>
-#include <numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h>
-#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h>
-#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h>
-
-#define MAX_ITER 10
-
-using namespace std;
-
-GbTriFaceMesh3D::GbTriFaceMesh3D() 
-   :   GbObject3D()
-     , buildVertTriRelationMap(false)
-     , kdTree(NULL)
-     , transX1(0.0)
-     , transX2(0.0)
-     , transX3(0.0)
-     , transferViaFilename(false)
-
-{
-   this->setName("CAB_GbTriFaceMesh3D");
-   this->nodes          = new vector<Vertex>;
-   this->triangles      = new vector<TriFace>;
-   this->consistent     = false;
-   this->kdtreeSplitAlg = KDTREE_SAHPLIT;
-}
-/*=======================================================================*/
-GbTriFaceMesh3D::GbTriFaceMesh3D(string name, vector<Vertex>* nodes, vector<TriFace>* triangles, KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
-   :  GbObject3D()
-    , nodes(nodes)
-    , triangles(triangles)
-    , buildVertTriRelationMap(false)
-    , consistent(false)
-    , kdTree(NULL)
-    , kdtreeSplitAlg(splitAlg)
-    , transX1(0.0)
-    , transX2(0.0)
-    , transX3(0.0)
-    , transferViaFilename(false)
-{
-   if( name.empty() ) throw UbException(UB_EXARGS,"no name specified");
-   if( !nodes       ) throw UbException(UB_EXARGS,"no nodes specified");
-   if( !triangles   ) throw UbException(UB_EXARGS,"no triangles specified");
-
-   this->setName(name);
-
-   if(removeRedundantNodes)
-   {
-      this->deleteRedundantNodes(); //dort wird autoamtisch calculateValues() aufgerufen
-   }
-   else
-   {
-      this->calculateValues();
-   }
-}
-/*=======================================================================*/
-GbTriFaceMesh3D::~GbTriFaceMesh3D()
-{
-   if( nodes     ) { delete nodes;     nodes     = NULL; }
-   if( triangles ) { delete triangles; triangles = NULL; }
-   if( kdTree    ) { delete kdTree;    kdTree    = NULL; }
-}
-/*======================================================================*/
-ObObjectCreator* GbTriFaceMesh3D::getCreator()
-{
-   return GbTriFaceMesh3DCreator::getInstance();
-}
-/*======================================================================*/
-void GbTriFaceMesh3D::init()
-{
-   nodes      = NULL;
-   triangles  = NULL;
-   x1min      = 0.0;
-   x1max      = 0.0;
-   x1center   = 0.0;
-   x2min      = 0.0;
-   x2max      = 0.0;
-   x2center   = 0.0;
-   x3min      = 0.0;
-   x3max      = 0.0;
-   x3center   = 0.0;
-   consistent = false;
-}
-/*======================================================================*/
-GbTriFaceMesh3D* GbTriFaceMesh3D::clone()
-{
-   vector<GbTriFaceMesh3D::Vertex>    *newNodes     = new vector<GbTriFaceMesh3D::Vertex>;
-   vector<GbTriFaceMesh3D::TriFace>   *newTriangles = new vector<GbTriFaceMesh3D::TriFace>;
-
-   int numberNodes = (int)this->nodes->size();
-
-   double x,y,z;
-   for(int u=0;u<numberNodes;u++)
-   {
-      x=(*nodes)[u].x;
-      y=(*nodes)[u].y;
-      z=(*nodes)[u].z;
-      newNodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-   }
-   int numberTris  = (int)this->triangles->size();
-   UBLOG(logDEBUG1,"numberTris:"<<numberTris);
-
-   int id1,id2,id3;
-   for(int u=0;u<numberTris;u++)
-   {
-      id1 = (*this->triangles)[u].v1;
-      id2 = (*this->triangles)[u].v2;
-      id3 = (*this->triangles)[u].v3;
-      newTriangles->push_back(GbTriFaceMesh3D::TriFace(id1,id2,id3));
-      //cout<<u<<" - id1,id2,id3:"<<id1<<","<<id2<<","<<id3<<endl;
-   }
-   UBLOG(logDEBUG1,"Tris gelesen");
-
-   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D("no name", newNodes, newTriangles);
-   UBLOG(logDEBUG1,"mesh cloned ...");
-
-   return mesh;
-}
-
-/*======================================================================*/
-//checks for doppelt nodes und fixed Dreicke die zweimal denselben Knoten haben
-void GbTriFaceMesh3D::deleteRedundantNodes()
-{
-    UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Nodes before deleting redundant: "<<this->nodes->size());
-
-    map<Vertex,size_t/*new vecIndex*/> vertexMap;
-    map<Vertex,size_t/*new vecIndex*/>::iterator pos;
-    map<Vertex,size_t/*new vecIndex*/>::iterator it;
-    
-    vector<TriFace>& tris     = *this->triangles;
-    vector<Vertex>&  oldNodes = *this->nodes;
-    vector<Vertex>   newNodes;
-
-    for(size_t t=0; t<tris.size(); t++)
-    {
-       if(t%100==0) UBLOG(logDEBUG5,"GbTriFaceMesh3D::deleteRedundantNodes - tri: "<<(t)<<" von "<<tris.size());
-       TriFace& tri = tris[t];
-       //Knoten bereits in neuem node vector?
-       for(int v=0; v<=2; v++)
-       {
-          Vertex& vert = tri.getNode(v,oldNodes);
-          //pos=vertexMap.find( vert );
-          //if( pos==vertexMap.end() )
-          {
-             for(pos=vertexMap.begin();pos!=vertexMap.end();pos++)
-             {
-               Vertex rhs = pos->first;
-             //if(UbMath::inClosedInterval(vert.z,0.01999, 0.02001))
-               if ( fabs(vert.x-rhs.x)<1.E-5 && fabs(vert.y-rhs.y)<1.E-5 && fabs(vert.z-rhs.z)<1.E-5 )
-               {
-                  break;
-               }
-             }
-          }
-          if( pos!=vertexMap.end() ) tri.setNode(v, (int)pos->second);
-          else
-          {
-             newNodes.push_back(vert);
-             int index = (int)newNodes.size()-1;
-             vertexMap[vert] = index;                       
-             tri.setNode(v,index);
-          }
-       }
-    }
-
-    std::swap(*nodes,newNodes);
-
-    UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Nodes after deleting redundant:"<<this->nodes->size());
-    //
-    //Das geht irgendwie nicht ...
-    //
-    //UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - checking for double triangles !!!");
-    //UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Triangles before deleting redundant: "<<this->triangles->size());
-    //vector<TriFace> newSingleTris;
-    //newSingleTris.reserve( this->triangles->size() );
-    //for(size_t t=0; t<tris.size(); t++)
-    //{
-    //   Vertex& v1 = tris[t].getNode(0,*nodes); 
-    //   Vertex& v2 = tris[t].getNode(1,*nodes); 
-    //   Vertex& v3 = tris[t].getNode(2,*nodes); 
-
-    //   if(UbMath::greater(std::fabs(v1.x), 0.0634) && UbMath::inClosedInterval(v1.z, 0.01999, 0.02001))
-    //   {
-    //      UBLOG2(logINFO,std::cout, "V1:"<<v1.x<<" "<<v1.y<<" "<<v1.z);
-    //   }
-    //   if(UbMath::greater(std::fabs(v2.x), 0.0634) && UbMath::inClosedInterval(v2.z, 0.01999, 0.02001))
-    //   {
-    //      UBLOG2(logINFO,std::cout, "V2:"<<v2.x<<" "<<v2.y<<" "<<v2.z);
-    //   }
-    //   if(UbMath::greater(std::fabs(v3.x), 0.0634) && UbMath::inClosedInterval(v3.z, 0.01999, 0.02001))
-    //   {
-    //      UBLOG2(logINFO,std::cout, "V3:"<<v3.x<<" "<<v3.y<<" "<<v3.z);
-    //   }
-
-    //   bool inList = false;
-    //   for(size_t u=0; u<newSingleTris.size(); u++)
-    //   {
-    //      Vertex& vn1 = newSingleTris[t].getNode(0,*nodes); 
-    //      Vertex& vn2 = newSingleTris[t].getNode(1,*nodes); 
-    //      Vertex& vn3 = newSingleTris[t].getNode(2,*nodes); 
-
-    //      if(v1==vn1 && v2==vn2 && v3==vn3)      inList = true;
-    //      else if(v1==vn1 && v2==vn3 && v3==vn2) inList = true;
-    //      else if(v1==vn2 && v2==vn3 && v3==vn1) inList = true;
-    //      else if(v1==vn2 && v2==vn1 && v3==vn3) inList = true;
-    //      else if(v1==vn3 && v2==vn1 && v3==vn2) inList = true;
-    //      else if(v1==vn3 && v2==vn2 && v3==vn1) inList = true;
-    //   }
-    //   if(!inList) newSingleTris.push_back(tris[t]);
-    //   else 
-    //      UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - inList !!!!");
-    
-    //}
-    //swap(tris,newSingleTris);
-
-    //UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Triangles after deleting redundant:"<<this->triangles->size());
-    UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - checking for triangles that have same node several times or are lines!!!");
-    int counter1 = 0;
-    int counter2 = 0;
-    vector<TriFace> newTris;
-    newTris.reserve( this->triangles->size() );
-    for(size_t t=0; t<tris.size(); t++)
-    {
-       Vertex& v1 = tris[t].getNode(0,*nodes); 
-       Vertex& v2 = tris[t].getNode(1,*nodes); 
-       Vertex& v3 = tris[t].getNode(2,*nodes); 
-       if( v1==v2 || v1==v3 || v2==v3 )
-       {
-          counter1++;
-       }
-       else if( tris[t].getArea(*nodes)<1.0E-8 )
-       {
-          counter2++;
-       }
-       else newTris.push_back(tris[t]);
-    }
-    if(counter1)
-    {
-       UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - ### Warning ###: found and removed  "<<counter1<<" triangle with double nodes!");
-    }
-    if(counter2)
-    {
-       UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - ### Warning ###: found and removed  "<<counter2<<" triangle that are lines!") ;
-    }
-    if(!counter1 && !counter2) { UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - alles gut... nix doppelt"); }
-    else swap(tris,newTris);
-    
-    UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - done" );
-    this->calculateValues();
-}
-/*======================================================================*/
-void GbTriFaceMesh3D::setKdTreeSplitAlgorithm(KDTREE_SPLITAGORITHM mode) 
-{ 
-   if(kdTree && mode != this->kdtreeSplitAlg) { delete kdTree; kdTree = NULL; }
-   this->kdtreeSplitAlg = mode; 
-}
-/*======================================================================*/
-   /**
-    * Returns a string representation of this triangular mesh.
-    * @return a string representation of this triangular mesh
-    */
-string GbTriFaceMesh3D::toString()
-{
-	stringstream ss;
-	ss<<"GbTriFaceMesh3D[";
-	ss<<(int)this->triangles->size()<<"-Triangles, "<<(int)this->nodes->size()<<"-Nodes, "<<endl;
-   ss<<"]";
-   return(ss.str());
-}
-/**
- * Returns the nodes of this triangular mesh.
- * @return the nodes of this triangular mesh
- */
-vector<GbTriFaceMesh3D::Vertex>* GbTriFaceMesh3D::getNodes()       {  return this->nodes;   }
-/**
- * Returns the triangles of this triangular mesh.
- * @return the triangles of this triangular mesh
- */
-vector<GbTriFaceMesh3D::TriFace>* GbTriFaceMesh3D::getTriangles()  { return this->triangles;  }
-/**
- * Returns the center x1 coordinate of this triangular mesh.
- * @return the center x1 coordinate of this triangular mesh
- */
-double GbTriFaceMesh3D::getVolume()
-{
-   vector<Vertex>&  vertices = *nodes;
-   vector<TriFace>& tris     = *triangles;
-
-   double x1,x2,x3,y1,y2,y3,z1,z2,z3, G3i;
-   //double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0;
-   double volume = 0.0;
-   for(size_t t=0; t<tris.size(); t++)
-   {
-      TriFace& triangle = tris[t];
-      x1     = triangle.getV1x(vertices); y1 = triangle.getV1y(vertices); z1 = triangle.getV1z(vertices);
-      x2     = triangle.getV2x(vertices); y2 = triangle.getV2y(vertices); z2 = triangle.getV2z(vertices);
-      x3     = triangle.getV3x(vertices); y3 = triangle.getV3y(vertices); z3 = triangle.getV3z(vertices);
-      G3i    = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
-      volume = volume+G3i/6.0;
-   }
-   return volume;
-}
-/*===============================================*/
-UbTupleDouble3 GbTriFaceMesh3D::calculateCenterOfGravity()
-{
-   vector<Vertex>&  vertices = *nodes;
-   vector<TriFace>& tris     = *triangles;
-   
-   double x1,x2,x3,y1,y2,y3,z1,z2,z3;
-   double G3i;
-   double rSP1 = 0.0, rSP2 = 0.0, rSP3 = 0.0, volume = 0.0;
-   
-   for(size_t t=0; t<tris.size(); t++)
-   {
-      TriFace& triangle = tris[t];
-      x1     = triangle.getV1x(vertices); y1 = triangle.getV1y(vertices); z1 = triangle.getV1z(vertices);
-      x2     = triangle.getV2x(vertices); y2 = triangle.getV2y(vertices); z2 = triangle.getV2z(vertices);
-      x3     = triangle.getV3x(vertices); y3 = triangle.getV3y(vertices); z3 = triangle.getV3z(vertices);
-      G3i    = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
-      volume = volume+G3i/6.0;
-      rSP1   = rSP1+G3i*(x1+x2+x3);
-      rSP2   = rSP2+G3i*(y1+y2+y3);
-      rSP3   = rSP3+G3i*(z1+z2+z3);
-   }
-   rSP1 = rSP1/(24.0*volume);
-   rSP2 = rSP2/(24.0*volume);
-   rSP3 = rSP3/(24.0*volume);
-
-   return UbTupleDouble3(rSP1, rSP2, rSP3);
-}
-/*===============================================*/
-UbTupleDouble6 GbTriFaceMesh3D::calculateMomentOfInertia(double rhoP)
-{
-   vector<Vertex>& vertices = *nodes;
-
-   double x1,x2,x3,y1,y2,y3,z1,z2,z3;
-   double G3i;
-   double xx,yy,zz,xy,yz,zx;
-   double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0;
-   double volume = 0.0;
-   double top11 = 0.0;double top22 = 0.0;double top33 = 0.0;
-   double top12 = 0.0;double top23 = 0.0;double top13 = 0.0;
-   int size = (int)this->triangles->size();
-   for(int u=0; u<size;u++)
-   {
-      TriFace& triangle = (*this->triangles)[u];
-      x1 = triangle.getV1x(vertices); y1 = triangle.getV1y(vertices); z1 = triangle.getV1z(vertices);
-      x2 = triangle.getV2x(vertices); y2 = triangle.getV2y(vertices); z2 = triangle.getV2z(vertices);
-      x3 = triangle.getV3x(vertices); y3 = triangle.getV3y(vertices); z3 = triangle.getV3z(vertices);
-      G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
-      volume = volume+G3i/6.0;
-      rSP1 = rSP1+G3i*(x1+x2+x3);
-      rSP2 = rSP2+G3i*(y1+y2+y3);
-      rSP3 = rSP3+G3i*(z1+z2+z3);
-   }
-   rSP1 = rSP1/(24.0*volume);
-   rSP2 = rSP2/(24.0*volume);
-   rSP3 = rSP3/(24.0*volume);
-
-   double x1s = 0.0;//rSP1;//0.0;//
-   double x2s = 0.0;//rSP2;//0.0;//
-   double x3s = 0.0;//rSP3;//0.0;//
-
-   for(int u=0; u<size;u++)
-   {
-      TriFace& triangle = (*this->triangles)[u];
-      x1 = triangle.getV1x(vertices)-x1s;
-      y1 = triangle.getV1y(vertices)-x2s;
-      z1 = triangle.getV1z(vertices)-x3s;
-      x2 = triangle.getV2x(vertices)-x1s;
-      y2 = triangle.getV2y(vertices)-x2s;
-      z2 = triangle.getV2z(vertices)-x3s;
-      x3 = triangle.getV3x(vertices)-x1s;
-      y3 = triangle.getV3y(vertices)-x2s;
-      z3 = triangle.getV3z(vertices)-x3s;
-      G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
-      //rSP1 = rSP1+G3i*(x1+x2+x3)/(24.0*volume);
-      //rSP2 = rSP2+G3i*(y1+y2+y3)/(24.0*volume);
-      //rSP3 = rSP3+G3i*(z1+z2+z3)/(24.0*volume);
-      xx = x1*x1+x2*x2+x3*x3+x1*x2+x2*x3+x3*x1;
-      yy = y1*y1+y2*y2+y3*y3+y1*y2+y2*y3+y3*y1;
-      zz = z1*z1+z2*z2+z3*z3+z1*z2+z2*z3+z3*z1;
-      top11 = top11+(yy+zz)*rhoP*G3i/60.;
-      top22 = top22+(xx+zz)*rhoP*G3i/60.;
-      top33 = top33+(yy+xx)*rhoP*G3i/60.;
-      xy = 2.0*(x1*y1+x2*y2+x3*y3)+x2*y3+x3*y1+x1*y2+x3*y2+x1*y3+x2*y1;
-      yz = 2.0*(y1*z1+y2*z2+y3*z3)+y2*z3+y3*z1+y1*z2+y3*z2+y1*z3+y2*z1;
-      zx = 2.0*(z1*x1+z2*x2+z3*x3)+z2*x3+z3*x1+z1*x2+z3*x2+z1*x3+z2*x1;
-      top12 = top12-xy*rhoP*G3i/120.;
-      top23 = top23-yz*rhoP*G3i/120.;
-      top13 = top13-zx*rhoP*G3i/120.;
-   }
-   //Satz von Steiner ...
-   top11 = top11-rhoP*volume*(rSP2*rSP2+rSP3+rSP3);
-   top22 = top22-rhoP*volume*(rSP3*rSP3+rSP1*rSP1);
-   top33 = top33-rhoP*volume*(rSP1*rSP1+rSP2*rSP2);
-   top12 = top12+rhoP*volume*rSP1*rSP2;
-   top23 = top23+rhoP*volume*rSP2*rSP3;
-   top13 = top13+rhoP*volume*rSP3*rSP1;
-
-   cout<<"Volume:"<<volume<<"\n Traegheitsmomente:\n";
-   cout<<" top11:"<<top11<<" top22:"<<top22<<" top33:"<<top33<<endl;
-   cout<<" top12:"<<top12<<" top23:"<<top23<<" top13:"<<top13<<endl;
-
-   return UbTupleDouble6(top11,top22,top33,top12,top23,top13);
-}
-/*==============================================================*/
-void GbTriFaceMesh3D::calculateValues()
-{
-   relationVertTris.clear();
-
-   if( nodes->empty() )
-   {
-      x1min = x1max = x2min = x2max = x3min = x3max = 0.0;
-   }
-   else
-   {
-      Vertex& v = (*nodes)[0];
-      x1min = x1max = v.x;
-      x2min = x2max = v.y;
-      x3min = x3max = v.z;
-
-      for(size_t i=1; i<this->nodes->size(); i++)
-      {
-         Vertex& v1 = (*nodes)[i];
-         
-         x1min = UbMath::min<double>(x1min,v1.x);
-         x2min = UbMath::min<double>(x2min,v1.y);
-         x3min = UbMath::min<double>(x3min,v1.z);
-         
-         x1max = UbMath::max<double>(x1max,v1.x);
-         x2max = UbMath::max<double>(x2max,v1.y);
-         x3max = UbMath::max<double>(x3max,v1.z);
-      }
-      x1center = 0.5 * (x1min + x1max );
-      x2center = 0.5 * (x2min + x2max );
-      x3center = 0.5 * (x3min + x3max );
-      
-      vector<TriFace>& tris  = *this->triangles;
-      vector<Vertex>&  verts = *this->nodes;
-      for(size_t i=0; i<this->triangles->size(); i++)
-      {
-         tris[i].calculateNormal(verts);
-      }
-      //relation Vertex <-> Triangle ermitteln
-      if(buildVertTriRelationMap)
-      {
-         for(size_t t=0; t<tris.size(); t++)
-         {
-            TriFace& tri = tris[t];
-            relationVertTris.insert( make_pair( &verts[tri.v1], &tri) );
-            relationVertTris.insert( make_pair( &verts[tri.v2], &tri) );
-            relationVertTris.insert( make_pair( &verts[tri.v3], &tri) );
-         }
-      }
-   }
-   if(kdTree)
-   { 
-      delete kdTree; 
-      kdTree=NULL; 
-   }
-   
-   this->consistent = true;
-}
-/*=========================================================================*/
-std::vector<GbTriFaceMesh3D::TriFace*> GbTriFaceMesh3D::getTrianglesForVertex(Vertex* vertex)
-{
-   if(!buildVertTriRelationMap) { buildVertTriRelationMap=true; consistent = false;}
-   if(!consistent) this->calculateValues();
-
-   typedef std::multimap<Vertex*,TriFace*>::iterator Iterator;
-   pair<Iterator,Iterator> objRange = relationVertTris.equal_range(vertex);
-
-   std::vector<TriFace*> tmpTris;
-   for(Iterator pos=objRange.first; pos!=objRange.second; ++pos) 
-      tmpTris.push_back( pos->second );
-
-   return tmpTris;
-}
-/*=======================================================*/
-void GbTriFaceMesh3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) 
-{
-   this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() );
-}
-
-/*======================================================================*/
-void GbTriFaceMesh3D::scale(const double& sx1, const double& sx2, const double& sx3)
-{
-   CoordinateTransformation3D trafoForw(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), 1.0, 1.0, 1.0, 0.0, 0.0, 0.0);
-   CoordinateTransformation3D trafoBack(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), sx1, sx2, sx3, 0, 0, 0);
-
-   vector<Vertex>& vertices = *nodes;
-   for(size_t i=0; i<vertices.size(); i++)
-   {
-      Vertex& v = vertices[i];
-      double p1x1 = trafoForw.transformForwardToX1Coordinate(v.x, v.y, v.z);
-      double p1x2 = trafoForw.transformForwardToX2Coordinate(v.x, v.y, v.z);
-      double p1x3 = trafoForw.transformForwardToX3Coordinate(v.x, v.y, v.z);
-      v.x = (float)trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3);
-      v.y = (float)trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3);
-      v.z = (float)trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3);
-   }
-   this->calculateValues();
-}
-/*======================================================================*/
-void GbTriFaceMesh3D::rotate(const double& alpha, const double& beta, const double& gamma)
-{
-   CoordinateTransformation3D trafoForw(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), 1.0, 1.0, 1.0, 0.0, 0.0, 0.0);
-   CoordinateTransformation3D trafoBack(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), 1.0, 1.0, 1.0, alpha, beta, gamma);
-
-   vector<Vertex>& vertices = *nodes;
-   for(size_t i=0; i<vertices.size(); i++)
-   {
-      Vertex& v = vertices[i];
-      double p1x1 = trafoForw.transformForwardToX1Coordinate(v.x, v.y, v.z);
-      double p1x2 = trafoForw.transformForwardToX2Coordinate(v.x, v.y, v.z);
-      double p1x3 = trafoForw.transformForwardToX3Coordinate(v.x, v.y, v.z);
-      v.x = (float)trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3);
-      v.y = (float)trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3);
-      v.z = (float)trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3);
-   }
-   this->calculateValues();
-}
-/*======================================================================*/
-void GbTriFaceMesh3D::rotateAroundPoint(const double& px1, const double& px2, const double& px3, const double& alpha, const double& beta, const double& gamma)
-{
-   CoordinateTransformation3D trafoForw(px1, px2, px3, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0);
-   CoordinateTransformation3D trafoBack(px1, px2, px3, 1.0, 1.0, 1.0, alpha, beta, gamma);
-
-   vector<Vertex>& vertices = *nodes;
-   for(size_t i=0; i<vertices.size(); i++)
-   {
-      Vertex& v = vertices[i];
-      double p1x1 = trafoForw.transformForwardToX1Coordinate(v.x, v.y, v.z);
-      double p1x2 = trafoForw.transformForwardToX2Coordinate(v.x, v.y, v.z);
-      double p1x3 = trafoForw.transformForwardToX3Coordinate(v.x, v.y, v.z);
-      v.x = (float)trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3);
-      v.y = (float)trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3);
-      v.z = (float)trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3);
-   }
-   this->calculateValues();
-}
-
-
-/*======================================================================*/
-void GbTriFaceMesh3D::translate(const double& x1, const double& x2, const double& x3)
-{
-   vector<Vertex>& vertices = *nodes;
-   for(size_t i=0; i<vertices.size(); i++)
-   {
-      Vertex& v = vertices[i];
-      v.x += static_cast<float>(x1);
-      v.y += static_cast<float>(x2);
-      v.z += static_cast<float>(x3);
-   }
-   this->calculateValues();
-}
-/*======================================================================*/
-vector<GbTriangle3D*> GbTriFaceMesh3D::getSurfaceTriangleSet()
-{
-   //SirAnn: eine miese Speicherlochmethode
-   //        hier werden dynmamische Objekte angelegt 
-   //        mit sowas rechnet von aussen kein Mensch!!!
-   vector<GbTriangle3D*> tris( triangles->size() );
-
-   for(size_t i=0; i<this->triangles->size(); i++)
-   {
-      Vertex& v1 = (*nodes)[(*triangles)[i].v1];
-      Vertex& v2 = (*nodes)[(*triangles)[i].v2];
-      Vertex& v3 = (*nodes)[(*triangles)[i].v3];
-
-      tris[i] = new GbTriangle3D(  new GbPoint3D(v1.x,v1.y,v1.z)
-                                 , new GbPoint3D(v2.x,v2.y,v2.z)
-                                 , new GbPoint3D(v3.x,v3.y,v3.z) );
-   }
-   return tris;
-}
-/*=======================================================*/
-void GbTriFaceMesh3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& pts, vector<UbTupleInt3>& tris)
-{
-   for(int i=0; i<(int)this->triangles->size(); i++)
-   {
-      Vertex& v1 = (*nodes)[(*triangles)[i].v1];
-      Vertex& v2 = (*nodes)[(*triangles)[i].v2];
-      Vertex& v3 = (*nodes)[(*triangles)[i].v3];
-      pts.push_back( makeUbTuple(v1.x,v1.y,v1.z));
-      pts.push_back( makeUbTuple(v2.x,v2.y,v2.z));
-      pts.push_back( makeUbTuple(v3.x,v3.y,v3.z));
-
-      tris.push_back( makeUbTuple( 3*i, 3*i+1, 3*i+2) );
-   }
-}
-/*======================================================================*/
-//bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, int counter)
-//{
-//
-//
-//   if( !nodes->empty() )
-//   {
-//      //Baum erstellen, wen noch keiner vorhanden
-//      if( !kdTree)
-//      {
-//         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start");
-//         UbTimer timer; timer.start();
-//         if(kdtreeSplitAlg == KDTREE_SAHPLIT     ) 
-//         {
-//            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit");
-//            this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>()            );
-//         }
-//         else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT)
-//         {
-//            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit");
-//            this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); 
-//         }
-//         else throw UbException(UB_EXARGS, "unknown kdtree split option)" );
-//         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds");
-//      }
-//
-//      //eigentlicher PIO-Test
-//      //int iSec;
-//      //for(int i=0; i<100; i++)
-//      //{
-//      //   Kd::Ray<double> ray(  x1, x2, x3  //, 1, 0 ,0 );
-//      //                        , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) )
-//      //                        , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) )
-//      //                        , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) );
-//      //                        
-//      //   iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() );
-//      //     
-//      //   if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen
-//      //   {
-//      //      if(iSec == Kd::Intersection::ON_BOUNDARY )
-//      //      {
-//      //         return true;
-//      //      }
-//      //      return (iSec&1);  //ungerade anzahl an schnitten --> drinnen
-//      //   }
-//      //   UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if  - an edge was hit ");
-//      //}
-//      //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
-//      int iSec1,iSec2;
-//         
-//      Kd::Ray<double> ray1(  x1, x2, x3, 1.0, 0.0 ,0.0 );
-//      iSec1 = kdTree->intersectRay( ray1, Kd::CountRayIntersectionHandler<double>() );
-//      Kd::Ray<double> ray2(  x1, x2, x3, -1.0, 0.0 ,0.0 );
-//      iSec2 = kdTree->intersectRay( ray2, Kd::CountRayIntersectionHandler<double>() );
-//
-//      if(iSec1 == Kd::Intersection::ON_BOUNDARY || iSec2 == Kd::Intersection::ON_BOUNDARY)
-//      {
-//         return true;
-//      }
-//      if( iSec1 == Kd::Intersection::INTERSECT_EDGE && iSec2 == Kd::Intersection::INTERSECT_EDGE) 
-//      {
-//         UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.INTERSECT_EDGE");
-//         double eps = UbMath::getEqualityEpsilon<float>()*1000.0;
-//         if (counter>100) {return(iSec1&1);  UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");}
-//         return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); 
-//      }
-//      else if( iSec1 == Kd::Intersection::INTERSECT_EDGE)
-//      {
-//         return (iSec2&1);  
-//      }
-//      else if( iSec2 == Kd::Intersection::INTERSECT_EDGE)
-//      {
-//         return (iSec1&1);  
-//      }
-//      else
-//      {
-//         if((iSec1&1) != (iSec2&1))
-//         {
-//            UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.iSec1&1 != iSec2&1");
-//            double eps = UbMath::getEqualityEpsilon<float>()*1000.0;
-//            if (counter>100) {return(iSec1&1);  UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");}
-//            return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1));
-//         }
-//         return iSec1&1;
-//      }
-//      //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
-//
-//   }
-//   return false;
-//}
-bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, int counter)
-{
-
-
-   if( !nodes->empty() )
-   {
-      //Baum erstellen, wen noch keiner vorhanden
-      if( !kdTree)
-      {
-         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start");
-         UbTimer timer; timer.start();
-         if(kdtreeSplitAlg == KDTREE_SAHPLIT     ) 
-         {
-            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit");
-            this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>()            );
-         }
-         else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT)
-         {
-            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit");
-            this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); 
-         }
-         else throw UbException(UB_EXARGS, "unknown kdtree split option)" );
-         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds");
-      }
-
-      //eigentlicher PIO-Test
-      //int iSec;
-      //for(int i=0; i<100; i++)
-      //{
-      //   Kd::Ray<double> ray(  x1, x2, x3  //, 1, 0 ,0 );
-      //                        , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) )
-      //                        , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) )
-      //                        , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) );
-      //                        
-      //   iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() );
-      //     
-      //   if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen
-      //   {
-      //      if(iSec == Kd::Intersection::ON_BOUNDARY )
-      //      {
-      //         return true;
-      //      }
-      //      return (iSec&1);  //ungerade anzahl an schnitten --> drinnen
-      //   }
-      //   UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if  - an edge was hit ");
-      //}
-      //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
-      int iSec1,iSec2;
-      double eps = 0.05;        
-      Kd::Ray<double> ray1(  x1, x2, x3, 1.0+eps*((double)counter), eps*((double)counter) ,eps*((double)counter) );
-      iSec1 = kdTree->intersectRay( ray1, Kd::CountRayIntersectionHandler<double>() );
-      Kd::Ray<double> ray2(  x1, x2, x3, -1.0-eps*((double)counter), -eps*((double)counter) ,-eps*((double)counter) );
- 
-      iSec2 = kdTree->intersectRay( ray2, Kd::CountRayIntersectionHandler<double>() );
-
-      if(iSec1 == Kd::Intersection::ON_BOUNDARY || iSec2 == Kd::Intersection::ON_BOUNDARY)
-      {
-         return true;
-      }
-      if( iSec1 == Kd::Intersection::INTERSECT_EDGE && iSec2 == Kd::Intersection::INTERSECT_EDGE) 
-      {
-         //UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.INTERSECT_EDGE");
-
-         if (counter>20) {return(iSec1&1);  UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");}
-         return this->isPointInGbObject3D(x1, x2, x3,(counter+1)); 
-      }
-      else if( iSec1 == Kd::Intersection::INTERSECT_EDGE)
-      {
-         return (iSec2&1);  
-      }
-      else if( iSec2 == Kd::Intersection::INTERSECT_EDGE)
-      {
-         return (iSec1&1);  
-      }
-      else
-      {
-         if((iSec1&1) != (iSec2&1))
-         {
-            //UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.iSec1&1 != iSec2&1");
-
-            if (counter>20) {return(iSec1&1);  UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");}
-            return this->isPointInGbObject3D(x1, x2, x3,(counter+1));
-         }
-         return iSec1&1;
-      }
-      //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
-
-   }
-   return false;
-}
-/*======================================================================*/
-bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3)
-{
-  int counter=0;
-
-   if( !nodes->empty() )
-   {
-      //Baum erstellen, wen noch keiner vorhanden
-      if( !kdTree)
-      {
-         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start");
-         UbTimer timer; timer.start();
-         if(kdtreeSplitAlg == KDTREE_SAHPLIT     ) 
-         {
-            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit");
-            this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>()            );
-         }
-         else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT)
-         {
-            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit");
-            this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); 
-         }
-         else throw UbException(UB_EXARGS, "unknown kdtree split option)" );
-         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds");
-      }
-
-      //eigentlicher PIO-Test
-      int iSec;
-      for(int i=0; i<MAX_ITER; i++)
-      {
-         Kd::Ray<double> ray(  x1, x2, x3  //, 1, 0 ,0 );
-                              , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) )
-                              , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) )
-                              , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) );
-                              
-         iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() );
-           
-         if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen
-         {
-            if(iSec == Kd::Intersection::ON_BOUNDARY )
-            {
-               return true;
-            }
-            return (iSec&1);  //ungerade anzahl an schnitten --> drinnen
-         }
-         UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if  - an edge was hit ");
-      }
-      throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
-
-   //   int iSec1,iSec2;
-   //      
-   //   Kd::Ray<double> ray1(  x1, x2, x3, 1.0, 0.0 ,0.0 );
-   //   iSec1 = kdTree->intersectRay( ray1, Kd::CountRayIntersectionHandler<double>() );
-   //   Kd::Ray<double> ray2(  x1, x2, x3, -1.0, 0.0 ,0.0 );
-   //   iSec2 = kdTree->intersectRay( ray2, Kd::CountRayIntersectionHandler<double>() );
-
-   //   if(iSec1 == Kd::Intersection::ON_BOUNDARY || iSec2 == Kd::Intersection::ON_BOUNDARY)
-   //   {
-   //      return true;
-   //   }
-   //   if( iSec1 == Kd::Intersection::INTERSECT_EDGE && iSec2 == Kd::Intersection::INTERSECT_EDGE) 
-   //   {
-   //      //UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.INTERSECT_EDGE");
-   //      double eps = UbMath::getEqualityEpsilon<double>();
-   //      if (counter>100) {return(iSec1&1);  UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");}
-   //      return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); 
-   //   }
-   //   else if( iSec1 == Kd::Intersection::INTERSECT_EDGE)
-   //   {
-   //      return (iSec2&1);  
-   //   }
-   //   else if( iSec2 == Kd::Intersection::INTERSECT_EDGE)
-   //   {
-   //      return (iSec1&1);  
-   //   }
-   //   else
-   //   {
-   //      if((iSec1&1) != (iSec2&1))
-   //      {
-   //         UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.iSec1&1 != iSec2&1");
-   //         double eps = UbMath::getEqualityEpsilon<double>();
-   //         if (counter>100) {return(iSec1&1);  UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");}
-   //         return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1));
-   //      }
-   //      return iSec1&1;
-   //   }
-   //   //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
-
-   }
-   return false;
-}
-/*======================================================================*/
-bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)
-{
-   if( !nodes->empty() )
-   {
-      //Baum erstellen, wen noch keiner vorhanden
-      if( !kdTree)
-      {
-         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start");
-         UbTimer timer; timer.start();
-         if(kdtreeSplitAlg == KDTREE_SAHPLIT     ) 
-         {
-            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit");
-            this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>()            );
-         }
-         else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT)
-         {
-            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit");
-            this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); 
-         }
-         else throw UbException(UB_EXARGS, "unknown kdtree split option)" );
-         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds");
-      }
-
-      //eigentlicher PIO-Test
-      int iSec;
-      for(int i=0; i<MAX_ITER; i++)
-      {
-         Kd::Ray<double> ray(  x1, x2, x3 
-                            , float( ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) )
-                            , float( ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) )
-                            , float( ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ) );
-
-         iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>()    );
-
-         if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen
-         {
-            if(iSec == Kd::Intersection::ON_BOUNDARY )
-            {
-               pointIsOnBoundary = true;
-               return true;
-            }
-            pointIsOnBoundary = false;
-            return (iSec&1);  //ungerade anzahl an schnitten --> drinnen
-         }
-      }
-
-      throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
-   }
-   
-   return false;
-}
-/*======================================================================*/
-GbLine3D* GbTriFaceMesh3D::createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2)
-{
-   throw UbException(UB_EXARGS,"not implemented");
-}
-/*======================================================================*/
-void GbTriFaceMesh3D::write(UbFileOutput* out)
-{
-   out->writeString(this->getCreator()->getTypeID());
-   out->writeInteger((int)kdtreeSplitAlg);
-   out->writeBool(transferViaFilename);
-
-   if(!transferViaFilename)
-   {
-      //nodes
-      vector<Vertex>& vertices = *nodes;
-      out->writeSize_t( nodes->size() );
-      out->writeLine();
-      for(size_t i=0; i<vertices.size(); i++)
-      {
-         Vertex& v = vertices[i];
-         out->writeFloat(v.x);
-         out->writeFloat(v.y);
-         out->writeFloat(v.z);
-         out->writeLine();
-      }
-      
-      //triangles
-      vector<TriFace>& tris = *triangles;
-      out->writeSize_t( tris.size() );
-      out->writeLine();
-      for(size_t i=0; i<tris.size(); i++)
-      {
-         TriFace& t = tris[i];
-         out->writeInteger(t.v1);
-         out->writeInteger(t.v2);
-         out->writeInteger(t.v3);
-         out->writeLine();
-      }
-   }
-   else
-   {
-      out->writeString(filename);
-      out->writeLine();
-      out->writeDouble(transX1);
-      out->writeDouble(transX2);
-      out->writeDouble(transX3);
-
-   }
-}
-/*======================================================================*/
-void GbTriFaceMesh3D::read(UbFileInput* in)
-{
-   kdtreeSplitAlg =  (KDTREE_SPLITAGORITHM)in->readInteger();
-   transferViaFilename = in->readBool();
-
-   if(!transferViaFilename)
-   {
-      if(!nodes) nodes = new vector<Vertex>;
-      //nodes
-      vector<Vertex>& vertices = *nodes;
-      vertices.resize( in->readSize_t( ) );
-      in->readLine();
-      for(size_t i=0; i<vertices.size(); i++)
-      {
-         Vertex& v = vertices[i];
-         v.x = in->readFloat();
-         v.y = in->readFloat();
-         v.z = in->readFloat();
-         in->readLine();
-      }
-
-      //triangles
-      if(!triangles) triangles = new vector<TriFace>;
-      vector<TriFace>& tris = *triangles;
-      tris.resize( in->readSize_t( ) );
-      in->readLine();
-      for(size_t i=0; i<tris.size(); i++)
-      {
-         TriFace& t = tris[i];
-         t.v1 = in->readInteger();
-         t.v2 = in->readInteger();
-         t.v3 = in->readInteger();
-         in->readLine();
-      }
-
-      this->calculateValues();
-   }
-   else
-   {
-      filename = in->readString();
-      in->readLine();
-      transX1 = in->readDouble();
-      transX2 = in->readDouble();
-      transX3 = in->readDouble();
-
-      this->readMeshFromSTLFile(filename, true);
-      this->translate(transX1,transX2,transX3);
-   }
-}
-/*======================================================================*/
-UbTuple<string, string> GbTriFaceMesh3D::writeMesh(string filename, WbWriter* writer, bool writeNormals, vector< string >* datanames, std::vector< std::vector < double > >* nodedata )
-{
-   UBLOG(logINFO, "GbTriFaceMesh3D::writeMesh ");
-
-   vector<UbTupleFloat3 > triNodes(nodes->size());
-   vector<UbTupleInt3 >   tris(triangles->size());
-
-   for(size_t i=0; i<nodes->size(); i++)
-      triNodes[i] = makeUbTuple( (*nodes)[i].x, (*nodes)[i].y, (*nodes)[i].z );
-
-   for(size_t i=0; i<triangles->size(); i++)
-      tris[i] = makeUbTuple( (*triangles)[i].v1, (*triangles)[i].v2, (*triangles)[i].v3 ) ;
-
-   UbTuple<string, string> filenames("","");
-
-   if( !datanames || datanames->empty() || !nodedata  )
-   {
-      val<1>(filenames) = writer->writeTriangles(filename,triNodes,tris);
-   }
-   else
-   {
-      val<1>(filenames) = writer->writeTrianglesWithNodeData(filename,triNodes,tris,*datanames,*nodedata);
-   }
-
-   if(writeNormals)
-   {
-      vector<UbTupleFloat3 > lineNodes(triangles->size()*2);
-      vector<UbTupleInt2 >   lines(triangles->size());
-      for(size_t i=0; i<triangles->size(); i++)
-      {
-         TriFace& triangle = (*triangles)[i];
-         lineNodes[i*2  ] = makeUbTuple( triangle.getX1Centroid(*nodes)
-                                        ,triangle.getX2Centroid(*nodes)
-                                        ,triangle.getX3Centroid(*nodes));
-
-         lineNodes[i*2+1] = makeUbTuple( (float)(triangle.getX1Centroid(*nodes)+1.0*triangle.nx)
-                                        ,(float)(triangle.getX2Centroid(*nodes)+1.0*triangle.ny)
-                                        ,(float)(triangle.getX3Centroid(*nodes)+1.0*triangle.nz));
-
-         lines[i] = makeUbTuple((int)i*2,(int)i*2+1);
-      }
-      val<2>(filenames) = writer->writeLines(filename+"_normals",lineNodes,lines);
-   }
-
-   return filenames;
-}
-/*======================================================================*/
-void GbTriFaceMesh3D::writeMeshPly( const std::string& filename)
-{
-   ofstream out(filename.c_str() );
-   if( !out )
-      throw UbException(UB_EXARGS, "couldn't open " + filename);
-
-   out << "ply" << endl;
-   out << "format ascii 1.0" << endl;
-   out << "element vertex " << (int)nodes->size() << endl;
-   out << "property float x" << endl;
-   out << "property float y" << endl;
-   out << "property float z" << endl;
-   out << "element face " << (int)triangles->size() << endl;
-   out << "property list uchar int vertex_indices" << endl;
-   out << "end_header" << endl;
-
-   for(size_t i=0; i<nodes->size(); i++)
-      out << (*nodes)[i].x << " " << (*nodes)[i].y << " " << (*nodes)[i].z << endl;
-
-   for(size_t i=0; i<triangles->size(); i++)
-      out << "3 " << (*triangles)[i].v1 << " " << (*triangles)[i].v2 << " " << (*triangles)[i].v3 << endl;
-}
-/*======================================================================*/
-void GbTriFaceMesh3D::readMeshFromSTLFile(string filename, bool removeRedundantNodes)
-{
-   UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ...");
-
-   UbFileInputASCII in(filename);
-   //this->nodes     = new vector<GbTriFaceMesh3D::Vertex>;
-   //this->triangles = new vector<GbTriFaceMesh3D::TriFace>;
-   string dummy;
-
-   double x, y, z;
-   int nr=0;
-
-   in.readLine();
-   while(dummy!="endsolid")
-   {
-      in.readLine();
-      in.readLine();
-      dummy = in.readString();
-      if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format");
-      x=in.readDouble();
-      y=in.readDouble();
-      z=in.readDouble();
-      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-      in.readLine();
-      in.readString();
-      x=in.readDouble();
-      y=in.readDouble();
-      z=in.readDouble();
-      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-      in.readLine();
-      in.readString();
-      x=in.readDouble();
-      y=in.readDouble();
-      z=in.readDouble();
-      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-      triangles->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2));
-      in.readLine();
-      in.readLine();
-      in.readLine();
-      dummy = in.readString();
-      nr+=3;
-   }
-   if(removeRedundantNodes)
-   {
-      this->deleteRedundantNodes(); //dort wird autoamtisch calculateValues() aufgerufen
-   }
-   else
-   {
-      this->calculateValues();
-   }
-}
-//////////////////////////////////////////////////////////////////////////
-//void GbTriFaceMesh3D::writeMeshToSTLFile(string filename, bool isBinaryFormat)
-//{
-//   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
-//   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
-//   int nr=0;
-//
-//   if (!isBinaryFormat) {
-//      ofstream out(filename.c_str());
-//      if (!out.good())
-//      {
-//         delete nodes;
-//         delete triangles;
-//         UB_THROW(UbException(UB_EXARGS, "Can not open STL file: "+filename));
-//      }
-//      char title[80] = "ASCII";
-//      std::string s0, s1;
-//      float n0, n1, n2, f0, f1, f2, f3, f4, f5, f6, f7, f8;
-//      out.write(title, 80);
-//      size_t size = nodes->size();
-//      for (size_t i = 0; i < size)
-//      {
-//         out << nodes[i++]
-//         in >> s0;                                // facet || endsolid
-//         if (s0=="facet") {
-//            in >> s1 >> n0 >> n1 >> n2;            // normal x y z
-//            in >> s0 >> s1;                        // outer loop
-//            in >> s0 >> f0 >> f1 >> f2;         // vertex x y z
-//            in >> s0 >> f3 >> f4 >> f5;         // vertex x y z
-//            in >> s0 >> f6 >> f7 >> f8;         // vertex x y z
-//            in >> s0;                            // endloop
-//            in >> s0;                            // endfacet
-//            // Generate a new Triangle without Normal as 3 Vertices
-//            nodes->push_back(GbTriFaceMesh3D::Vertex(f0, f1, f2));
-//            nodes->push_back(GbTriFaceMesh3D::Vertex(f3, f4, f5));
-//            nodes->push_back(GbTriFaceMesh3D::Vertex(f6, f7, f8));
-//            triangles->push_back(GbTriFaceMesh3D::TriFace(nr, nr+1, nr+2));
-//            nr+=3;
-//         }
-//         else if (s0=="endsolid") {
-//            break;
-//         }
-//      }
-//      in.close();
-//   }
-//   else {
-//      FILE *f = fopen(filename.c_str(), "rb");
-//      if (!f)
-//      {
-//         delete nodes;
-//         delete triangles;
-//         UB_THROW(UbException(UB_EXARGS, "Can not open STL file: "+filename));
-//      }
-//      char title[80];
-//      int nFaces;
-//      fread(title, 80, 1, f);
-//      fread((void*)&nFaces, 4, 1, f);
-//      float v[12]; // normal=3, vertices=3*3 = 12
-//      unsigned short uint16;
-//      // Every Face is 50 Bytes: Normal(3*float), Vertices(9*float), 2 Bytes Spacer
-//      for (size_t i=0; i<nFaces; ++i) {
-//         for (size_t j=0; j<12; ++j) {
-//            fread((void*)&v[j], sizeof(float), 1, f);
-//         }
-//         fread((void*)&uint16, sizeof(unsigned short), 1, f); // spacer between successive faces
-//         nodes->push_back(GbTriFaceMesh3D::Vertex(v[3], v[4], v[5]));
-//         nodes->push_back(GbTriFaceMesh3D::Vertex(v[6], v[7], v[8]));
-//         nodes->push_back(GbTriFaceMesh3D::Vertex(v[9], v[10], v[11]));
-//         triangles->push_back(GbTriFaceMesh3D::TriFace(nr, nr+1, nr+2));
-//         nr+=3;
-//      }
-//      fclose(f);
-//   }
-//
-//   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes);
-//
-//   return mesh;
-//}
-//////////////////////////////////////////////////////////////////////////
+
+#include <numerics/geometry3d/GbTriFaceMesh3D.h>
+
+#include <numerics/geometry3d/GbCuboid3D.h>
+#include <numerics/geometry3d/GbHalfSpace3D.h>
+#include <numerics/geometry3d/CoordinateTransformation3D.h>
+#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h>
+#include <basics/utilities/UbRandom.h>
+#include <basics/utilities/UbTiming.h>
+#include <basics/utilities/UbLogger.h>
+
+#include <numerics/geometry3d/KdTree/KdTree.h>
+#include <numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h>
+#include <numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h>
+#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h>
+#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h>
+
+#define MAX_ITER 10
+
+using namespace std;
+
+GbTriFaceMesh3D::GbTriFaceMesh3D() 
+   :   GbObject3D()
+     , buildVertTriRelationMap(false)
+     , kdTree(NULL)
+     , transX1(0.0)
+     , transX2(0.0)
+     , transX3(0.0)
+     , transferViaFilename(false)
+
+{
+   this->setName("CAB_GbTriFaceMesh3D");
+   this->nodes          = new vector<Vertex>;
+   this->triangles      = new vector<TriFace>;
+   this->consistent     = false;
+   this->kdtreeSplitAlg = KDTREE_SAHPLIT;
+}
+/*=======================================================================*/
+GbTriFaceMesh3D::GbTriFaceMesh3D(string name, vector<Vertex>* nodes, vector<TriFace>* triangles, KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
+   :  GbObject3D()
+    , nodes(nodes)
+    , triangles(triangles)
+    , buildVertTriRelationMap(false)
+    , consistent(false)
+    , kdTree(NULL)
+    , kdtreeSplitAlg(splitAlg)
+    , transX1(0.0)
+    , transX2(0.0)
+    , transX3(0.0)
+    , transferViaFilename(false)
+{
+   if( name.empty() ) throw UbException(UB_EXARGS,"no name specified");
+   if( !nodes       ) throw UbException(UB_EXARGS,"no nodes specified");
+   if( !triangles   ) throw UbException(UB_EXARGS,"no triangles specified");
+
+   this->setName(name);
+
+   if(removeRedundantNodes)
+   {
+      this->deleteRedundantNodes(); //dort wird autoamtisch calculateValues() aufgerufen
+   }
+   else
+   {
+      this->calculateValues();
+   }
+}
+/*=======================================================================*/
+GbTriFaceMesh3D::~GbTriFaceMesh3D()
+{
+   if( nodes     ) { delete nodes;     nodes     = NULL; }
+   if( triangles ) { delete triangles; triangles = NULL; }
+   if( kdTree    ) { delete kdTree;    kdTree    = NULL; }
+}
+/*======================================================================*/
+ObObjectCreator* GbTriFaceMesh3D::getCreator()
+{
+   return GbTriFaceMesh3DCreator::getInstance();
+}
+/*======================================================================*/
+void GbTriFaceMesh3D::init()
+{
+   nodes      = NULL;
+   triangles  = NULL;
+   x1min      = 0.0;
+   x1max      = 0.0;
+   x1center   = 0.0;
+   x2min      = 0.0;
+   x2max      = 0.0;
+   x2center   = 0.0;
+   x3min      = 0.0;
+   x3max      = 0.0;
+   x3center   = 0.0;
+   consistent = false;
+}
+/*======================================================================*/
+GbTriFaceMesh3D* GbTriFaceMesh3D::clone()
+{
+   vector<GbTriFaceMesh3D::Vertex>    *newNodes     = new vector<GbTriFaceMesh3D::Vertex>;
+   vector<GbTriFaceMesh3D::TriFace>   *newTriangles = new vector<GbTriFaceMesh3D::TriFace>;
+
+   int numberNodes = (int)this->nodes->size();
+
+   double x,y,z;
+   for(int u=0;u<numberNodes;u++)
+   {
+      x=(*nodes)[u].x;
+      y=(*nodes)[u].y;
+      z=(*nodes)[u].z;
+      newNodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+   }
+   int numberTris  = (int)this->triangles->size();
+   UBLOG(logDEBUG1,"numberTris:"<<numberTris);
+
+   int id1,id2,id3;
+   for(int u=0;u<numberTris;u++)
+   {
+      id1 = (*this->triangles)[u].v1;
+      id2 = (*this->triangles)[u].v2;
+      id3 = (*this->triangles)[u].v3;
+      newTriangles->push_back(GbTriFaceMesh3D::TriFace(id1,id2,id3));
+      //cout<<u<<" - id1,id2,id3:"<<id1<<","<<id2<<","<<id3<<endl;
+   }
+   UBLOG(logDEBUG1,"Tris gelesen");
+
+   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D("no name", newNodes, newTriangles);
+   UBLOG(logDEBUG1,"mesh cloned ...");
+
+   return mesh;
+}
+
+/*======================================================================*/
+//checks for doppelt nodes und fixed Dreicke die zweimal denselben Knoten haben
+void GbTriFaceMesh3D::deleteRedundantNodes()
+{
+    UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Nodes before deleting redundant: "<<this->nodes->size());
+
+    map<Vertex,size_t/*new vecIndex*/> vertexMap;
+    map<Vertex,size_t/*new vecIndex*/>::iterator pos;
+    map<Vertex,size_t/*new vecIndex*/>::iterator it;
+    
+    vector<TriFace>& tris     = *this->triangles;
+    vector<Vertex>&  oldNodes = *this->nodes;
+    vector<Vertex>   newNodes;
+
+    for(size_t t=0; t<tris.size(); t++)
+    {
+       if(t%100==0) UBLOG(logDEBUG5,"GbTriFaceMesh3D::deleteRedundantNodes - tri: "<<(t)<<" von "<<tris.size());
+       TriFace& tri = tris[t];
+       //Knoten bereits in neuem node vector?
+       for(int v=0; v<=2; v++)
+       {
+          Vertex& vert = tri.getNode(v,oldNodes);
+          //pos=vertexMap.find( vert );
+          //if( pos==vertexMap.end() )
+          {
+             for(pos=vertexMap.begin();pos!=vertexMap.end();pos++)
+             {
+               Vertex rhs = pos->first;
+             //if(UbMath::inClosedInterval(vert.z,0.01999, 0.02001))
+               if ( fabs(vert.x-rhs.x)<1.E-5 && fabs(vert.y-rhs.y)<1.E-5 && fabs(vert.z-rhs.z)<1.E-5 )
+               {
+                  break;
+               }
+             }
+          }
+          if( pos!=vertexMap.end() ) tri.setNode(v, (int)pos->second);
+          else
+          {
+             newNodes.push_back(vert);
+             int index = (int)newNodes.size()-1;
+             vertexMap[vert] = index;                       
+             tri.setNode(v,index);
+          }
+       }
+    }
+
+    std::swap(*nodes,newNodes);
+
+    UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Nodes after deleting redundant:"<<this->nodes->size());
+    //
+    //Das geht irgendwie nicht ...
+    //
+    //UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - checking for double triangles !!!");
+    //UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Triangles before deleting redundant: "<<this->triangles->size());
+    //vector<TriFace> newSingleTris;
+    //newSingleTris.reserve( this->triangles->size() );
+    //for(size_t t=0; t<tris.size(); t++)
+    //{
+    //   Vertex& v1 = tris[t].getNode(0,*nodes); 
+    //   Vertex& v2 = tris[t].getNode(1,*nodes); 
+    //   Vertex& v3 = tris[t].getNode(2,*nodes); 
+
+    //   if(UbMath::greater(std::fabs(v1.x), 0.0634) && UbMath::inClosedInterval(v1.z, 0.01999, 0.02001))
+    //   {
+    //      UBLOG2(logINFO,std::cout, "V1:"<<v1.x<<" "<<v1.y<<" "<<v1.z);
+    //   }
+    //   if(UbMath::greater(std::fabs(v2.x), 0.0634) && UbMath::inClosedInterval(v2.z, 0.01999, 0.02001))
+    //   {
+    //      UBLOG2(logINFO,std::cout, "V2:"<<v2.x<<" "<<v2.y<<" "<<v2.z);
+    //   }
+    //   if(UbMath::greater(std::fabs(v3.x), 0.0634) && UbMath::inClosedInterval(v3.z, 0.01999, 0.02001))
+    //   {
+    //      UBLOG2(logINFO,std::cout, "V3:"<<v3.x<<" "<<v3.y<<" "<<v3.z);
+    //   }
+
+    //   bool inList = false;
+    //   for(size_t u=0; u<newSingleTris.size(); u++)
+    //   {
+    //      Vertex& vn1 = newSingleTris[t].getNode(0,*nodes); 
+    //      Vertex& vn2 = newSingleTris[t].getNode(1,*nodes); 
+    //      Vertex& vn3 = newSingleTris[t].getNode(2,*nodes); 
+
+    //      if(v1==vn1 && v2==vn2 && v3==vn3)      inList = true;
+    //      else if(v1==vn1 && v2==vn3 && v3==vn2) inList = true;
+    //      else if(v1==vn2 && v2==vn3 && v3==vn1) inList = true;
+    //      else if(v1==vn2 && v2==vn1 && v3==vn3) inList = true;
+    //      else if(v1==vn3 && v2==vn1 && v3==vn2) inList = true;
+    //      else if(v1==vn3 && v2==vn2 && v3==vn1) inList = true;
+    //   }
+    //   if(!inList) newSingleTris.push_back(tris[t]);
+    //   else 
+    //      UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - inList !!!!");
+    
+    //}
+    //swap(tris,newSingleTris);
+
+    //UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Triangles after deleting redundant:"<<this->triangles->size());
+    UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - checking for triangles that have same node several times or are lines!!!");
+    int counter1 = 0;
+    int counter2 = 0;
+    vector<TriFace> newTris;
+    newTris.reserve( this->triangles->size() );
+    for(size_t t=0; t<tris.size(); t++)
+    {
+       Vertex& v1 = tris[t].getNode(0,*nodes); 
+       Vertex& v2 = tris[t].getNode(1,*nodes); 
+       Vertex& v3 = tris[t].getNode(2,*nodes); 
+       if( v1==v2 || v1==v3 || v2==v3 )
+       {
+          counter1++;
+       }
+       else if( tris[t].getArea(*nodes)<1.0E-8 )
+       {
+          counter2++;
+       }
+       else newTris.push_back(tris[t]);
+    }
+    if(counter1)
+    {
+       UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - ### Warning ###: found and removed  "<<counter1<<" triangle with double nodes!");
+    }
+    if(counter2)
+    {
+       UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - ### Warning ###: found and removed  "<<counter2<<" triangle that are lines!") ;
+    }
+    if(!counter1 && !counter2) { UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - alles gut... nix doppelt"); }
+    else swap(tris,newTris);
+    
+    UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - done" );
+    this->calculateValues();
+}
+/*======================================================================*/
+void GbTriFaceMesh3D::setKdTreeSplitAlgorithm(KDTREE_SPLITAGORITHM mode) 
+{ 
+   if(kdTree && mode != this->kdtreeSplitAlg) { delete kdTree; kdTree = NULL; }
+   this->kdtreeSplitAlg = mode; 
+}
+/*======================================================================*/
+   /**
+    * Returns a string representation of this triangular mesh.
+    * @return a string representation of this triangular mesh
+    */
+string GbTriFaceMesh3D::toString()
+{
+	stringstream ss;
+	ss<<"GbTriFaceMesh3D[";
+	ss<<(int)this->triangles->size()<<"-Triangles, "<<(int)this->nodes->size()<<"-Nodes, "<<endl;
+   ss<<"]";
+   return(ss.str());
+}
+/**
+ * Returns the nodes of this triangular mesh.
+ * @return the nodes of this triangular mesh
+ */
+vector<GbTriFaceMesh3D::Vertex>* GbTriFaceMesh3D::getNodes()       {  return this->nodes;   }
+/**
+ * Returns the triangles of this triangular mesh.
+ * @return the triangles of this triangular mesh
+ */
+vector<GbTriFaceMesh3D::TriFace>* GbTriFaceMesh3D::getTriangles()  { return this->triangles;  }
+/**
+ * Returns the center x1 coordinate of this triangular mesh.
+ * @return the center x1 coordinate of this triangular mesh
+ */
+double GbTriFaceMesh3D::getVolume()
+{
+   vector<Vertex>&  vertices = *nodes;
+   vector<TriFace>& tris     = *triangles;
+
+   double x1,x2,x3,y1,y2,y3,z1,z2,z3, G3i;
+   //double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0;
+   double volume = 0.0;
+   for(size_t t=0; t<tris.size(); t++)
+   {
+      TriFace& triangle = tris[t];
+      x1     = triangle.getV1x(vertices); y1 = triangle.getV1y(vertices); z1 = triangle.getV1z(vertices);
+      x2     = triangle.getV2x(vertices); y2 = triangle.getV2y(vertices); z2 = triangle.getV2z(vertices);
+      x3     = triangle.getV3x(vertices); y3 = triangle.getV3y(vertices); z3 = triangle.getV3z(vertices);
+      G3i    = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
+      volume = volume+G3i/6.0;
+   }
+   return volume;
+}
+/*===============================================*/
+UbTupleDouble3 GbTriFaceMesh3D::calculateCenterOfGravity()
+{
+   vector<Vertex>&  vertices = *nodes;
+   vector<TriFace>& tris     = *triangles;
+   
+   double x1,x2,x3,y1,y2,y3,z1,z2,z3;
+   double G3i;
+   double rSP1 = 0.0, rSP2 = 0.0, rSP3 = 0.0, volume = 0.0;
+   
+   for(size_t t=0; t<tris.size(); t++)
+   {
+      TriFace& triangle = tris[t];
+      x1     = triangle.getV1x(vertices); y1 = triangle.getV1y(vertices); z1 = triangle.getV1z(vertices);
+      x2     = triangle.getV2x(vertices); y2 = triangle.getV2y(vertices); z2 = triangle.getV2z(vertices);
+      x3     = triangle.getV3x(vertices); y3 = triangle.getV3y(vertices); z3 = triangle.getV3z(vertices);
+      G3i    = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
+      volume = volume+G3i/6.0;
+      rSP1   = rSP1+G3i*(x1+x2+x3);
+      rSP2   = rSP2+G3i*(y1+y2+y3);
+      rSP3   = rSP3+G3i*(z1+z2+z3);
+   }
+   rSP1 = rSP1/(24.0*volume);
+   rSP2 = rSP2/(24.0*volume);
+   rSP3 = rSP3/(24.0*volume);
+
+   return UbTupleDouble3(rSP1, rSP2, rSP3);
+}
+/*===============================================*/
+UbTupleDouble6 GbTriFaceMesh3D::calculateMomentOfInertia(double rhoP)
+{
+   vector<Vertex>& vertices = *nodes;
+
+   double x1,x2,x3,y1,y2,y3,z1,z2,z3;
+   double G3i;
+   double xx,yy,zz,xy,yz,zx;
+   double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0;
+   double volume = 0.0;
+   double top11 = 0.0;double top22 = 0.0;double top33 = 0.0;
+   double top12 = 0.0;double top23 = 0.0;double top13 = 0.0;
+   int size = (int)this->triangles->size();
+   for(int u=0; u<size;u++)
+   {
+      TriFace& triangle = (*this->triangles)[u];
+      x1 = triangle.getV1x(vertices); y1 = triangle.getV1y(vertices); z1 = triangle.getV1z(vertices);
+      x2 = triangle.getV2x(vertices); y2 = triangle.getV2y(vertices); z2 = triangle.getV2z(vertices);
+      x3 = triangle.getV3x(vertices); y3 = triangle.getV3y(vertices); z3 = triangle.getV3z(vertices);
+      G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
+      volume = volume+G3i/6.0;
+      rSP1 = rSP1+G3i*(x1+x2+x3);
+      rSP2 = rSP2+G3i*(y1+y2+y3);
+      rSP3 = rSP3+G3i*(z1+z2+z3);
+   }
+   rSP1 = rSP1/(24.0*volume);
+   rSP2 = rSP2/(24.0*volume);
+   rSP3 = rSP3/(24.0*volume);
+
+   double x1s = 0.0;//rSP1;//0.0;//
+   double x2s = 0.0;//rSP2;//0.0;//
+   double x3s = 0.0;//rSP3;//0.0;//
+
+   for(int u=0; u<size;u++)
+   {
+      TriFace& triangle = (*this->triangles)[u];
+      x1 = triangle.getV1x(vertices)-x1s;
+      y1 = triangle.getV1y(vertices)-x2s;
+      z1 = triangle.getV1z(vertices)-x3s;
+      x2 = triangle.getV2x(vertices)-x1s;
+      y2 = triangle.getV2y(vertices)-x2s;
+      z2 = triangle.getV2z(vertices)-x3s;
+      x3 = triangle.getV3x(vertices)-x1s;
+      y3 = triangle.getV3y(vertices)-x2s;
+      z3 = triangle.getV3z(vertices)-x3s;
+      G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
+      //rSP1 = rSP1+G3i*(x1+x2+x3)/(24.0*volume);
+      //rSP2 = rSP2+G3i*(y1+y2+y3)/(24.0*volume);
+      //rSP3 = rSP3+G3i*(z1+z2+z3)/(24.0*volume);
+      xx = x1*x1+x2*x2+x3*x3+x1*x2+x2*x3+x3*x1;
+      yy = y1*y1+y2*y2+y3*y3+y1*y2+y2*y3+y3*y1;
+      zz = z1*z1+z2*z2+z3*z3+z1*z2+z2*z3+z3*z1;
+      top11 = top11+(yy+zz)*rhoP*G3i/60.;
+      top22 = top22+(xx+zz)*rhoP*G3i/60.;
+      top33 = top33+(yy+xx)*rhoP*G3i/60.;
+      xy = 2.0*(x1*y1+x2*y2+x3*y3)+x2*y3+x3*y1+x1*y2+x3*y2+x1*y3+x2*y1;
+      yz = 2.0*(y1*z1+y2*z2+y3*z3)+y2*z3+y3*z1+y1*z2+y3*z2+y1*z3+y2*z1;
+      zx = 2.0*(z1*x1+z2*x2+z3*x3)+z2*x3+z3*x1+z1*x2+z3*x2+z1*x3+z2*x1;
+      top12 = top12-xy*rhoP*G3i/120.;
+      top23 = top23-yz*rhoP*G3i/120.;
+      top13 = top13-zx*rhoP*G3i/120.;
+   }
+   //Satz von Steiner ...
+   top11 = top11-rhoP*volume*(rSP2*rSP2+rSP3+rSP3);
+   top22 = top22-rhoP*volume*(rSP3*rSP3+rSP1*rSP1);
+   top33 = top33-rhoP*volume*(rSP1*rSP1+rSP2*rSP2);
+   top12 = top12+rhoP*volume*rSP1*rSP2;
+   top23 = top23+rhoP*volume*rSP2*rSP3;
+   top13 = top13+rhoP*volume*rSP3*rSP1;
+
+   cout<<"Volume:"<<volume<<"\n Traegheitsmomente:\n";
+   cout<<" top11:"<<top11<<" top22:"<<top22<<" top33:"<<top33<<endl;
+   cout<<" top12:"<<top12<<" top23:"<<top23<<" top13:"<<top13<<endl;
+
+   return UbTupleDouble6(top11,top22,top33,top12,top23,top13);
+}
+/*==============================================================*/
+void GbTriFaceMesh3D::calculateValues()
+{
+   relationVertTris.clear();
+
+   if( nodes->empty() )
+   {
+      x1min = x1max = x2min = x2max = x3min = x3max = 0.0;
+   }
+   else
+   {
+      Vertex& v = (*nodes)[0];
+      x1min = x1max = v.x;
+      x2min = x2max = v.y;
+      x3min = x3max = v.z;
+
+      for(size_t i=1; i<this->nodes->size(); i++)
+      {
+         Vertex& v1 = (*nodes)[i];
+         
+         x1min = UbMath::min<double>(x1min,v1.x);
+         x2min = UbMath::min<double>(x2min,v1.y);
+         x3min = UbMath::min<double>(x3min,v1.z);
+         
+         x1max = UbMath::max<double>(x1max,v1.x);
+         x2max = UbMath::max<double>(x2max,v1.y);
+         x3max = UbMath::max<double>(x3max,v1.z);
+      }
+      x1center = 0.5 * (x1min + x1max );
+      x2center = 0.5 * (x2min + x2max );
+      x3center = 0.5 * (x3min + x3max );
+      
+      vector<TriFace>& tris  = *this->triangles;
+      vector<Vertex>&  verts = *this->nodes;
+      for(size_t i=0; i<this->triangles->size(); i++)
+      {
+         tris[i].calculateNormal(verts);
+      }
+      //relation Vertex <-> Triangle ermitteln
+      if(buildVertTriRelationMap)
+      {
+         for(size_t t=0; t<tris.size(); t++)
+         {
+            TriFace& tri = tris[t];
+            relationVertTris.insert( make_pair( &verts[tri.v1], &tri) );
+            relationVertTris.insert( make_pair( &verts[tri.v2], &tri) );
+            relationVertTris.insert( make_pair( &verts[tri.v3], &tri) );
+         }
+      }
+   }
+   if(kdTree)
+   { 
+      delete kdTree; 
+      kdTree=NULL; 
+   }
+   
+   this->consistent = true;
+}
+/*=========================================================================*/
+std::vector<GbTriFaceMesh3D::TriFace*> GbTriFaceMesh3D::getTrianglesForVertex(Vertex* vertex)
+{
+   if(!buildVertTriRelationMap) { buildVertTriRelationMap=true; consistent = false;}
+   if(!consistent) this->calculateValues();
+
+   typedef std::multimap<Vertex*,TriFace*>::iterator Iterator;
+   pair<Iterator,Iterator> objRange = relationVertTris.equal_range(vertex);
+
+   std::vector<TriFace*> tmpTris;
+   for(Iterator pos=objRange.first; pos!=objRange.second; ++pos) 
+      tmpTris.push_back( pos->second );
+
+   return tmpTris;
+}
+/*=======================================================*/
+void GbTriFaceMesh3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) 
+{
+   this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() );
+}
+
+/*======================================================================*/
+void GbTriFaceMesh3D::scale(const double& sx1, const double& sx2, const double& sx3)
+{
+   CoordinateTransformation3D trafoForw(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), 1.0, 1.0, 1.0, 0.0, 0.0, 0.0);
+   CoordinateTransformation3D trafoBack(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), sx1, sx2, sx3, 0, 0, 0);
+
+   vector<Vertex>& vertices = *nodes;
+   for(size_t i=0; i<vertices.size(); i++)
+   {
+      Vertex& v = vertices[i];
+      double p1x1 = trafoForw.transformForwardToX1Coordinate(v.x, v.y, v.z);
+      double p1x2 = trafoForw.transformForwardToX2Coordinate(v.x, v.y, v.z);
+      double p1x3 = trafoForw.transformForwardToX3Coordinate(v.x, v.y, v.z);
+      v.x = (float)trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3);
+      v.y = (float)trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3);
+      v.z = (float)trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3);
+   }
+   this->calculateValues();
+}
+/*======================================================================*/
+void GbTriFaceMesh3D::rotate(const double& alpha, const double& beta, const double& gamma)
+{
+   CoordinateTransformation3D trafoForw(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), 1.0, 1.0, 1.0, 0.0, 0.0, 0.0);
+   CoordinateTransformation3D trafoBack(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), 1.0, 1.0, 1.0, alpha, beta, gamma);
+
+   vector<Vertex>& vertices = *nodes;
+   for(size_t i=0; i<vertices.size(); i++)
+   {
+      Vertex& v = vertices[i];
+      double p1x1 = trafoForw.transformForwardToX1Coordinate(v.x, v.y, v.z);
+      double p1x2 = trafoForw.transformForwardToX2Coordinate(v.x, v.y, v.z);
+      double p1x3 = trafoForw.transformForwardToX3Coordinate(v.x, v.y, v.z);
+      v.x = (float)trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3);
+      v.y = (float)trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3);
+      v.z = (float)trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3);
+   }
+   this->calculateValues();
+}
+/*======================================================================*/
+void GbTriFaceMesh3D::rotateAroundPoint(const double& px1, const double& px2, const double& px3, const double& alpha, const double& beta, const double& gamma)
+{
+   CoordinateTransformation3D trafoForw(px1, px2, px3, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0);
+   CoordinateTransformation3D trafoBack(px1, px2, px3, 1.0, 1.0, 1.0, alpha, beta, gamma);
+
+   vector<Vertex>& vertices = *nodes;
+   for(size_t i=0; i<vertices.size(); i++)
+   {
+      Vertex& v = vertices[i];
+      double p1x1 = trafoForw.transformForwardToX1Coordinate(v.x, v.y, v.z);
+      double p1x2 = trafoForw.transformForwardToX2Coordinate(v.x, v.y, v.z);
+      double p1x3 = trafoForw.transformForwardToX3Coordinate(v.x, v.y, v.z);
+      v.x = (float)trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3);
+      v.y = (float)trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3);
+      v.z = (float)trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3);
+   }
+   this->calculateValues();
+}
+
+
+/*======================================================================*/
+void GbTriFaceMesh3D::translate(const double& x1, const double& x2, const double& x3)
+{
+   vector<Vertex>& vertices = *nodes;
+   for(size_t i=0; i<vertices.size(); i++)
+   {
+      Vertex& v = vertices[i];
+      v.x += static_cast<float>(x1);
+      v.y += static_cast<float>(x2);
+      v.z += static_cast<float>(x3);
+   }
+   this->calculateValues();
+}
+/*======================================================================*/
+vector<GbTriangle3D*> GbTriFaceMesh3D::getSurfaceTriangleSet()
+{
+   //SirAnn: eine miese Speicherlochmethode
+   //        hier werden dynmamische Objekte angelegt 
+   //        mit sowas rechnet von aussen kein Mensch!!!
+   vector<GbTriangle3D*> tris( triangles->size() );
+
+   for(size_t i=0; i<this->triangles->size(); i++)
+   {
+      Vertex& v1 = (*nodes)[(*triangles)[i].v1];
+      Vertex& v2 = (*nodes)[(*triangles)[i].v2];
+      Vertex& v3 = (*nodes)[(*triangles)[i].v3];
+
+      tris[i] = new GbTriangle3D(  new GbPoint3D(v1.x,v1.y,v1.z)
+                                 , new GbPoint3D(v2.x,v2.y,v2.z)
+                                 , new GbPoint3D(v3.x,v3.y,v3.z) );
+   }
+   return tris;
+}
+/*=======================================================*/
+void GbTriFaceMesh3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& pts, vector<UbTupleInt3>& tris)
+{
+   for(int i=0; i<(int)this->triangles->size(); i++)
+   {
+      Vertex& v1 = (*nodes)[(*triangles)[i].v1];
+      Vertex& v2 = (*nodes)[(*triangles)[i].v2];
+      Vertex& v3 = (*nodes)[(*triangles)[i].v3];
+      pts.push_back( makeUbTuple(v1.x,v1.y,v1.z));
+      pts.push_back( makeUbTuple(v2.x,v2.y,v2.z));
+      pts.push_back( makeUbTuple(v3.x,v3.y,v3.z));
+
+      tris.push_back( makeUbTuple( 3*i, 3*i+1, 3*i+2) );
+   }
+}
+/*======================================================================*/
+//bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, int counter)
+//{
+//
+//
+//   if( !nodes->empty() )
+//   {
+//      //Baum erstellen, wen noch keiner vorhanden
+//      if( !kdTree)
+//      {
+//         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start");
+//         UbTimer timer; timer.start();
+//         if(kdtreeSplitAlg == KDTREE_SAHPLIT     ) 
+//         {
+//            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit");
+//            this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>()            );
+//         }
+//         else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT)
+//         {
+//            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit");
+//            this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); 
+//         }
+//         else throw UbException(UB_EXARGS, "unknown kdtree split option)" );
+//         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds");
+//      }
+//
+//      //eigentlicher PIO-Test
+//      //int iSec;
+//      //for(int i=0; i<100; i++)
+//      //{
+//      //   Kd::Ray<double> ray(  x1, x2, x3  //, 1, 0 ,0 );
+//      //                        , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) )
+//      //                        , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) )
+//      //                        , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) );
+//      //                        
+//      //   iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() );
+//      //     
+//      //   if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen
+//      //   {
+//      //      if(iSec == Kd::Intersection::ON_BOUNDARY )
+//      //      {
+//      //         return true;
+//      //      }
+//      //      return (iSec&1);  //ungerade anzahl an schnitten --> drinnen
+//      //   }
+//      //   UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if  - an edge was hit ");
+//      //}
+//      //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
+//      int iSec1,iSec2;
+//         
+//      Kd::Ray<double> ray1(  x1, x2, x3, 1.0, 0.0 ,0.0 );
+//      iSec1 = kdTree->intersectRay( ray1, Kd::CountRayIntersectionHandler<double>() );
+//      Kd::Ray<double> ray2(  x1, x2, x3, -1.0, 0.0 ,0.0 );
+//      iSec2 = kdTree->intersectRay( ray2, Kd::CountRayIntersectionHandler<double>() );
+//
+//      if(iSec1 == Kd::Intersection::ON_BOUNDARY || iSec2 == Kd::Intersection::ON_BOUNDARY)
+//      {
+//         return true;
+//      }
+//      if( iSec1 == Kd::Intersection::INTERSECT_EDGE && iSec2 == Kd::Intersection::INTERSECT_EDGE) 
+//      {
+//         UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.INTERSECT_EDGE");
+//         double eps = UbMath::getEqualityEpsilon<float>()*1000.0;
+//         if (counter>100) {return(iSec1&1);  UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");}
+//         return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); 
+//      }
+//      else if( iSec1 == Kd::Intersection::INTERSECT_EDGE)
+//      {
+//         return (iSec2&1);  
+//      }
+//      else if( iSec2 == Kd::Intersection::INTERSECT_EDGE)
+//      {
+//         return (iSec1&1);  
+//      }
+//      else
+//      {
+//         if((iSec1&1) != (iSec2&1))
+//         {
+//            UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.iSec1&1 != iSec2&1");
+//            double eps = UbMath::getEqualityEpsilon<float>()*1000.0;
+//            if (counter>100) {return(iSec1&1);  UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");}
+//            return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1));
+//         }
+//         return iSec1&1;
+//      }
+//      //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
+//
+//   }
+//   return false;
+//}
+bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, int counter)
+{
+
+
+   if( !nodes->empty() )
+   {
+      //Baum erstellen, wen noch keiner vorhanden
+      if( !kdTree)
+      {
+         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start");
+         UbTimer timer; timer.start();
+         if(kdtreeSplitAlg == KDTREE_SAHPLIT     ) 
+         {
+            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit");
+            this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>()            );
+         }
+         else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT)
+         {
+            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit");
+            this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); 
+         }
+         else throw UbException(UB_EXARGS, "unknown kdtree split option)" );
+         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds");
+      }
+
+      //eigentlicher PIO-Test
+      //int iSec;
+      //for(int i=0; i<100; i++)
+      //{
+      //   Kd::Ray<double> ray(  x1, x2, x3  //, 1, 0 ,0 );
+      //                        , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) )
+      //                        , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) )
+      //                        , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) );
+      //                        
+      //   iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() );
+      //     
+      //   if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen
+      //   {
+      //      if(iSec == Kd::Intersection::ON_BOUNDARY )
+      //      {
+      //         return true;
+      //      }
+      //      return (iSec&1);  //ungerade anzahl an schnitten --> drinnen
+      //   }
+      //   UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if  - an edge was hit ");
+      //}
+      //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
+      int iSec1,iSec2;
+      double eps = 0.05;        
+      Kd::Ray<double> ray1(  x1, x2, x3, 1.0+eps*((double)counter), eps*((double)counter) ,eps*((double)counter) );
+      iSec1 = kdTree->intersectRay( ray1, Kd::CountRayIntersectionHandler<double>() );
+      Kd::Ray<double> ray2(  x1, x2, x3, -1.0-eps*((double)counter), -eps*((double)counter) ,-eps*((double)counter) );
+ 
+      iSec2 = kdTree->intersectRay( ray2, Kd::CountRayIntersectionHandler<double>() );
+
+      if(iSec1 == Kd::Intersection::ON_BOUNDARY || iSec2 == Kd::Intersection::ON_BOUNDARY)
+      {
+         return true;
+      }
+      if( iSec1 == Kd::Intersection::INTERSECT_EDGE && iSec2 == Kd::Intersection::INTERSECT_EDGE) 
+      {
+         //UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.INTERSECT_EDGE");
+
+         if (counter>20) {return(iSec1&1);  UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");}
+         return this->isPointInGbObject3D(x1, x2, x3,(counter+1)); 
+      }
+      else if( iSec1 == Kd::Intersection::INTERSECT_EDGE)
+      {
+         return (iSec2&1);  
+      }
+      else if( iSec2 == Kd::Intersection::INTERSECT_EDGE)
+      {
+         return (iSec1&1);  
+      }
+      else
+      {
+         if((iSec1&1) != (iSec2&1))
+         {
+            //UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.iSec1&1 != iSec2&1");
+
+            if (counter>20) {return(iSec1&1);  UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");}
+            return this->isPointInGbObject3D(x1, x2, x3,(counter+1));
+         }
+         return iSec1&1;
+      }
+      //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
+
+   }
+   return false;
+}
+/*======================================================================*/
+bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3)
+{
+  int counter=0;
+
+   if( !nodes->empty() )
+   {
+      //Baum erstellen, wen noch keiner vorhanden
+      if( !kdTree)
+      {
+         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start");
+         UbTimer timer; timer.start();
+         if(kdtreeSplitAlg == KDTREE_SAHPLIT     ) 
+         {
+            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit");
+            this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>()            );
+         }
+         else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT)
+         {
+            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit");
+            this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); 
+         }
+         else throw UbException(UB_EXARGS, "unknown kdtree split option)" );
+         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds");
+      }
+
+      //eigentlicher PIO-Test
+      int iSec;
+      for(int i=0; i<MAX_ITER; i++)
+      {
+         Kd::Ray<double> ray(  x1, x2, x3  //, 1, 0 ,0 );
+                              , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) )
+                              , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) )
+                              , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) );
+                              
+         iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() );
+           
+         if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen
+         {
+            if(iSec == Kd::Intersection::ON_BOUNDARY )
+            {
+               return true;
+            }
+            return (iSec&1);  //ungerade anzahl an schnitten --> drinnen
+         }
+         UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if  - an edge was hit ");
+      }
+      throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
+
+   //   int iSec1,iSec2;
+   //      
+   //   Kd::Ray<double> ray1(  x1, x2, x3, 1.0, 0.0 ,0.0 );
+   //   iSec1 = kdTree->intersectRay( ray1, Kd::CountRayIntersectionHandler<double>() );
+   //   Kd::Ray<double> ray2(  x1, x2, x3, -1.0, 0.0 ,0.0 );
+   //   iSec2 = kdTree->intersectRay( ray2, Kd::CountRayIntersectionHandler<double>() );
+
+   //   if(iSec1 == Kd::Intersection::ON_BOUNDARY || iSec2 == Kd::Intersection::ON_BOUNDARY)
+   //   {
+   //      return true;
+   //   }
+   //   if( iSec1 == Kd::Intersection::INTERSECT_EDGE && iSec2 == Kd::Intersection::INTERSECT_EDGE) 
+   //   {
+   //      //UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.INTERSECT_EDGE");
+   //      double eps = UbMath::getEqualityEpsilon<double>();
+   //      if (counter>100) {return(iSec1&1);  UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");}
+   //      return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); 
+   //   }
+   //   else if( iSec1 == Kd::Intersection::INTERSECT_EDGE)
+   //   {
+   //      return (iSec2&1);  
+   //   }
+   //   else if( iSec2 == Kd::Intersection::INTERSECT_EDGE)
+   //   {
+   //      return (iSec1&1);  
+   //   }
+   //   else
+   //   {
+   //      if((iSec1&1) != (iSec2&1))
+   //      {
+   //         UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.iSec1&1 != iSec2&1");
+   //         double eps = UbMath::getEqualityEpsilon<double>();
+   //         if (counter>100) {return(iSec1&1);  UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");}
+   //         return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1));
+   //      }
+   //      return iSec1&1;
+   //   }
+   //   //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
+
+   }
+   return false;
+}
+/*======================================================================*/
+bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)
+{
+   if( !nodes->empty() )
+   {
+      //Baum erstellen, wen noch keiner vorhanden
+      if( !kdTree)
+      {
+         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start");
+         UbTimer timer; timer.start();
+         if(kdtreeSplitAlg == KDTREE_SAHPLIT     ) 
+         {
+            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit");
+            this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>()            );
+         }
+         else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT)
+         {
+            UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit");
+            this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); 
+         }
+         else throw UbException(UB_EXARGS, "unknown kdtree split option)" );
+         UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds");
+      }
+
+      //eigentlicher PIO-Test
+      int iSec;
+      for(int i=0; i<MAX_ITER; i++)
+      {
+         Kd::Ray<double> ray(  x1, x2, x3 
+                            , float( ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) )
+                            , float( ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) )
+                            , float( ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ) );
+
+         iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>()    );
+
+         if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen
+         {
+            if(iSec == Kd::Intersection::ON_BOUNDARY )
+            {
+               pointIsOnBoundary = true;
+               return true;
+            }
+            pointIsOnBoundary = false;
+            return (iSec&1);  //ungerade anzahl an schnitten --> drinnen
+         }
+      }
+
+      throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
+   }
+   
+   return false;
+}
+/*======================================================================*/
+GbLine3D* GbTriFaceMesh3D::createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2)
+{
+   throw UbException(UB_EXARGS,"not implemented");
+}
+/*======================================================================*/
+void GbTriFaceMesh3D::write(UbFileOutput* out)
+{
+   out->writeString(this->getCreator()->getTypeID());
+   out->writeInteger((int)kdtreeSplitAlg);
+   out->writeBool(transferViaFilename);
+
+   if(!transferViaFilename)
+   {
+      //nodes
+      vector<Vertex>& vertices = *nodes;
+      out->writeSize_t( nodes->size() );
+      out->writeLine();
+      for(size_t i=0; i<vertices.size(); i++)
+      {
+         Vertex& v = vertices[i];
+         out->writeFloat(v.x);
+         out->writeFloat(v.y);
+         out->writeFloat(v.z);
+         out->writeLine();
+      }
+      
+      //triangles
+      vector<TriFace>& tris = *triangles;
+      out->writeSize_t( tris.size() );
+      out->writeLine();
+      for(size_t i=0; i<tris.size(); i++)
+      {
+         TriFace& t = tris[i];
+         out->writeInteger(t.v1);
+         out->writeInteger(t.v2);
+         out->writeInteger(t.v3);
+         out->writeLine();
+      }
+   }
+   else
+   {
+      out->writeString(filename);
+      out->writeLine();
+      out->writeDouble(transX1);
+      out->writeDouble(transX2);
+      out->writeDouble(transX3);
+
+   }
+}
+/*======================================================================*/
+void GbTriFaceMesh3D::read(UbFileInput* in)
+{
+   kdtreeSplitAlg =  (KDTREE_SPLITAGORITHM)in->readInteger();
+   transferViaFilename = in->readBool();
+
+   if(!transferViaFilename)
+   {
+      if(!nodes) nodes = new vector<Vertex>;
+      //nodes
+      vector<Vertex>& vertices = *nodes;
+      vertices.resize( in->readSize_t( ) );
+      in->readLine();
+      for(size_t i=0; i<vertices.size(); i++)
+      {
+         Vertex& v = vertices[i];
+         v.x = in->readFloat();
+         v.y = in->readFloat();
+         v.z = in->readFloat();
+         in->readLine();
+      }
+
+      //triangles
+      if(!triangles) triangles = new vector<TriFace>;
+      vector<TriFace>& tris = *triangles;
+      tris.resize( in->readSize_t( ) );
+      in->readLine();
+      for(size_t i=0; i<tris.size(); i++)
+      {
+         TriFace& t = tris[i];
+         t.v1 = in->readInteger();
+         t.v2 = in->readInteger();
+         t.v3 = in->readInteger();
+         in->readLine();
+      }
+
+      this->calculateValues();
+   }
+   else
+   {
+      filename = in->readString();
+      in->readLine();
+      transX1 = in->readDouble();
+      transX2 = in->readDouble();
+      transX3 = in->readDouble();
+
+      this->readMeshFromSTLFile(filename, true);
+      this->translate(transX1,transX2,transX3);
+   }
+}
+/*======================================================================*/
+UbTuple<string, string> GbTriFaceMesh3D::writeMesh(string filename, WbWriter* writer, bool writeNormals, vector< string >* datanames, std::vector< std::vector < double > >* nodedata )
+{
+   UBLOG(logINFO, "GbTriFaceMesh3D::writeMesh ");
+
+   vector<UbTupleFloat3 > triNodes(nodes->size());
+   vector<UbTupleInt3 >   tris(triangles->size());
+
+   for(size_t i=0; i<nodes->size(); i++)
+      triNodes[i] = makeUbTuple( (*nodes)[i].x, (*nodes)[i].y, (*nodes)[i].z );
+
+   for(size_t i=0; i<triangles->size(); i++)
+      tris[i] = makeUbTuple( (*triangles)[i].v1, (*triangles)[i].v2, (*triangles)[i].v3 ) ;
+
+   UbTuple<string, string> filenames("","");
+
+   if( !datanames || datanames->empty() || !nodedata  )
+   {
+      val<1>(filenames) = writer->writeTriangles(filename,triNodes,tris);
+   }
+   else
+   {
+      val<1>(filenames) = writer->writeTrianglesWithNodeData(filename,triNodes,tris,*datanames,*nodedata);
+   }
+
+   if(writeNormals)
+   {
+      vector<UbTupleFloat3 > lineNodes(triangles->size()*2);
+      vector<UbTupleInt2 >   lines(triangles->size());
+      for(size_t i=0; i<triangles->size(); i++)
+      {
+         TriFace& triangle = (*triangles)[i];
+         lineNodes[i*2  ] = makeUbTuple( triangle.getX1Centroid(*nodes)
+                                        ,triangle.getX2Centroid(*nodes)
+                                        ,triangle.getX3Centroid(*nodes));
+
+         lineNodes[i*2+1] = makeUbTuple( (float)(triangle.getX1Centroid(*nodes)+1.0*triangle.nx)
+                                        ,(float)(triangle.getX2Centroid(*nodes)+1.0*triangle.ny)
+                                        ,(float)(triangle.getX3Centroid(*nodes)+1.0*triangle.nz));
+
+         lines[i] = makeUbTuple((int)i*2,(int)i*2+1);
+      }
+      val<2>(filenames) = writer->writeLines(filename+"_normals",lineNodes,lines);
+   }
+
+   return filenames;
+}
+/*======================================================================*/
+void GbTriFaceMesh3D::writeMeshPly( const std::string& filename)
+{
+   ofstream out(filename.c_str() );
+   if( !out )
+      throw UbException(UB_EXARGS, "couldn't open " + filename);
+
+   out << "ply" << endl;
+   out << "format ascii 1.0" << endl;
+   out << "element vertex " << (int)nodes->size() << endl;
+   out << "property float x" << endl;
+   out << "property float y" << endl;
+   out << "property float z" << endl;
+   out << "element face " << (int)triangles->size() << endl;
+   out << "property list uchar int vertex_indices" << endl;
+   out << "end_header" << endl;
+
+   for(size_t i=0; i<nodes->size(); i++)
+      out << (*nodes)[i].x << " " << (*nodes)[i].y << " " << (*nodes)[i].z << endl;
+
+   for(size_t i=0; i<triangles->size(); i++)
+      out << "3 " << (*triangles)[i].v1 << " " << (*triangles)[i].v2 << " " << (*triangles)[i].v3 << endl;
+}
+/*======================================================================*/
+void GbTriFaceMesh3D::readMeshFromSTLFile(string filename, bool removeRedundantNodes)
+{
+   UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ...");
+
+   UbFileInputASCII in(filename);
+   //this->nodes     = new vector<GbTriFaceMesh3D::Vertex>;
+   //this->triangles = new vector<GbTriFaceMesh3D::TriFace>;
+   string dummy;
+
+   double x, y, z;
+   int nr=0;
+
+   in.readLine();
+   while(dummy!="endsolid")
+   {
+      in.readLine();
+      in.readLine();
+      dummy = in.readString();
+      if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format");
+      x=in.readDouble();
+      y=in.readDouble();
+      z=in.readDouble();
+      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+      in.readLine();
+      in.readString();
+      x=in.readDouble();
+      y=in.readDouble();
+      z=in.readDouble();
+      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+      in.readLine();
+      in.readString();
+      x=in.readDouble();
+      y=in.readDouble();
+      z=in.readDouble();
+      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+      triangles->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2));
+      in.readLine();
+      in.readLine();
+      in.readLine();
+      dummy = in.readString();
+      nr+=3;
+   }
+   if(removeRedundantNodes)
+   {
+      this->deleteRedundantNodes(); //dort wird autoamtisch calculateValues() aufgerufen
+   }
+   else
+   {
+      this->calculateValues();
+   }
+}
+//////////////////////////////////////////////////////////////////////////
+//void GbTriFaceMesh3D::writeMeshToSTLFile(string filename, bool isBinaryFormat)
+//{
+//   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
+//   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
+//   int nr=0;
+//
+//   if (!isBinaryFormat) {
+//      ofstream out(filename.c_str());
+//      if (!out.good())
+//      {
+//         delete nodes;
+//         delete triangles;
+//         UB_THROW(UbException(UB_EXARGS, "Can not open STL file: "+filename));
+//      }
+//      char title[80] = "ASCII";
+//      std::string s0, s1;
+//      float n0, n1, n2, f0, f1, f2, f3, f4, f5, f6, f7, f8;
+//      out.write(title, 80);
+//      size_t size = nodes->size();
+//      for (size_t i = 0; i < size)
+//      {
+//         out << nodes[i++]
+//         in >> s0;                                // facet || endsolid
+//         if (s0=="facet") {
+//            in >> s1 >> n0 >> n1 >> n2;            // normal x y z
+//            in >> s0 >> s1;                        // outer loop
+//            in >> s0 >> f0 >> f1 >> f2;         // vertex x y z
+//            in >> s0 >> f3 >> f4 >> f5;         // vertex x y z
+//            in >> s0 >> f6 >> f7 >> f8;         // vertex x y z
+//            in >> s0;                            // endloop
+//            in >> s0;                            // endfacet
+//            // Generate a new Triangle without Normal as 3 Vertices
+//            nodes->push_back(GbTriFaceMesh3D::Vertex(f0, f1, f2));
+//            nodes->push_back(GbTriFaceMesh3D::Vertex(f3, f4, f5));
+//            nodes->push_back(GbTriFaceMesh3D::Vertex(f6, f7, f8));
+//            triangles->push_back(GbTriFaceMesh3D::TriFace(nr, nr+1, nr+2));
+//            nr+=3;
+//         }
+//         else if (s0=="endsolid") {
+//            break;
+//         }
+//      }
+//      in.close();
+//   }
+//   else {
+//      FILE *f = fopen(filename.c_str(), "rb");
+//      if (!f)
+//      {
+//         delete nodes;
+//         delete triangles;
+//         UB_THROW(UbException(UB_EXARGS, "Can not open STL file: "+filename));
+//      }
+//      char title[80];
+//      int nFaces;
+//      fread(title, 80, 1, f);
+//      fread((void*)&nFaces, 4, 1, f);
+//      float v[12]; // normal=3, vertices=3*3 = 12
+//      unsigned short uint16;
+//      // Every Face is 50 Bytes: Normal(3*float), Vertices(9*float), 2 Bytes Spacer
+//      for (size_t i=0; i<nFaces; ++i) {
+//         for (size_t j=0; j<12; ++j) {
+//            fread((void*)&v[j], sizeof(float), 1, f);
+//         }
+//         fread((void*)&uint16, sizeof(unsigned short), 1, f); // spacer between successive faces
+//         nodes->push_back(GbTriFaceMesh3D::Vertex(v[3], v[4], v[5]));
+//         nodes->push_back(GbTriFaceMesh3D::Vertex(v[6], v[7], v[8]));
+//         nodes->push_back(GbTriFaceMesh3D::Vertex(v[9], v[10], v[11]));
+//         triangles->push_back(GbTriFaceMesh3D::TriFace(nr, nr+1, nr+2));
+//         nr+=3;
+//      }
+//      fclose(f);
+//   }
+//
+//   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes);
+//
+//   return mesh;
+//}
+//////////////////////////////////////////////////////////////////////////
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbTriFaceMesh3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbTriFaceMesh3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbTriFaceMesh3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbTriFaceMesh3D.h
index 8abadd3a09d38d927c15882e006a7f107858fe00..30601cba76176ad0cfc9ec2efbab4b2b8eedfa3a 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbTriFaceMesh3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbTriFaceMesh3D.h
@@ -1,382 +1,382 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBTRIFACEMESH3D_H
-#define GBTRIFACEMESH3D_H
-
-#include <sstream>
-#include <iostream>
-#include <vector>
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbMath.h>
-#include <basics/utilities/Vector3D.h>
-#include <basics/writer/WbWriter.h>
-
-#include <basics/memory/MbSmartPtr.h>
-
-#include <numerics/geometry3d/GbPoint3D.h> 
-
-#include <PointerDefinitions.h>
-
-namespace Kd 
-{ 
-   template< typename T>  class Tree; 
-   template< typename T > class SplitAlgorithm;
-   template< typename T > class RayIntersectionHandler;
-}
-
-
-/*=========================================================================*/
-/* GbTriFaceMesh3D                                                                  */
-/*                                                                         */
-/**
- * This Class provides the triangular meshes.
- * Note, that up to now no methods for checking consistency are included.
- * in this context this class describes facettes from an 3D-object !!!
-*/
-class GbTriFaceMesh3D : public GbObject3D
-{
-public:
-  // nested class start
-   class Vertex
-   {
-   public:
-      Vertex() : x(0.0), y(0.0), z(0.0) { }
-      Vertex(const float& x, const float& y, const float& z) : x(x), y(y),z(z) { }
-      Vertex(Vertex* vert)
-      {
-         this->x = vert->x;
-         this->y = vert->y;
-         this->z = vert->z;
-      }
-      float operator[] (const int&i) const
-      {
-         if     (i==0) return x;
-         else if(i==1) return y;
-         else if(i==2) return z;
-
-         throw UbException(UB_EXARGS,"i not in [0;2]");
-      }
-      float& operator[] (const int& i)
-      {
-         if     (i==0) return x;
-         else if(i==1) return y;
-         else if(i==2) return z;
-
-         throw UbException(UB_EXARGS,"not in [0;2]");
-      }
-      bool operator== (const Vertex& rhs)
-      {
-         return ( fabs(x-rhs.x)<1.E-8 && fabs(y-rhs.y)<1.E-8 && fabs(z-rhs.z)<1.E-8 );
-      }
-      friend inline bool operator<(const Vertex & lhsVert,const Vertex & rhsVert)
-      {
-         if( lhsVert.x < rhsVert.x ) return true;
-         if( lhsVert.x > rhsVert.x ) return false;
-         if( lhsVert.y < rhsVert.y ) return true;
-         if( lhsVert.y > rhsVert.y ) return false;
-         if( lhsVert.z < rhsVert.z ) return true;
-
-         return false;
-      }
-      friend std::ostream& operator<<( std::ostream& os, const Vertex& node )
-      {
-         return os<<node.x<<","<<node.y<<","<<node.z;
-      }
-      Vertex* clone()
-      {
-         return(new Vertex(this));
-      }
-
-#ifdef CAB_RCF
-      template<class Archive>
-      void SF_SERIALIZE(Archive & ar)
-      {
-         ar & x; ar & y; ar & z;
-      }
-#endif //CAB_RCF
-
-   public:
-      float x, y, z;
-   };
-   //////////////////////////////////////////////////////////////////////////
-   class TriFace
-   {
-   public:
-      TriFace()
-         : v1(-1), v2(-1), v3(-1), nx(0.0), ny(0.0), nz(0.0)
-      {
-
-      }
-      TriFace(const int& v1, const int& v2, const int& v3)
-         : v1(v1), v2(v2), v3(v3), nx(0.0), ny(0.0), nz(0.0)
-      {
-      }
-
-      const int& getIndexVertex1() const { return v1; }
-      const int& getIndexVertex2() const { return v2; }
-      const int& getIndexVertex3() const { return v3; }
-
-      Vertex& getNode(const int& i, std::vector<Vertex>& nodes)
-      {
-         if(i==0) return nodes[v1];
-         if(i==1) return nodes[v2];
-         if(i==2) return nodes[v3];
-         throw UbException(UB_EXARGS,"invalid i - not in range [0;2]");
-      }
-      void setNode(const int& i, const int& index)
-      {
-         if     (i==0) v1=index;
-         else if(i==1) v2=index;
-         else if(i==2) v3=index;
-         else throw UbException(UB_EXARGS,"invalid i - not in range [0;2]");
-      }
-
-      int operator[] (int index)
-      { 
-         if(index==0) return v1;
-         if(index==1) return v2;
-         if(index==2) return v3;
-         throw UbException(UB_EXARGS,"invalid i - not in range [0;2]");
-      }
-
-      float& getV1x(std::vector<Vertex>& nodes) { return nodes[v1].x; }
-      float& getV1y(std::vector<Vertex>& nodes) { return nodes[v1].y; }
-      float& getV1z(std::vector<Vertex>& nodes) { return nodes[v1].z; }
-
-      float& getV2x(std::vector<Vertex>& nodes) { return nodes[v2].x; }
-      float& getV2y(std::vector<Vertex>& nodes) { return nodes[v2].y; }
-      float& getV2z(std::vector<Vertex>& nodes) { return nodes[v2].z; }
-
-      float& getV3x(std::vector<Vertex>& nodes) { return nodes[v3].x; }
-      float& getV3y(std::vector<Vertex>& nodes) { return nodes[v3].y; }
-      float& getV3z(std::vector<Vertex>& nodes) { return nodes[v3].z; }
-
-      float getMinX(std::vector<Vertex>& nodes) { return (float)UbMath::min(nodes[v1].x,nodes[v2].x,nodes[v3].x); }
-      float getMinY(std::vector<Vertex>& nodes) { return (float)UbMath::min(nodes[v1].y,nodes[v2].y,nodes[v3].y); }
-      float getMinZ(std::vector<Vertex>& nodes) { return (float)UbMath::min(nodes[v1].z,nodes[v2].z,nodes[v3].z); }
-
-      float getMaxX(std::vector<Vertex>& nodes) { return (float)UbMath::max(nodes[v1].x,nodes[v2].x,nodes[v3].x); }
-      float getMaxY(std::vector<Vertex>& nodes) { return (float)UbMath::max(nodes[v1].y,nodes[v2].y,nodes[v3].y); }
-      float getMaxZ(std::vector<Vertex>& nodes) { return (float)UbMath::max(nodes[v1].z,nodes[v2].z,nodes[v3].z); }
-
-      float getX1Centroid(std::vector<Vertex>& nodes) {return (float)UbMath::c1o3 * (getV1x(nodes)+getV2x(nodes)+getV3x(nodes)); }
-      float getX2Centroid(std::vector<Vertex>& nodes) {return (float)UbMath::c1o3 * (getV1y(nodes)+getV2y(nodes)+getV3y(nodes)); }
-      float getX3Centroid(std::vector<Vertex>& nodes) {return (float)UbMath::c1o3 * (getV1z(nodes)+getV2z(nodes)+getV3z(nodes)); }
-
-      double calculateDistanceToPoint3D(const double& x1, const double& x2, const double& x3, std::vector<Vertex>& nodes);
-
-      double getArea(std::vector<Vertex>& nodes)
-      {
-         //GbVector3D A(nodes[v1].x, nodes[v1].y, nodes[v1].z);
-         //GbVector3D B(nodes[v2].x, nodes[v2].y, nodes[v2].z);
-         //GbVector3D C(nodes[v3].x, nodes[v3].y, nodes[v3].z);
-         //GbVector3D AB = B-A;
-         //GbVector3D AC = C-A;
-         //GbVector3D N = AB.Cross(AC);
-         //return 0.5*N.Length();
-         Vector3D A(nodes[v1].x, nodes[v1].y, nodes[v1].z);
-         Vector3D B(nodes[v2].x, nodes[v2].y, nodes[v2].z);
-         Vector3D C(nodes[v3].x, nodes[v3].y, nodes[v3].z);
-         Vector3D AB = B-A;
-         Vector3D AC = C-A;
-         Vector3D N = AB.Cross(AC);
-         return 0.5*N.Length();
-      }
-      void calculateNormal(std::vector<Vertex>& nodes)
-      {
-         const float& v1x = nodes[v1].x; const float& v1y = nodes[v1].y; const float& v1z = nodes[v1].z;
-         const float& v2x = nodes[v2].x; const float& v2y = nodes[v2].y; const float& v2z = nodes[v2].z;
-         const float& v3x = nodes[v3].x; const float& v3y = nodes[v3].y; const float& v3z = nodes[v3].z;
-
-         nx = ( v3z - v1z) * ( v2y - v1y ) - ( v2z - v1z) * ( v3y - v1y );
-         ny = ( v2z - v1z) * ( v3x - v1x ) - ( v2x - v1x) * ( v3z - v1z );
-         nz = ( v2x - v1x) * ( v3y - v1y ) - ( v2y - v1y) * ( v3x - v1x );
-
-         float length = std::sqrt( nx*nx + ny*ny + nz*nz );
-         if(length>1.E-10)
-         {
-            length = 1.0f/length;
-            nx *= length;
-            ny *= length;
-            nz *= length;
-         }
-         //else 
-         //{
-         //   std::cerr<<"GbTriFaceMesh3D::TriFace - calculateNormal: nx=ny=nz=0 -> kann nich sein "
-         //            <<"(dreieck hat evtl knoten doppelt oder ist ne Linie)"
-         //            <<"->removeRedunantNodes"<<std::endl;
-         //}
-      }
-   #ifdef CAB_RCF
-      template<class Archive>
-      void SF_SERIALIZE(Archive & ar)
-      {
-         ar & v1; ar & v2; ar & v3;
-      }
-   #endif //CAB_RCF
-
-   public:
-      int   v1, v2, v3;
-      float nx, ny, nz;
-   };
-
-public:
-  enum KDTREE_SPLITAGORITHM { KDTREE_SAHPLIT, KDTREE_SPATIALSPLIT };
-
-public:
-   GbTriFaceMesh3D();
-   GbTriFaceMesh3D(std::string name, std::vector<Vertex>* nodes, std::vector<TriFace>* triangles, KDTREE_SPLITAGORITHM splitAlg = KDTREE_SAHPLIT, bool removeRedundantNodes=true);
-	~GbTriFaceMesh3D();
-
-   GbTriFaceMesh3D* clone();// { throw UbException(UB_EXARGS,"not implemented"); }
-   void finalize() {}
-
-   //void setRegardPointInPolyhedronTest(bool value) { this->regardPiO=value; }
-
-   std::string toString();
-
-   //std::string getName();
-   std::vector<Vertex>*  getNodes();
-   std::vector<TriFace>* getTriangles();
-   
-   void setTransferViaFilename(bool transferViaFilename, std::string filename, double transX1, double transX2, double transX3)
-   {
-      this->filename = filename;
-      this->transferViaFilename = transferViaFilename;
-      this->transX1 = transX1;
-      this->transX2 = transX2;
-      this->transX3 = transX3;
-   }
-   void readMeshFromSTLFile(std::string filename, bool removeRedundantNodes);
-
-   double getX1Minimum()  { if(!this->consistent) this->calculateValues(); return this->x1min;    }
-   double getX1Maximum()  { if(!this->consistent) this->calculateValues(); return this->x1max;    }
-   double getX1Centroid() { if(!this->consistent) this->calculateValues(); return this->x1center; }
-
-   double getX2Minimum()  { if(!this->consistent) this->calculateValues(); return this->x2min;    }
-   double getX2Maximum()  { if(!this->consistent) this->calculateValues(); return this->x2max;    }
-   double getX2Centroid() { if(!this->consistent) this->calculateValues(); return this->x2center; }
-   
-   double getX3Minimum()  { if(!this->consistent) this->calculateValues(); return this->x3min;    }
-   double getX3Centroid() { if(!this->consistent) this->calculateValues(); return this->x3center; }
-   double getX3Maximum()  { if(!this->consistent) this->calculateValues(); return this->x3max;    }
-
-   void   calculateValues();
-
-   double getVolume();
-   void   deleteRedundantNodes();
-
-   UbTupleDouble6 calculateMomentOfInertia(double rhoP);
-   UbTupleDouble3 calculateCenterOfGravity();
-
-   void setCenterCoordinates(const double& x1, const double& x2, const double& x3);
-
-
-   void scale(const double& sx1, const double& sx2, const double& sx3);
-   void rotate(const double& alpha, const double& beta, const double& gamma);
-   void rotateAroundPoint(const double& px1, const double& px2, const double& px3, const double& alpha, const double& beta, const double& gamma);
-   void translate(const double& x1, const double& x2, const double& x3);
-   void reflectAcrossXYLine(const double& alpha);
-
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3);
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, int counter);
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary);
-
-   virtual GbLine3D* createClippedLine3D (GbPoint3D &point1,GbPoint3D &point2);
-
-   virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet();
-   void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles);
-
-   std::vector<GbTriFaceMesh3D::TriFace*> getTrianglesForVertex(Vertex* vertex);
-
-   void setKdTreeSplitAlgorithm(KDTREE_SPLITAGORITHM mode); 
-   KDTREE_SPLITAGORITHM getKdTreeSplitAlgorithm() { return this->kdtreeSplitAlg; }
-   Kd::Tree<double>* getKdTree() { return this->kdTree; }
-
-   virtual ObObjectCreator* getCreator();
-
-   void write(UbFileOutput* out);
-   void read(UbFileInput* in);  
-
-   virtual UbTuple<std::string, std::string> writeMesh(std::string filename, WbWriter* writer, bool writeNormals=false, std::vector< std::string >* datanames=NULL, std::vector< std::vector < double > >* nodedata=NULL );
-   void writeMeshPly( const std::string& filename);
-
-   /*======================================================================*/
-   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void SF_SERIALIZE(Archive & ar)
-   {
-      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
-      ar & kdtreeSplitAlg;
-      ar & transferViaFilename;
-      if(!transferViaFilename)
-      {
-         ar & nodes;
-         ar & triangles;
-      }
-      else
-      {
-         ar & filename;
-         ar & transX1;
-         ar & transX2;
-         ar & transX3;
-         if(ArchiveTools::isReading(ar) ) 
-         {
-            this->readMeshFromSTLFile(filename, true);
-            this->translate(transX1,transX2,transX3);
-         }
-      }
-      
-      if(ArchiveTools::isReading(ar)) this->calculateValues();
-   }
-#endif //CAB_RCF
-
-protected:
-   KDTREE_SPLITAGORITHM kdtreeSplitAlg;
-   void init();
-
-   std::vector<Vertex>*  nodes;
-   std::vector<TriFace>* triangles;
-   //for transfer
-   std::string filename;
-   bool transferViaFilename;
-   double transX1;
-   double transX2;
-   double transX3;
-
-   double x1min;
-   double x1max;
-   double x2min;
-   double x2max;
-   double x3min;
-   double x3max;
-   double x1center;
-   double x2center;
-   double x3center;
-
-   bool   consistent;
-
-   bool buildVertTriRelationMap;
-   std::multimap<Vertex*,TriFace*> relationVertTris;
-
-   Kd::Tree< double >* kdTree;
-};
-
-#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
-   UB_AUTO_RUN_NAMED(   SF::registerType<GbTriFaceMesh3D  >("GbTriFaceMesh3D  ")     , SF_GbTriFaceMesh3D     );
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbTriFaceMesh3D >() ), SF_GbTriFaceMesh3D_BD1 );
-#endif //RCF_USE_SF_SERIALIZATION
-
-#endif //GBTRIFACEMESH3D_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBTRIFACEMESH3D_H
+#define GBTRIFACEMESH3D_H
+
+#include <sstream>
+#include <iostream>
+#include <vector>
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbMath.h>
+#include <basics/utilities/Vector3D.h>
+#include <basics/writer/WbWriter.h>
+
+#include <basics/memory/MbSmartPtr.h>
+
+#include <numerics/geometry3d/GbPoint3D.h> 
+
+#include <PointerDefinitions.h>
+
+namespace Kd 
+{ 
+   template< typename T>  class Tree; 
+   template< typename T > class SplitAlgorithm;
+   template< typename T > class RayIntersectionHandler;
+}
+
+
+/*=========================================================================*/
+/* GbTriFaceMesh3D                                                                  */
+/*                                                                         */
+/**
+ * This Class provides the triangular meshes.
+ * Note, that up to now no methods for checking consistency are included.
+ * in this context this class describes facettes from an 3D-object !!!
+*/
+class GbTriFaceMesh3D : public GbObject3D
+{
+public:
+  // nested class start
+   class Vertex
+   {
+   public:
+      Vertex() : x(0.0), y(0.0), z(0.0) { }
+      Vertex(const float& x, const float& y, const float& z) : x(x), y(y),z(z) { }
+      Vertex(Vertex* vert)
+      {
+         this->x = vert->x;
+         this->y = vert->y;
+         this->z = vert->z;
+      }
+      float operator[] (const int&i) const
+      {
+         if     (i==0) return x;
+         else if(i==1) return y;
+         else if(i==2) return z;
+
+         throw UbException(UB_EXARGS,"i not in [0;2]");
+      }
+      float& operator[] (const int& i)
+      {
+         if     (i==0) return x;
+         else if(i==1) return y;
+         else if(i==2) return z;
+
+         throw UbException(UB_EXARGS,"not in [0;2]");
+      }
+      bool operator== (const Vertex& rhs)
+      {
+         return ( fabs(x-rhs.x)<1.E-8 && fabs(y-rhs.y)<1.E-8 && fabs(z-rhs.z)<1.E-8 );
+      }
+      friend inline bool operator<(const Vertex & lhsVert,const Vertex & rhsVert)
+      {
+         if( lhsVert.x < rhsVert.x ) return true;
+         if( lhsVert.x > rhsVert.x ) return false;
+         if( lhsVert.y < rhsVert.y ) return true;
+         if( lhsVert.y > rhsVert.y ) return false;
+         if( lhsVert.z < rhsVert.z ) return true;
+
+         return false;
+      }
+      friend std::ostream& operator<<( std::ostream& os, const Vertex& node )
+      {
+         return os<<node.x<<","<<node.y<<","<<node.z;
+      }
+      Vertex* clone()
+      {
+         return(new Vertex(this));
+      }
+
+#ifdef CAB_RCF
+      template<class Archive>
+      void SF_SERIALIZE(Archive & ar)
+      {
+         ar & x; ar & y; ar & z;
+      }
+#endif //CAB_RCF
+
+   public:
+      float x, y, z;
+   };
+   //////////////////////////////////////////////////////////////////////////
+   class TriFace
+   {
+   public:
+      TriFace()
+         : v1(-1), v2(-1), v3(-1), nx(0.0), ny(0.0), nz(0.0)
+      {
+
+      }
+      TriFace(const int& v1, const int& v2, const int& v3)
+         : v1(v1), v2(v2), v3(v3), nx(0.0), ny(0.0), nz(0.0)
+      {
+      }
+
+      const int& getIndexVertex1() const { return v1; }
+      const int& getIndexVertex2() const { return v2; }
+      const int& getIndexVertex3() const { return v3; }
+
+      Vertex& getNode(const int& i, std::vector<Vertex>& nodes)
+      {
+         if(i==0) return nodes[v1];
+         if(i==1) return nodes[v2];
+         if(i==2) return nodes[v3];
+         throw UbException(UB_EXARGS,"invalid i - not in range [0;2]");
+      }
+      void setNode(const int& i, const int& index)
+      {
+         if     (i==0) v1=index;
+         else if(i==1) v2=index;
+         else if(i==2) v3=index;
+         else throw UbException(UB_EXARGS,"invalid i - not in range [0;2]");
+      }
+
+      int operator[] (int index)
+      { 
+         if(index==0) return v1;
+         if(index==1) return v2;
+         if(index==2) return v3;
+         throw UbException(UB_EXARGS,"invalid i - not in range [0;2]");
+      }
+
+      float& getV1x(std::vector<Vertex>& nodes) { return nodes[v1].x; }
+      float& getV1y(std::vector<Vertex>& nodes) { return nodes[v1].y; }
+      float& getV1z(std::vector<Vertex>& nodes) { return nodes[v1].z; }
+
+      float& getV2x(std::vector<Vertex>& nodes) { return nodes[v2].x; }
+      float& getV2y(std::vector<Vertex>& nodes) { return nodes[v2].y; }
+      float& getV2z(std::vector<Vertex>& nodes) { return nodes[v2].z; }
+
+      float& getV3x(std::vector<Vertex>& nodes) { return nodes[v3].x; }
+      float& getV3y(std::vector<Vertex>& nodes) { return nodes[v3].y; }
+      float& getV3z(std::vector<Vertex>& nodes) { return nodes[v3].z; }
+
+      float getMinX(std::vector<Vertex>& nodes) { return (float)UbMath::min(nodes[v1].x,nodes[v2].x,nodes[v3].x); }
+      float getMinY(std::vector<Vertex>& nodes) { return (float)UbMath::min(nodes[v1].y,nodes[v2].y,nodes[v3].y); }
+      float getMinZ(std::vector<Vertex>& nodes) { return (float)UbMath::min(nodes[v1].z,nodes[v2].z,nodes[v3].z); }
+
+      float getMaxX(std::vector<Vertex>& nodes) { return (float)UbMath::max(nodes[v1].x,nodes[v2].x,nodes[v3].x); }
+      float getMaxY(std::vector<Vertex>& nodes) { return (float)UbMath::max(nodes[v1].y,nodes[v2].y,nodes[v3].y); }
+      float getMaxZ(std::vector<Vertex>& nodes) { return (float)UbMath::max(nodes[v1].z,nodes[v2].z,nodes[v3].z); }
+
+      float getX1Centroid(std::vector<Vertex>& nodes) {return (float)UbMath::c1o3 * (getV1x(nodes)+getV2x(nodes)+getV3x(nodes)); }
+      float getX2Centroid(std::vector<Vertex>& nodes) {return (float)UbMath::c1o3 * (getV1y(nodes)+getV2y(nodes)+getV3y(nodes)); }
+      float getX3Centroid(std::vector<Vertex>& nodes) {return (float)UbMath::c1o3 * (getV1z(nodes)+getV2z(nodes)+getV3z(nodes)); }
+
+      double calculateDistanceToPoint3D(const double& x1, const double& x2, const double& x3, std::vector<Vertex>& nodes);
+
+      double getArea(std::vector<Vertex>& nodes)
+      {
+         //GbVector3D A(nodes[v1].x, nodes[v1].y, nodes[v1].z);
+         //GbVector3D B(nodes[v2].x, nodes[v2].y, nodes[v2].z);
+         //GbVector3D C(nodes[v3].x, nodes[v3].y, nodes[v3].z);
+         //GbVector3D AB = B-A;
+         //GbVector3D AC = C-A;
+         //GbVector3D N = AB.Cross(AC);
+         //return 0.5*N.Length();
+         Vector3D A(nodes[v1].x, nodes[v1].y, nodes[v1].z);
+         Vector3D B(nodes[v2].x, nodes[v2].y, nodes[v2].z);
+         Vector3D C(nodes[v3].x, nodes[v3].y, nodes[v3].z);
+         Vector3D AB = B-A;
+         Vector3D AC = C-A;
+         Vector3D N = AB.Cross(AC);
+         return 0.5*N.Length();
+      }
+      void calculateNormal(std::vector<Vertex>& nodes)
+      {
+         const float& v1x = nodes[v1].x; const float& v1y = nodes[v1].y; const float& v1z = nodes[v1].z;
+         const float& v2x = nodes[v2].x; const float& v2y = nodes[v2].y; const float& v2z = nodes[v2].z;
+         const float& v3x = nodes[v3].x; const float& v3y = nodes[v3].y; const float& v3z = nodes[v3].z;
+
+         nx = ( v3z - v1z) * ( v2y - v1y ) - ( v2z - v1z) * ( v3y - v1y );
+         ny = ( v2z - v1z) * ( v3x - v1x ) - ( v2x - v1x) * ( v3z - v1z );
+         nz = ( v2x - v1x) * ( v3y - v1y ) - ( v2y - v1y) * ( v3x - v1x );
+
+         float length = std::sqrt( nx*nx + ny*ny + nz*nz );
+         if(length>1.E-10)
+         {
+            length = 1.0f/length;
+            nx *= length;
+            ny *= length;
+            nz *= length;
+         }
+         //else 
+         //{
+         //   std::cerr<<"GbTriFaceMesh3D::TriFace - calculateNormal: nx=ny=nz=0 -> kann nich sein "
+         //            <<"(dreieck hat evtl knoten doppelt oder ist ne Linie)"
+         //            <<"->removeRedunantNodes"<<std::endl;
+         //}
+      }
+   #ifdef CAB_RCF
+      template<class Archive>
+      void SF_SERIALIZE(Archive & ar)
+      {
+         ar & v1; ar & v2; ar & v3;
+      }
+   #endif //CAB_RCF
+
+   public:
+      int   v1, v2, v3;
+      float nx, ny, nz;
+   };
+
+public:
+  enum KDTREE_SPLITAGORITHM { KDTREE_SAHPLIT, KDTREE_SPATIALSPLIT };
+
+public:
+   GbTriFaceMesh3D();
+   GbTriFaceMesh3D(std::string name, std::vector<Vertex>* nodes, std::vector<TriFace>* triangles, KDTREE_SPLITAGORITHM splitAlg = KDTREE_SAHPLIT, bool removeRedundantNodes=true);
+	~GbTriFaceMesh3D();
+
+   GbTriFaceMesh3D* clone();// { throw UbException(UB_EXARGS,"not implemented"); }
+   void finalize() {}
+
+   //void setRegardPointInPolyhedronTest(bool value) { this->regardPiO=value; }
+
+   std::string toString();
+
+   //std::string getName();
+   std::vector<Vertex>*  getNodes();
+   std::vector<TriFace>* getTriangles();
+   
+   void setTransferViaFilename(bool transferViaFilename, std::string filename, double transX1, double transX2, double transX3)
+   {
+      this->filename = filename;
+      this->transferViaFilename = transferViaFilename;
+      this->transX1 = transX1;
+      this->transX2 = transX2;
+      this->transX3 = transX3;
+   }
+   void readMeshFromSTLFile(std::string filename, bool removeRedundantNodes);
+
+   double getX1Minimum()  { if(!this->consistent) this->calculateValues(); return this->x1min;    }
+   double getX1Maximum()  { if(!this->consistent) this->calculateValues(); return this->x1max;    }
+   double getX1Centroid() { if(!this->consistent) this->calculateValues(); return this->x1center; }
+
+   double getX2Minimum()  { if(!this->consistent) this->calculateValues(); return this->x2min;    }
+   double getX2Maximum()  { if(!this->consistent) this->calculateValues(); return this->x2max;    }
+   double getX2Centroid() { if(!this->consistent) this->calculateValues(); return this->x2center; }
+   
+   double getX3Minimum()  { if(!this->consistent) this->calculateValues(); return this->x3min;    }
+   double getX3Centroid() { if(!this->consistent) this->calculateValues(); return this->x3center; }
+   double getX3Maximum()  { if(!this->consistent) this->calculateValues(); return this->x3max;    }
+
+   void   calculateValues();
+
+   double getVolume();
+   void   deleteRedundantNodes();
+
+   UbTupleDouble6 calculateMomentOfInertia(double rhoP);
+   UbTupleDouble3 calculateCenterOfGravity();
+
+   void setCenterCoordinates(const double& x1, const double& x2, const double& x3);
+
+
+   void scale(const double& sx1, const double& sx2, const double& sx3);
+   void rotate(const double& alpha, const double& beta, const double& gamma);
+   void rotateAroundPoint(const double& px1, const double& px2, const double& px3, const double& alpha, const double& beta, const double& gamma);
+   void translate(const double& x1, const double& x2, const double& x3);
+   void reflectAcrossXYLine(const double& alpha);
+
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3);
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, int counter);
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary);
+
+   virtual GbLine3D* createClippedLine3D (GbPoint3D &point1,GbPoint3D &point2);
+
+   virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet();
+   void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles);
+
+   std::vector<GbTriFaceMesh3D::TriFace*> getTrianglesForVertex(Vertex* vertex);
+
+   void setKdTreeSplitAlgorithm(KDTREE_SPLITAGORITHM mode); 
+   KDTREE_SPLITAGORITHM getKdTreeSplitAlgorithm() { return this->kdtreeSplitAlg; }
+   Kd::Tree<double>* getKdTree() { return this->kdTree; }
+
+   virtual ObObjectCreator* getCreator();
+
+   void write(UbFileOutput* out);
+   void read(UbFileInput* in);  
+
+   virtual UbTuple<std::string, std::string> writeMesh(std::string filename, WbWriter* writer, bool writeNormals=false, std::vector< std::string >* datanames=NULL, std::vector< std::vector < double > >* nodedata=NULL );
+   void writeMeshPly( const std::string& filename);
+
+   /*======================================================================*/
+   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void SF_SERIALIZE(Archive & ar)
+   {
+      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
+      ar & kdtreeSplitAlg;
+      ar & transferViaFilename;
+      if(!transferViaFilename)
+      {
+         ar & nodes;
+         ar & triangles;
+      }
+      else
+      {
+         ar & filename;
+         ar & transX1;
+         ar & transX2;
+         ar & transX3;
+         if(ArchiveTools::isReading(ar) ) 
+         {
+            this->readMeshFromSTLFile(filename, true);
+            this->translate(transX1,transX2,transX3);
+         }
+      }
+      
+      if(ArchiveTools::isReading(ar)) this->calculateValues();
+   }
+#endif //CAB_RCF
+
+protected:
+   KDTREE_SPLITAGORITHM kdtreeSplitAlg;
+   void init();
+
+   std::vector<Vertex>*  nodes;
+   std::vector<TriFace>* triangles;
+   //for transfer
+   std::string filename;
+   bool transferViaFilename;
+   double transX1;
+   double transX2;
+   double transX3;
+
+   double x1min;
+   double x1max;
+   double x2min;
+   double x2max;
+   double x3min;
+   double x3max;
+   double x1center;
+   double x2center;
+   double x3center;
+
+   bool   consistent;
+
+   bool buildVertTriRelationMap;
+   std::multimap<Vertex*,TriFace*> relationVertTris;
+
+   Kd::Tree< double >* kdTree;
+};
+
+#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
+   UB_AUTO_RUN_NAMED(   SF::registerType<GbTriFaceMesh3D  >("GbTriFaceMesh3D  ")     , SF_GbTriFaceMesh3D     );
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbTriFaceMesh3D >() ), SF_GbTriFaceMesh3D_BD1 );
+#endif //RCF_USE_SF_SERIALIZATION
+
+#endif //GBTRIFACEMESH3D_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbTriangle3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbTriangle3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbTriangle3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbTriangle3D.cpp
index f3edda2240522d65a212729acaf258da4fcc94e6..0ac50c0f76aafb7bdfb7414c26b04997eb0cc279 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbTriangle3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbTriangle3D.cpp
@@ -1,1229 +1,1229 @@
-#include <numerics/geometry3d/GbTriangle3D.h>
-#include <numerics/geometry3d/creator/GbTriangle3DCreator.h>
-
-#include <basics/utilities/UbMath.h>
-
-#include <numerics/geometry3d/GbSystem3D.h>
-#include <numerics/geometry3d/GbLine3D.h>
-#include <numerics/geometry3d/GbCuboid3D.h>
-//#include <numerics/geometry3d/GbPolygon3D.h>                                  
-
-using namespace std;
-
-ObObjectCreator* GbTriangle3D::getCreator()
-{
-   return GbTriangle3DCreator::getInstance();
-}
-
-/*=========================================================================*/
-/* GbTriangle3D                                                            */
-/*                                                                         */
-/*
-* This Class provides basic 3D triangle objects.
-* The describing points are observed by 2D triangle objects.
-* <BR><BR><HR>
-* @version 1.0 - 24.01.05
-*/                                                                  
-
-GbTriangle3D::GbTriangle3D()
-{
-   this->init();
-   this->consistent = false;
-}
-/*======================================================================*/
-/*
-* Creates an empty 2D triangle with the specified points.
-* @param point1 the 1st point
-* @param point2 the 2nd point
-* @param point3 the 3nd point
-*/
-GbTriangle3D::GbTriangle3D(GbPoint3D* point1, GbPoint3D* point2, GbPoint3D* point3)
-{
-   this->init();
-   this->points[0] = point1;
-   this->points[1] = point2;
-   this->points[2] = point3;
-
-   this->calculateNormal();
-   this->consistent = false;
-
-   this->points[0]->addObserver(this);
-   this->points[1]->addObserver(this);
-   this->points[2]->addObserver(this);
-   
-   //this.po        = new PointObserver(this);
-   //this.points[0].addObserver(this.po);
-   //this.points[1].addObserver(this.po);
-   //this.points[2].addObserver(this.po);
-}
-/*======================================================================*/
-/*
-* Creates a 3D triangle as clone of the specified 2D triangle.
-* @param triangle the 3D triangle to be cloned
-*/
-GbTriangle3D::GbTriangle3D(GbTriangle3D* triangle)
-{
-   this->init();
-   this->points[0] = triangle->points[0]->clone();
-   this->points[1] = triangle->points[1]->clone();
-   this->points[2] = triangle->points[2]->clone();
-
-   this->consistent = false;
-   this->calculateNormal();
-   this->calculateValues();
-}
-/*======================================================================*/
-GbTriangle3D::~GbTriangle3D()
-{
-   if(this->points[0]) this->points[0]->removeObserver(this);
-   if(this->points[1]) this->points[1]->removeObserver(this);
-   if(this->points[2]) this->points[2]->removeObserver(this);
-}
-/*======================================================================*/
-void GbTriangle3D::deletePoints()
-{ 
-   if(points[0]) { delete points[0]; points[0]=NULL;}
-   if(points[1]) { delete points[1]; points[1]=NULL;}
-   if(points[2]) { delete points[2]; points[2]=NULL;}
-}
-
-/*======================================================================*/
-/*  Methoden                                                            */
-/*                                                                      */
-/*
-* Creates a 3D triangle as clone of this 3D triangle.
-*/
-GbTriangle3D* GbTriangle3D::clone()
-{
-   return(new GbTriangle3D(this));
-}
-/*======================================================================*/
-/*
-* Returns the number of times this 2D triangle contains the specified point.
-* @param point the point
-* @return the number of times this 2D triangle contains the specified point
-*/
-int GbTriangle3D::contains(GbPoint3D* point)
-{
-   int n = 0;
-   for(int i=0; i<3; i++) if(this->points[i]->equals(point)) n++;
-   return(n);
-}
-/*======================================================================*/
-/*
-* Returns the number of times this 2D triangle contains a point equal to the specified point.
-* @param point the point
-* @return the number of times this 2D triangle contains a point equal to the specified point
-*/
-int GbTriangle3D::containsEqual(GbPoint3D* point)
-{
-   int n = 0;
-   for(int i=0; i<3; i++) if(this->points[i]->equals(point)) n++;
-   return(n);
-}
-/*======================================================================*/
-/*
-* Returns the specified point.
-* @param index the index (must be 0, 1, or 2)
-* @return the specified point
-* @exception ArrayIndexOutOfBoundsException if the specified index is not valid
-*/
-GbPoint3D* GbTriangle3D::getPoint(const int& index) 
-{
-   if(index < 0 || index > 2) throw UbException(UB_EXARGS,"invalid index specified: ");
-   return((this->points[index]));
-}
-/*======================================================================*/
-vector<GbPoint3D> GbTriangle3D::getPoints() 
-{
-   vector<GbPoint3D> p(3);
-   p[0] = *(points[0]);
-   p[1] = *(points[1]);
-   p[2] = *(points[2]);
-   return p;
-   //
-   //vector<GbPoint3D> p(3);// = new vector<GbPoint3D*>;
-   //p.resize(3);//, NULL);
-   //p[0] = this->points[0];
-   //p[1] = this->points[1];
-   //p[2] = this->points[2];
-   //return(p);
-}
-/*======================================================================*/
-/*
-* Returns the area of this triangle.
-* The area is positive for positive ordered points, otherwise negative.
-* @return the area of this triangle
-*/
-double GbTriangle3D::getArea()
-{
-   if(!this->consistent) this->calculateValues();
-   // throw UbException(UB_EXARGS,"not correct calculated ...");
-   return(this->area);
-}
-/*
-* Returns the centroid x1 coordinate of this triangle.
-* @return the centroid x1 coordinate of this triangle
-*/
-double GbTriangle3D::getX1Centroid()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x1s);
-}
-/*
-* Returns the minimum x1 coordinate of this triangle.
-* @return the minimum x1 coordinate of this triangle
-*/
-double GbTriangle3D::getX1Minimum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x1min);
-}
-/*
-* Returns the maximum x1 coordinate of this triangle.
-* @return the maximum x1 coordinate of this triangle
-*/
-double GbTriangle3D::getX1Maximum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x1max);
-}
-/*
-* Returns the centroid x2 coordinate of this triangle.
-* @return the centroid x2 coordinate of this triangle
-*/
-double GbTriangle3D::getX2Centroid()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x2s);
-}
-/*                                                         
-* Returns the minimum x2 coordinate of this triangle.
-* @return the minimum x2 coordinate of this triangle
-*/
-double GbTriangle3D::getX2Minimum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x2min);
-}
-/*
-* Returns the maximum x2 coordinate of this triangle.
-* @return the maximum x2 coordinate of this triangle
-*/
-double GbTriangle3D::getX2Maximum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x2max);
-}
-double GbTriangle3D::getX3Centroid()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x3s);
-}
-double GbTriangle3D::getX3Minimum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x3min);
-}
-double GbTriangle3D::getX3Maximum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x3max);
-}
-
-/*
-* Sets the specified point.
-* @param point the point
-* @param index the index (must be 0, 1, or 2)
-* @exception ArrayIndexOutOfBoundsException if the specified index is not valid
-*/
-void GbTriangle3D::setPoint(GbPoint3D* point, int index) 
-{
-   if(index < 0 || index > 2) throw UbException(UB_EXARGS,"invalid index specified: ");
-   this->points[index] = point;
-   this->consistent    = false;
-   this->calculateNormal();
-}
-
-/*
-* Returns true if this 2D triangle equals the specified object.
-* Two triangle are equal, if their points are equal.
-* <BR>Note that the order of points is not recognized!
-* @return true if this 2D triangle equals the specified object
-* @see GbPoint2D#equals(java.lang.Object)
-* @see GbPoint3D#equals(java.lang.Object)
-*/
-//bool equals(GbObject3D *object)
-//{
-//   try
-//   {
-//      GbTriangle3D *triangle = (GbTriangle3D*) object;
-
-//if(this.points[0].equals(triangle.points[0]))
-//{
-//   if(this.points[1].equals(triangle.points[1]) && this.points[2].equals(triangle.points[2])) return(true);
-//   if(this.points[1].equals(triangle.points[2]) && this.points[2].equals(triangle.points[1])) return(true);
-//   return(false);
-//}
-//else if(this.points[0].equals(triangle.points[1]))
-//{
-//   if(this.points[1].equals(triangle.points[0]) && this.points[2].equals(triangle.points[2])) return(true);
-//   if(this.points[1].equals(triangle.points[2]) && this.points[2].equals(triangle.points[0])) return(true);
-//   return(false);
-//}
-//else if(this.points[0].equals(triangle.points[2]))
-//{
-//   if(this.points[1].equals(triangle.points[0]) && this.points[2].equals(triangle.points[1])) return(true);
-//   if(this.points[1].equals(triangle.points[1]) && this.points[2].equals(triangle.points[0])) return(true);
-//   return(false);
-//}
-//return(false);
-//    }
-//    catch(Exception e){ return(false); }
-// }
-/*
-* Returns the surface triangle set with new nodes !!!
-* @returns the surface triangle set with new nodes !!!
-*/
-vector<GbTriangle3D*> GbTriangle3D::getSurfaceTriangleSet()
-{
-   vector<GbTriangle3D*> triangles;
-   
-   triangles.push_back(new GbTriangle3D(new GbPoint3D(getPoint1()),new GbPoint3D(getPoint2()),new GbPoint3D(getPoint3())));
-
-   return triangles;
-}
-
-
-/*
-* Returns the string representation of the triangle
-* @returns the string representation of the triangle
-*/
-
-string GbTriangle3D::toString()
-{
-   stringstream ss;
-   ss<<"GbTriangle3D[area=";
-   ss<<this->getArea();
-
-   ss<<", x1s="<<this->x1s;
-   ss<<", x2s="<<this->x2s;
-   ss<<", x3s="<<this->x3s;
-   ss<<", x1min="<<this->x1min;
-   ss<<", x1max="<<this->x1max;
-   ss<<", x2min="<<this->x2min;
-   ss<<", x2max="<<this->x2max;
-   ss<<", x3min="<<this->x3min;
-   ss<<", x3max="<<this->x3max;
-   ss<<", points1="<<this->points[0]->toString();
-   ss<<", points2="<<this->points[1]->toString();
-   ss<<", points3="<<this->points[2]->toString();
-   ss<<"]";
-   return((ss.str()).c_str());
-}
-/*======================================================================*/
-double GbTriangle3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
-{
-   //e1 = v1 - v0
-   double e1x1 = this->points[1]->x1-this->points[0]->x1;
-   double e1x2 = this->points[1]->x2-this->points[0]->x2;
-   double e1x3 = this->points[1]->x3-this->points[0]->x3;  
-
-   //e2 = v2 - v0
-   double e2x1 = this->points[2]->x1-this->points[0]->x1;
-   double e2x2 = this->points[2]->x2-this->points[0]->x2;
-   double e2x3 = this->points[2]->x3-this->points[0]->x3;  
-
-   //p = d x e2
-   double px1 = rx2*e2x3 - rx3*e2x2;
-   double px2 = rx3*e2x1 - rx1*e2x3;
-   double px3 = rx1*e2x2 - rx2*e2x1;
-
-   //a = e1 dot p
-   double a = e1x1*px1 + e1x2*px2 + e1x3*px3;
-   if(fabs(a)<1.E-10) return -1.0;
-   double f = 1.0/a;
-
-   //s = o - v0
-   double sx1 = x1 - this->points[0]->x1;
-   double sx2 = x2 - this->points[0]->x2;
-   double sx3 = x3 - this->points[0]->x3;
-
-   //u = f * ( s dot p)
-   double u = f * ( sx1*px1 + sx2*px2 + sx3*px3 );
-   if(u<-1.E-10 || u>1.0+1.E-10) return -1.0;
-
-   //q = s x e1
-   double qx1 = sx2*e1x3 - sx3*e1x2;
-   double qx2 = sx3*e1x1 - sx1*e1x3;
-   double qx3 = sx1*e1x2 - sx2*e1x1;
-
-   //v = f*(e2 dot q)
-   double v = f * (rx1*qx1 + rx2*qx2 + rx3*qx3);
-   if(v<-1.E-10 || (u+v)>1.0+1.E-10) return -1.0;
-
-   //t = f * (e2 dot q)
-   return f * (e2x1*qx1 + e2x2*qx2 + e2x3*qx3);
-}
-
-/*======================================================================*/
-/*  Calculation                                                         */
-/*                                                                      */
-/*
-* Returns the intersection points of this 2D triangle and the specified 2D line.
-* @param line the 2D line to intersect
-* @return the intersection points of this 2D triangle and the specified 2D line
-*/
-/*
-vector<GbPoint3D> GbTriangle3D::calculateIntersectionPoints3D(GbLine3D *line)
-{
-//throw UbException(UB_EXARGS,"not yet implemented");	
-
-GbSystem::PointSet3 pointSet(0);
-GbPoint3D          *pCrossed = NULL;
-
-pCrossed = GbSystem::calculateIntersectionPoint3D(*this->points[0], *this->points[1], *line->getPoint1(), *line->getPoint2());
-if(pCrossed != NULL) pointSet.addUnequal(pCrossed);
-pCrossed = GbSystem::calculateIntersectionPoint3D(*this->points[1], *this->points[2], *line->getPoint1(), *line->getPoint2());
-if(pCrossed != NULL) pointSet.addUnequal(pCrossed);
-pCrossed = GbSystem::calculateIntersectionPoint3D(*this->points[2], *this->points[0], *line->getPoint1(), *line->getPoint2());
-if(pCrossed != NULL) pointSet.addUnequal(pCrossed);
-//vector<GbPoint3D> points = pointSet->getPoints();
-return(pointSet.getPoints());
-}
-*/
-/*===========================================================*/
-
-GbLine3D* GbTriangle3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
-{
-   GbPoint3D *result = this->calculateIntersectionPoints3D(&point1, &point2);
-   if(!result) return NULL;
-
-   return new GbLine3D(result, new GbPoint3D(point2));
-
-   //return GbSystem::createClipLine3D(point1, point2,
-      //p1->getX1Coordinate(),p1->getX2Coordinate(),p1->getX3Coordinate(),
-      //p2->getX1Coordinate(),p2->getX2Coordinate(),p2->getX3Coordinate() );
-}
-
-//von Navodit ...
-/*===========================================================*/
-GbPoint3D* GbTriangle3D::calculateIntersectionPoints3D(GbLine3D* line)
-{
-   return this->calculateIntersectionPoints3D(line->getPoint1(), line->getPoint2());
-}
-/*===========================================================*/
-GbPoint3D* GbTriangle3D::calculateIntersectionPoints3D(GbPoint3D* linePoint1, GbPoint3D* linePoint2)
-{
-   GbVector3D Point1(linePoint1->x1, linePoint1->x2, linePoint1->x3);
-   GbVector3D Point2(linePoint2->x1, linePoint2->x2, linePoint2->x3);
-   GbVector3D direction = Point2-Point1;
-   GbVector3D GbPoint3D1(this->getPoint1()->x1,this->getPoint1()->x2,this->getPoint1()->x3);
-   GbVector3D GbPoint3D2(this->getPoint2()->x1,this->getPoint2()->x2,this->getPoint2()->x3);
-   GbVector3D GbPoint3D3(this->getPoint3()->x1,this->getPoint3()->x2,this->getPoint3()->x3);
-   GbVector3D V2V1 = GbPoint3D2-GbPoint3D1;
-   GbVector3D V3V1 = GbPoint3D3-GbPoint3D1;
-   GbVector3D V2V1V3V1 = V2V1.Cross(V3V1);
-   V2V1V3V1.Normalize();
-   GbVector3D Normal = V2V1V3V1;
-
-   double d = -Normal.Dot(GbPoint3D1);            
-   double denom = Normal.Dot(direction);       
-
-   if (UbMath::zero(denom)) return NULL;   //line does not intersect the plane of the triangle !
-   else
-   {
-      double mu = -1.*(d + Point1.Dot(Normal))/denom;            //mu = -(d+ Normal.Point1)/denom
-
-      //   GbVector3D p1 = Point2-Point1;
-      //   GbVector3D p2 = p1*mu;
-      //   GbVector3D p3 = Point1+p2;
-      GbVector3D point = Point1 + mu*(Point2 -Point1);
-
-      if (mu<0.0 || mu>1.0)    return NULL;     // Point of intersection of line and plane does not lie on the triangle   
-      else
-      {
-         //Test whether Point lies inside the triangle or not
-         bool test=true;
-         GbVector3D a = GbPoint3D1-point;
-         GbVector3D b = GbPoint3D2-point;
-         GbVector3D c = GbPoint3D3-point;
-         GbVector3D ab = a.Cross(b);
-         GbVector3D bc = b.Cross(c);
-         GbVector3D ca = c.Cross(a);
-         GbVector3D Q1 = ab*0.5;
-         GbVector3D Q2 = bc*0.5;
-         GbVector3D Q3 = ca*0.5;
-         GbVector3D Q1Q2 = Q1+Q2;
-         GbVector3D Q = Q1Q2+Q3;
-
-         if (UbMath::less(Q.Dot(Q1), 0.0)) test = false; 
-         if (UbMath::less(Q.Dot(Q2), 0.0)) test = false; 
-         if (UbMath::less(Q.Dot(Q3), 0.0)) test = false; 
-
-         if (test == true) return (new GbPoint3D(point.X1(), point.X2(), point.X3()));
-         else          return NULL;
-      }
-   }
-}
-
-/**
-* Returns the distance between the 3D triangle and the specified 3D Point                                                                      
-* @param point the 3D point from whom the distance is to be calculated
-* @return the distance of the specified point from the triangle
-*/
-double GbTriangle3D::calculateDistanceToPoint3D(GbPoint3D *point) 
-{
-   return this->calculateDistanceToPoint3D(point->x1, point->x2, point->x3);
-}
-/*=======================================================================*/
-double GbTriangle3D::calculateDistanceToPoint3D(const double& x1, const double& x2, const double& x3) 
-{
-   //
-   //throw UbException(UB_EXARGS,"Ich glaub GbTriangle3D::calculateDistanceToPoint3D(...) kann man so nicht nehmen,jedenfalls nicht fuer die q's");
-   cout<<"??? ch glaub GbTriangle3D::calculateDistanceToPoint3D(...) kann man so nicht nehmen,jedenfalls nicht fuer die q's"<<endl;
-   GbVector3D P0(x1, x2, x3);
-   GbVector3D P1(this->points[0]->x1, this->points[0]->x2, this->points[0]->x3);
-   GbVector3D P2(this->points[1]->x1, this->points[1]->x2, this->points[1]->x3);
-   GbVector3D P3(this->points[2]->x1, this->points[2]->x2, this->points[2]->x3);
-
-   //Determine normal to triangle
-   GbVector3D Normal = (P1-P2).Cross(P1-P3);
-   double alpha = UbMath::ACos((P1-P0).Dot(Normal)/((P1-P0).Length()*Normal.Length()));
-
-   double P0P0dash = (P0-P1).Length()*cos(alpha);
-   Normal.Normalize();
-   GbVector3D Projection = Normal*(-P0P0dash);
-
-   GbVector3D P0dash = P0+Projection;
-
-   //Check if point P0dash lies within the triangle P1P2P3.
-   bool test = false;
-   if ( ((P1-P0).Cross(P2-P0)).Dot(Normal) > 0 ) test = true;
-   if ( ((P2-P0).Cross(P3-P0)).Dot(Normal) > 0 ) test = true;
-   if ( ((P3-P0).Cross(P1-P0)).Dot(Normal) > 0 ) test = true;
-
-   if (test == true) return (P0-P0dash).Length();
-   else
-   // Determine the distance of point P0 from all edges and vertices and return the minimum distance
-   {
-      double dP0P1 = (P0-P1).Length(); //Distance of Point P0 from Point P1
-      double dP0P2 = (P0-P2).Length(); //Distance of Point P0 from Point P2
-      double dP0P3 = (P0-P3).Length(); //Distance of Point P0 from Point P3
-
-      GbVector3D MP1P2 = P2-P1;        //Direction vector for line P1P2
-      GbVector3D MP2P3 = P3-P2;        //Direction vector for line P2P3
-      GbVector3D MP3P1 = P1-P3;        //Direction vector for line P3P1
-
-      double tP1P2 = MP1P2.Dot(P0-P1) / MP1P2.Dot(MP1P2);
-      double tP2P3 = MP2P3.Dot(P0-P2) / MP2P3.Dot(MP2P3);
-      double tP3P1 = MP3P1.Dot(P0-P3) / MP3P1.Dot(MP3P1);
-
-      double dP1P2 = (P0-(P1+(MP1P2*tP1P2))).Length(); //Distance of Point P0 from line P1P2
-      double dP2P3 = (P0-(P2+(MP2P3*tP2P3))).Length(); //Distance of Point P0 from line P2P3
-      double dP3P1 = (P0-(P3+(MP3P1*tP3P1))).Length(); //Distance of Point P0 from line P3P1
-
-      double distanceP0[6]; //Array to store all the distances from Point P0
-      distanceP0[0] = dP0P1; 
-      distanceP0[1] = dP0P2; 
-      distanceP0[2] = dP0P3; 
-      distanceP0[3] = dP1P2; 
-      distanceP0[4] = dP2P3; 
-      distanceP0[5] = dP3P1; 
-
-      double d = 0.0;
-      //Find the minimum distance from Point P0
-      for (int i=0; i<6; i++)
-      {
-         if(distanceP0[i]<d) d = distanceP0[i];
-      }
-      return d;
-   }
-}
-/**
-* Returns the normalized distance between the 3D triangle and the specified 3D Point
-* copied from Benjamin A.
-* @param point the 3D point from whom the distance is to be calculated
-* @return the distance of the specified point from the triangle
-*/
-double GbTriangle3D::calculateNormalizedDistanceToPoint3D(const double& x1, const double& y1, const double& z1, 
-                                                          const double& x2, const double& y2, const double& z2)
-{
-    //face* pf
-    double xa, xb, xc, ya, yb, yc, za, zb, zc;
-    //double xp, yp, zp;
-    double tt=0, xi=0, eta=0;
-    double zaehler, nenner;
-    double wurzel3 = sqrt(3.);
-
-    //Weltkoordinaten der Dreiecke
-    xa = this->points[0]->x1;
-    xb = this->points[1]->x1;
-    xc = this->points[2]->x1;
-         
-    ya = this->points[0]->x2;
-    yb = this->points[1]->x2;
-    yc = this->points[2]->x2;
-
-    za = this->points[0]->x3;
-    zb = this->points[1]->x3;
-    zc = this->points[2]->x3;
-
-    //Shape-Funktionen zum Berechnen der Schnittpunkte
-    zaehler =
-       static_cast<double>(((-1.0*zc+zb)*ya+(yc-1.0*yb)*za+zc*yb-1.0*zb*yc)*x1
-       +((-1.0*zb+zc)*xa+(xb-1.0*xc)*za-1.0*xb*zc+xc*zb)*y1+((-1.0*yc+yb)*xa
-       +(-1.0*xb+xc)*ya-1.0*xc*yb+xb*yc)*z1+((-1.0*zc+zb)*ya+(yc-1.0*yb)*za
-       +zc*yb-1.0*zb*yc)*x2+((-1.0*zb+zc)*xa+(xb-1.0*xc)*za-1.0*xb*zc+xc*zb)*y2
-       +((-1.0*yc+yb)*xa+(-1.0*xb+xc)*ya-1.0*xc*yb+xb*yc)*z2+(2.0*zb*yc-2.0*zc*yb)*xa
-       +(2.0*xb*zc-2.0*xc*zb)*ya+(-2.0*xb*yc+2.0*xc*yb)*za);
-    nenner  =
-       static_cast<double>((((-1.0*zc+zb)*ya+(yc-1.0*yb)*za+zc*yb-1.0*zb*yc)*x1
-       +((-1.0*zb+zc)*xa+(xb-1.0*xc)*za-1.0*xb*zc+xc*zb)*y1+((-1.0*yc+yb)*xa
-       +(-1.0*xb+xc)*ya-1.0*xc*yb+xb*yc)*z1+((-1.0*zb+zc)*ya+(-1.0*yc+yb)*za-1.0*zc*yb+zb*yc)
-       *x2+((-1.0*zc+zb)*xa+(-1.0*xb+xc)*za+xb*zc-1.0*xc*zb)*y2+((yc-1.0*yb)*xa+(xb
-       -1.0*xc)*ya+xc*yb-1.0*xb*yc)*z2));
-    if( UbMath::greater(nenner, 0.0) ) tt = zaehler/nenner;
-    else tt=-999.;
-
-    zaehler =
-       static_cast<double>(((-2.0*zc+za+zb)*y2+(-1.0*yb-1.0*ya+2.0*yc)*z2+zc*ya
-       -1.0*zb*yc+zc*yb-1.0*za*yc)*x1+((-1.0*za+2.0*zc-1.0*zb)*x2+(xa-2.0*xc+xb)*z2
-       -1.0*xa*zc-1.0*xb*zc+xc*za+xc*zb)*y1+((-2.0*yc+ya+yb)*x2+(-1.0*xa-1.0*xb+2.0*xc)
-       *y2-1.0*xc*yb+xa*yc+xb*yc-1.0*xc*ya)*z1+(zb*yc-1.0*zc*ya-1.0*zc*yb+za*yc)
-       *x2+(-1.0*xc*za+xb*zc+xa*zc-1.0*xc*zb)*y2+(xc*yb-1.0*xa*yc-1.0*xb*yc+xc*ya)*z2);
-    nenner  =
-       static_cast<double>((((zc-1.0*zb)*ya+(yb-1.0*yc)*za+zb*yc-1.0*zc*yb)*x1
-       +((zb-1.0*zc)*xa+(xc-1.0*xb)*za-1.0*xc*zb+xb*zc)*y1+((-1.0*yb+yc)*xa+(xb-1.0*xc)
-       *ya-1.0*xb*yc+xc*yb)*z1+((zb-1.0*zc)*ya+(-1.0*yb+yc)*za+zc*yb-1.0*zb*yc)*x2
-       +((zc-1.0*zb)*xa+(xb-1.0*xc)*za-1.0*xb*zc+xc*zb)*y2+((yb-1.0*yc)*xa
-       +(xc-1.0*xb)*ya+xb*yc-1.0*xc*yb)*z2));
-    if( UbMath::greater(nenner, 0.0) ) xi = zaehler/nenner;
-    else xi=-999.;
-
-    zaehler =
-       static_cast<double>(((za-1.0*zb)*y2+(-1.0*ya+yb)*z2-1.0*za*yb+zb*ya)*x1+
-       ((-1.0*za+zb)*x2+(xa-1.0*xb)*z2-1.0*xa*zb+xb*za)*y1+((ya-1.0*yb)*x2+(xb-1.0*xa)
-       *y2+xa*yb-1.0*xb*ya)*z1+(-1.0*zb*ya+za*yb)*x2+(-1.0*xb*za+xa*zb)*y2
-       +(-1.0*xa*yb+xb*ya)*z2);
-    nenner  =
-       static_cast<double>((((zc-1.0*zb)*ya+(yb-1.0*yc)*za+zb*yc-1.0*zc*yb)*x1
-       +((zb-1.0*zc)*xa+(xc-1.0*xb)*za-1.0*xc*zb+xb*zc)*y1+((-1.0*yb+yc)*xa+(xb-1.0*xc)
-       *ya-1.0*xb*yc+xc*yb)*z1+((zb-1.0*zc)*ya+(-1.0*yb+yc)*za+zc*yb-1.0*zb*yc)*x2
-       +((zc-1.0*zb)*xa+(xb-1.0*xc)*za-1.0*xb*zc+xc*zb)*y2+((yb-1.0*yc)*xa+(xc-1.0*xb)
-       *ya+xb*yc-1.0*xc*yb)*z2));
-    if ( UbMath::greater(nenner, 0.0) ) eta = static_cast<double>((zaehler/nenner)*wurzel3*-1.);
-    else eta=-999.;
-
-    if (tt >= -1.0-UbMath::Epsilon<double>::val() && tt <= 1.0){
-       if(xi >= -1.0+eta/wurzel3-UbMath::Epsilon<double>::val() && xi <=
-          1.0-eta/wurzel3+UbMath::Epsilon<double>::val()){
-             if (eta >= 0-UbMath::Epsilon<double>::val() && eta <= wurzel3+UbMath::Epsilon<double>::val()){
-                /*xp = x1*(0.5-tt/2)+x2*(0.5+tt/2);
-                yp = y1*(0.5-tt/2)+y2*(0.5+tt/2);
-                zp = z1*(0.5-tt/2)+z2*(0.5+tt/2);*/
-                return
-                   static_cast<double>((sqrt(pow((x1*(0.5-tt/2)+x2*(0.5+tt/2))-x1,2)
-                   +pow((y1*(0.5-tt/2)+y2*(0.5+tt/2))-y1,2)+pow((z1*(0.5-tt/2)+z2*(0.5+tt/2))-z1,2))));
-             }
-          }
-    }
-    return (-999.);
-}
-/*
-* Returns true if the specified 2D point lies within (or on the border of) this 2D triangle.
-* @param point the 2D point to check
-* @return true if the specified 2D point lies within (or on the border of) this 2D triangle
-*/
- bool GbTriangle3D::enclosesPoint2D(double x1, double x2)
- {
-	 int i=0;
-	 //Punkt(x1,x2) liegt auf einem der Eckpunkte
-    if(x1==this->getPoint(0)->getX1Coordinate() && x2 == this->getPoint(0)->getX2Coordinate())	return true;
-	 if(x1==this->getPoint(1)->getX1Coordinate() && x2 == this->getPoint(1)->getX2Coordinate())	return true;
-	 if(x1==this->getPoint(2)->getX1Coordinate() && x2 == this->getPoint(2)->getX2Coordinate())  return true;
-
-	 //Erste Grade aus dem zu pruefenden Punkt(x,y) und einem zweiten Punkt(x+0.333,y+2.333)
-	 GbPoint3D p1;		p1.setX1(x1);			p1.setX2(x2);			p1.setX3(0.0);
-	 GbPoint3D p2;		p2.setX1(x1+0.333);	p2.setX2(x2+3.333);	p2.setX3(0.0);
-	 //Punkte des Dreiecks auf 2D reduziert
-	 GbPoint3D dp1;	dp1.setX1(this->getPoint(0)->getX1Coordinate());	dp1.setX2(this->getPoint(0)->getX2Coordinate());	dp1.setX3(0.0);
-	 GbPoint3D dp2;	dp2.setX1(this->getPoint(1)->getX1Coordinate());	dp2.setX2(this->getPoint(1)->getX2Coordinate());	dp2.setX3(0.0);
-	 GbPoint3D dp3;	dp3.setX1(this->getPoint(2)->getX1Coordinate());	dp3.setX2(this->getPoint(2)->getX2Coordinate());	dp3.setX3(0.0);
-	 //ueberpruefen, ob der Punkt(x,y) innerhalt der Boundingbox des Dreiecks liegt
-	 if(	 x1<this->getX1Maximum() && x1>getX1Minimum()
-		 && x2<this->getX2Maximum() && x2>getX2Minimum())
-	 {
-		 GbPoint3D* dummy = NULL;
-		 //ueberpruefen, ob der Punkt innerhalb des Dreiecks liegt
-		 dummy = GbSystem3D::calculateIntersectionPoint3D(p1,p2,dp1,dp2);
-		 if(dummy!=NULL)
-       {
-          if(dummy->getX1Coordinate()==p1.getX1Coordinate() && dummy->getX2Coordinate()==p1.getX2Coordinate())	
-          {
-             delete dummy;
-             return true;
-          }
-			 else if(dummy->getX1Coordinate()>p1.getX1Coordinate())
-          {
-             i++;
-          }
-			 else
-          {
-             i--;
-          }
-       }
-       if(dummy)  delete dummy;
-
-       dummy = GbSystem3D::calculateIntersectionPoint3D(p1,p2,dp2,dp3);
-		 if(dummy!=NULL)
-       {
-          if(dummy->getX1Coordinate()==p1.getX1Coordinate() && dummy->getX2Coordinate()==p1.getX2Coordinate())
-          {
-             if(dummy)  delete dummy;
-             return true;
-          }
-			 else if(dummy->getX1Coordinate()>p1.getX1Coordinate())
-          {
-             i++;
-          }
-			 else
-          {
-             i--;
-          }
-       }
-       if(dummy)  delete dummy;
-
-		 dummy = GbSystem3D::calculateIntersectionPoint3D(p1,p2,dp3,dp1);
-		 if(dummy!=NULL)
-       {
-          if(dummy->getX1Coordinate()==p1.getX1Coordinate() && dummy->getX2Coordinate()==p1.getX2Coordinate())
-          {
-             if(dummy)  delete dummy;
-             return true;
-          }
-			 else if(dummy->getX1Coordinate()>p1.getX1Coordinate())
-          {
-             i++;
-          }
-          else
-          {
-             i--;
-          }
-       }
-       if(dummy)  delete dummy;
-	 }
-	 if(i==-1) return true;
-	 if(i==1 ) return true;
-	
-    return false;
- }
-
-///*
-//* Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!).
-//* @param rectangle the 2D rectangle
-//* @return a new 2D polygon clipped by the specified 2D rectangle
-//*/
-GbPolygon3D* GbTriangle3D::createClippedPolygon3D(GbCuboid3D* cube)
-{
-   return(GbSystem3D::clipPolygon3D(this->getPoints(), cube->getPoint1()->getX1Coordinate(), cube->getPoint1()->getX2Coordinate(), cube->getPoint1()->getX3Coordinate(), cube->getPoint2()->getX1Coordinate(), cube->getPoint2()->getX2Coordinate(), cube->getPoint2()->getX3Coordinate()));
-}
-///*
-//* Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!).
-//* @param p1 the 1st point of the rectangle
-//* @param p2 the 2nd point of the rectangle
-//* @return a new 2D polygon clipped by the specified 2D rectangle
-//*/
-//public GbPolygon2D createClippedPolygon2D(GbPoint2D p1, GbPoint2D p2)
-//{
-//   return(GbSystem.clipPolygon2D(this.points, p1.x1, p1.x2, p2.x1, p2.x2));
-//}
-/*
-* Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!).
-* @param p1x1 the 1st x1 coordinate of the rectangle
-* @param p1x2 the 1st x2 coordinate of the rectangle
-* @param p2x1 the 2nd x1 coordinate of the rectangle
-* @param p2x2 the 2nd x2 coordinate of the rectangle
-* @return a new 2D polygon clipped by the specified 2D rectangle
-*/
-GbPolygon3D* GbTriangle3D::createClippedPolygon3D(const double& p1x1, const double& p1x2, const double& p1x3, const double& p2x1, const double& p2x2, const double& p2x3)
-{
-   return(GbSystem3D::clipPolygon3D(this->getPoints(), p1x1, p1x2, p1x3, p2x1, p2x2, p2x3));
-}
-
-/*
-* Returns true if the specified 2D rectangle lies completely within this 2D triangle.
-* @param rectangle the 2D rectangle to check
-* @return true if the specified 2D rectangle lies completely within this 2D triangle
-*/
-//bool enclosesRectangle2D(GbRectangle2D *rectangle)
-//{
-//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
-//   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), rectangle.getArea()));
-//}
-/*
-* Returns true if the specified 2D rectangle lies completely within this 2D triangle.
-* @param p1 the 1st point of the rectangle to check
-* @param p2 the 2nd point of the rectangle to check                         triangle
-* @return true if the specified 2D rectangle lies completely within this 2D
-*/
-//public boolean enclosesRectangle2D(GbPoint2D p1, GbPoint2D p2)
-//{
-//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1.x1, p1.x2, p2.x1, p2.x2);
-//   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2))));
-//}
-/*
-* Returns true if the specified 2D rectangle lies completely within this 2D triangle.
-* @param p1x1 the 1st x1 coordinate of the rectangle to check
-* @param p1x2 the 1st x2 coordinate of the rectangle to check
-* @param p2x1 the 2nd x1 coordinate of the rectangle to check
-* @param p2x2 the 2nd x2 coordinate of the rectangle to check
-* @return true if the specified 2D rectangle lies completely within this 2D triangle
-*/
-//public boolean enclosesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2)
-//{
-//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1x1, p1x2, p2x1, p2x2);
-//   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1x1-p2x1)*(p1x2-p2x2))));
-//}
-
-/*
-* Returns true if the specified 2D rectangle is crossed by this 2D triangle.
-* @param rectangle the 2D rectangle to check
-* @return true if the specified 2D rectangle is crossed by this 2D triangle
-*/
-//public boolean crossesRectangle2D(GbRectangle2D rectangle)
-//{
-//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
-//   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, rectangle.getArea()));
-//}
-/*
-* Returns true if the specified 2D rectangle is crossed by this 2D triangle.
-* @param p1 the 1st point of the rectangle to check
-* @param p2 the 2nd point of the rectangle to check
-* @return true if the specified 2D rectangle is crossed by this 2D triangle
-*/
-//public boolean crossesRectangle2D(GbPoint2D p1, GbPoint2D p2)
-//{
-//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1.x1, p1.x2, p2.x1, p2.x2);
-//   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2))));
-//}
-/*
-* Returns true if the specified 2D rectangle is crossed by this 2D triangle.
-* @param p1x1 the 1st x1 coordinate of the rectangle to check
-* @param p1x2 the 1st x2 coordinate of the rectangle to check
-* @param p2x1 the 2nd x1 coordinate of the rectangle to check
-* @param p2x2 the 2nd x2 coordinate of the rectangle to check
-* @return true if the specified 2D rectangle is crossed by this 2D triangle
-*/
-//public boolean crossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2)
-//{
-//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1x1, p1x2, p2x1, p2x2);
-//   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1x1-p2x1)*(p1x2-p2x2))));
-//}
-
-/*
-* Returns true if the specified 2D rectangle lies (at least partly) within this 2D triangle.
-* @param rectangle the 2D rectangle to check
-* @return true if the specified 2D rectangle lies (at least partly) within this 2D triangle
-*/
-//public boolean enclosesOrCrossesRectangle2D(GbRectangle2D rectangle)
-//{
-//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
-//   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
-//}
-/*
-* Returns true if the specified 2D rectangle lies (at least partly) within this 2D triangle.
-* @param p1 the 1st point of the rectangle to check
-* @param p2 the 2nd point of the rectangle to check
-* @return true if the specified 2D rectangle lies (at least partly) within this 2D triangle
-*/
-//public boolean enclosesOrCrossesRectangle2D(GbPoint2D p1, GbPoint2D p2)
-//{
-//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1.x1, p1.x2, p2.x1, p2.x2);
-//   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
-//}
-/*
-* Returns true if the specified 2D rectangle lies (at least partly) within this 2D triangle.
-* @param p1x1 the 1st x1 coordinate of the rectangle to check
-* @param p1x2 the 1st x2 coordinate of the rectangle to check
-* @param p2x1 the 2nd x1 coordinate of the rectangle to check
-* @param p2x2 the 2nd x2 coordinate of the rectangle to check
-* @return true if the specified 2D rectangle lies (at least partly) within this 2D triangle
-*/
-//public boolean enclosesOrCrossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2)
-//{
-//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1x1, p1x2, p2x1, p2x2);
-//   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
-//}
-/*======================================================================*/
-
-
-/*======================================================================*/
-/*  Private Methoden                                                    */
-/*                                                                      */
-void GbTriangle3D::calculateValues()
-{
-   this->x1min = this->points[0]->x1;
-   this->x1max = this->points[0]->x1;
-   this->x2min = this->points[0]->x2;
-   this->x2max = this->points[0]->x2;
-   this->x3min = this->points[0]->x3;
-   this->x3max = this->points[0]->x3;
-
-   if(this->points[1]->x1 < this->x1min) this->x1min = this->points[1]->x1;
-   if(this->points[1]->x1 > this->x1max) this->x1max = this->points[1]->x1;
-   if(this->points[1]->x2 < this->x2min) this->x2min = this->points[1]->x2;
-   if(this->points[1]->x2 > this->x2max) this->x2max = this->points[1]->x2;
-   if(this->points[1]->x3 < this->x3min) this->x3min = this->points[1]->x3;
-   if(this->points[1]->x3 > this->x3max) this->x3max = this->points[1]->x3;
-
-   if(this->points[2]->x1 < this->x1min) this->x1min = this->points[2]->x1;
-   if(this->points[2]->x1 > this->x1max) this->x1max = this->points[2]->x1;
-   if(this->points[2]->x2 < this->x2min) this->x2min = this->points[2]->x2;
-   if(this->points[2]->x2 > this->x2max) this->x2max = this->points[2]->x2;
-   if(this->points[2]->x3 < this->x3min) this->x3min = this->points[2]->x3;
-   if(this->points[2]->x3 > this->x3max) this->x3max = this->points[2]->x3;
-
-   this->x1s   = (this->points[0]->x1+this->points[1]->x1+this->points[2]->x1)/3.0;
-   this->x2s   = (this->points[0]->x2+this->points[1]->x2+this->points[2]->x2)/3.0;
-   this->x3s   = (this->points[0]->x3+this->points[1]->x3+this->points[2]->x3)/3.0;
-
-   GbVector3D A(points[0]->x1,points[0]->x2,points[0]->x3);
-   GbVector3D B(points[1]->x1,points[1]->x2,points[1]->x3);
-   GbVector3D C(points[2]->x1,points[2]->x2,points[2]->x3);
-   GbVector3D AB = B-A;
-   GbVector3D AC = C-A;
-   GbVector3D N = AB.Cross(AC);
-   this->area = 0.5*N.Length();
-   this->consistent = true;
-}
-/*======================================================================*/
-
-
-/*======================================================================*/
-//class PointObserver : public UbObserver
-//{
-//    GbTriangle3D *triangle;
-
-//    PointObserver(GbTriangle3D *triangle)
-//    {
-//      this->triangle = triangle;
-//    }
-
-//public:
-//   void objectChanged(GbObject3D *object)
-//    {
-//      if(object == this->triangle->points[0] || object == this->triangle->points[1]  || object == this->triangle->points[2])
-//      {
-//         this->triangle->consistent = false;
-//         this->triangle->notifyObservers();
-//      }
-//    }
-//};
-//bool GbTriangle3D::isPointOnEdge(GbVector3D& q)
-//{
-////cout<<"muss einer machen ...\n";
-//   return false;
-//}
-/*======================================================================*/
-GbVector3D GbTriangle3D::getNormal()
-{
-   this->calculateNormal();
-   return normal; 
-}
-/*======================================================================*/
-void GbTriangle3D::init()
-{
-   x1s        = 0.0;
-   x2s        = 0.0;
-   x3s        = 0.0;
-   x1min      = 0.0;
-   x1max      = 0.0;
-   x2min      = 0.0;
-   x2max      = 0.0;
-   area       = 0.0;
-   consistent = false;
-   points.resize(3,NULL);
-}
-/*=======================================================*/
-void GbTriangle3D::write(UbFileOutput* out) 
-{                                      
-   out->writeString(this->getCreator()->getTypeID());
-   if(points[0]) points[0]->write(out);
-   else {GbPoint3D tmp; tmp.write(out);}
-   if(points[1]) points[1]->write(out);
-   else {GbPoint3D tmp; tmp.write(out);}
-   if(points[2]) points[2]->write(out);
-   else {GbPoint3D tmp; tmp.write(out);}
-}
-/*=======================================================*/
-void GbTriangle3D::read(UbFileInput* in) 
-{  
-   this->deletePoints();
-   points[0] = new GbPoint3D;
-   points[1] = new GbPoint3D;
-   points[2] = new GbPoint3D;
-   in->readString();                                    
-   points[0]->read(in);
-   in->readString();                                    
-   points[1]->read(in);
-   in->readString();                                    
-   points[2]->read(in);
-   consistent = false;
-}
-/*=======================================================*/
-void GbTriangle3D::calculateNormal()
-{
-   GbPoint3D*& a = points[0]; 
-   GbPoint3D*& b = points[1];
-   GbPoint3D*& c = points[2];
-   normal[0] = ( c->getX3Coordinate() - a->getX3Coordinate()) * ( b->getX2Coordinate() - a->getX2Coordinate() ) -
-               ( b->getX3Coordinate() - a->getX3Coordinate()) * ( c->getX2Coordinate() - a->getX2Coordinate() );
-   normal[1] = ( b->getX3Coordinate() - a->getX3Coordinate()) * ( c->getX1Coordinate() - a->getX1Coordinate() ) -
-               ( b->getX1Coordinate() - a->getX1Coordinate()) * ( c->getX3Coordinate() - a->getX3Coordinate() );
-   normal[2] = ( b->getX1Coordinate() - a->getX1Coordinate()) * ( c->getX2Coordinate() - a->getX2Coordinate() ) -
-               ( b->getX2Coordinate() - a->getX2Coordinate()) * ( c->getX1Coordinate() - a->getX1Coordinate() );
-   normal.Normalize();
-}
-/*=======================================================*/
-//toDo: 
-double GbTriangle3D::getDistanceFromPoint(GbVector3D punct)
-{
-	GbVector3D Point1(this->getPoint1()->getX1Coordinate(), this->getPoint1()->getX2Coordinate(), this->getPoint1()->getX3Coordinate());
-	GbVector3D Point2(this->getPoint2()->getX1Coordinate(), this->getPoint2()->getX2Coordinate(), this->getPoint2()->getX3Coordinate());
-	GbVector3D Point3(this->getPoint3()->getX1Coordinate(), this->getPoint3()->getX2Coordinate(), this->getPoint3()->getX3Coordinate());
-
-	GbVector3D kDiff = Point1 - punct;
-	GbVector3D kEdge0 = Point2 - Point1;
-	GbVector3D kEdge1 = Point3 - Point1;
-	double fA00 = kEdge0.SquaredLength();
-	double fA01 = kEdge0.Dot(kEdge1);
-	double fA11 = kEdge1.SquaredLength();
-	double fB0 = kDiff.Dot(kEdge0);
-	double fB1 = kDiff.Dot(kEdge1);
-	double fC = kDiff.SquaredLength();
-	double fDet = fabs(fA00*fA11-fA01*fA01);
-	double fS = fA01*fB1-fA11*fB0;
-	double fT = fA01*fB0-fA00*fB1;
-	double fSqrDistance;
-
-	if (fS + fT <= fDet)
-	{
-		if (fS < (double)0.0)
-		{
-			if (fT < (double)0.0)  // region 4
-			{
-				if (fB0 < (double)0.0)
-				{
-					fT = (double)0.0;
-					if (-fB0 >= fA00)
-					{
-						fS = (double)1.0;
-						fSqrDistance = fA00+((double)2.0)*fB0+fC;
-					}
-					else
-					{
-						fS = -fB0/fA00;
-						fSqrDistance = fB0*fS+fC;
-					}
-				}
-				else
-				{
-					fS = (double)0.0;
-					if (fB1 >= (double)0.0)
-					{
-						fT = (double)0.0;
-						fSqrDistance = fC;
-					}
-					else if (-fB1 >= fA11)
-					{
-						fT = (double)1.0;
-						fSqrDistance = fA11+((double)2.0)*fB1+fC;
-					}
-					else
-					{
-						fT = -fB1/fA11;
-						fSqrDistance = fB1*fT+fC;
-					}
-				}
-			}
-			else  // region 3
-			{
-				fS = (double)0.0;
-				if (fB1 >= (double)0.0)
-				{
-					fT = (double)0.0;
-					fSqrDistance = fC;
-				}
-				else if (-fB1 >= fA11)
-				{
-					fT = (double)1.0;
-					fSqrDistance = fA11+((double)2.0)*fB1+fC;
-				}
-				else
-				{
-					fT = -fB1/fA11;
-					fSqrDistance = fB1*fT+fC;
-				}
-			}
-		}
-		else if (fT < (double)0.0)  // region 5
-		{
-			fT = (double)0.0;
-			if (fB0 >= (double)0.0)
-			{
-				fS = (double)0.0;
-				fSqrDistance = fC;
-			}
-			else if (-fB0 >= fA00)
-			{
-				fS = (double)1.0;
-				fSqrDistance = fA00+((double)2.0)*fB0+fC;
-			}
-			else
-			{
-				fS = -fB0/fA00;
-				fSqrDistance = fB0*fS+fC;
-			}
-		}
-		else  // region 0
-		{
-			// minimum at interior point
-			double fInvDet = ((double)1.0)/fDet;
-			fS *= fInvDet;
-			fT *= fInvDet;
-			fSqrDistance = fS*(fA00*fS+fA01*fT+((double)2.0)*fB0) +
-				fT*(fA01*fS+fA11*fT+((double)2.0)*fB1)+fC;
-		}
-	}
-	else
-	{
-		double fTmp0, fTmp1, fNumer, fDenom;
-
-		if (fS < (double)0.0)  // region 2
-		{
-			fTmp0 = fA01 + fB0;
-			fTmp1 = fA11 + fB1;
-			if (fTmp1 > fTmp0)
-			{
-				fNumer = fTmp1 - fTmp0;
-				fDenom = fA00-2.0f*fA01+fA11;
-				if (fNumer >= fDenom)
-				{
-					fS = (double)1.0;
-					fT = (double)0.0;
-					fSqrDistance = fA00+((double)2.0)*fB0+fC;
-				}
-				else
-				{
-					fS = fNumer/fDenom;
-					fT = (double)1.0 - fS;
-					fSqrDistance = fS*(fA00*fS+fA01*fT+2.0f*fB0) +
-						fT*(fA01*fS+fA11*fT+((double)2.0)*fB1)+fC;
-				}
-			}
-			else
-			{
-				fS = (double)0.0;
-				if (fTmp1 <= (double)0.0)
-				{
-					fT = (double)1.0;
-					fSqrDistance = fA11+((double)2.0)*fB1+fC;
-				}
-				else if (fB1 >= (double)0.0)
-				{
-					fT = (double)0.0;
-					fSqrDistance = fC;
-				}
-				else
-				{
-					fT = -fB1/fA11;
-					fSqrDistance = fB1*fT+fC;
-				}
-			}
-		}
-		else if (fT < (double)0.0)  // region 6
-		{
-			fTmp0 = fA01 + fB1;
-			fTmp1 = fA00 + fB0;
-			if (fTmp1 > fTmp0)
-			{
-				fNumer = fTmp1 - fTmp0;
-				fDenom = fA00-((double)2.0)*fA01+fA11;
-				if (fNumer >= fDenom)
-				{
-					fT = (double)1.0;
-					fS = (double)0.0;
-					fSqrDistance = fA11+((double)2.0)*fB1+fC;
-				}
-				else
-				{
-					fT = fNumer/fDenom;
-					fS = (double)1.0 - fT;
-					fSqrDistance = fS*(fA00*fS+fA01*fT+((double)2.0)*fB0) +
-						fT*(fA01*fS+fA11*fT+((double)2.0)*fB1)+fC;
-				}
-			}
-			else
-			{
-				fT = (double)0.0;
-				if (fTmp1 <= (double)0.0)
-				{
-					fS = (double)1.0;
-					fSqrDistance = fA00+((double)2.0)*fB0+fC;
-				}
-				else if (fB0 >= (double)0.0)
-				{
-					fS = (double)0.0;
-					fSqrDistance = fC;
-				}
-				else
-				{
-					fS = -fB0/fA00;
-					fSqrDistance = fB0*fS+fC;
-				}
-			}
-		}
-		else  // region 1
-		{
-			fNumer = fA11 + fB1 - fA01 - fB0;
-			if (fNumer <= (double)0.0)
-			{
-				fS = (double)0.0;
-				fT = (double)1.0;
-				fSqrDistance = fA11+((double)2.0)*fB1+fC;
-			}
-			else
-			{
-				fDenom = fA00-2.0f*fA01+fA11;
-				if (fNumer >= fDenom)
-				{
-					fS = (double)1.0;
-					fT = (double)0.0;
-					fSqrDistance = fA00+((double)2.0)*fB0+fC;
-				}
-				else
-				{
-					fS = fNumer/fDenom;
-					fT = (double)1.0 - fS;
-					fSqrDistance = fS*(fA00*fS+fA01*fT+((double)2.0)*fB0) +
-						fT*(fA01*fS+fA11*fT+((double)2.0)*fB1)+fC;
-				}
-			}
-		}
-	}
-
-	// account for numerical round-off error
-	if (fSqrDistance < (double)0.0)
-	{
-		fSqrDistance = (double)0.0;
-	}
-/*
-	m_kClosestPoint0 = punct;
-	m_kClosestPoint1 = m_rkTriangle.V[0] + fS*kEdge0 + fT*kEdge1;
-	m_afTriangleBary[1] = fS;
-	m_afTriangleBary[2] = fT;
-	m_afTriangleBary[0] = (double)1.0 - fS - fT;
-*/
-	return sqrt(fSqrDistance);
-}
+#include <numerics/geometry3d/GbTriangle3D.h>
+#include <numerics/geometry3d/creator/GbTriangle3DCreator.h>
+
+#include <basics/utilities/UbMath.h>
+
+#include <numerics/geometry3d/GbSystem3D.h>
+#include <numerics/geometry3d/GbLine3D.h>
+#include <numerics/geometry3d/GbCuboid3D.h>
+//#include <numerics/geometry3d/GbPolygon3D.h>                                  
+
+using namespace std;
+
+ObObjectCreator* GbTriangle3D::getCreator()
+{
+   return GbTriangle3DCreator::getInstance();
+}
+
+/*=========================================================================*/
+/* GbTriangle3D                                                            */
+/*                                                                         */
+/*
+* This Class provides basic 3D triangle objects.
+* The describing points are observed by 2D triangle objects.
+* <BR><BR><HR>
+* @version 1.0 - 24.01.05
+*/                                                                  
+
+GbTriangle3D::GbTriangle3D()
+{
+   this->init();
+   this->consistent = false;
+}
+/*======================================================================*/
+/*
+* Creates an empty 2D triangle with the specified points.
+* @param point1 the 1st point
+* @param point2 the 2nd point
+* @param point3 the 3nd point
+*/
+GbTriangle3D::GbTriangle3D(GbPoint3D* point1, GbPoint3D* point2, GbPoint3D* point3)
+{
+   this->init();
+   this->points[0] = point1;
+   this->points[1] = point2;
+   this->points[2] = point3;
+
+   this->calculateNormal();
+   this->consistent = false;
+
+   this->points[0]->addObserver(this);
+   this->points[1]->addObserver(this);
+   this->points[2]->addObserver(this);
+   
+   //this.po        = new PointObserver(this);
+   //this.points[0].addObserver(this.po);
+   //this.points[1].addObserver(this.po);
+   //this.points[2].addObserver(this.po);
+}
+/*======================================================================*/
+/*
+* Creates a 3D triangle as clone of the specified 2D triangle.
+* @param triangle the 3D triangle to be cloned
+*/
+GbTriangle3D::GbTriangle3D(GbTriangle3D* triangle)
+{
+   this->init();
+   this->points[0] = triangle->points[0]->clone();
+   this->points[1] = triangle->points[1]->clone();
+   this->points[2] = triangle->points[2]->clone();
+
+   this->consistent = false;
+   this->calculateNormal();
+   this->calculateValues();
+}
+/*======================================================================*/
+GbTriangle3D::~GbTriangle3D()
+{
+   if(this->points[0]) this->points[0]->removeObserver(this);
+   if(this->points[1]) this->points[1]->removeObserver(this);
+   if(this->points[2]) this->points[2]->removeObserver(this);
+}
+/*======================================================================*/
+void GbTriangle3D::deletePoints()
+{ 
+   if(points[0]) { delete points[0]; points[0]=NULL;}
+   if(points[1]) { delete points[1]; points[1]=NULL;}
+   if(points[2]) { delete points[2]; points[2]=NULL;}
+}
+
+/*======================================================================*/
+/*  Methoden                                                            */
+/*                                                                      */
+/*
+* Creates a 3D triangle as clone of this 3D triangle.
+*/
+GbTriangle3D* GbTriangle3D::clone()
+{
+   return(new GbTriangle3D(this));
+}
+/*======================================================================*/
+/*
+* Returns the number of times this 2D triangle contains the specified point.
+* @param point the point
+* @return the number of times this 2D triangle contains the specified point
+*/
+int GbTriangle3D::contains(GbPoint3D* point)
+{
+   int n = 0;
+   for(int i=0; i<3; i++) if(this->points[i]->equals(point)) n++;
+   return(n);
+}
+/*======================================================================*/
+/*
+* Returns the number of times this 2D triangle contains a point equal to the specified point.
+* @param point the point
+* @return the number of times this 2D triangle contains a point equal to the specified point
+*/
+int GbTriangle3D::containsEqual(GbPoint3D* point)
+{
+   int n = 0;
+   for(int i=0; i<3; i++) if(this->points[i]->equals(point)) n++;
+   return(n);
+}
+/*======================================================================*/
+/*
+* Returns the specified point.
+* @param index the index (must be 0, 1, or 2)
+* @return the specified point
+* @exception ArrayIndexOutOfBoundsException if the specified index is not valid
+*/
+GbPoint3D* GbTriangle3D::getPoint(const int& index) 
+{
+   if(index < 0 || index > 2) throw UbException(UB_EXARGS,"invalid index specified: ");
+   return((this->points[index]));
+}
+/*======================================================================*/
+vector<GbPoint3D> GbTriangle3D::getPoints() 
+{
+   vector<GbPoint3D> p(3);
+   p[0] = *(points[0]);
+   p[1] = *(points[1]);
+   p[2] = *(points[2]);
+   return p;
+   //
+   //vector<GbPoint3D> p(3);// = new vector<GbPoint3D*>;
+   //p.resize(3);//, NULL);
+   //p[0] = this->points[0];
+   //p[1] = this->points[1];
+   //p[2] = this->points[2];
+   //return(p);
+}
+/*======================================================================*/
+/*
+* Returns the area of this triangle.
+* The area is positive for positive ordered points, otherwise negative.
+* @return the area of this triangle
+*/
+double GbTriangle3D::getArea()
+{
+   if(!this->consistent) this->calculateValues();
+   // throw UbException(UB_EXARGS,"not correct calculated ...");
+   return(this->area);
+}
+/*
+* Returns the centroid x1 coordinate of this triangle.
+* @return the centroid x1 coordinate of this triangle
+*/
+double GbTriangle3D::getX1Centroid()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x1s);
+}
+/*
+* Returns the minimum x1 coordinate of this triangle.
+* @return the minimum x1 coordinate of this triangle
+*/
+double GbTriangle3D::getX1Minimum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x1min);
+}
+/*
+* Returns the maximum x1 coordinate of this triangle.
+* @return the maximum x1 coordinate of this triangle
+*/
+double GbTriangle3D::getX1Maximum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x1max);
+}
+/*
+* Returns the centroid x2 coordinate of this triangle.
+* @return the centroid x2 coordinate of this triangle
+*/
+double GbTriangle3D::getX2Centroid()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x2s);
+}
+/*                                                         
+* Returns the minimum x2 coordinate of this triangle.
+* @return the minimum x2 coordinate of this triangle
+*/
+double GbTriangle3D::getX2Minimum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x2min);
+}
+/*
+* Returns the maximum x2 coordinate of this triangle.
+* @return the maximum x2 coordinate of this triangle
+*/
+double GbTriangle3D::getX2Maximum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x2max);
+}
+double GbTriangle3D::getX3Centroid()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x3s);
+}
+double GbTriangle3D::getX3Minimum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x3min);
+}
+double GbTriangle3D::getX3Maximum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x3max);
+}
+
+/*
+* Sets the specified point.
+* @param point the point
+* @param index the index (must be 0, 1, or 2)
+* @exception ArrayIndexOutOfBoundsException if the specified index is not valid
+*/
+void GbTriangle3D::setPoint(GbPoint3D* point, int index) 
+{
+   if(index < 0 || index > 2) throw UbException(UB_EXARGS,"invalid index specified: ");
+   this->points[index] = point;
+   this->consistent    = false;
+   this->calculateNormal();
+}
+
+/*
+* Returns true if this 2D triangle equals the specified object.
+* Two triangle are equal, if their points are equal.
+* <BR>Note that the order of points is not recognized!
+* @return true if this 2D triangle equals the specified object
+* @see GbPoint2D#equals(java.lang.Object)
+* @see GbPoint3D#equals(java.lang.Object)
+*/
+//bool equals(GbObject3D *object)
+//{
+//   try
+//   {
+//      GbTriangle3D *triangle = (GbTriangle3D*) object;
+
+//if(this.points[0].equals(triangle.points[0]))
+//{
+//   if(this.points[1].equals(triangle.points[1]) && this.points[2].equals(triangle.points[2])) return(true);
+//   if(this.points[1].equals(triangle.points[2]) && this.points[2].equals(triangle.points[1])) return(true);
+//   return(false);
+//}
+//else if(this.points[0].equals(triangle.points[1]))
+//{
+//   if(this.points[1].equals(triangle.points[0]) && this.points[2].equals(triangle.points[2])) return(true);
+//   if(this.points[1].equals(triangle.points[2]) && this.points[2].equals(triangle.points[0])) return(true);
+//   return(false);
+//}
+//else if(this.points[0].equals(triangle.points[2]))
+//{
+//   if(this.points[1].equals(triangle.points[0]) && this.points[2].equals(triangle.points[1])) return(true);
+//   if(this.points[1].equals(triangle.points[1]) && this.points[2].equals(triangle.points[0])) return(true);
+//   return(false);
+//}
+//return(false);
+//    }
+//    catch(Exception e){ return(false); }
+// }
+/*
+* Returns the surface triangle set with new nodes !!!
+* @returns the surface triangle set with new nodes !!!
+*/
+vector<GbTriangle3D*> GbTriangle3D::getSurfaceTriangleSet()
+{
+   vector<GbTriangle3D*> triangles;
+   
+   triangles.push_back(new GbTriangle3D(new GbPoint3D(getPoint1()),new GbPoint3D(getPoint2()),new GbPoint3D(getPoint3())));
+
+   return triangles;
+}
+
+
+/*
+* Returns the string representation of the triangle
+* @returns the string representation of the triangle
+*/
+
+string GbTriangle3D::toString()
+{
+   stringstream ss;
+   ss<<"GbTriangle3D[area=";
+   ss<<this->getArea();
+
+   ss<<", x1s="<<this->x1s;
+   ss<<", x2s="<<this->x2s;
+   ss<<", x3s="<<this->x3s;
+   ss<<", x1min="<<this->x1min;
+   ss<<", x1max="<<this->x1max;
+   ss<<", x2min="<<this->x2min;
+   ss<<", x2max="<<this->x2max;
+   ss<<", x3min="<<this->x3min;
+   ss<<", x3max="<<this->x3max;
+   ss<<", points1="<<this->points[0]->toString();
+   ss<<", points2="<<this->points[1]->toString();
+   ss<<", points3="<<this->points[2]->toString();
+   ss<<"]";
+   return((ss.str()).c_str());
+}
+/*======================================================================*/
+double GbTriangle3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
+{
+   //e1 = v1 - v0
+   double e1x1 = this->points[1]->x1-this->points[0]->x1;
+   double e1x2 = this->points[1]->x2-this->points[0]->x2;
+   double e1x3 = this->points[1]->x3-this->points[0]->x3;  
+
+   //e2 = v2 - v0
+   double e2x1 = this->points[2]->x1-this->points[0]->x1;
+   double e2x2 = this->points[2]->x2-this->points[0]->x2;
+   double e2x3 = this->points[2]->x3-this->points[0]->x3;  
+
+   //p = d x e2
+   double px1 = rx2*e2x3 - rx3*e2x2;
+   double px2 = rx3*e2x1 - rx1*e2x3;
+   double px3 = rx1*e2x2 - rx2*e2x1;
+
+   //a = e1 dot p
+   double a = e1x1*px1 + e1x2*px2 + e1x3*px3;
+   if(fabs(a)<1.E-10) return -1.0;
+   double f = 1.0/a;
+
+   //s = o - v0
+   double sx1 = x1 - this->points[0]->x1;
+   double sx2 = x2 - this->points[0]->x2;
+   double sx3 = x3 - this->points[0]->x3;
+
+   //u = f * ( s dot p)
+   double u = f * ( sx1*px1 + sx2*px2 + sx3*px3 );
+   if(u<-1.E-10 || u>1.0+1.E-10) return -1.0;
+
+   //q = s x e1
+   double qx1 = sx2*e1x3 - sx3*e1x2;
+   double qx2 = sx3*e1x1 - sx1*e1x3;
+   double qx3 = sx1*e1x2 - sx2*e1x1;
+
+   //v = f*(e2 dot q)
+   double v = f * (rx1*qx1 + rx2*qx2 + rx3*qx3);
+   if(v<-1.E-10 || (u+v)>1.0+1.E-10) return -1.0;
+
+   //t = f * (e2 dot q)
+   return f * (e2x1*qx1 + e2x2*qx2 + e2x3*qx3);
+}
+
+/*======================================================================*/
+/*  Calculation                                                         */
+/*                                                                      */
+/*
+* Returns the intersection points of this 2D triangle and the specified 2D line.
+* @param line the 2D line to intersect
+* @return the intersection points of this 2D triangle and the specified 2D line
+*/
+/*
+vector<GbPoint3D> GbTriangle3D::calculateIntersectionPoints3D(GbLine3D *line)
+{
+//throw UbException(UB_EXARGS,"not yet implemented");	
+
+GbSystem::PointSet3 pointSet(0);
+GbPoint3D          *pCrossed = NULL;
+
+pCrossed = GbSystem::calculateIntersectionPoint3D(*this->points[0], *this->points[1], *line->getPoint1(), *line->getPoint2());
+if(pCrossed != NULL) pointSet.addUnequal(pCrossed);
+pCrossed = GbSystem::calculateIntersectionPoint3D(*this->points[1], *this->points[2], *line->getPoint1(), *line->getPoint2());
+if(pCrossed != NULL) pointSet.addUnequal(pCrossed);
+pCrossed = GbSystem::calculateIntersectionPoint3D(*this->points[2], *this->points[0], *line->getPoint1(), *line->getPoint2());
+if(pCrossed != NULL) pointSet.addUnequal(pCrossed);
+//vector<GbPoint3D> points = pointSet->getPoints();
+return(pointSet.getPoints());
+}
+*/
+/*===========================================================*/
+
+GbLine3D* GbTriangle3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
+{
+   GbPoint3D *result = this->calculateIntersectionPoints3D(&point1, &point2);
+   if(!result) return NULL;
+
+   return new GbLine3D(result, new GbPoint3D(point2));
+
+   //return GbSystem::createClipLine3D(point1, point2,
+      //p1->getX1Coordinate(),p1->getX2Coordinate(),p1->getX3Coordinate(),
+      //p2->getX1Coordinate(),p2->getX2Coordinate(),p2->getX3Coordinate() );
+}
+
+//von Navodit ...
+/*===========================================================*/
+GbPoint3D* GbTriangle3D::calculateIntersectionPoints3D(GbLine3D* line)
+{
+   return this->calculateIntersectionPoints3D(line->getPoint1(), line->getPoint2());
+}
+/*===========================================================*/
+GbPoint3D* GbTriangle3D::calculateIntersectionPoints3D(GbPoint3D* linePoint1, GbPoint3D* linePoint2)
+{
+   GbVector3D Point1(linePoint1->x1, linePoint1->x2, linePoint1->x3);
+   GbVector3D Point2(linePoint2->x1, linePoint2->x2, linePoint2->x3);
+   GbVector3D direction = Point2-Point1;
+   GbVector3D GbPoint3D1(this->getPoint1()->x1,this->getPoint1()->x2,this->getPoint1()->x3);
+   GbVector3D GbPoint3D2(this->getPoint2()->x1,this->getPoint2()->x2,this->getPoint2()->x3);
+   GbVector3D GbPoint3D3(this->getPoint3()->x1,this->getPoint3()->x2,this->getPoint3()->x3);
+   GbVector3D V2V1 = GbPoint3D2-GbPoint3D1;
+   GbVector3D V3V1 = GbPoint3D3-GbPoint3D1;
+   GbVector3D V2V1V3V1 = V2V1.Cross(V3V1);
+   V2V1V3V1.Normalize();
+   GbVector3D Normal = V2V1V3V1;
+
+   double d = -Normal.Dot(GbPoint3D1);            
+   double denom = Normal.Dot(direction);       
+
+   if (UbMath::zero(denom)) return NULL;   //line does not intersect the plane of the triangle !
+   else
+   {
+      double mu = -1.*(d + Point1.Dot(Normal))/denom;            //mu = -(d+ Normal.Point1)/denom
+
+      //   GbVector3D p1 = Point2-Point1;
+      //   GbVector3D p2 = p1*mu;
+      //   GbVector3D p3 = Point1+p2;
+      GbVector3D point = Point1 + mu*(Point2 -Point1);
+
+      if (mu<0.0 || mu>1.0)    return NULL;     // Point of intersection of line and plane does not lie on the triangle   
+      else
+      {
+         //Test whether Point lies inside the triangle or not
+         bool test=true;
+         GbVector3D a = GbPoint3D1-point;
+         GbVector3D b = GbPoint3D2-point;
+         GbVector3D c = GbPoint3D3-point;
+         GbVector3D ab = a.Cross(b);
+         GbVector3D bc = b.Cross(c);
+         GbVector3D ca = c.Cross(a);
+         GbVector3D Q1 = ab*0.5;
+         GbVector3D Q2 = bc*0.5;
+         GbVector3D Q3 = ca*0.5;
+         GbVector3D Q1Q2 = Q1+Q2;
+         GbVector3D Q = Q1Q2+Q3;
+
+         if (UbMath::less(Q.Dot(Q1), 0.0)) test = false; 
+         if (UbMath::less(Q.Dot(Q2), 0.0)) test = false; 
+         if (UbMath::less(Q.Dot(Q3), 0.0)) test = false; 
+
+         if (test == true) return (new GbPoint3D(point.X1(), point.X2(), point.X3()));
+         else          return NULL;
+      }
+   }
+}
+
+/**
+* Returns the distance between the 3D triangle and the specified 3D Point                                                                      
+* @param point the 3D point from whom the distance is to be calculated
+* @return the distance of the specified point from the triangle
+*/
+double GbTriangle3D::calculateDistanceToPoint3D(GbPoint3D *point) 
+{
+   return this->calculateDistanceToPoint3D(point->x1, point->x2, point->x3);
+}
+/*=======================================================================*/
+double GbTriangle3D::calculateDistanceToPoint3D(const double& x1, const double& x2, const double& x3) 
+{
+   //
+   //throw UbException(UB_EXARGS,"Ich glaub GbTriangle3D::calculateDistanceToPoint3D(...) kann man so nicht nehmen,jedenfalls nicht fuer die q's");
+   cout<<"??? ch glaub GbTriangle3D::calculateDistanceToPoint3D(...) kann man so nicht nehmen,jedenfalls nicht fuer die q's"<<endl;
+   GbVector3D P0(x1, x2, x3);
+   GbVector3D P1(this->points[0]->x1, this->points[0]->x2, this->points[0]->x3);
+   GbVector3D P2(this->points[1]->x1, this->points[1]->x2, this->points[1]->x3);
+   GbVector3D P3(this->points[2]->x1, this->points[2]->x2, this->points[2]->x3);
+
+   //Determine normal to triangle
+   GbVector3D Normal = (P1-P2).Cross(P1-P3);
+   double alpha = UbMath::ACos((P1-P0).Dot(Normal)/((P1-P0).Length()*Normal.Length()));
+
+   double P0P0dash = (P0-P1).Length()*cos(alpha);
+   Normal.Normalize();
+   GbVector3D Projection = Normal*(-P0P0dash);
+
+   GbVector3D P0dash = P0+Projection;
+
+   //Check if point P0dash lies within the triangle P1P2P3.
+   bool test = false;
+   if ( ((P1-P0).Cross(P2-P0)).Dot(Normal) > 0 ) test = true;
+   if ( ((P2-P0).Cross(P3-P0)).Dot(Normal) > 0 ) test = true;
+   if ( ((P3-P0).Cross(P1-P0)).Dot(Normal) > 0 ) test = true;
+
+   if (test == true) return (P0-P0dash).Length();
+   else
+   // Determine the distance of point P0 from all edges and vertices and return the minimum distance
+   {
+      double dP0P1 = (P0-P1).Length(); //Distance of Point P0 from Point P1
+      double dP0P2 = (P0-P2).Length(); //Distance of Point P0 from Point P2
+      double dP0P3 = (P0-P3).Length(); //Distance of Point P0 from Point P3
+
+      GbVector3D MP1P2 = P2-P1;        //Direction vector for line P1P2
+      GbVector3D MP2P3 = P3-P2;        //Direction vector for line P2P3
+      GbVector3D MP3P1 = P1-P3;        //Direction vector for line P3P1
+
+      double tP1P2 = MP1P2.Dot(P0-P1) / MP1P2.Dot(MP1P2);
+      double tP2P3 = MP2P3.Dot(P0-P2) / MP2P3.Dot(MP2P3);
+      double tP3P1 = MP3P1.Dot(P0-P3) / MP3P1.Dot(MP3P1);
+
+      double dP1P2 = (P0-(P1+(MP1P2*tP1P2))).Length(); //Distance of Point P0 from line P1P2
+      double dP2P3 = (P0-(P2+(MP2P3*tP2P3))).Length(); //Distance of Point P0 from line P2P3
+      double dP3P1 = (P0-(P3+(MP3P1*tP3P1))).Length(); //Distance of Point P0 from line P3P1
+
+      double distanceP0[6]; //Array to store all the distances from Point P0
+      distanceP0[0] = dP0P1; 
+      distanceP0[1] = dP0P2; 
+      distanceP0[2] = dP0P3; 
+      distanceP0[3] = dP1P2; 
+      distanceP0[4] = dP2P3; 
+      distanceP0[5] = dP3P1; 
+
+      double d = 0.0;
+      //Find the minimum distance from Point P0
+      for (int i=0; i<6; i++)
+      {
+         if(distanceP0[i]<d) d = distanceP0[i];
+      }
+      return d;
+   }
+}
+/**
+* Returns the normalized distance between the 3D triangle and the specified 3D Point
+* copied from Benjamin A.
+* @param point the 3D point from whom the distance is to be calculated
+* @return the distance of the specified point from the triangle
+*/
+double GbTriangle3D::calculateNormalizedDistanceToPoint3D(const double& x1, const double& y1, const double& z1, 
+                                                          const double& x2, const double& y2, const double& z2)
+{
+    //face* pf
+    double xa, xb, xc, ya, yb, yc, za, zb, zc;
+    //double xp, yp, zp;
+    double tt=0, xi=0, eta=0;
+    double zaehler, nenner;
+    double wurzel3 = sqrt(3.);
+
+    //Weltkoordinaten der Dreiecke
+    xa = this->points[0]->x1;
+    xb = this->points[1]->x1;
+    xc = this->points[2]->x1;
+         
+    ya = this->points[0]->x2;
+    yb = this->points[1]->x2;
+    yc = this->points[2]->x2;
+
+    za = this->points[0]->x3;
+    zb = this->points[1]->x3;
+    zc = this->points[2]->x3;
+
+    //Shape-Funktionen zum Berechnen der Schnittpunkte
+    zaehler =
+       static_cast<double>(((-1.0*zc+zb)*ya+(yc-1.0*yb)*za+zc*yb-1.0*zb*yc)*x1
+       +((-1.0*zb+zc)*xa+(xb-1.0*xc)*za-1.0*xb*zc+xc*zb)*y1+((-1.0*yc+yb)*xa
+       +(-1.0*xb+xc)*ya-1.0*xc*yb+xb*yc)*z1+((-1.0*zc+zb)*ya+(yc-1.0*yb)*za
+       +zc*yb-1.0*zb*yc)*x2+((-1.0*zb+zc)*xa+(xb-1.0*xc)*za-1.0*xb*zc+xc*zb)*y2
+       +((-1.0*yc+yb)*xa+(-1.0*xb+xc)*ya-1.0*xc*yb+xb*yc)*z2+(2.0*zb*yc-2.0*zc*yb)*xa
+       +(2.0*xb*zc-2.0*xc*zb)*ya+(-2.0*xb*yc+2.0*xc*yb)*za);
+    nenner  =
+       static_cast<double>((((-1.0*zc+zb)*ya+(yc-1.0*yb)*za+zc*yb-1.0*zb*yc)*x1
+       +((-1.0*zb+zc)*xa+(xb-1.0*xc)*za-1.0*xb*zc+xc*zb)*y1+((-1.0*yc+yb)*xa
+       +(-1.0*xb+xc)*ya-1.0*xc*yb+xb*yc)*z1+((-1.0*zb+zc)*ya+(-1.0*yc+yb)*za-1.0*zc*yb+zb*yc)
+       *x2+((-1.0*zc+zb)*xa+(-1.0*xb+xc)*za+xb*zc-1.0*xc*zb)*y2+((yc-1.0*yb)*xa+(xb
+       -1.0*xc)*ya+xc*yb-1.0*xb*yc)*z2));
+    if( UbMath::greater(nenner, 0.0) ) tt = zaehler/nenner;
+    else tt=-999.;
+
+    zaehler =
+       static_cast<double>(((-2.0*zc+za+zb)*y2+(-1.0*yb-1.0*ya+2.0*yc)*z2+zc*ya
+       -1.0*zb*yc+zc*yb-1.0*za*yc)*x1+((-1.0*za+2.0*zc-1.0*zb)*x2+(xa-2.0*xc+xb)*z2
+       -1.0*xa*zc-1.0*xb*zc+xc*za+xc*zb)*y1+((-2.0*yc+ya+yb)*x2+(-1.0*xa-1.0*xb+2.0*xc)
+       *y2-1.0*xc*yb+xa*yc+xb*yc-1.0*xc*ya)*z1+(zb*yc-1.0*zc*ya-1.0*zc*yb+za*yc)
+       *x2+(-1.0*xc*za+xb*zc+xa*zc-1.0*xc*zb)*y2+(xc*yb-1.0*xa*yc-1.0*xb*yc+xc*ya)*z2);
+    nenner  =
+       static_cast<double>((((zc-1.0*zb)*ya+(yb-1.0*yc)*za+zb*yc-1.0*zc*yb)*x1
+       +((zb-1.0*zc)*xa+(xc-1.0*xb)*za-1.0*xc*zb+xb*zc)*y1+((-1.0*yb+yc)*xa+(xb-1.0*xc)
+       *ya-1.0*xb*yc+xc*yb)*z1+((zb-1.0*zc)*ya+(-1.0*yb+yc)*za+zc*yb-1.0*zb*yc)*x2
+       +((zc-1.0*zb)*xa+(xb-1.0*xc)*za-1.0*xb*zc+xc*zb)*y2+((yb-1.0*yc)*xa
+       +(xc-1.0*xb)*ya+xb*yc-1.0*xc*yb)*z2));
+    if( UbMath::greater(nenner, 0.0) ) xi = zaehler/nenner;
+    else xi=-999.;
+
+    zaehler =
+       static_cast<double>(((za-1.0*zb)*y2+(-1.0*ya+yb)*z2-1.0*za*yb+zb*ya)*x1+
+       ((-1.0*za+zb)*x2+(xa-1.0*xb)*z2-1.0*xa*zb+xb*za)*y1+((ya-1.0*yb)*x2+(xb-1.0*xa)
+       *y2+xa*yb-1.0*xb*ya)*z1+(-1.0*zb*ya+za*yb)*x2+(-1.0*xb*za+xa*zb)*y2
+       +(-1.0*xa*yb+xb*ya)*z2);
+    nenner  =
+       static_cast<double>((((zc-1.0*zb)*ya+(yb-1.0*yc)*za+zb*yc-1.0*zc*yb)*x1
+       +((zb-1.0*zc)*xa+(xc-1.0*xb)*za-1.0*xc*zb+xb*zc)*y1+((-1.0*yb+yc)*xa+(xb-1.0*xc)
+       *ya-1.0*xb*yc+xc*yb)*z1+((zb-1.0*zc)*ya+(-1.0*yb+yc)*za+zc*yb-1.0*zb*yc)*x2
+       +((zc-1.0*zb)*xa+(xb-1.0*xc)*za-1.0*xb*zc+xc*zb)*y2+((yb-1.0*yc)*xa+(xc-1.0*xb)
+       *ya+xb*yc-1.0*xc*yb)*z2));
+    if ( UbMath::greater(nenner, 0.0) ) eta = static_cast<double>((zaehler/nenner)*wurzel3*-1.);
+    else eta=-999.;
+
+    if (tt >= -1.0-UbMath::Epsilon<double>::val() && tt <= 1.0){
+       if(xi >= -1.0+eta/wurzel3-UbMath::Epsilon<double>::val() && xi <=
+          1.0-eta/wurzel3+UbMath::Epsilon<double>::val()){
+             if (eta >= 0-UbMath::Epsilon<double>::val() && eta <= wurzel3+UbMath::Epsilon<double>::val()){
+                /*xp = x1*(0.5-tt/2)+x2*(0.5+tt/2);
+                yp = y1*(0.5-tt/2)+y2*(0.5+tt/2);
+                zp = z1*(0.5-tt/2)+z2*(0.5+tt/2);*/
+                return
+                   static_cast<double>((sqrt(pow((x1*(0.5-tt/2)+x2*(0.5+tt/2))-x1,2)
+                   +pow((y1*(0.5-tt/2)+y2*(0.5+tt/2))-y1,2)+pow((z1*(0.5-tt/2)+z2*(0.5+tt/2))-z1,2))));
+             }
+          }
+    }
+    return (-999.);
+}
+/*
+* Returns true if the specified 2D point lies within (or on the border of) this 2D triangle.
+* @param point the 2D point to check
+* @return true if the specified 2D point lies within (or on the border of) this 2D triangle
+*/
+ bool GbTriangle3D::enclosesPoint2D(double x1, double x2)
+ {
+	 int i=0;
+	 //Punkt(x1,x2) liegt auf einem der Eckpunkte
+    if(x1==this->getPoint(0)->getX1Coordinate() && x2 == this->getPoint(0)->getX2Coordinate())	return true;
+	 if(x1==this->getPoint(1)->getX1Coordinate() && x2 == this->getPoint(1)->getX2Coordinate())	return true;
+	 if(x1==this->getPoint(2)->getX1Coordinate() && x2 == this->getPoint(2)->getX2Coordinate())  return true;
+
+	 //Erste Grade aus dem zu pruefenden Punkt(x,y) und einem zweiten Punkt(x+0.333,y+2.333)
+	 GbPoint3D p1;		p1.setX1(x1);			p1.setX2(x2);			p1.setX3(0.0);
+	 GbPoint3D p2;		p2.setX1(x1+0.333);	p2.setX2(x2+3.333);	p2.setX3(0.0);
+	 //Punkte des Dreiecks auf 2D reduziert
+	 GbPoint3D dp1;	dp1.setX1(this->getPoint(0)->getX1Coordinate());	dp1.setX2(this->getPoint(0)->getX2Coordinate());	dp1.setX3(0.0);
+	 GbPoint3D dp2;	dp2.setX1(this->getPoint(1)->getX1Coordinate());	dp2.setX2(this->getPoint(1)->getX2Coordinate());	dp2.setX3(0.0);
+	 GbPoint3D dp3;	dp3.setX1(this->getPoint(2)->getX1Coordinate());	dp3.setX2(this->getPoint(2)->getX2Coordinate());	dp3.setX3(0.0);
+	 //ueberpruefen, ob der Punkt(x,y) innerhalt der Boundingbox des Dreiecks liegt
+	 if(	 x1<this->getX1Maximum() && x1>getX1Minimum()
+		 && x2<this->getX2Maximum() && x2>getX2Minimum())
+	 {
+		 GbPoint3D* dummy = NULL;
+		 //ueberpruefen, ob der Punkt innerhalb des Dreiecks liegt
+		 dummy = GbSystem3D::calculateIntersectionPoint3D(p1,p2,dp1,dp2);
+		 if(dummy!=NULL)
+       {
+          if(dummy->getX1Coordinate()==p1.getX1Coordinate() && dummy->getX2Coordinate()==p1.getX2Coordinate())	
+          {
+             delete dummy;
+             return true;
+          }
+			 else if(dummy->getX1Coordinate()>p1.getX1Coordinate())
+          {
+             i++;
+          }
+			 else
+          {
+             i--;
+          }
+       }
+       if(dummy)  delete dummy;
+
+       dummy = GbSystem3D::calculateIntersectionPoint3D(p1,p2,dp2,dp3);
+		 if(dummy!=NULL)
+       {
+          if(dummy->getX1Coordinate()==p1.getX1Coordinate() && dummy->getX2Coordinate()==p1.getX2Coordinate())
+          {
+             if(dummy)  delete dummy;
+             return true;
+          }
+			 else if(dummy->getX1Coordinate()>p1.getX1Coordinate())
+          {
+             i++;
+          }
+			 else
+          {
+             i--;
+          }
+       }
+       if(dummy)  delete dummy;
+
+		 dummy = GbSystem3D::calculateIntersectionPoint3D(p1,p2,dp3,dp1);
+		 if(dummy!=NULL)
+       {
+          if(dummy->getX1Coordinate()==p1.getX1Coordinate() && dummy->getX2Coordinate()==p1.getX2Coordinate())
+          {
+             if(dummy)  delete dummy;
+             return true;
+          }
+			 else if(dummy->getX1Coordinate()>p1.getX1Coordinate())
+          {
+             i++;
+          }
+          else
+          {
+             i--;
+          }
+       }
+       if(dummy)  delete dummy;
+	 }
+	 if(i==-1) return true;
+	 if(i==1 ) return true;
+	
+    return false;
+ }
+
+///*
+//* Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!).
+//* @param rectangle the 2D rectangle
+//* @return a new 2D polygon clipped by the specified 2D rectangle
+//*/
+GbPolygon3D* GbTriangle3D::createClippedPolygon3D(GbCuboid3D* cube)
+{
+   return(GbSystem3D::clipPolygon3D(this->getPoints(), cube->getPoint1()->getX1Coordinate(), cube->getPoint1()->getX2Coordinate(), cube->getPoint1()->getX3Coordinate(), cube->getPoint2()->getX1Coordinate(), cube->getPoint2()->getX2Coordinate(), cube->getPoint2()->getX3Coordinate()));
+}
+///*
+//* Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!).
+//* @param p1 the 1st point of the rectangle
+//* @param p2 the 2nd point of the rectangle
+//* @return a new 2D polygon clipped by the specified 2D rectangle
+//*/
+//public GbPolygon2D createClippedPolygon2D(GbPoint2D p1, GbPoint2D p2)
+//{
+//   return(GbSystem.clipPolygon2D(this.points, p1.x1, p1.x2, p2.x1, p2.x2));
+//}
+/*
+* Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!).
+* @param p1x1 the 1st x1 coordinate of the rectangle
+* @param p1x2 the 1st x2 coordinate of the rectangle
+* @param p2x1 the 2nd x1 coordinate of the rectangle
+* @param p2x2 the 2nd x2 coordinate of the rectangle
+* @return a new 2D polygon clipped by the specified 2D rectangle
+*/
+GbPolygon3D* GbTriangle3D::createClippedPolygon3D(const double& p1x1, const double& p1x2, const double& p1x3, const double& p2x1, const double& p2x2, const double& p2x3)
+{
+   return(GbSystem3D::clipPolygon3D(this->getPoints(), p1x1, p1x2, p1x3, p2x1, p2x2, p2x3));
+}
+
+/*
+* Returns true if the specified 2D rectangle lies completely within this 2D triangle.
+* @param rectangle the 2D rectangle to check
+* @return true if the specified 2D rectangle lies completely within this 2D triangle
+*/
+//bool enclosesRectangle2D(GbRectangle2D *rectangle)
+//{
+//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
+//   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), rectangle.getArea()));
+//}
+/*
+* Returns true if the specified 2D rectangle lies completely within this 2D triangle.
+* @param p1 the 1st point of the rectangle to check
+* @param p2 the 2nd point of the rectangle to check                         triangle
+* @return true if the specified 2D rectangle lies completely within this 2D
+*/
+//public boolean enclosesRectangle2D(GbPoint2D p1, GbPoint2D p2)
+//{
+//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1.x1, p1.x2, p2.x1, p2.x2);
+//   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2))));
+//}
+/*
+* Returns true if the specified 2D rectangle lies completely within this 2D triangle.
+* @param p1x1 the 1st x1 coordinate of the rectangle to check
+* @param p1x2 the 1st x2 coordinate of the rectangle to check
+* @param p2x1 the 2nd x1 coordinate of the rectangle to check
+* @param p2x2 the 2nd x2 coordinate of the rectangle to check
+* @return true if the specified 2D rectangle lies completely within this 2D triangle
+*/
+//public boolean enclosesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2)
+//{
+//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1x1, p1x2, p2x1, p2x2);
+//   return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1x1-p2x1)*(p1x2-p2x2))));
+//}
+
+/*
+* Returns true if the specified 2D rectangle is crossed by this 2D triangle.
+* @param rectangle the 2D rectangle to check
+* @return true if the specified 2D rectangle is crossed by this 2D triangle
+*/
+//public boolean crossesRectangle2D(GbRectangle2D rectangle)
+//{
+//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
+//   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, rectangle.getArea()));
+//}
+/*
+* Returns true if the specified 2D rectangle is crossed by this 2D triangle.
+* @param p1 the 1st point of the rectangle to check
+* @param p2 the 2nd point of the rectangle to check
+* @return true if the specified 2D rectangle is crossed by this 2D triangle
+*/
+//public boolean crossesRectangle2D(GbPoint2D p1, GbPoint2D p2)
+//{
+//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1.x1, p1.x2, p2.x1, p2.x2);
+//   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2))));
+//}
+/*
+* Returns true if the specified 2D rectangle is crossed by this 2D triangle.
+* @param p1x1 the 1st x1 coordinate of the rectangle to check
+* @param p1x2 the 1st x2 coordinate of the rectangle to check
+* @param p2x1 the 2nd x1 coordinate of the rectangle to check
+* @param p2x2 the 2nd x2 coordinate of the rectangle to check
+* @return true if the specified 2D rectangle is crossed by this 2D triangle
+*/
+//public boolean crossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2)
+//{
+//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1x1, p1x2, p2x1, p2x2);
+//   return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1x1-p2x1)*(p1x2-p2x2))));
+//}
+
+/*
+* Returns true if the specified 2D rectangle lies (at least partly) within this 2D triangle.
+* @param rectangle the 2D rectangle to check
+* @return true if the specified 2D rectangle lies (at least partly) within this 2D triangle
+*/
+//public boolean enclosesOrCrossesRectangle2D(GbRectangle2D rectangle)
+//{
+//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2);
+//   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
+//}
+/*
+* Returns true if the specified 2D rectangle lies (at least partly) within this 2D triangle.
+* @param p1 the 1st point of the rectangle to check
+* @param p2 the 2nd point of the rectangle to check
+* @return true if the specified 2D rectangle lies (at least partly) within this 2D triangle
+*/
+//public boolean enclosesOrCrossesRectangle2D(GbPoint2D p1, GbPoint2D p2)
+//{
+//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1.x1, p1.x2, p2.x1, p2.x2);
+//   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
+//}
+/*
+* Returns true if the specified 2D rectangle lies (at least partly) within this 2D triangle.
+* @param p1x1 the 1st x1 coordinate of the rectangle to check
+* @param p1x2 the 1st x2 coordinate of the rectangle to check
+* @param p2x1 the 2nd x1 coordinate of the rectangle to check
+* @param p2x2 the 2nd x2 coordinate of the rectangle to check
+* @return true if the specified 2D rectangle lies (at least partly) within this 2D triangle
+*/
+//public boolean enclosesOrCrossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2)
+//{
+//   GbPolygon2D p = GbSystem.clipPolygon2D(this.points, p1x1, p1x2, p2x1, p2x2);
+//   return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0));
+//}
+/*======================================================================*/
+
+
+/*======================================================================*/
+/*  Private Methoden                                                    */
+/*                                                                      */
+void GbTriangle3D::calculateValues()
+{
+   this->x1min = this->points[0]->x1;
+   this->x1max = this->points[0]->x1;
+   this->x2min = this->points[0]->x2;
+   this->x2max = this->points[0]->x2;
+   this->x3min = this->points[0]->x3;
+   this->x3max = this->points[0]->x3;
+
+   if(this->points[1]->x1 < this->x1min) this->x1min = this->points[1]->x1;
+   if(this->points[1]->x1 > this->x1max) this->x1max = this->points[1]->x1;
+   if(this->points[1]->x2 < this->x2min) this->x2min = this->points[1]->x2;
+   if(this->points[1]->x2 > this->x2max) this->x2max = this->points[1]->x2;
+   if(this->points[1]->x3 < this->x3min) this->x3min = this->points[1]->x3;
+   if(this->points[1]->x3 > this->x3max) this->x3max = this->points[1]->x3;
+
+   if(this->points[2]->x1 < this->x1min) this->x1min = this->points[2]->x1;
+   if(this->points[2]->x1 > this->x1max) this->x1max = this->points[2]->x1;
+   if(this->points[2]->x2 < this->x2min) this->x2min = this->points[2]->x2;
+   if(this->points[2]->x2 > this->x2max) this->x2max = this->points[2]->x2;
+   if(this->points[2]->x3 < this->x3min) this->x3min = this->points[2]->x3;
+   if(this->points[2]->x3 > this->x3max) this->x3max = this->points[2]->x3;
+
+   this->x1s   = (this->points[0]->x1+this->points[1]->x1+this->points[2]->x1)/3.0;
+   this->x2s   = (this->points[0]->x2+this->points[1]->x2+this->points[2]->x2)/3.0;
+   this->x3s   = (this->points[0]->x3+this->points[1]->x3+this->points[2]->x3)/3.0;
+
+   GbVector3D A(points[0]->x1,points[0]->x2,points[0]->x3);
+   GbVector3D B(points[1]->x1,points[1]->x2,points[1]->x3);
+   GbVector3D C(points[2]->x1,points[2]->x2,points[2]->x3);
+   GbVector3D AB = B-A;
+   GbVector3D AC = C-A;
+   GbVector3D N = AB.Cross(AC);
+   this->area = 0.5*N.Length();
+   this->consistent = true;
+}
+/*======================================================================*/
+
+
+/*======================================================================*/
+//class PointObserver : public UbObserver
+//{
+//    GbTriangle3D *triangle;
+
+//    PointObserver(GbTriangle3D *triangle)
+//    {
+//      this->triangle = triangle;
+//    }
+
+//public:
+//   void objectChanged(GbObject3D *object)
+//    {
+//      if(object == this->triangle->points[0] || object == this->triangle->points[1]  || object == this->triangle->points[2])
+//      {
+//         this->triangle->consistent = false;
+//         this->triangle->notifyObservers();
+//      }
+//    }
+//};
+//bool GbTriangle3D::isPointOnEdge(GbVector3D& q)
+//{
+////cout<<"muss einer machen ...\n";
+//   return false;
+//}
+/*======================================================================*/
+GbVector3D GbTriangle3D::getNormal()
+{
+   this->calculateNormal();
+   return normal; 
+}
+/*======================================================================*/
+void GbTriangle3D::init()
+{
+   x1s        = 0.0;
+   x2s        = 0.0;
+   x3s        = 0.0;
+   x1min      = 0.0;
+   x1max      = 0.0;
+   x2min      = 0.0;
+   x2max      = 0.0;
+   area       = 0.0;
+   consistent = false;
+   points.resize(3,NULL);
+}
+/*=======================================================*/
+void GbTriangle3D::write(UbFileOutput* out) 
+{                                      
+   out->writeString(this->getCreator()->getTypeID());
+   if(points[0]) points[0]->write(out);
+   else {GbPoint3D tmp; tmp.write(out);}
+   if(points[1]) points[1]->write(out);
+   else {GbPoint3D tmp; tmp.write(out);}
+   if(points[2]) points[2]->write(out);
+   else {GbPoint3D tmp; tmp.write(out);}
+}
+/*=======================================================*/
+void GbTriangle3D::read(UbFileInput* in) 
+{  
+   this->deletePoints();
+   points[0] = new GbPoint3D;
+   points[1] = new GbPoint3D;
+   points[2] = new GbPoint3D;
+   in->readString();                                    
+   points[0]->read(in);
+   in->readString();                                    
+   points[1]->read(in);
+   in->readString();                                    
+   points[2]->read(in);
+   consistent = false;
+}
+/*=======================================================*/
+void GbTriangle3D::calculateNormal()
+{
+   GbPoint3D*& a = points[0]; 
+   GbPoint3D*& b = points[1];
+   GbPoint3D*& c = points[2];
+   normal[0] = ( c->getX3Coordinate() - a->getX3Coordinate()) * ( b->getX2Coordinate() - a->getX2Coordinate() ) -
+               ( b->getX3Coordinate() - a->getX3Coordinate()) * ( c->getX2Coordinate() - a->getX2Coordinate() );
+   normal[1] = ( b->getX3Coordinate() - a->getX3Coordinate()) * ( c->getX1Coordinate() - a->getX1Coordinate() ) -
+               ( b->getX1Coordinate() - a->getX1Coordinate()) * ( c->getX3Coordinate() - a->getX3Coordinate() );
+   normal[2] = ( b->getX1Coordinate() - a->getX1Coordinate()) * ( c->getX2Coordinate() - a->getX2Coordinate() ) -
+               ( b->getX2Coordinate() - a->getX2Coordinate()) * ( c->getX1Coordinate() - a->getX1Coordinate() );
+   normal.Normalize();
+}
+/*=======================================================*/
+//toDo: 
+double GbTriangle3D::getDistanceFromPoint(GbVector3D punct)
+{
+	GbVector3D Point1(this->getPoint1()->getX1Coordinate(), this->getPoint1()->getX2Coordinate(), this->getPoint1()->getX3Coordinate());
+	GbVector3D Point2(this->getPoint2()->getX1Coordinate(), this->getPoint2()->getX2Coordinate(), this->getPoint2()->getX3Coordinate());
+	GbVector3D Point3(this->getPoint3()->getX1Coordinate(), this->getPoint3()->getX2Coordinate(), this->getPoint3()->getX3Coordinate());
+
+	GbVector3D kDiff = Point1 - punct;
+	GbVector3D kEdge0 = Point2 - Point1;
+	GbVector3D kEdge1 = Point3 - Point1;
+	double fA00 = kEdge0.SquaredLength();
+	double fA01 = kEdge0.Dot(kEdge1);
+	double fA11 = kEdge1.SquaredLength();
+	double fB0 = kDiff.Dot(kEdge0);
+	double fB1 = kDiff.Dot(kEdge1);
+	double fC = kDiff.SquaredLength();
+	double fDet = fabs(fA00*fA11-fA01*fA01);
+	double fS = fA01*fB1-fA11*fB0;
+	double fT = fA01*fB0-fA00*fB1;
+	double fSqrDistance;
+
+	if (fS + fT <= fDet)
+	{
+		if (fS < (double)0.0)
+		{
+			if (fT < (double)0.0)  // region 4
+			{
+				if (fB0 < (double)0.0)
+				{
+					fT = (double)0.0;
+					if (-fB0 >= fA00)
+					{
+						fS = (double)1.0;
+						fSqrDistance = fA00+((double)2.0)*fB0+fC;
+					}
+					else
+					{
+						fS = -fB0/fA00;
+						fSqrDistance = fB0*fS+fC;
+					}
+				}
+				else
+				{
+					fS = (double)0.0;
+					if (fB1 >= (double)0.0)
+					{
+						fT = (double)0.0;
+						fSqrDistance = fC;
+					}
+					else if (-fB1 >= fA11)
+					{
+						fT = (double)1.0;
+						fSqrDistance = fA11+((double)2.0)*fB1+fC;
+					}
+					else
+					{
+						fT = -fB1/fA11;
+						fSqrDistance = fB1*fT+fC;
+					}
+				}
+			}
+			else  // region 3
+			{
+				fS = (double)0.0;
+				if (fB1 >= (double)0.0)
+				{
+					fT = (double)0.0;
+					fSqrDistance = fC;
+				}
+				else if (-fB1 >= fA11)
+				{
+					fT = (double)1.0;
+					fSqrDistance = fA11+((double)2.0)*fB1+fC;
+				}
+				else
+				{
+					fT = -fB1/fA11;
+					fSqrDistance = fB1*fT+fC;
+				}
+			}
+		}
+		else if (fT < (double)0.0)  // region 5
+		{
+			fT = (double)0.0;
+			if (fB0 >= (double)0.0)
+			{
+				fS = (double)0.0;
+				fSqrDistance = fC;
+			}
+			else if (-fB0 >= fA00)
+			{
+				fS = (double)1.0;
+				fSqrDistance = fA00+((double)2.0)*fB0+fC;
+			}
+			else
+			{
+				fS = -fB0/fA00;
+				fSqrDistance = fB0*fS+fC;
+			}
+		}
+		else  // region 0
+		{
+			// minimum at interior point
+			double fInvDet = ((double)1.0)/fDet;
+			fS *= fInvDet;
+			fT *= fInvDet;
+			fSqrDistance = fS*(fA00*fS+fA01*fT+((double)2.0)*fB0) +
+				fT*(fA01*fS+fA11*fT+((double)2.0)*fB1)+fC;
+		}
+	}
+	else
+	{
+		double fTmp0, fTmp1, fNumer, fDenom;
+
+		if (fS < (double)0.0)  // region 2
+		{
+			fTmp0 = fA01 + fB0;
+			fTmp1 = fA11 + fB1;
+			if (fTmp1 > fTmp0)
+			{
+				fNumer = fTmp1 - fTmp0;
+				fDenom = fA00-2.0f*fA01+fA11;
+				if (fNumer >= fDenom)
+				{
+					fS = (double)1.0;
+					fT = (double)0.0;
+					fSqrDistance = fA00+((double)2.0)*fB0+fC;
+				}
+				else
+				{
+					fS = fNumer/fDenom;
+					fT = (double)1.0 - fS;
+					fSqrDistance = fS*(fA00*fS+fA01*fT+2.0f*fB0) +
+						fT*(fA01*fS+fA11*fT+((double)2.0)*fB1)+fC;
+				}
+			}
+			else
+			{
+				fS = (double)0.0;
+				if (fTmp1 <= (double)0.0)
+				{
+					fT = (double)1.0;
+					fSqrDistance = fA11+((double)2.0)*fB1+fC;
+				}
+				else if (fB1 >= (double)0.0)
+				{
+					fT = (double)0.0;
+					fSqrDistance = fC;
+				}
+				else
+				{
+					fT = -fB1/fA11;
+					fSqrDistance = fB1*fT+fC;
+				}
+			}
+		}
+		else if (fT < (double)0.0)  // region 6
+		{
+			fTmp0 = fA01 + fB1;
+			fTmp1 = fA00 + fB0;
+			if (fTmp1 > fTmp0)
+			{
+				fNumer = fTmp1 - fTmp0;
+				fDenom = fA00-((double)2.0)*fA01+fA11;
+				if (fNumer >= fDenom)
+				{
+					fT = (double)1.0;
+					fS = (double)0.0;
+					fSqrDistance = fA11+((double)2.0)*fB1+fC;
+				}
+				else
+				{
+					fT = fNumer/fDenom;
+					fS = (double)1.0 - fT;
+					fSqrDistance = fS*(fA00*fS+fA01*fT+((double)2.0)*fB0) +
+						fT*(fA01*fS+fA11*fT+((double)2.0)*fB1)+fC;
+				}
+			}
+			else
+			{
+				fT = (double)0.0;
+				if (fTmp1 <= (double)0.0)
+				{
+					fS = (double)1.0;
+					fSqrDistance = fA00+((double)2.0)*fB0+fC;
+				}
+				else if (fB0 >= (double)0.0)
+				{
+					fS = (double)0.0;
+					fSqrDistance = fC;
+				}
+				else
+				{
+					fS = -fB0/fA00;
+					fSqrDistance = fB0*fS+fC;
+				}
+			}
+		}
+		else  // region 1
+		{
+			fNumer = fA11 + fB1 - fA01 - fB0;
+			if (fNumer <= (double)0.0)
+			{
+				fS = (double)0.0;
+				fT = (double)1.0;
+				fSqrDistance = fA11+((double)2.0)*fB1+fC;
+			}
+			else
+			{
+				fDenom = fA00-2.0f*fA01+fA11;
+				if (fNumer >= fDenom)
+				{
+					fS = (double)1.0;
+					fT = (double)0.0;
+					fSqrDistance = fA00+((double)2.0)*fB0+fC;
+				}
+				else
+				{
+					fS = fNumer/fDenom;
+					fT = (double)1.0 - fS;
+					fSqrDistance = fS*(fA00*fS+fA01*fT+((double)2.0)*fB0) +
+						fT*(fA01*fS+fA11*fT+((double)2.0)*fB1)+fC;
+				}
+			}
+		}
+	}
+
+	// account for numerical round-off error
+	if (fSqrDistance < (double)0.0)
+	{
+		fSqrDistance = (double)0.0;
+	}
+/*
+	m_kClosestPoint0 = punct;
+	m_kClosestPoint1 = m_rkTriangle.V[0] + fS*kEdge0 + fT*kEdge1;
+	m_afTriangleBary[1] = fS;
+	m_afTriangleBary[2] = fT;
+	m_afTriangleBary[0] = (double)1.0 - fS - fT;
+*/
+	return sqrt(fSqrDistance);
+}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbTriangle3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbTriangle3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbTriangle3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbTriangle3D.h
index b4ea886868085617bcc1d3c4736b1889909922db..276652b40fadebc1fd8d4347a70eeba559082066 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbTriangle3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbTriangle3D.h
@@ -1,245 +1,245 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBTRIANGLE3D_H
-#define GBTRIANGLE3D_H
-
-#include <sstream>
-
-#include <numerics/geometry3d/GbObject3D.h>
-#include <numerics/geometry3d/GbVector3D.h>
-#include <numerics/geometry3d/GbPoint3D.h>
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-#include <PointerDefinitions.h>
-
-class GbCuboid3D;
-class GbPolygon3D;
-class GbObject3DCreator;
-
-/*=========================================================================*/
-/* GbTriangle3D                                                            */
-/*                                                                         */
-/*                                                               
-* This Class provides basic 3D triangle objects.
-*/
-//class GbLine2D;
-
-class GbTriangle3D : public GbObject3D , public UbObserver
-{
-public:
-   /*======================================================================*/
-   /*  Konstruktoren                                                       */
-   /*                                                                      */
-   GbTriangle3D();
-   GbTriangle3D(GbPoint3D* point1, GbPoint3D* point2, GbPoint3D* point3);
-   GbTriangle3D(GbTriangle3D* triangle);
-   ~GbTriangle3D();
-   /*======================================================================*/
-   /*  Methoden                                                            */
-   /*                                                                      */
-   GbTriangle3D* clone();
-   void finalize()
-   {
-      this->deletePoints();
-   }
-
-   GbPoint3D* getPoint1()   { return this->points[0]; }
-   GbPoint3D* getPoint2()   { return this->points[1]; }
-   GbPoint3D* getPoint3()   { return this->points[2]; }
-
-   GbVector3D getNormal();
-   void       calculateNormal();
-
-   void deletePoints();
-
-   int contains(GbPoint3D* point);
-   int containsEqual(GbPoint3D* point);
-   GbPoint3D* getPoint(const int& index);
-   std::vector<GbPoint3D> getPoints();
-   double getArea();
-   double getX1Centroid();
-   double getX1Minimum();
-   double getX1Maximum();           
-   double getX2Centroid();
-   double getX2Minimum();
-   double getX2Maximum();
-   double getX3Centroid();
-   double getX3Minimum();
-   double getX3Maximum();
-
-   void setInconsistent() { this->consistent = false;}
-
-   void setPoint(GbPoint3D *point, int index);
-
-   //bool equals(GbObject3D *object)
-   std::vector<GbTriangle3D*> getSurfaceTriangleSet();
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3)   
-   {
-      //der einfachheit halber ... 
-      return false;
-      //throw UbException(__FILE__, __LINE__, "GbTriangle3D::isPointInObject3D- not implemented");
-   }
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)   
-   {
-      //der einfachheit halber ... 
-      pointIsOnBoundary = false;
-      return false;
-      //throw UbException(__FILE__, __LINE__, "GbTriangle3D::isPointInObject3D- not implemented");
-   }
-   bool isCellInsideGbObject3D(const double& x11,const double& x21,const double& x31,const double& x12,const double& x22,const double& x23) { return false; }
-
-
-   // get distance from a point to the triangle
-   //todo CHANGE...
-   double getDistanceFromPoint(GbVector3D punct);
-
-   std::string toString();
-   ObObjectCreator* getCreator();
-   void write(UbFileOutput* out);
-   void read(UbFileInput* in);
-
-   /*======================================================================*/
-   /*  Calculation                                                         */
-   /*                                                                      */
-//   std::vector<GbPoint3D> calculateIntersectionPoints3D(GbLine3D *line);
-   bool hasRaytracing() { return true; }
-   /*|r| must be 1! einheitsvector!!*/
-   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
-//   bool isPointOnEdge(GbVector3D& q);
-   
-   GbPoint3D* calculateIntersectionPoints3D(GbLine3D* line);
-   GbPoint3D* calculateIntersectionPoints3D(GbPoint3D* linePoint1, GbPoint3D* linePoint2);
-   double calculateDistanceToPoint3D(GbPoint3D *point);
-   double calculateDistanceToPoint3D(const double& x1, const double& x2, const double& x3);      
-   double calculateNormalizedDistanceToPoint3D(const double& x1, const double& y1, const double& z1, const double& x2, const double& y2, const double& z2);
-
-   bool enclosesPoint2D(double x1, double x2);
-   GbPolygon3D* createClippedPolygon3D(GbCuboid3D* cube);   
-   GbLine3D* createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2);
-   //public GbPolygon2D createClippedPolygon2D(GbPoint2D p1, GbPoint2D p2);
-   GbPolygon3D* createClippedPolygon3D(const double& p1x1, const double& p1x2, const double& p1x3, const double& p2x1, const double& p2x2, const double& p2x3);
-   //bool enclosesRectangle2D(GbRectangle2D *rectangle);
-   //public boolean enclosesRectangle2D(GbPoint2D p1, GbPoint2D p2);
-   //public boolean enclosesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2);
-   //public boolean crossesRectangle2D(GbRectangle2D rectangle);
-   //public boolean crossesRectangle2D(GbPoint2D p1, GbPoint2D p2);
-   //public boolean crossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2);
-   //public boolean enclosesOrCrossesRectangle2D(GbRectangle2D rectangle);
-   //public boolean enclosesOrCrossesRectangle2D(GbPoint2D p1, GbPoint2D p2);
-   //public boolean enclosesOrCrossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2);
-   /*======================================================================*/
-   /*======================================================================*/
-   /*  Private Methoden                                                    */
-   /*                                                                      */
-   virtual void calculateValues();
-
-   /*======================================================================*/
-   //class PointObserver : public UbObserver
-   //{
-   //    GbTriangle3D *triangle;
-
-   //    PointObserver(GbTriangle3D *triangle)
-   //    {
-   //      this->triangle = triangle;
-   //    }
-
-   //public:
-   //   void objectChanged(GbObject3D *object)
-   //    {
-   //      if(object == this->triangle->points[0] || object == this->triangle->points[1]  || object == this->triangle->points[2])
-   //      {
-   //         this->triangle->consistent = false;
-   //         this->triangle->notifyObservers();
-   //      }
-   //    }
-   //};
-   /*======================================================================*/
-
-   //virtuelle Methoden von UbObserver
-   //!! quick and dirty von sirann !!
-   void objectChanged(UbObservable* changedObject)
-   {
-      GbPoint3D* point = dynamic_cast<GbPoint3D*>(changedObject);
-      if(!point || (  this->points[0]!=point && this->points[1]!=point && this->points[2]!=point) ) 
-         return;
-      
-      this->consistent = false;
-   }
-   void objectWillBeDeleted(UbObservable* objectForDeletion)
-   {
-      if(this->points[0])
-      {
-         UbObservable* observedObj = dynamic_cast<UbObservable*>(this->points[0]);
-         if(objectForDeletion == observedObj) { this->points[0] = NULL; }
-      }
-      if(this->points[1])
-      {
-         UbObservable* observedObj = dynamic_cast<UbObservable*>(this->points[1]);
-         if(objectForDeletion == observedObj) { this->points[1] = NULL; }
-      }
-      if(this->points[2])
-      {
-         UbObservable* observedObj = dynamic_cast<UbObservable*>(this->points[2]);
-         if(objectForDeletion == observedObj) { this->points[2] = NULL; }
-      }
-      //ACHTUNG: eigentlich muessten in allen methoden von GbLine if abfragen fuer NULL pointer hin... toDo
-   }
-   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void SF_SERIALIZE(Archive & ar)
-   {
-      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
-      ar & points;
-      ar & normal;
-      ar & x1s;
-      ar & x2s;
-      ar & x3s;
-      ar & x1min;
-      ar & x1max;
-      ar & x2min;
-      ar & x2max;
-      ar & x3min;
-      ar & x3max;
-      ar & area;
-      ar & consistent;
-      if( ArchiveTools::isReading(ar) ) this->calculateNormal();
-   }
-#endif //CAB_RCF
-
-protected:
-   bool   consistent;
-   double x1s;
-   double x2s;
-   double x3s;
-   double x1min;
-   double x1max;
-   double x2min;
-   double x2max;
-   double x3min;
-   double x3max;
-   double area;
-   
-   GbVector3D normal;
-   std::vector<GbPoint3D*> points;
-   
-private:
-   void init();
-};
-/*=========================================================================*/
-
-#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
-   UB_AUTO_RUN_NAMED(   SF::registerType<GbTriangle3D  >("GbTriangle3D  ")        , SF_GbTriangle3D     );
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbTriangle3D >() ), SF_GbTriangle3D_BD1 );
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbTriangle3D>()  ), SF_GbTriangle3D_BD2 );
-#endif //RCF_USE_SF_SERIALIZATION
-
-#endif
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBTRIANGLE3D_H
+#define GBTRIANGLE3D_H
+
+#include <sstream>
+
+#include <numerics/geometry3d/GbObject3D.h>
+#include <numerics/geometry3d/GbVector3D.h>
+#include <numerics/geometry3d/GbPoint3D.h>
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+#include <PointerDefinitions.h>
+
+class GbCuboid3D;
+class GbPolygon3D;
+class GbObject3DCreator;
+
+/*=========================================================================*/
+/* GbTriangle3D                                                            */
+/*                                                                         */
+/*                                                               
+* This Class provides basic 3D triangle objects.
+*/
+//class GbLine2D;
+
+class GbTriangle3D : public GbObject3D , public UbObserver
+{
+public:
+   /*======================================================================*/
+   /*  Konstruktoren                                                       */
+   /*                                                                      */
+   GbTriangle3D();
+   GbTriangle3D(GbPoint3D* point1, GbPoint3D* point2, GbPoint3D* point3);
+   GbTriangle3D(GbTriangle3D* triangle);
+   ~GbTriangle3D();
+   /*======================================================================*/
+   /*  Methoden                                                            */
+   /*                                                                      */
+   GbTriangle3D* clone();
+   void finalize()
+   {
+      this->deletePoints();
+   }
+
+   GbPoint3D* getPoint1()   { return this->points[0]; }
+   GbPoint3D* getPoint2()   { return this->points[1]; }
+   GbPoint3D* getPoint3()   { return this->points[2]; }
+
+   GbVector3D getNormal();
+   void       calculateNormal();
+
+   void deletePoints();
+
+   int contains(GbPoint3D* point);
+   int containsEqual(GbPoint3D* point);
+   GbPoint3D* getPoint(const int& index);
+   std::vector<GbPoint3D> getPoints();
+   double getArea();
+   double getX1Centroid();
+   double getX1Minimum();
+   double getX1Maximum();           
+   double getX2Centroid();
+   double getX2Minimum();
+   double getX2Maximum();
+   double getX3Centroid();
+   double getX3Minimum();
+   double getX3Maximum();
+
+   void setInconsistent() { this->consistent = false;}
+
+   void setPoint(GbPoint3D *point, int index);
+
+   //bool equals(GbObject3D *object)
+   std::vector<GbTriangle3D*> getSurfaceTriangleSet();
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3)   
+   {
+      //der einfachheit halber ... 
+      return false;
+      //throw UbException(__FILE__, __LINE__, "GbTriangle3D::isPointInObject3D- not implemented");
+   }
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)   
+   {
+      //der einfachheit halber ... 
+      pointIsOnBoundary = false;
+      return false;
+      //throw UbException(__FILE__, __LINE__, "GbTriangle3D::isPointInObject3D- not implemented");
+   }
+   bool isCellInsideGbObject3D(const double& x11,const double& x21,const double& x31,const double& x12,const double& x22,const double& x23) { return false; }
+
+
+   // get distance from a point to the triangle
+   //todo CHANGE...
+   double getDistanceFromPoint(GbVector3D punct);
+
+   std::string toString();
+   ObObjectCreator* getCreator();
+   void write(UbFileOutput* out);
+   void read(UbFileInput* in);
+
+   /*======================================================================*/
+   /*  Calculation                                                         */
+   /*                                                                      */
+//   std::vector<GbPoint3D> calculateIntersectionPoints3D(GbLine3D *line);
+   bool hasRaytracing() { return true; }
+   /*|r| must be 1! einheitsvector!!*/
+   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
+//   bool isPointOnEdge(GbVector3D& q);
+   
+   GbPoint3D* calculateIntersectionPoints3D(GbLine3D* line);
+   GbPoint3D* calculateIntersectionPoints3D(GbPoint3D* linePoint1, GbPoint3D* linePoint2);
+   double calculateDistanceToPoint3D(GbPoint3D *point);
+   double calculateDistanceToPoint3D(const double& x1, const double& x2, const double& x3);      
+   double calculateNormalizedDistanceToPoint3D(const double& x1, const double& y1, const double& z1, const double& x2, const double& y2, const double& z2);
+
+   bool enclosesPoint2D(double x1, double x2);
+   GbPolygon3D* createClippedPolygon3D(GbCuboid3D* cube);   
+   GbLine3D* createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2);
+   //public GbPolygon2D createClippedPolygon2D(GbPoint2D p1, GbPoint2D p2);
+   GbPolygon3D* createClippedPolygon3D(const double& p1x1, const double& p1x2, const double& p1x3, const double& p2x1, const double& p2x2, const double& p2x3);
+   //bool enclosesRectangle2D(GbRectangle2D *rectangle);
+   //public boolean enclosesRectangle2D(GbPoint2D p1, GbPoint2D p2);
+   //public boolean enclosesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2);
+   //public boolean crossesRectangle2D(GbRectangle2D rectangle);
+   //public boolean crossesRectangle2D(GbPoint2D p1, GbPoint2D p2);
+   //public boolean crossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2);
+   //public boolean enclosesOrCrossesRectangle2D(GbRectangle2D rectangle);
+   //public boolean enclosesOrCrossesRectangle2D(GbPoint2D p1, GbPoint2D p2);
+   //public boolean enclosesOrCrossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2);
+   /*======================================================================*/
+   /*======================================================================*/
+   /*  Private Methoden                                                    */
+   /*                                                                      */
+   virtual void calculateValues();
+
+   /*======================================================================*/
+   //class PointObserver : public UbObserver
+   //{
+   //    GbTriangle3D *triangle;
+
+   //    PointObserver(GbTriangle3D *triangle)
+   //    {
+   //      this->triangle = triangle;
+   //    }
+
+   //public:
+   //   void objectChanged(GbObject3D *object)
+   //    {
+   //      if(object == this->triangle->points[0] || object == this->triangle->points[1]  || object == this->triangle->points[2])
+   //      {
+   //         this->triangle->consistent = false;
+   //         this->triangle->notifyObservers();
+   //      }
+   //    }
+   //};
+   /*======================================================================*/
+
+   //virtuelle Methoden von UbObserver
+   //!! quick and dirty von sirann !!
+   void objectChanged(UbObservable* changedObject)
+   {
+      GbPoint3D* point = dynamic_cast<GbPoint3D*>(changedObject);
+      if(!point || (  this->points[0]!=point && this->points[1]!=point && this->points[2]!=point) ) 
+         return;
+      
+      this->consistent = false;
+   }
+   void objectWillBeDeleted(UbObservable* objectForDeletion)
+   {
+      if(this->points[0])
+      {
+         UbObservable* observedObj = dynamic_cast<UbObservable*>(this->points[0]);
+         if(objectForDeletion == observedObj) { this->points[0] = NULL; }
+      }
+      if(this->points[1])
+      {
+         UbObservable* observedObj = dynamic_cast<UbObservable*>(this->points[1]);
+         if(objectForDeletion == observedObj) { this->points[1] = NULL; }
+      }
+      if(this->points[2])
+      {
+         UbObservable* observedObj = dynamic_cast<UbObservable*>(this->points[2]);
+         if(objectForDeletion == observedObj) { this->points[2] = NULL; }
+      }
+      //ACHTUNG: eigentlich muessten in allen methoden von GbLine if abfragen fuer NULL pointer hin... toDo
+   }
+   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void SF_SERIALIZE(Archive & ar)
+   {
+      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
+      ar & points;
+      ar & normal;
+      ar & x1s;
+      ar & x2s;
+      ar & x3s;
+      ar & x1min;
+      ar & x1max;
+      ar & x2min;
+      ar & x2max;
+      ar & x3min;
+      ar & x3max;
+      ar & area;
+      ar & consistent;
+      if( ArchiveTools::isReading(ar) ) this->calculateNormal();
+   }
+#endif //CAB_RCF
+
+protected:
+   bool   consistent;
+   double x1s;
+   double x2s;
+   double x3s;
+   double x1min;
+   double x1max;
+   double x2min;
+   double x2max;
+   double x3min;
+   double x3max;
+   double area;
+   
+   GbVector3D normal;
+   std::vector<GbPoint3D*> points;
+   
+private:
+   void init();
+};
+/*=========================================================================*/
+
+#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
+   UB_AUTO_RUN_NAMED(   SF::registerType<GbTriangle3D  >("GbTriangle3D  ")        , SF_GbTriangle3D     );
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbTriangle3D >() ), SF_GbTriangle3D_BD1 );
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbTriangle3D>()  ), SF_GbTriangle3D_BD2 );
+#endif //RCF_USE_SF_SERIALIZATION
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbTriangularMesh3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbTriangularMesh3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbTriangularMesh3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbTriangularMesh3D.cpp
index b98dca0da97656d937c8ad6562b936b6e81c42a5..9006ca690836b45e69ca88cb0072d792c47b0f5f 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbTriangularMesh3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbTriangularMesh3D.cpp
@@ -1,1535 +1,1535 @@
-#include <numerics/geometry3d/GbTriangularMesh3D.h>
-#include <numerics/geometry3d/creator/GbTriangularMesh3DCreator.h>
-
-#include <map>
-
-#include <basics/utilities/UbMath.h>
-
-#include <numerics/geometry3d/GbHalfSpace3D.h>
-#include <numerics/geometry3d/GbCuboid3D.h>
-#include <numerics/geometry3d/CoordinateTransformation3D.h>
-                         
-using namespace std;
-
-GbTriangularMesh3D::GbTriangularMesh3D() : GbObject3D()
-{
-   this->setName("new GbMesh");
-   this->nodes     = new vector<GbPoint3D*>;           
-   this->triangles = new vector<GbTriangle3D*>;
-   this->edges     = new vector<GbLine3D*>;
-   
-   this->pointinobjecttest = RAYCROSSING;
-
-   this->consistent = false;                                 
-   x1min = x1max = x2min = x2max = x3min = x3max = 0.0;
-}
-/*=============================================================================================*/
-GbTriangularMesh3D::GbTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbTriangle3D*> *triangles) : GbObject3D()
-{
-   if(name.size()==0 ) throw UbException(UB_EXARGS,"no name specified");
-   if(!nodes         ) throw UbException(UB_EXARGS,"no nodes specified");
-   if(!triangles     ) throw UbException(UB_EXARGS,"no triangles specified");
-                                                         
-   this->setName(name);
-   this->nodes      = nodes;           
-   this->triangles  = triangles;     
-   this->edges      = new vector<GbLine3D*>;
-   this->pointinobjecttest = RAYCROSSING;
-
-   this->consistent = false;                                 
-   x1min = x1max = x2min = x2max = x3min = x3max = 0.0;
-}
-/*=============================================================================================*/
-GbTriangularMesh3D::GbTriangularMesh3D(string name, vector<GbTriangle3D*> *tris) : GbObject3D()
-{
-   cout<<"Das Teil erzeugt seinen KnotenVector aus den Dreiecken ...\n Es sollte deleteRedundantNodes() aufgerufen werden \n";
-   if(name.size()==0 ) throw UbException(UB_EXARGS,"no name specified");
-   if(!tris          ) throw UbException(UB_EXARGS,"no triangles specified");
-
-   vector<GbPoint3D*> *points = new vector<GbPoint3D*>;
-   this->triangles = new vector<GbTriangle3D*>;
-   GbPoint3D* p1 = NULL;
-   GbPoint3D* p2 = NULL;
-   GbPoint3D* p3 = NULL;
-   for(int u=0;u<(int)tris->size();u++)
-   {
-      if(UbMath::zero((*tris)[u]->getArea()))
-      {
-         (*tris)[u]->finalize();
-         delete (*tris)[u];
-         (*tris)[u] = NULL;
-         continue;
-      }
-      this->triangles->push_back((*tris)[u]);
-      p1 = (*tris)[u]->getPoint1();
-      p2 = (*tris)[u]->getPoint2();
-      p3 = (*tris)[u]->getPoint3();
-      points->push_back(p1);
-      points->push_back(p2);
-      points->push_back(p3);
-   }
-
-   this->setName(name);
-   this->nodes            = points; 
-   //this->triangles        = triangles;     
-   this->edges = new vector<GbLine3D*>;
-   this->edges->resize(0, NULL);
-   this->pointinobjecttest = RAYCROSSING;
-   
-   this->consistent       = false;                                 
-   x1min = x1max = x2min = x2max = x3min = x3max = 0.0;
-}
-/*=============================================================================================*/
-GbTriangularMesh3D::GbTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbLine3D*> *edges, vector<GbTriangle3D*> *triangles) : GbObject3D()
-{
-   if(name.size()==0) throw UbException(UB_EXARGS,"no name specified");
-   if(!nodes        ) throw UbException(UB_EXARGS,"no nodes specified");
-   if(!triangles    ) throw UbException(UB_EXARGS,"no triangles specified");
-   if(!edges        ) throw UbException(UB_EXARGS,"no edges specified");
-
-   this->setName(name);
-   this->nodes            = nodes;
-   this->edges            = edges;
-   this->triangles        = triangles;                   
-   this->pointinobjecttest = RAYCROSSING;
-
-   this->consistent = false;                                 
-   x1min = x1max = x2min = x2max = x3min = x3max = 0.0;
-}
-/*=============================================================================================*/
-GbTriangularMesh3D::~GbTriangularMesh3D()
-{
-	if( this->nodes )
-	{
-		for(unsigned u=0; u<nodes->size(); u++) delete (*nodes)[u];
-      delete nodes;
-	}
-	if(triangles)
-	{
-		for(unsigned u=0; u<triangles->size(); u++)	delete (*triangles)[u];
-      delete triangles;
-	}
-}
-/*======================================================================*/
-ObObjectCreator* GbTriangularMesh3D::getCreator()
-{
-   return GbTriangularMesh3DCreator::getInstance();
-}
-/*======================================================================*/
-void GbTriangularMesh3D::deleteRedundantNodes()
-{
-   std::map<GbPoint3D*,GbTriangle3D*> pointTriMap;
-   GbPoint3D* p1 = NULL;
-   GbPoint3D* p2 = NULL;
-   GbPoint3D* p3 = NULL;
-   GbTriangle3D* tri = NULL;
-
-   for(int u=0;u<(int)this->triangles->size();u++)
-   {
-      tri = (*this->triangles)[u];
-      p1 = tri->getPoint1();
-      p2 = tri->getPoint2();
-      p3 = tri->getPoint3();
-      pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p1,tri));
-      pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p2,tri));
-      pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p3,tri));
-   }
-
-   cout<<"Nodes before deleting redundant:"<<this->nodes->size()<<endl;
-   GbPoint3D* pA = NULL;
-   GbPoint3D* pB = NULL;
-   std::map<GbPoint3D*,GbTriangle3D*>::iterator mapIterator; 
-   for(int u=0;u<(int)this->nodes->size();u++)
-   {
-      //cout<<u<<" von "<<this->nodes->size()<<endl;
-      pA = (*this->nodes)[u];
-      if(pA==NULL) continue;
-      for(int w=u+1;w<(int)this->nodes->size();w++)
-      {
-      //   cout<<w<<" Wvon "<<this->nodes->size()<<endl;
-         pB = (*this->nodes)[w];
-         if(pB==NULL) continue;
-         if(pA->equals(pB))
-         {
-            //doppelter Knoten ...
-            mapIterator = pointTriMap.find(pB);
-            tri = dynamic_cast<GbTriangle3D*>(mapIterator->second);
-            if(!tri) throw UbException(UB_EXARGS,"triangle not found");
-            p1 = tri->getPoint1();
-            p2 = tri->getPoint2();
-            p3 = tri->getPoint3();
-            if(pB==p1) tri->setPoint(pA, 0);
-            else if(pB==p2) tri->setPoint(pA, 1);
-            else if(pB==p3) tri->setPoint(pA, 2);
-            else throw UbException(UB_EXARGS,"node should be there");
-            delete pB;
-            (*this->nodes)[w] = NULL;
-         }
-      }
-   }
-   vector<GbPoint3D*> *points = new vector<GbPoint3D*>;
-   for(int u=0;u<(int)this->nodes->size();u++)
-   {
-      pA = (*this->nodes)[u];
-      if(pA!=NULL) points->push_back(pA);
-   }
-   delete this->nodes;
-   this->nodes = points;
-   cout<<"Nodes after deleting redundant:"<<this->nodes->size()<<endl;   
-
-
-//nochmal kontrolle ...
-   pointTriMap.clear();
-   for(int u=0;u<(int)this->triangles->size();u++)
-   {
-      tri = (*this->triangles)[u];
-      p1 = tri->getPoint1();
-      p2 = tri->getPoint2();
-      p3 = tri->getPoint3();
-      pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p1,tri));
-      pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p2,tri));
-      pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p3,tri));
-   }
-   for(int u=0;u<(int)this->nodes->size();u++)
-   {
-      pA = (*this->nodes)[u];
-      if(pA==NULL) throw UbException(UB_EXARGS,"sollte kein NULL pointer sein ...");
-      mapIterator = pointTriMap.find(pA);
-      tri = dynamic_cast<GbTriangle3D*>(mapIterator->second);
-      if(!tri) throw UbException(UB_EXARGS,"triangle not found");
-   }
-}
-/*======================================================================*/
-void GbTriangularMesh3D::translate(const double& x1, const double& x2, const double& x3) 
-{
-   GbPoint3D* pt;
-   for(int u=0;u<(int)this->nodes->size();u++)
-   {
-      pt = (*nodes)[u];
-      pt->setX1(pt->getX1Coordinate()+x1);
-      pt->setX2(pt->getX2Coordinate()+x2);
-      pt->setX3(pt->getX3Coordinate()+x3);
-   }
-   this->consistent = false;
-}
-/*======================================================================*/
-void GbTriangularMesh3D::rotate(const double& alpha, const double& beta, const double& gamma)
-{
-   if(!this->consistent) this->calculateValues();
-   double a1 = this->getX1Centroid();
-   double a2 = this->getX2Centroid();
-   double a3 = this->getX3Centroid();
-   CoordinateTransformation3D trafoFor(a1, a2, a3, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0);
-   CoordinateTransformation3D trafoBack(a1, a2, a3, 1.0, 1.0, 1.0, alpha, beta, gamma);
-
-   vector<GbPoint3D*> points;
-   GbPoint3D* p1 = NULL;
-   GbPoint3D* p2 = NULL;
-   GbPoint3D* p3 = NULL;
-   for(int u=0;u<(int)this->triangles->size();u++)
-   {
-      p1 = (*triangles)[u]->getPoint1();
-      p2 = (*triangles)[u]->getPoint2();
-      p3 = (*triangles)[u]->getPoint3();
-      double p1x1 = trafoFor.transformForwardToX1Coordinate(p1->x1, p1->x2, p1->x3);
-      double p1x2 = trafoFor.transformForwardToX2Coordinate(p1->x1, p1->x2, p1->x3);
-      double p1x3 = trafoFor.transformForwardToX3Coordinate(p1->x1, p1->x2, p1->x3);
-      double p2x1 = trafoFor.transformForwardToX1Coordinate(p2->x1, p2->x2, p2->x3);
-      double p2x2 = trafoFor.transformForwardToX2Coordinate(p2->x1, p2->x2, p2->x3);
-      double p2x3 = trafoFor.transformForwardToX3Coordinate(p2->x1, p2->x2, p2->x3);
-      double p3x1 = trafoFor.transformForwardToX1Coordinate(p3->x1, p3->x2, p3->x3);
-      double p3x2 = trafoFor.transformForwardToX2Coordinate(p3->x1, p3->x2, p3->x3);
-      double p3x3 = trafoFor.transformForwardToX3Coordinate(p3->x1, p3->x2, p3->x3);
-      p1->x1 = trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3);
-      p1->x2 = trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3);
-      p1->x3 = trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3);
-      p2->x1 = trafoBack.transformBackwardToX1Coordinate(p2x1, p2x2, p2x3);
-      p2->x2 = trafoBack.transformBackwardToX2Coordinate(p2x1, p2x2, p2x3);
-      p2->x3 = trafoBack.transformBackwardToX3Coordinate(p2x1, p2x2, p2x3);
-      p3->x1 = trafoBack.transformBackwardToX1Coordinate(p3x1, p3x2, p3x3);
-      p3->x2 = trafoBack.transformBackwardToX2Coordinate(p3x1, p3x2, p3x3);
-      p3->x3 = trafoBack.transformBackwardToX3Coordinate(p3x1, p3x2, p3x3);
-   }
-   this->calculateValues();
-}
-/*======================================================================*/
-   /**
-    * Returns a string representation of this triangular mesh.
-    * @return a string representation of this triangular mesh
-    */
-string GbTriangularMesh3D::toString()
-{
-	stringstream ss;
-	ss<<"GbTriangularMesh3D[";
-	ss<<(int)this->triangles->size()<<"-Triangles, "<<(int)this->nodes->size()<<"-Nodes, "<<(int)this->edges->size()<<"-Edges"<<endl;
-	//ss<<"\""<<this->name<<", Area=sollt mal berechnet werden ;-)"<<"\"";
-   //ss<<", x1min="<<this->x1min;
-   //ss<<", x1max="<<this->x1max;
-   //ss<<", x2min="<<this->x2min;
-   //ss<<", x2max="<<this->x2max;
-   //ss<<", x3min="<<this->x3min;
-   //ss<<", x3max="<<this->x3max;
-   ss<<"]";
-   return(ss.str());
-}
-/**
- * Returns the name of this triangular mesh.
- * @return the name of this triangular mesh
- */
-//string GbTriangularMesh3D::getName(){ return(this->name); }
-
-/**
- * Returns the nodes of this triangular mesh.
- * @return the nodes of this triangular mesh
- */
-vector<GbPoint3D*>* GbTriangularMesh3D::getNodes()   {  return(this->nodes);   }
-/**
- * Returns the triangles of this triangular mesh.
- * @return the triangles of this triangular mesh
- */
-vector<GbTriangle3D*>* GbTriangularMesh3D::getTriangles()  { return(this->triangles);  }
-/**
- * Returns the center x1 coordinate of this triangular mesh.
- * @return the center x1 coordinate of this triangular mesh
- */
-double GbTriangularMesh3D::getX1Centroid()
-{
-   if(!this->consistent) this->calculateValues();
-   return(0.5*(this->x1min+this->x1max));
-}
-/**
- * Returns the center x2 coordinate of this triangular mesh.
- * @return the center x2 coordinate of this triangular mesh
- */
-double GbTriangularMesh3D::getX2Centroid()
-{
-   if(!this->consistent) this->calculateValues();
-   return(0.5*(this->x2min+this->x2max));
-}
-/**
-* Returns the center x3 coordinate of this triangular mesh.
-	* @return the center x3 coordinate of this triangular mesh
-	*/
-double GbTriangularMesh3D::getX3Centroid()
-{
-	if(!this->consistent) this->calculateValues();
-	return(0.5*(this->x3min+this->x3max));
-}
-
-/**
- * Returns the minimum x1 coordinate of this triangular mesh.
- * @return the minimum x1 coordinate of this triangular mesh
- */
-double GbTriangularMesh3D::getX1Minimum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x1min);
-}
-/**
- * Returns the maximum x1 coordinate of this triangular mesh.
- * @return the maximum x1 coordinate of this triangular mesh
- */
-double GbTriangularMesh3D::getX1Maximum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x1max);
-}
-/**
- * Returns the minimum x2 coordinate of this triangular mesh.
- * @return the minimum x2 coordinate of this triangular mesh
- */
-double GbTriangularMesh3D::getX2Minimum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x2min);
-}
-/**
- * Returns the maximum x2 coordinate of this triangular mesh.
- * @return the maximum x2 coordinate of this triangular mesh
- */
-double GbTriangularMesh3D::getX2Maximum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x2max);
-}
-/**
- * Returns the minimum x3 coordinate of this triangular mesh.
- * @return the minimum x3 coordinate of this triangular mesh
- */
-double GbTriangularMesh3D::getX3Minimum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x3min);
-}
-/**
- * Returns the maximum x3 coordinate of this triangular mesh.
- * @return the maximum x3 coordinate of this triangular mesh
- */
-double GbTriangularMesh3D::getX3Maximum()
-{
-   if(!this->consistent) this->calculateValues();
-   return(this->x3max);
-}
-
-void GbTriangularMesh3D::calculateValues()
-{
-   double x1, x2, x3;
-
-	this->x1min = (*this->nodes)[0]->getX1Coordinate();
-   this->x1max = (*this->nodes)[0]->getX1Coordinate();
-   this->x2min = (*this->nodes)[0]->getX2Coordinate();
-   this->x2max = (*this->nodes)[0]->getX2Coordinate();
-   this->x3min = (*this->nodes)[0]->getX3Coordinate();
-   this->x3max = (*this->nodes)[0]->getX3Coordinate();
-
-   for(int i=1; i<(int)this->nodes->size(); i++)
-   {
-		x1 = (*this->nodes)[i]->getX1Coordinate();
-		x2 = (*this->nodes)[i]->getX2Coordinate();
-		x3 = (*this->nodes)[i]->getX3Coordinate();
-		if(x1 < this->x1min) this->x1min = x1;
-		if(x1 > this->x1max) this->x1max = x1;
-		if(x2 < this->x2min) this->x2min = x2;
-		if(x2 > this->x2max) this->x2max = x2;
-		if(x3 < this->x3min) this->x3min = x3;
-		if(x3 > this->x3max) this->x3max = x3;
-   }
-   this->consistent = true;
-}
-
-/**
- * Returns the total area of this triangular mesh.
- * @return the total area of this triangular mesh
- */
-double GbTriangularMesh3D::getArea()
-{
-   double area = 0.0;
-   for(int i=0; i<(int)this->triangles->size(); i++) area += (*this->triangles)[i]->getArea();
-   return(area);
-}
-/**
- * Returns the total volume of this triangular mesh.
- * @return the total volume of this triangular mesh
-  */
-double GbTriangularMesh3D::getVolume()
-{
-   GbTriangle3D* triangle;
-   GbPoint3D* p1;
-   GbPoint3D* p2;
-   GbPoint3D* p3;
-
-   double x1,x2,x3,y1,y2,y3,z1,z2,z3;
-   double G3i;
-   double volume = 0.0;
-   int size = (int)this->triangles->size();
-   for(int u=0; u<size;u++)
-   {
-      triangle = (*this->triangles)[u];
-      p1 = triangle->getPoint1();
-      p2 = triangle->getPoint2();
-      p3 = triangle->getPoint3();
-      x1 = p1->getX1Coordinate(); y1 = p1->getX2Coordinate(); z1 = p1->getX3Coordinate();
-      x2 = p2->getX1Coordinate(); y2 = p2->getX2Coordinate(); z2 = p2->getX3Coordinate();
-      x3 = p3->getX1Coordinate(); y3 = p3->getX2Coordinate(); z3 = p3->getX3Coordinate();
-      G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
-      volume = volume+G3i/6.0;
-   }
-   return volume;
-}
-/*===============================================*/
-UbTupleDouble3 GbTriangularMesh3D::calculateCenterOfGravity()
-{
-   GbTriangle3D* triangle;
-   GbPoint3D* p1;
-   GbPoint3D* p2;
-   GbPoint3D* p3;
-
-   double x1,x2,x3,y1,y2,y3,z1,z2,z3;
-   double G3i;
-   double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0;
-   double volume = 0.0;
-   int size = (int)this->triangles->size();
-   for(int u=0; u<size;u++)
-   {
-      triangle = (*this->triangles)[u];
-      p1 = triangle->getPoint1();
-      p2 = triangle->getPoint2();
-      p3 = triangle->getPoint3();
-      x1 = p1->getX1Coordinate(); y1 = p1->getX2Coordinate(); z1 = p1->getX3Coordinate();
-      x2 = p2->getX1Coordinate(); y2 = p2->getX2Coordinate(); z2 = p2->getX3Coordinate();
-      x3 = p3->getX1Coordinate(); y3 = p3->getX2Coordinate(); z3 = p3->getX3Coordinate();
-      G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
-      volume = volume+G3i/6.0;
-      rSP1 = rSP1+G3i*(x1+x2+x3);
-      rSP2 = rSP2+G3i*(y1+y2+y3);
-      rSP3 = rSP3+G3i*(z1+z2+z3);
-   }
-   rSP1 = rSP1/(24.0*volume);
-   rSP2 = rSP2/(24.0*volume);
-   rSP3 = rSP3/(24.0*volume);
-
-   return UbTupleDouble3(rSP1, rSP2, rSP3);
-}
-/*===============================================*/
-UbTupleDouble6 GbTriangularMesh3D::calculateMomentOfInertia(double rhoP)
-{
-   GbTriangle3D* triangle;
-   GbPoint3D* p1;
-   GbPoint3D* p2;
-   GbPoint3D* p3;
-   
-   double x1,x2,x3,y1,y2,y3,z1,z2,z3;
-   double G3i;
-   double xx,yy,zz,xy,yz,zx;
-   double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0;
-   double volume = 0.0;
-   double top11 = 0.0;double top22 = 0.0;double top33 = 0.0;
-   double top12 = 0.0;double top23 = 0.0;double top13 = 0.0;
-   int size = (int)this->triangles->size();
-   for(int u=0; u<size;u++)
-   {
-      triangle = (*this->triangles)[u];
-      p1 = triangle->getPoint1();
-      p2 = triangle->getPoint2();
-      p3 = triangle->getPoint3();
-      x1 = p1->getX1Coordinate(); y1 = p1->getX2Coordinate(); z1 = p1->getX3Coordinate();
-      x2 = p2->getX1Coordinate(); y2 = p2->getX2Coordinate(); z2 = p2->getX3Coordinate();
-      x3 = p3->getX1Coordinate(); y3 = p3->getX2Coordinate(); z3 = p3->getX3Coordinate();
-      G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
-      volume = volume+G3i/6.0;
-      rSP1 = rSP1+G3i*(x1+x2+x3);
-      rSP2 = rSP2+G3i*(y1+y2+y3);
-      rSP3 = rSP3+G3i*(z1+z2+z3);
-   }
-   rSP1 = rSP1/(24.0*volume);
-   rSP2 = rSP2/(24.0*volume);
-   rSP3 = rSP3/(24.0*volume);
-
-   double x1s = 0.0;//rSP1;//0.0;//
-   double x2s = 0.0;//rSP2;//0.0;//
-   double x3s = 0.0;//rSP3;//0.0;//
-
-   for(int u=0; u<size;u++)
-   {
-      triangle = (*this->triangles)[u];
-      p1 = triangle->getPoint1();
-      p2 = triangle->getPoint2();
-      p3 = triangle->getPoint3();
-      x1 = p1->getX1Coordinate()-x1s; 
-      y1 = p1->getX2Coordinate()-x2s; 
-      z1 = p1->getX3Coordinate()-x3s;
-      x2 = p2->getX1Coordinate()-x1s; 
-      y2 = p2->getX2Coordinate()-x2s; 
-      z2 = p2->getX3Coordinate()-x3s;
-      x3 = p3->getX1Coordinate()-x1s; 
-      y3 = p3->getX2Coordinate()-x2s; 
-      z3 = p3->getX3Coordinate()-x3s;
-      G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
-      //rSP1 = rSP1+G3i*(x1+x2+x3)/(24.0*volume);
-      //rSP2 = rSP2+G3i*(y1+y2+y3)/(24.0*volume);
-      //rSP3 = rSP3+G3i*(z1+z2+z3)/(24.0*volume);
-      xx = x1*x1+x2*x2+x3*x3+x1*x2+x2*x3+x3*x1;
-      yy = y1*y1+y2*y2+y3*y3+y1*y2+y2*y3+y3*y1;
-      zz = z1*z1+z2*z2+z3*z3+z1*z2+z2*z3+z3*z1;
-      top11 = top11+(yy+zz)*rhoP*G3i/60.;
-      top22 = top22+(xx+zz)*rhoP*G3i/60.;
-      top33 = top33+(yy+xx)*rhoP*G3i/60.;
-      xy = 2.0*(x1*y1+x2*y2+x3*y3)+x2*y3+x3*y1+x1*y2+x3*y2+x1*y3+x2*y1;
-      yz = 2.0*(y1*z1+y2*z2+y3*z3)+y2*z3+y3*z1+y1*z2+y3*z2+y1*z3+y2*z1;
-      zx = 2.0*(z1*x1+z2*x2+z3*x3)+z2*x3+z3*x1+z1*x2+z3*x2+z1*x3+z2*x1;
-      top12 = top12-xy*rhoP*G3i/120.;
-      top23 = top23-yz*rhoP*G3i/120.;
-      top13 = top13-zx*rhoP*G3i/120.;
-   }
-   //Satz von Steiner ...
-   top11 = top11-rhoP*volume*(rSP2*rSP2+rSP3+rSP3);
-   top22 = top22-rhoP*volume*(rSP3*rSP3+rSP1*rSP1);
-   top33 = top33-rhoP*volume*(rSP1*rSP1+rSP2*rSP2);
-   top12 = top12+rhoP*volume*rSP1*rSP2;
-   top23 = top23+rhoP*volume*rSP2*rSP3;
-   top13 = top13+rhoP*volume*rSP3*rSP1;
-   
-   cout<<"Volume:"<<volume<<"\n Traegheitsmomente:\n";
-   cout<<" top11:"<<top11<<" top22:"<<top22<<" top33:"<<top33<<endl;
-   cout<<" top12:"<<top12<<" top23:"<<top23<<" top13:"<<top13<<endl;
-
-   return UbTupleDouble6(top11,top22,top33,top12,top23,top13);
-}
-
- /**
-  * Returns the volume of this triangular mesh within the specified rectangle.
-  * @param p1x1 the 1st x1 coordinate of the rectangle
-  * @param p1x2 the 1st x2 coordinate of the rectangle
-  * @param p2x1 the 2nd x1 coordinate of the rectangle
-  * @param p2x2 the 2nd x2 coordinate of the rectangle
-  * @return the volume of this triangular mesh within the specified rectangle
-  * @exception NullPointerException if no triangles are found within the specified rectangle
-  */
-double GbTriangularMesh3D::getVolumeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) 
-{
-	throw UbException(UB_EXARGS,"not yet implemented");
-  //    GbPolygon2D polygon;
-  //    double      volume = 0.0;
-  //    double      area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2));
-  //    double      area2 = 0.0;
-  //    double      t1min, t1max, t2min, t2max;
-  //    double      x1, x2;
-  //    boolean     f = false;
-
-  //    for(int i=0; i<this.triangles.length; i++)
-  //    {
-		//	t1min = this.triangles[i].getX1Minimum();
-		//	t1max = this.triangles[i].getX1Maximum();
-		//	if(GbSystem.less2(t1min, t1max, p1x1, p2x1))    continue;
-		//	if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue;
-
-		//	t2min = this.triangles[i].getX2Minimum();
-		//	t2max = this.triangles[i].getX2Maximum();
-		//	if(GbSystem.less2(t2min, t2max, p1x2, p2x2))    continue;
-		//	if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue;
-
-		//	if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) &&
-		//		GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2))
-		//	{
-		//		volume += this.triangles[i].getVolume();
-		//		area2  += this.triangles[i].getArea();
-		//		f       = true;
-		//	}
-		//	else
-		//	{
-		//		polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2);
-
-		//		if(polygon != null && polygon.size() > 2)
-		//		{
-		//			try
-		//			{
-		//				x1      = polygon.getX1Centroid();
-		//				x2      = polygon.getX2Centroid();
-		//				volume += this.triangles[i].getX3Coordinate(x1, x2) * Math.abs(polygon.getArea());
-		//				area2  += Math.abs(polygon.getArea());
-		//				f       = true;
-		//			}
-		//			catch(Exception e){}
-		//		}
-		//	}
-		//	if(GbSystem.greaterEqual(area2, area1)) break;
-		//}
-  //    if(f) return(volume);
-  //    else  throw new NullPointerException();
-}
-
-/**
- * Returns the triangles of this triangular mesh located within the specified rectangle (may be an empty array).
- * @param p1x1 the 1st x1 coordinate of the rectangle
- * @param p1x2 the 1st x2 coordinate of the rectangle
- * @param p2x1 the 2nd x1 coordinate of the rectangle
- * @param p2x2 the 2nd x2 coordinate of the rectangle
- * @return the triangles of this triangular mesh located within the specified rectangle
- */
-vector<GbTriangle3D*>* GbTriangularMesh3D::getTrianglesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2)
-{
-	throw UbException(UB_EXARGS,"not yet implemented");
-  //    QbList      triangleList = new QbList(GbTriangle3D.class);
-  //    GbPolygon2D polygon;
-  //    double      t1min, t1max, t2min, t2max;
-  //    double      area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2));
-  //    double      area2 = 0.0;
-
-  //    for(int i=0; i<this.triangles.length; i++)
-  //    {
-		//	t1min = this.triangles[i].getX1Minimum();
-		//	t1max = this.triangles[i].getX1Maximum();
-		//	if(GbSystem.less2(t1min, t1max, p1x1, p2x1))    continue;
-		//	if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue;
-
-		//	t2min = this.triangles[i].getX2Minimum();
-		//	t2max = this.triangles[i].getX2Maximum();
-		//	if(GbSystem.less2(t2min, t2max, p1x2, p2x2))    continue;
-		//	if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue;
-
-		//	if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) &&
-		//		GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2))
-		//	{
-		//		try { triangleList.append(this.triangles[i]); } catch(Exception e){}
-		//		area2 += this.triangles[i].getArea();
-		//	}
-		//	else
-		//	{
-		//		polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2);
-		//		if(polygon != null && polygon.size() > 2)
-		//		{
-		//			try { triangleList.append(this.triangles[i]); } catch(Exception e){}
-		//			area2 += Math.abs(polygon.getArea());
-		//		}
-		//	}
-		//	if(GbSystem.greaterEqual(area2, area1)) break;
-		//}
-  //    return((GbTriangle3D[])triangleList.getObjectArray());
-}
-/**
- * Returns the nodes of this triangular mesh located within the specified rectangle (may be an empty array).
- * @param p1x1 the 1st x1 coordinate of the rectangle
- * @param p1x2 the 1st x2 coordinate of the rectangle
- * @param p2x1 the 2nd x1 coordinate of the rectangle
- * @param p2x2 the 2nd x2 coordinate of the rectangle
- * @return the nodes of this triangular mesh located within the specified rectangle
- */
-vector<GbPoint3D*>* GbTriangularMesh3D::getNodesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2)
-{
-	throw UbException(UB_EXARGS,"not implemented");
-//   QbList nodeList = new QbList(GbPoint3D.class);
-
-   //   for(int i=0; i<this.edges.length; i++)
-   //   {
-			//if(GbSystem.inClosedInterval(this.nodes[i].getX1Coordinate(), p1x1, p2x1) && GbSystem.inClosedInterval(this.nodes[i].getX2Coordinate(), p1x2, p2x2))
-			//{
-			//	try { nodeList.append(this.nodes[i]); } catch(Exception e){}
-			//}
-   //   }
-   //   return((GbPoint3D[])nodeList.getObjectArray());
-}
-
-/**
- * Returns the difference of maximum and minimum x3 coordinates
- * of this triangular mesh within the specified rectangle.
- * @param p1x1 the 1st x1 coordinate of the rectangle
- * @param p1x2 the 1st x2 coordinate of the rectangle
- * @param p2x1 the 2nd x1 coordinate of the rectangle
- * @param p2x2 the 2nd x2 coordinate of the rectangle
- * @return the difference of maximum and minimum x3 coordinates of this triangular mesh within the specified rectangle
- * @exception NullPointerException if no triangles are found within the specified rectangle
- */
-double GbTriangularMesh3D::getX3RangeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) 
-{
-	throw UbException(UB_EXARGS,"not implemented");
- //     GbPolygon3D polygon;
- //     boolean     f     = false;
- //     double      x3min = 0.0;
- //     double      x3max = 0.0;
- //     double      t1min, t1max, t2min, t2max;
- //     double      area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2));
- //     double      area2 = 0.0;
-
- //     for(int i=0; i<this.triangles.length; i++)
- //     {
-	// t1min = this.triangles[i].getX1Minimum();
-	// t1max = this.triangles[i].getX1Maximum();
-	// if(GbSystem.less2(t1min, t1max, p1x1, p2x1))    continue;
-	// if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue;
-
-	// t2min = this.triangles[i].getX2Minimum();
-	// t2max = this.triangles[i].getX2Maximum();
-	// if(GbSystem.less2(t2min, t2max, p1x2, p2x2))    continue;
-	// if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue;
-
-	// if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) &&
-	//    GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2))
-	// {
-	//    if(f)
-	//    {
-	//       if(this.triangles[i].getX3Minimum() < x3min) x3min = this.triangles[i].getX3Minimum();
-	//       if(this.triangles[i].getX3Maximum() > x3max) x3max = this.triangles[i].getX3Maximum();
-	//    }
-	//    else
-	//    {
-	//       x3min = this.triangles[i].getX3Minimum();
-	//       x3max = this.triangles[i].getX3Maximum();
-	//       f     = true;
-	//    }
-	//    area2 += this.triangles[i].getArea();
-	//}
-	// else
-	// {
-	//    polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2);
-
-	//    if(polygon != null && polygon.size() > 2)
-	//    {
-	//       if(f)
-	//       {
-	//          if(polygon.getX3Minimum() < x3min) x3min = polygon.getX3Minimum();
-	//          if(polygon.getX3Maximum() > x3max) x3max = polygon.getX3Maximum();
-	//       }
-	//       else
-	//       {
-	//          x3min = polygon.getX3Minimum();
-	//          x3max = polygon.getX3Maximum();
-	//          f     = true;
-	//       }
-	//       area2 += Math.abs(polygon.getArea());
-	//    }
-	// }
-	// if(GbSystem.greaterEqual(area2, area1)) break;
- //     }
- //     if(f) return(x3max-x3min);
- //     else  throw new NullPointerException();
-}
-/**
- * Returns the minimum x3 coordinates of this triangular mesh within the specified rectangle.
- * @param p1x1 the 1st x1 coordinate of the rectangle
- * @param p1x2 the 1st x2 coordinate of the rectangle
- * @param p2x1 the 2nd x1 coordinate of the rectangle
- * @param p2x2 the 2nd x2 coordinate of the rectangle
- * @return the minimum x3 coordinates of this triangular mesh within the specified rectangle
- * @exception NullPointerException if no triangles are found within the specified rectangle
- */
-double GbTriangularMesh3D::getX3MinimumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) 
-{
-	throw UbException(UB_EXARGS,"not implemented");
-  //    GbPolygon3D polygon;
-  //    boolean     f     = false;
-  //    double      x3min = 0.0;
-  //    double      t1min, t1max, t2min, t2max;
-  //    double      area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2));
-  //    double      area2 = 0.0;
-
-  //    for(int i=0; i<this.triangles.length; i++)
-  //    {
-	 //t1min = this.triangles[i].getX1Minimum();
-	 //t1max = this.triangles[i].getX1Maximum();
-	 //if(GbSystem.less2(t1min, t1max, p1x1, p2x1))    continue;
-	 //if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue;
-
-	 //t2min = this.triangles[i].getX2Minimum();
-	 //t2max = this.triangles[i].getX2Maximum();
-	 //if(GbSystem.less2(t2min, t2max, p1x2, p2x2))    continue;
-	 //if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue;
-
-	 //if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) &&
-	 //   GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2))
-	 //{
-	 //   if(f)
-	 //   {
-	 //      if(this.triangles[i].getX3Minimum() < x3min) x3min = this.triangles[i].getX3Minimum();
-	 //   }
-	 //   else
-	 //   {
-	 //      x3min = this.triangles[i].getX3Minimum();
-	 //      f     = true;
-	 //   }
-	 //   area2 += this.triangles[i].getArea();
-	 //}
-	 //else
-	 //{
-	 //   polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2);
-
-	 //   if(polygon != null && polygon.size() > 2)
-	 //   {
-	 //      if(f)
-	 //      {
-	 //         if(polygon.getX3Minimum() < x3min) x3min = polygon.getX3Minimum();
-	 //      }
-	 //      else
-	 //      {
-	 //         x3min = polygon.getX3Minimum();
-	 //         f     = true;
-	 //      }
-	 //      area2 += Math.abs(polygon.getArea());
-	 //   }
-	 //}
-	 //if(GbSystem.greaterEqual(area2, area1)) break;
-  //    }
-  //    if(f) return(x3min);
-  //    else  throw new NullPointerException();
-}
-/**
- * Returns the maximum x3 coordinates of this triangular mesh within the specified rectangle.
- * @param p1x1 the 1st x1 coordinate of the rectangle
- * @param p1x2 the 1st x2 coordinate of the rectangle
- * @param p2x1 the 2nd x1 coordinate of the rectangle
- * @param p2x2 the 2nd x2 coordinate of the rectangle
- * @return the maximum x3 coordinates of this triangular mesh within the specified rectangle
- * @exception NullPointerException if no triangles are found within the specified rectangle
- */
-double GbTriangularMesh3D::getX3MaximumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) 
-{
-   throw UbException(UB_EXARGS,"not implemented");
-  //    GbPolygon3D polygon;
-  //    boolean     f     = false;
-  //    double      x3max = 0.0;
-  //    double      t1min, t1max, t2min, t2max;
-  //    double      area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2));
-  //    double      area2 = 0.0;
-
-  //    for(int i=0; i<this.triangles.length; i++)
-  //    {
-	 //t1min = this.triangles[i].getX1Minimum();
-	 //t1max = this.triangles[i].getX1Maximum();
-	 //if(GbSystem.less2(t1min, t1max, p1x1, p2x1))    continue;
-	 //if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue;
-
-	 //t2min = this.triangles[i].getX2Minimum();
-	 //t2max = this.triangles[i].getX2Maximum();
-	 //if(GbSystem.less2(t2min, t2max, p1x2, p2x2))    continue;
-	 //if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue;
-
-	 //if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) &&
-	 //   GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2))
-	 //{
-	 //   if(f)
-	 //   {
-	 //      if(this.triangles[i].getX3Maximum() < x3max) x3max = this.triangles[i].getX3Maximum();
-	 //   }
-	 //   else
-	 //   {
-	 //      x3max = this.triangles[i].getX3Maximum();
-	 //      f     = true;
-	 //   }
-	 //   area2 += this.triangles[i].getArea();
-	 //}
-	 //else
-	 //{
-	 //   polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2);
-
-	 //   if(polygon != null && polygon.size() > 2)
-	 //   {
-	 //      if(f)
-	 //      {
-	 //         if(polygon.getX3Maximum() < x3max) x3max = polygon.getX3Maximum();
-	 //      }
-	 //      else
-	 //      {
-	 //         x3max = polygon.getX3Maximum();
-	 //         f     = true;
-	 //      }
-	 //      area2 += Math.abs(polygon.getArea());
-	 //   }
-	 //}
-	 //if(GbSystem.greaterEqual(area2, area1)) break;
-  //    }
-  //    if(f) return(x3max);
-  //    else  throw new NullPointerException();
-}
-/*======================================================================*/
-vector<GbTriangle3D*> GbTriangularMesh3D::getSurfaceTriangleSet()
-{
-   vector<GbTriangle3D*> tris;
-   GbTriangle3D* triangle;
-   GbPoint3D* p1;
-   GbPoint3D* p2;
-   GbPoint3D* p3;
-   int size = (int)this->triangles->size();
-   for(int u=0; u<size;u++)
-   {
-      triangle = (*this->triangles)[u];
-      p1 = new GbPoint3D(triangle->getPoint1());
-      p2 = new GbPoint3D(triangle->getPoint2());
-      p3 = new GbPoint3D(triangle->getPoint3());
-      tris.push_back(new GbTriangle3D(p1, p2, p3));
-   }
-   return tris;
-}
-/*======================================================================*/
-/*
-* Function to determine if the point is inside the polyhedron defined as a 3D object
-* using the Halfspace algorithm
-* @param xp the x-coordinate of the point
-* @param yp the y-coordinate of the point
-* @param zp the z-coordinate of the point
-* @return true if point is inside else return false
-*/
-bool GbTriangularMesh3D::isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp)
-{ 
-   vector<GbTriangle3D*> *Triangles = this->triangles;
-   int Trianglesize = (int)Triangles->size();
-   //GbPoint3D Point(xp,yp,zp);
-   for (int i=0; i<Trianglesize; i++)
-   {
-      //GbPoint3D* point1 = (*Triangles)[i]->getPoint1();
-      //GbPoint3D* point2 = (*Triangles)[i]->getPoint2();
-      //GbPoint3D* point3 = (*Triangles)[i]->getPoint3();
-
-      //GbHalfSpace3D halfspace(point1, point2, point3);
-      GbHalfSpace3D halfspace((*Triangles)[i]);
-      if (halfspace.ptInside(xp,yp,zp)) return false;
-   }
-   return true;
-}
-/*======================================================================*/
-bool GbTriangularMesh3D::isPointInObject3DRayCrossing(const double& xp, const double& yp, const double& zp, int radius, int numVertices, int numTriangles)
-{
-   GbVector3D point(xp,yp,zp);
-
-   if ( this->InPolyhedron(numTriangles, point, radius) ) return true;
-   else                                                   return false;
-   
-}
-/*======================================================================*/
-bool GbTriangularMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3)
-{
-   double xmin=this->getX1Minimum();	double xmax=this->getX1Maximum();
-   double ymin=this->getX2Minimum();	double ymax=this->getX2Maximum();
-   double zmin=this->getX3Minimum();	double zmax=this->getX3Maximum();
-   double dX = (xmax-xmin)/100.;
-   double dY = (ymax-ymin)/100.;
-   double dZ = (zmax-zmin)/100.;
-   GbCuboid3D boundingCube(xmin-dX, ymin-dY, zmin-dZ, xmax+dX, ymax+dY, zmax+dZ);
-   if(!boundingCube.isPointInGbObject3D(x1, x2, x3)) { boundingCube.finalize(); return false; }
-
-   // Halfspace algorithm, Area of spherical polygons algorithm or Ray crossing algorithm
-   GbVector3D bMin(boundingCube.getPoint1());
-   GbVector3D bMax(boundingCube.getPoint2());
-
-   boundingCube.finalize();
-
-   bMin = bMax.Subtract(bMin);
-   int radius = (int)(bMin.Length()+1)+1;
-
-   if(this->pointinobjecttest == HALFSPACE)        return this->isPointInObject3DHalfSpace(x1,x2,x3);
-   else if(this->pointinobjecttest == RAYCROSSING) return this->isPointInObject3DRayCrossing(x1,x2,x3,radius,(int)this->nodes->size(),(int)this->triangles->size());
-   else throw UbException(UB_EXARGS,"no ptInObjTest");
-}
-/*======================================================================*/
-bool GbTriangularMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)
-{
-    throw UbException(UB_EXARGS,"not implemented");
-}
-/*======================================================================*/
-GbLine3D* GbTriangularMesh3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
-{
-   throw UbException(UB_EXARGS,"not implemented");
-}
-/*======================================================================*/
-void GbTriangularMesh3D::writeMesh(string filename, WbWriter* writer, bool writeNormals) 
-{
-   vector<UbTupleFloat3 > nodes(triangles->size()*3);
-   vector<UbTupleInt3 >   tris(triangles->size());
-
-   for(size_t i=0; i<triangles->size(); i++)
-   {
-      GbTriangle3D&  tri = *((*triangles)[i]);
-      GbPoint3D&   node1 = *tri.getPoint(0);
-      GbPoint3D&   node2 = *tri.getPoint(1);
-      GbPoint3D&   node3 = *tri.getPoint(2);
-      
-      nodes[i*3  ] = makeUbTuple( (float)node1.getX1Coordinate()
-                                 ,(float)node1.getX2Coordinate()  
-                                 ,(float)node1.getX3Coordinate());
-      nodes[i*3+1] = makeUbTuple( (float)node2.getX1Coordinate()
-                                 ,(float)node2.getX2Coordinate()  
-                                 ,(float)node2.getX3Coordinate());
-      nodes[i*3+2] = makeUbTuple( (float)node3.getX1Coordinate()
-                                 ,(float)node3.getX2Coordinate()  
-                                 ,(float)node3.getX3Coordinate());
-
-      tris[i] = makeUbTuple((int)i*3,(int)i*3+1,(int)i*3+2);
-   }
-   writer->writeTriangles(filename,nodes,tris);
-   
-   if(writeNormals)
-   {
-      vector<UbTupleFloat3 > lineNodes(triangles->size()*2);
-      vector<UbTupleInt2 >   lines(triangles->size());
-      for(size_t i=0; i<triangles->size(); i++)
-      {
-         GbVector3D vec = (*triangles)[i]->getNormal();
-         lineNodes[i*2  ] = makeUbTuple( (float)(*triangles)[i]->getX1Centroid()
-                                        ,(float)(*triangles)[i]->getX2Centroid()  
-                                        ,(float)(*triangles)[i]->getX3Centroid());
-         lineNodes[i*2+1] = makeUbTuple( (float)((*triangles)[i]->getX1Centroid()+vec.X1())
-                                        ,(float)((*triangles)[i]->getX2Centroid()+vec.X2())  
-                                        ,(float)((*triangles)[i]->getX3Centroid()+vec.X3()));
-
-         lines[i] = makeUbTuple((int)i*2,(int)i*2+1);
-      }
-      writer->writeLines(filename+"_normals",lineNodes,lines);
-   }
-}
-/*======================================================================*/
-void GbTriangularMesh3D::writeAVSMesh(UbFileOutput *out, bool normals) 
-{
-   cout<<" - write_ucd ("<<out->getFileName()<<") -> ";
-   if(!out)
-   {
-      cout<<"GbTriangularMesh3D::writeAVSMesh() - File konnte nicht geschrieben werden: "<<endl;
-      return;
-   }
-   out->writeLine("# UCD-File created by GbTriangularMesh3D");
-   //vector<GbPoint3D*>     *nodes    = this->getNodes();
-   vector<GbTriangle3D*> *triangles = this->getTriangles();
-   //int nodesize     = (int)nodes->size();
-   int trianglesize = (int)triangles->size();
-   int nodesize     = trianglesize*3;
-   if(normals) 
-   {
-      out->writeInteger(nodesize+trianglesize*2);
-      out->writeInteger(trianglesize*2);
-   }
-   else
-   {
-      out->writeInteger(nodesize);
-      out->writeInteger(trianglesize);
-   }
-   out->writeInteger(0);
-   out->writeInteger(0);
-   out->writeInteger(0);
-   out->writeLine();
-   int nr=1;
-   GbPoint3D *node;
-   for(int i=0;i<trianglesize; i++)
-   {
-      node = (*triangles)[i]->getPoint(0); 
-      out->writeInteger(nr++);
-      out->writeDouble(node->getX1Coordinate());
-      out->writeDouble(node->getX2Coordinate());
-      out->writeDouble(node->getX3Coordinate());
-      out->writeLine();
-      node = (GbPoint3D*)(*triangles)[i]->getPoint(1); 
-      out->writeInteger(nr++);
-      out->writeDouble(node->getX1Coordinate());
-      out->writeDouble(node->getX2Coordinate());
-      out->writeDouble(node->getX3Coordinate());
-      out->writeLine();
-      node = (GbPoint3D*)(*triangles)[i]->getPoint(2); 
-      out->writeInteger(nr++);
-      out->writeDouble(node->getX1Coordinate());
-      out->writeDouble(node->getX2Coordinate());
-      out->writeDouble(node->getX3Coordinate());
-      out->writeLine();
-   }
-
-   if(normals) 
-   {
-      for(int i=0;i<trianglesize; i++)
-      {
-         GbVector3D vec = (*triangles)[i]->getNormal();
-         out->writeInteger(nr++);
-         out->writeDouble((*triangles)[i]->getX1Centroid());
-         out->writeDouble((*triangles)[i]->getX2Centroid());
-         out->writeDouble((*triangles)[i]->getX3Centroid());
-         out->writeLine();
-         out->writeInteger(nr++);
-         out->writeDouble((*triangles)[i]->getX1Centroid()+vec.X1());
-         out->writeDouble((*triangles)[i]->getX2Centroid()+vec.X2());
-         out->writeDouble((*triangles)[i]->getX3Centroid()+vec.X3());
-         out->writeLine();
-      }
-   }
-   nr=1;
-   int el=1;
-   for(int i=0;i<trianglesize; i++)
-   {
-      nr = 3*el-2;
-      out->writeInteger(el);
-      out->writeInteger(2);
-      out->writeString("tri");
-      out->writeInteger(nr);
-      out->writeInteger(nr+1);
-      out->writeInteger(nr+2);
-      out->writeLine();
-      el++;
-   }
-   if(normals)
-   {
-      nr = trianglesize*3+1;
-      for(int i=trianglesize;i<2*trianglesize; i++)
-      {
-         out->writeInteger(el);
-         out->writeInteger(2);
-         out->writeString("line");
-         out->writeInteger(nr++);
-         out->writeInteger(nr++);
-         out->writeLine();
-         el++;
-      }
-   }
-   cout<<"done\n";
-}
-
-/*======================================================================*/
-/*
-This function returns a char:
-'V': the query point a coincides with a Vertex of polyhedron P.
-'E': the query point a is in the relative interior of an Edge of polyhedron P.
-'F': the query point a is in the relative interior of a Face of polyhedron P.
-'i': the query point a is strictly interior to polyhedron P.
-'o': the query point a is strictly exterior to( or outside of) polyhedron P.
-*/
-bool GbTriangularMesh3D::InPolyhedron( int F, GbVector3D& q, int radius )
-{
-   GbVector3D r;  /* Ray endpoint. */
-   GbVector3D p;  /* Intersection point; not used. */
-   int f, k = 0, crossings = 0;
-   char code = '?';
-
-   while( k++ < F ) 
-   {
-      crossings = 0;
-
-      RandomRay( r, radius ); 
-      r = q.Add(r);
-      // printf("Ray endpoint: (%d,%d,%d)\n", r[0],r[1],r[2] );
-
-      for ( f = 0; f < F; f++ )  /* Begin check each face */
-      {
-          if( BoxTest( (*this->triangles)[f], q, r ) == false ) code = '0'; // printf("BoxTest = 0!\n");
-         else                                                  code = SegTriInt( (*this->triangles)[f], q, r, p );// printf( "Face = %d: BoxTest/SegTriInt returns %c\n\n", f, code );
-
-         /* If ray is degenerate, then goto outer while to generate another. */
-         if( code=='p' || code=='v' || code=='e' ) break; //goto LOOP; //printf("Degenerate ray\n");
-         /* If ray hits face at interior point, increment crossings. */
-         else if ( code=='f' ) crossings++; // printf( "crossings = %d\n", crossings );
-         /* If query endpoint q sits on a V/E/F, return that code. */
-         else if ( code=='V' || code=='E' || code=='F' ) return true;
-         /* If ray misses triangle, do nothing. */
-         else if ( code=='0' ) { /*nothing to do*/ }
-         else throw UbException(UB_EXARGS,"Error" );
-      } /* End check each face */
-
-      /* No degeneracies encountered: ray is generic, so finished. */
-      if(f>=F) break;
-   } /* End while loop */
-
-   //   printf( "Crossings = %d\n", crossings );
-   /* q strictly interior to polyhedron iff an odd number of crossings. */
-   if( (crossings%2) == 1 ) return true;
-   
-   return false;
-}
-
-/* Return a random ray endpoint */
-void GbTriangularMesh3D::RandomRay( GbVector3D& ray, int radius )
-{
-   double x, y, z, w, t;
-
-   double MAX_INT = 2147483647;
-   /* Generate a random point on a sphere of radius 1. */
-   /* the sphere is sliced at z, and a random point at angle t
-   generated on the circle of intersection. */
-   z = 2.0 * (double) rand() / MAX_INT - 1.0;
-   t = 2.0 * UbMath::PI * (double) rand() / MAX_INT;
-   w = sqrt( 1 - z*z );
-   x = w * cos( t );
-   y = w * sin( t );
-
-   ray[0] = radius * x;
-   ray[1] = radius * y;
-   ray[2] = radius * z;
-
-   /*printf( "RandomRay returns %6d %6d %6d\n", ray[X], ray[Y], ray[Z] );*/
-}
-
-/*---------------------------------------------------------------------
-'p': The segment lies wholly within the plane.
-'q': The q endpoint is on the plane (but not 'p').
-'r': The r endpoint is on the plane (but not 'p').
-'0': The segment lies strictly to one side or the other of the plane.
-'1': The segement intersects the plane, and 'p' does not hold.
----------------------------------------------------------------------*/
-char	GbTriangularMesh3D::SegPlaneInt( GbTriangle3D* T, GbVector3D& q, GbVector3D& r, GbVector3D& p, int *m)
-{
-  // cout<<"SegPlaneInt..\n";
-   GbVector3D N; double D;
-   GbVector3D rq;
-   double num, denom, t;
-   int i;
-
-   *m = PlaneCoeff( T, N, &D );
-   /*printf("m=%d; plane=(%lf,%lf,%lf,%lf)\n", m, N[X],N[Y],N[Z],D);*/
-   num = D - q.Dot( N );
-   rq = r.Subtract( q );
-   denom = rq.Dot( N );
-   /*printf("SegPlaneInt: num=%lf, denom=%lf\n", num, denom );*/
-
-   if ( denom == 0.0 ) {  /* Segment is parallel to plane. */
-      if ( num == 0.0 )   /* q is on plane. */
-   //if (UbMath::zero(denom)) {  /* Segment is parallel to plane. */
-   //   if ( UbMath::zero(num))   /* q is on plane. */
-         return 'p';
-      else
-         return '0';
-   }
-   else
-      t = num / denom;
-   /*printf("SegPlaneInt: t=%lf \n", t );*/
-
-   for( i = 0; i < 3; i++ )
-      p[i] = q[i] + t * ( r[i] - q[i] );
-
-   if ( (0.0 < t) && (t < 1.0) )
-      return '1';
-   else if ( num == 0.0 )   /* t == 0 */
-      return 'q';
-   else if ( num == denom ) /* t == 1 */
-      return 'r';
-   else return '0';
-
-   //if ( (0.0 < t) && (t < 1.0) )
-   //   return '1';
-   //else if ( UbMath::zero(num))   /* t == 0 */
-   //   return 'q';
-   //else if ( UbMath::equal(num , denom) ) /* t == 1 */
-   //   return 'r';
-   //else return '0';
-
-}
-/*---------------------------------------------------------------------
-Computes N & D and returns index m of largest component.
----------------------------------------------------------------------*/
-int	GbTriangularMesh3D::PlaneCoeff( GbTriangle3D* T, GbVector3D& N, double *D )
-{
-   int i;
-   double t;              /* Temp storage */
-   double biggest = 0.0;  /* Largest component of normal vector. */
-   int m = 0;             /* Index of largest component. */
-
-   N = T->getNormal();
-   /*printf("PlaneCoeff: N=(%lf,%lf,%lf)\n", N[X],N[Y],N[Z]);*/
-   GbVector3D a(T->getPoint1());
-
-   *D = a.Dot( N );
-
-   /* Find the largest component of N. */
-   for ( i = 0; i < 3; i++ )
-   {
-      t = std::fabs( N[i] );
-      if ( t > biggest ) 
-      {
-         biggest = t;
-         m = i;
-      }
-   }
-   return m;
-}
-
-/* Assumption: p lies in the plane containing T.
-Returns a char:
-'V': the query point p coincides with a Vertex of triangle T.
-'E': the query point p is in the relative interior of an Edge of triangle T.
-'F': the query point p is in the relative interior of a Face of triangle T.
-'0': the query point p does not intersect (misses) triangle T.
-*/
-
-char 	GbTriangularMesh3D::InTri3D( GbTriangle3D* T, int m, GbVector3D& p )
-{
-//   int i;           /* Index for X,Y,Z           */
-   int j;           /* Index for X,Y             */
-//   int k;           /* Index for triangle vertex */
-   GbVector3D pp;      /* projected p */
-   GbVector3D Tp[3];   /* projected T: three new vertices */
-
-   /* Project out coordinate m in both p and the triangular face */
-   //j = 0;
-   //for ( i = 0; i < 3; i++ ) {
-   //   if ( i != m ) {    /* skip largest coordinate */
-   //      pp[j] = p[i];
-   //      //for ( k = 0; k < 3; k++ )
-   //         std::cout<<"aachtung###############################################";
-   //      //            Tp[k][j] = Vertices[T[k]][i];
-   //      j++;
-   //   }
-   //}
-   j=0;
-   if(m!=0)
-   {
-      Tp[0][j] = T->getPoint1()->getX1Coordinate();
-      Tp[1][j] = T->getPoint2()->getX1Coordinate();
-      Tp[2][j] = T->getPoint3()->getX1Coordinate();
-      j++;
-   }
-   if(m!=1)
-   {
-      Tp[0][j] = T->getPoint1()->getX2Coordinate();
-      Tp[1][j] = T->getPoint2()->getX2Coordinate();
-      Tp[2][j] = T->getPoint3()->getX2Coordinate();
-      j++;
-   }
-   if(m!=2)
-   {
-      Tp[0][j] = T->getPoint1()->getX3Coordinate();
-      Tp[1][j] = T->getPoint2()->getX3Coordinate();
-      Tp[2][j] = T->getPoint3()->getX3Coordinate();
-      j++;
-   }
-
-   return( InTri2D( Tp, pp ) );
-}
-
-char 	GbTriangularMesh3D::InTri2D( GbVector3D Tp[3], GbVector3D& pp )
-{
-   double area0, area1, area2;
-
-   /* compute three AreaSign() values for pp w.r.t. each edge of the face in 2D */
-   area0 = AreaSign( pp, Tp[0], Tp[1] );
-   area1 = AreaSign( pp, Tp[1], Tp[2] );
-   area2 = AreaSign( pp, Tp[2], Tp[0] );
- //  printf("area0=%f  area1=%f  area2=%f\n",area0,area1,area2);
-
-   if ( ( area0 == 0. ) && ( area1 > 0. ) && ( area2 > 0. ) ||
-      ( area1 == 0. ) && ( area0 > 0. ) && ( area2 > 0. ) ||
-      ( area2 == 0. ) && ( area0 > 0. ) && ( area1 > 0. ) ) 
-      return 'E';
- 
-   if ( ( area0 == 0. ) && ( area1 < 0. ) && ( area2 < 0. ) ||
-      ( area1 == 0. ) && ( area0 < 0. ) && ( area2 < 0. ) ||
-      ( area2 == 0. ) && ( area0 < 0. ) && ( area1 < 0. ) )
-      return 'E';                 
-
-   if ( ( area0 >  0. ) && ( area1 > 0. ) && ( area2 > 0. ) ||
-      ( area0 <  0. ) && ( area1 < 0. ) && ( area2 < 0. ) )
-      return 'F';
-
-   if ( ( area0 == 0.0 ) && ( area1 == 0.0 ) && ( area2 == 0.0 ) )
-      fprintf( stderr, "Error in InTriD\n" ), exit(EXIT_FAILURE);
-
-   if ( ( area0 == 0. ) && ( area1 == 0. ) ||
-      ( area0 == 0. ) && ( area2 == 0. ) ||
-      ( area1 == 0. ) && ( area2 == 0. ) )
-      return 'V';
-
-   else  
-      return '0';  
-}
-
-double GbTriangularMesh3D::AreaSign( GbVector3D& a, GbVector3D& b, GbVector3D& c )  
-{
-   double area2;
-
-   area2 = ( b[0] - a[0] ) * ( c[1] - a[1] ) -
-           ( c[0] - a[0] ) * ( b[1] - a[1] );
-
-   return area2;
-   /* The area should be an integer. */
-   if      ( area2 >  0.5 ) return  1;
-   else if ( area2 < -0.5 ) return -1;
-   else                     return  0;
-}                            
-
-char    GbTriangularMesh3D::SegTriInt( GbTriangle3D* T, GbVector3D& q, GbVector3D& r, GbVector3D& p )
-{
-   int code = '?';
-   int m = -1;
-
-   code = SegPlaneInt( T, q, r, p, &m );
-   //  printf("SegPlaneInt code=%c, m=%d; p=(%lf,%lf,%lf)\n", code,m,p[0],p[1],p[2]);
-
-   if      ( code == '0')  return '0';
-   else if ( code == 'q')  return InTri3D( T, m, q );
-   else if ( code == 'r')  return InTri3D( T, m, r );
-   else if ( code == 'p' ) return InPlane( T, m, q, r, p );
-   else if ( code == '1' ) return SegTriCross( T, q, r );
-   else /* Error */        return code;
-}
-
-char	GbTriangularMesh3D::InPlane( GbTriangle3D* T, int m, GbVector3D& q, GbVector3D& r, GbVector3D& p)
-{
-  // cout<<"inplane\n";
-   /* NOT IMPLEMENTED */
-   return 'p';
-}
-
-/*---------------------------------------------------------------------
-The signed volumes of three tetrahedra are computed, determined
-by the segment qr, and each edge of the triangle.  
-Returns a char:
-'v': the open segment includes a vertex of T.
-'e': the open segment includes a point in the relative interior of an edge
-of T.
-'f': the open segment includes a point in the relative interior of a face
-of T.
-'0': the open segment does not intersect triangle T.
----------------------------------------------------------------------*/
-
-char GbTriangularMesh3D::SegTriCross( GbTriangle3D* T, GbVector3D& q, GbVector3D& r )
-{
-  // cout<<"SegTriCross\n";
-   double vol0, vol1, vol2;
-   GbVector3D vert0(T->getPoint1());
-   GbVector3D vert1(T->getPoint2());
-   GbVector3D vert2(T->getPoint3());
-
-   vol0 = VolumeSign( q, vert0, vert1, r ); 
-   vol1 = VolumeSign( q, vert1, vert2, r ); 
-   vol2 = VolumeSign( q, vert2, vert0, r );
-
-   //  printf( "SegTriCross:  vol0 = %d; vol1 = %d; vol2 = %d\n", vol0, vol1, vol2 ); 
-
-   /* Same sign: segment intersects interior of triangle. */
-   if ( ( ( vol0 > 0. ) && ( vol1 > 0. ) && ( vol2 > 0. ) ) || 
-      ( ( vol0 < 0. ) && ( vol1 < 0. ) && ( vol2 < 0. ) ) )
-   //if ( ( UbMath::greater(vol0, 0. ) && UbMath::greater(vol1 , 0. ) && UbMath::greater(vol2 , 0. ) ) || 
-   //     ( UbMath::less(vol0, 0. ) && UbMath::less(vol1, 0. ) && UbMath::less(vol2, 0. ) ) )
-   {
-      return 'f';
-   }
-
-   /* Opposite sign: no intersection between segment and triangle */
-   if ( ( ( vol0 > 0. ) || ( vol1 > 0. ) || ( vol2 > 0. ) ) &&
-      ( ( vol0 < 0. ) || ( vol1 < 0. ) || ( vol2 < 0. ) ) )
-   {
-      return '0';
-   }
-   else if ( ( vol0 == 0.0 ) && ( vol1 == 0.0 ) && ( vol2 == 0.0 ) )
-   {
-      std::cout<<vol0<<" "<<vol1<<" "<<vol2<<std::endl;
-      fprintf( stderr, "Error 1 in SegTriCross\n" ), exit(EXIT_FAILURE);
-   }
-
-   /* Two zeros: segment intersects vertex. */
-   else if ( ( ( vol0 == 0. ) && ( vol1 == 0. ) ) || 
-      ( ( vol0 == 0. ) && ( vol2 == 0. ) ) || 
-      ( ( vol1 == 0. ) && ( vol2 == 0. ) ) )
-   {
-      return 'v';
-   }
-
-   /* One zero: segment intersects edge. */
-   else if ( ( vol0 == 0. ) || ( vol1 == 0. ) || ( vol2 == 0. ) )
-   {
-      return 'e';
-   }
-   
-   throw UbException(UB_EXARGS,"fprintf( stderr, Error 2 in SegTriCross\n ), exit(EXIT_FAILURE);");
-}
-
-
-double GbTriangularMesh3D::VolumeSign( GbVector3D& a, GbVector3D& b, GbVector3D& c, GbVector3D& d )
-{ 
-   double vol;
-   double ax, ay, az, bx, by, bz, cx, cy, cz, dx, dy, dz;
-   double bxdx, bydy, bzdz, cxdx, cydy, czdz;
-
-   ax = a[0];   ay = a[1];   az = a[2];
-   bx = b[0];   by = b[1];   bz = b[2];
-   cx = c[0];   cy = c[1];   cz = c[2];
-   dx = d[0];   dy = d[1];   dz = d[2];
-
-   bxdx=bx-dx;
-   bydy=by-dy;
-   bzdz=bz-dz;
-   cxdx=cx-dx;
-   cydy=cy-dy;
-   czdz=cz-dz;
-   vol = (az-dz) * (bxdx*cydy - bydy*cxdx)
-      + (ay-dy) * (bzdz*cxdx - bxdx*czdz)
-      + (ax-dx) * (bydy*czdz - bzdz*cydy);
-
-   //std::cout<< vol<<std::endl;
-   return vol;
-
-
-   /* The volume should be an integer. */
-   if      ( vol > 0.5 )   return  1;
-   else if ( vol < -0.5 )  return -1;
-   else                    return  0;
-}
-
-bool GbTriangularMesh3D::BoxTest(GbTriangle3D* triangle, GbVector3D& PointQ, GbVector3D& PointR)
-{
-   double minX1 = triangle->getX1Minimum();
-   double minX2 = triangle->getX2Minimum();
-   double minX3 = triangle->getX3Minimum();
-
-   double maxX1 = triangle->getX1Maximum();
-   double maxX2 = triangle->getX2Maximum();
-   double maxX3 = triangle->getX3Maximum();
-
-   if((PointQ.X1() < minX1) && (PointR.X1() < minX1)) return false;
-   if((PointQ.X2() < minX2) && (PointR.X2() < minX2)) return false;
-   if((PointQ.X3() < minX3) && (PointR.X3() < minX3)) return false;
-   if((PointQ.X1() > maxX1) && (PointR.X1() > maxX1)) return false;
-   if((PointQ.X2() > maxX2) && (PointR.X2() > maxX2)) return false;
-   if((PointQ.X3() > maxX3) && (PointR.X3() > maxX3)) return false;
-
-   return true;
-}
-
+#include <numerics/geometry3d/GbTriangularMesh3D.h>
+#include <numerics/geometry3d/creator/GbTriangularMesh3DCreator.h>
+
+#include <map>
+
+#include <basics/utilities/UbMath.h>
+
+#include <numerics/geometry3d/GbHalfSpace3D.h>
+#include <numerics/geometry3d/GbCuboid3D.h>
+#include <numerics/geometry3d/CoordinateTransformation3D.h>
+                         
+using namespace std;
+
+GbTriangularMesh3D::GbTriangularMesh3D() : GbObject3D()
+{
+   this->setName("new GbMesh");
+   this->nodes     = new vector<GbPoint3D*>;           
+   this->triangles = new vector<GbTriangle3D*>;
+   this->edges     = new vector<GbLine3D*>;
+   
+   this->pointinobjecttest = RAYCROSSING;
+
+   this->consistent = false;                                 
+   x1min = x1max = x2min = x2max = x3min = x3max = 0.0;
+}
+/*=============================================================================================*/
+GbTriangularMesh3D::GbTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbTriangle3D*> *triangles) : GbObject3D()
+{
+   if(name.size()==0 ) throw UbException(UB_EXARGS,"no name specified");
+   if(!nodes         ) throw UbException(UB_EXARGS,"no nodes specified");
+   if(!triangles     ) throw UbException(UB_EXARGS,"no triangles specified");
+                                                         
+   this->setName(name);
+   this->nodes      = nodes;           
+   this->triangles  = triangles;     
+   this->edges      = new vector<GbLine3D*>;
+   this->pointinobjecttest = RAYCROSSING;
+
+   this->consistent = false;                                 
+   x1min = x1max = x2min = x2max = x3min = x3max = 0.0;
+}
+/*=============================================================================================*/
+GbTriangularMesh3D::GbTriangularMesh3D(string name, vector<GbTriangle3D*> *tris) : GbObject3D()
+{
+   cout<<"Das Teil erzeugt seinen KnotenVector aus den Dreiecken ...\n Es sollte deleteRedundantNodes() aufgerufen werden \n";
+   if(name.size()==0 ) throw UbException(UB_EXARGS,"no name specified");
+   if(!tris          ) throw UbException(UB_EXARGS,"no triangles specified");
+
+   vector<GbPoint3D*> *points = new vector<GbPoint3D*>;
+   this->triangles = new vector<GbTriangle3D*>;
+   GbPoint3D* p1 = NULL;
+   GbPoint3D* p2 = NULL;
+   GbPoint3D* p3 = NULL;
+   for(int u=0;u<(int)tris->size();u++)
+   {
+      if(UbMath::zero((*tris)[u]->getArea()))
+      {
+         (*tris)[u]->finalize();
+         delete (*tris)[u];
+         (*tris)[u] = NULL;
+         continue;
+      }
+      this->triangles->push_back((*tris)[u]);
+      p1 = (*tris)[u]->getPoint1();
+      p2 = (*tris)[u]->getPoint2();
+      p3 = (*tris)[u]->getPoint3();
+      points->push_back(p1);
+      points->push_back(p2);
+      points->push_back(p3);
+   }
+
+   this->setName(name);
+   this->nodes            = points; 
+   //this->triangles        = triangles;     
+   this->edges = new vector<GbLine3D*>;
+   this->edges->resize(0, NULL);
+   this->pointinobjecttest = RAYCROSSING;
+   
+   this->consistent       = false;                                 
+   x1min = x1max = x2min = x2max = x3min = x3max = 0.0;
+}
+/*=============================================================================================*/
+GbTriangularMesh3D::GbTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbLine3D*> *edges, vector<GbTriangle3D*> *triangles) : GbObject3D()
+{
+   if(name.size()==0) throw UbException(UB_EXARGS,"no name specified");
+   if(!nodes        ) throw UbException(UB_EXARGS,"no nodes specified");
+   if(!triangles    ) throw UbException(UB_EXARGS,"no triangles specified");
+   if(!edges        ) throw UbException(UB_EXARGS,"no edges specified");
+
+   this->setName(name);
+   this->nodes            = nodes;
+   this->edges            = edges;
+   this->triangles        = triangles;                   
+   this->pointinobjecttest = RAYCROSSING;
+
+   this->consistent = false;                                 
+   x1min = x1max = x2min = x2max = x3min = x3max = 0.0;
+}
+/*=============================================================================================*/
+GbTriangularMesh3D::~GbTriangularMesh3D()
+{
+	if( this->nodes )
+	{
+		for(unsigned u=0; u<nodes->size(); u++) delete (*nodes)[u];
+      delete nodes;
+	}
+	if(triangles)
+	{
+		for(unsigned u=0; u<triangles->size(); u++)	delete (*triangles)[u];
+      delete triangles;
+	}
+}
+/*======================================================================*/
+ObObjectCreator* GbTriangularMesh3D::getCreator()
+{
+   return GbTriangularMesh3DCreator::getInstance();
+}
+/*======================================================================*/
+void GbTriangularMesh3D::deleteRedundantNodes()
+{
+   std::map<GbPoint3D*,GbTriangle3D*> pointTriMap;
+   GbPoint3D* p1 = NULL;
+   GbPoint3D* p2 = NULL;
+   GbPoint3D* p3 = NULL;
+   GbTriangle3D* tri = NULL;
+
+   for(int u=0;u<(int)this->triangles->size();u++)
+   {
+      tri = (*this->triangles)[u];
+      p1 = tri->getPoint1();
+      p2 = tri->getPoint2();
+      p3 = tri->getPoint3();
+      pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p1,tri));
+      pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p2,tri));
+      pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p3,tri));
+   }
+
+   cout<<"Nodes before deleting redundant:"<<this->nodes->size()<<endl;
+   GbPoint3D* pA = NULL;
+   GbPoint3D* pB = NULL;
+   std::map<GbPoint3D*,GbTriangle3D*>::iterator mapIterator; 
+   for(int u=0;u<(int)this->nodes->size();u++)
+   {
+      //cout<<u<<" von "<<this->nodes->size()<<endl;
+      pA = (*this->nodes)[u];
+      if(pA==NULL) continue;
+      for(int w=u+1;w<(int)this->nodes->size();w++)
+      {
+      //   cout<<w<<" Wvon "<<this->nodes->size()<<endl;
+         pB = (*this->nodes)[w];
+         if(pB==NULL) continue;
+         if(pA->equals(pB))
+         {
+            //doppelter Knoten ...
+            mapIterator = pointTriMap.find(pB);
+            tri = dynamic_cast<GbTriangle3D*>(mapIterator->second);
+            if(!tri) throw UbException(UB_EXARGS,"triangle not found");
+            p1 = tri->getPoint1();
+            p2 = tri->getPoint2();
+            p3 = tri->getPoint3();
+            if(pB==p1) tri->setPoint(pA, 0);
+            else if(pB==p2) tri->setPoint(pA, 1);
+            else if(pB==p3) tri->setPoint(pA, 2);
+            else throw UbException(UB_EXARGS,"node should be there");
+            delete pB;
+            (*this->nodes)[w] = NULL;
+         }
+      }
+   }
+   vector<GbPoint3D*> *points = new vector<GbPoint3D*>;
+   for(int u=0;u<(int)this->nodes->size();u++)
+   {
+      pA = (*this->nodes)[u];
+      if(pA!=NULL) points->push_back(pA);
+   }
+   delete this->nodes;
+   this->nodes = points;
+   cout<<"Nodes after deleting redundant:"<<this->nodes->size()<<endl;   
+
+
+//nochmal kontrolle ...
+   pointTriMap.clear();
+   for(int u=0;u<(int)this->triangles->size();u++)
+   {
+      tri = (*this->triangles)[u];
+      p1 = tri->getPoint1();
+      p2 = tri->getPoint2();
+      p3 = tri->getPoint3();
+      pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p1,tri));
+      pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p2,tri));
+      pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p3,tri));
+   }
+   for(int u=0;u<(int)this->nodes->size();u++)
+   {
+      pA = (*this->nodes)[u];
+      if(pA==NULL) throw UbException(UB_EXARGS,"sollte kein NULL pointer sein ...");
+      mapIterator = pointTriMap.find(pA);
+      tri = dynamic_cast<GbTriangle3D*>(mapIterator->second);
+      if(!tri) throw UbException(UB_EXARGS,"triangle not found");
+   }
+}
+/*======================================================================*/
+void GbTriangularMesh3D::translate(const double& x1, const double& x2, const double& x3) 
+{
+   GbPoint3D* pt;
+   for(int u=0;u<(int)this->nodes->size();u++)
+   {
+      pt = (*nodes)[u];
+      pt->setX1(pt->getX1Coordinate()+x1);
+      pt->setX2(pt->getX2Coordinate()+x2);
+      pt->setX3(pt->getX3Coordinate()+x3);
+   }
+   this->consistent = false;
+}
+/*======================================================================*/
+void GbTriangularMesh3D::rotate(const double& alpha, const double& beta, const double& gamma)
+{
+   if(!this->consistent) this->calculateValues();
+   double a1 = this->getX1Centroid();
+   double a2 = this->getX2Centroid();
+   double a3 = this->getX3Centroid();
+   CoordinateTransformation3D trafoFor(a1, a2, a3, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0);
+   CoordinateTransformation3D trafoBack(a1, a2, a3, 1.0, 1.0, 1.0, alpha, beta, gamma);
+
+   vector<GbPoint3D*> points;
+   GbPoint3D* p1 = NULL;
+   GbPoint3D* p2 = NULL;
+   GbPoint3D* p3 = NULL;
+   for(int u=0;u<(int)this->triangles->size();u++)
+   {
+      p1 = (*triangles)[u]->getPoint1();
+      p2 = (*triangles)[u]->getPoint2();
+      p3 = (*triangles)[u]->getPoint3();
+      double p1x1 = trafoFor.transformForwardToX1Coordinate(p1->x1, p1->x2, p1->x3);
+      double p1x2 = trafoFor.transformForwardToX2Coordinate(p1->x1, p1->x2, p1->x3);
+      double p1x3 = trafoFor.transformForwardToX3Coordinate(p1->x1, p1->x2, p1->x3);
+      double p2x1 = trafoFor.transformForwardToX1Coordinate(p2->x1, p2->x2, p2->x3);
+      double p2x2 = trafoFor.transformForwardToX2Coordinate(p2->x1, p2->x2, p2->x3);
+      double p2x3 = trafoFor.transformForwardToX3Coordinate(p2->x1, p2->x2, p2->x3);
+      double p3x1 = trafoFor.transformForwardToX1Coordinate(p3->x1, p3->x2, p3->x3);
+      double p3x2 = trafoFor.transformForwardToX2Coordinate(p3->x1, p3->x2, p3->x3);
+      double p3x3 = trafoFor.transformForwardToX3Coordinate(p3->x1, p3->x2, p3->x3);
+      p1->x1 = trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3);
+      p1->x2 = trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3);
+      p1->x3 = trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3);
+      p2->x1 = trafoBack.transformBackwardToX1Coordinate(p2x1, p2x2, p2x3);
+      p2->x2 = trafoBack.transformBackwardToX2Coordinate(p2x1, p2x2, p2x3);
+      p2->x3 = trafoBack.transformBackwardToX3Coordinate(p2x1, p2x2, p2x3);
+      p3->x1 = trafoBack.transformBackwardToX1Coordinate(p3x1, p3x2, p3x3);
+      p3->x2 = trafoBack.transformBackwardToX2Coordinate(p3x1, p3x2, p3x3);
+      p3->x3 = trafoBack.transformBackwardToX3Coordinate(p3x1, p3x2, p3x3);
+   }
+   this->calculateValues();
+}
+/*======================================================================*/
+   /**
+    * Returns a string representation of this triangular mesh.
+    * @return a string representation of this triangular mesh
+    */
+string GbTriangularMesh3D::toString()
+{
+	stringstream ss;
+	ss<<"GbTriangularMesh3D[";
+	ss<<(int)this->triangles->size()<<"-Triangles, "<<(int)this->nodes->size()<<"-Nodes, "<<(int)this->edges->size()<<"-Edges"<<endl;
+	//ss<<"\""<<this->name<<", Area=sollt mal berechnet werden ;-)"<<"\"";
+   //ss<<", x1min="<<this->x1min;
+   //ss<<", x1max="<<this->x1max;
+   //ss<<", x2min="<<this->x2min;
+   //ss<<", x2max="<<this->x2max;
+   //ss<<", x3min="<<this->x3min;
+   //ss<<", x3max="<<this->x3max;
+   ss<<"]";
+   return(ss.str());
+}
+/**
+ * Returns the name of this triangular mesh.
+ * @return the name of this triangular mesh
+ */
+//string GbTriangularMesh3D::getName(){ return(this->name); }
+
+/**
+ * Returns the nodes of this triangular mesh.
+ * @return the nodes of this triangular mesh
+ */
+vector<GbPoint3D*>* GbTriangularMesh3D::getNodes()   {  return(this->nodes);   }
+/**
+ * Returns the triangles of this triangular mesh.
+ * @return the triangles of this triangular mesh
+ */
+vector<GbTriangle3D*>* GbTriangularMesh3D::getTriangles()  { return(this->triangles);  }
+/**
+ * Returns the center x1 coordinate of this triangular mesh.
+ * @return the center x1 coordinate of this triangular mesh
+ */
+double GbTriangularMesh3D::getX1Centroid()
+{
+   if(!this->consistent) this->calculateValues();
+   return(0.5*(this->x1min+this->x1max));
+}
+/**
+ * Returns the center x2 coordinate of this triangular mesh.
+ * @return the center x2 coordinate of this triangular mesh
+ */
+double GbTriangularMesh3D::getX2Centroid()
+{
+   if(!this->consistent) this->calculateValues();
+   return(0.5*(this->x2min+this->x2max));
+}
+/**
+* Returns the center x3 coordinate of this triangular mesh.
+	* @return the center x3 coordinate of this triangular mesh
+	*/
+double GbTriangularMesh3D::getX3Centroid()
+{
+	if(!this->consistent) this->calculateValues();
+	return(0.5*(this->x3min+this->x3max));
+}
+
+/**
+ * Returns the minimum x1 coordinate of this triangular mesh.
+ * @return the minimum x1 coordinate of this triangular mesh
+ */
+double GbTriangularMesh3D::getX1Minimum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x1min);
+}
+/**
+ * Returns the maximum x1 coordinate of this triangular mesh.
+ * @return the maximum x1 coordinate of this triangular mesh
+ */
+double GbTriangularMesh3D::getX1Maximum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x1max);
+}
+/**
+ * Returns the minimum x2 coordinate of this triangular mesh.
+ * @return the minimum x2 coordinate of this triangular mesh
+ */
+double GbTriangularMesh3D::getX2Minimum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x2min);
+}
+/**
+ * Returns the maximum x2 coordinate of this triangular mesh.
+ * @return the maximum x2 coordinate of this triangular mesh
+ */
+double GbTriangularMesh3D::getX2Maximum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x2max);
+}
+/**
+ * Returns the minimum x3 coordinate of this triangular mesh.
+ * @return the minimum x3 coordinate of this triangular mesh
+ */
+double GbTriangularMesh3D::getX3Minimum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x3min);
+}
+/**
+ * Returns the maximum x3 coordinate of this triangular mesh.
+ * @return the maximum x3 coordinate of this triangular mesh
+ */
+double GbTriangularMesh3D::getX3Maximum()
+{
+   if(!this->consistent) this->calculateValues();
+   return(this->x3max);
+}
+
+void GbTriangularMesh3D::calculateValues()
+{
+   double x1, x2, x3;
+
+	this->x1min = (*this->nodes)[0]->getX1Coordinate();
+   this->x1max = (*this->nodes)[0]->getX1Coordinate();
+   this->x2min = (*this->nodes)[0]->getX2Coordinate();
+   this->x2max = (*this->nodes)[0]->getX2Coordinate();
+   this->x3min = (*this->nodes)[0]->getX3Coordinate();
+   this->x3max = (*this->nodes)[0]->getX3Coordinate();
+
+   for(int i=1; i<(int)this->nodes->size(); i++)
+   {
+		x1 = (*this->nodes)[i]->getX1Coordinate();
+		x2 = (*this->nodes)[i]->getX2Coordinate();
+		x3 = (*this->nodes)[i]->getX3Coordinate();
+		if(x1 < this->x1min) this->x1min = x1;
+		if(x1 > this->x1max) this->x1max = x1;
+		if(x2 < this->x2min) this->x2min = x2;
+		if(x2 > this->x2max) this->x2max = x2;
+		if(x3 < this->x3min) this->x3min = x3;
+		if(x3 > this->x3max) this->x3max = x3;
+   }
+   this->consistent = true;
+}
+
+/**
+ * Returns the total area of this triangular mesh.
+ * @return the total area of this triangular mesh
+ */
+double GbTriangularMesh3D::getArea()
+{
+   double area = 0.0;
+   for(int i=0; i<(int)this->triangles->size(); i++) area += (*this->triangles)[i]->getArea();
+   return(area);
+}
+/**
+ * Returns the total volume of this triangular mesh.
+ * @return the total volume of this triangular mesh
+  */
+double GbTriangularMesh3D::getVolume()
+{
+   GbTriangle3D* triangle;
+   GbPoint3D* p1;
+   GbPoint3D* p2;
+   GbPoint3D* p3;
+
+   double x1,x2,x3,y1,y2,y3,z1,z2,z3;
+   double G3i;
+   double volume = 0.0;
+   int size = (int)this->triangles->size();
+   for(int u=0; u<size;u++)
+   {
+      triangle = (*this->triangles)[u];
+      p1 = triangle->getPoint1();
+      p2 = triangle->getPoint2();
+      p3 = triangle->getPoint3();
+      x1 = p1->getX1Coordinate(); y1 = p1->getX2Coordinate(); z1 = p1->getX3Coordinate();
+      x2 = p2->getX1Coordinate(); y2 = p2->getX2Coordinate(); z2 = p2->getX3Coordinate();
+      x3 = p3->getX1Coordinate(); y3 = p3->getX2Coordinate(); z3 = p3->getX3Coordinate();
+      G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
+      volume = volume+G3i/6.0;
+   }
+   return volume;
+}
+/*===============================================*/
+UbTupleDouble3 GbTriangularMesh3D::calculateCenterOfGravity()
+{
+   GbTriangle3D* triangle;
+   GbPoint3D* p1;
+   GbPoint3D* p2;
+   GbPoint3D* p3;
+
+   double x1,x2,x3,y1,y2,y3,z1,z2,z3;
+   double G3i;
+   double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0;
+   double volume = 0.0;
+   int size = (int)this->triangles->size();
+   for(int u=0; u<size;u++)
+   {
+      triangle = (*this->triangles)[u];
+      p1 = triangle->getPoint1();
+      p2 = triangle->getPoint2();
+      p3 = triangle->getPoint3();
+      x1 = p1->getX1Coordinate(); y1 = p1->getX2Coordinate(); z1 = p1->getX3Coordinate();
+      x2 = p2->getX1Coordinate(); y2 = p2->getX2Coordinate(); z2 = p2->getX3Coordinate();
+      x3 = p3->getX1Coordinate(); y3 = p3->getX2Coordinate(); z3 = p3->getX3Coordinate();
+      G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
+      volume = volume+G3i/6.0;
+      rSP1 = rSP1+G3i*(x1+x2+x3);
+      rSP2 = rSP2+G3i*(y1+y2+y3);
+      rSP3 = rSP3+G3i*(z1+z2+z3);
+   }
+   rSP1 = rSP1/(24.0*volume);
+   rSP2 = rSP2/(24.0*volume);
+   rSP3 = rSP3/(24.0*volume);
+
+   return UbTupleDouble3(rSP1, rSP2, rSP3);
+}
+/*===============================================*/
+UbTupleDouble6 GbTriangularMesh3D::calculateMomentOfInertia(double rhoP)
+{
+   GbTriangle3D* triangle;
+   GbPoint3D* p1;
+   GbPoint3D* p2;
+   GbPoint3D* p3;
+   
+   double x1,x2,x3,y1,y2,y3,z1,z2,z3;
+   double G3i;
+   double xx,yy,zz,xy,yz,zx;
+   double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0;
+   double volume = 0.0;
+   double top11 = 0.0;double top22 = 0.0;double top33 = 0.0;
+   double top12 = 0.0;double top23 = 0.0;double top13 = 0.0;
+   int size = (int)this->triangles->size();
+   for(int u=0; u<size;u++)
+   {
+      triangle = (*this->triangles)[u];
+      p1 = triangle->getPoint1();
+      p2 = triangle->getPoint2();
+      p3 = triangle->getPoint3();
+      x1 = p1->getX1Coordinate(); y1 = p1->getX2Coordinate(); z1 = p1->getX3Coordinate();
+      x2 = p2->getX1Coordinate(); y2 = p2->getX2Coordinate(); z2 = p2->getX3Coordinate();
+      x3 = p3->getX1Coordinate(); y3 = p3->getX2Coordinate(); z3 = p3->getX3Coordinate();
+      G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
+      volume = volume+G3i/6.0;
+      rSP1 = rSP1+G3i*(x1+x2+x3);
+      rSP2 = rSP2+G3i*(y1+y2+y3);
+      rSP3 = rSP3+G3i*(z1+z2+z3);
+   }
+   rSP1 = rSP1/(24.0*volume);
+   rSP2 = rSP2/(24.0*volume);
+   rSP3 = rSP3/(24.0*volume);
+
+   double x1s = 0.0;//rSP1;//0.0;//
+   double x2s = 0.0;//rSP2;//0.0;//
+   double x3s = 0.0;//rSP3;//0.0;//
+
+   for(int u=0; u<size;u++)
+   {
+      triangle = (*this->triangles)[u];
+      p1 = triangle->getPoint1();
+      p2 = triangle->getPoint2();
+      p3 = triangle->getPoint3();
+      x1 = p1->getX1Coordinate()-x1s; 
+      y1 = p1->getX2Coordinate()-x2s; 
+      z1 = p1->getX3Coordinate()-x3s;
+      x2 = p2->getX1Coordinate()-x1s; 
+      y2 = p2->getX2Coordinate()-x2s; 
+      z2 = p2->getX3Coordinate()-x3s;
+      x3 = p3->getX1Coordinate()-x1s; 
+      y3 = p3->getX2Coordinate()-x2s; 
+      z3 = p3->getX3Coordinate()-x3s;
+      G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3);
+      //rSP1 = rSP1+G3i*(x1+x2+x3)/(24.0*volume);
+      //rSP2 = rSP2+G3i*(y1+y2+y3)/(24.0*volume);
+      //rSP3 = rSP3+G3i*(z1+z2+z3)/(24.0*volume);
+      xx = x1*x1+x2*x2+x3*x3+x1*x2+x2*x3+x3*x1;
+      yy = y1*y1+y2*y2+y3*y3+y1*y2+y2*y3+y3*y1;
+      zz = z1*z1+z2*z2+z3*z3+z1*z2+z2*z3+z3*z1;
+      top11 = top11+(yy+zz)*rhoP*G3i/60.;
+      top22 = top22+(xx+zz)*rhoP*G3i/60.;
+      top33 = top33+(yy+xx)*rhoP*G3i/60.;
+      xy = 2.0*(x1*y1+x2*y2+x3*y3)+x2*y3+x3*y1+x1*y2+x3*y2+x1*y3+x2*y1;
+      yz = 2.0*(y1*z1+y2*z2+y3*z3)+y2*z3+y3*z1+y1*z2+y3*z2+y1*z3+y2*z1;
+      zx = 2.0*(z1*x1+z2*x2+z3*x3)+z2*x3+z3*x1+z1*x2+z3*x2+z1*x3+z2*x1;
+      top12 = top12-xy*rhoP*G3i/120.;
+      top23 = top23-yz*rhoP*G3i/120.;
+      top13 = top13-zx*rhoP*G3i/120.;
+   }
+   //Satz von Steiner ...
+   top11 = top11-rhoP*volume*(rSP2*rSP2+rSP3+rSP3);
+   top22 = top22-rhoP*volume*(rSP3*rSP3+rSP1*rSP1);
+   top33 = top33-rhoP*volume*(rSP1*rSP1+rSP2*rSP2);
+   top12 = top12+rhoP*volume*rSP1*rSP2;
+   top23 = top23+rhoP*volume*rSP2*rSP3;
+   top13 = top13+rhoP*volume*rSP3*rSP1;
+   
+   cout<<"Volume:"<<volume<<"\n Traegheitsmomente:\n";
+   cout<<" top11:"<<top11<<" top22:"<<top22<<" top33:"<<top33<<endl;
+   cout<<" top12:"<<top12<<" top23:"<<top23<<" top13:"<<top13<<endl;
+
+   return UbTupleDouble6(top11,top22,top33,top12,top23,top13);
+}
+
+ /**
+  * Returns the volume of this triangular mesh within the specified rectangle.
+  * @param p1x1 the 1st x1 coordinate of the rectangle
+  * @param p1x2 the 1st x2 coordinate of the rectangle
+  * @param p2x1 the 2nd x1 coordinate of the rectangle
+  * @param p2x2 the 2nd x2 coordinate of the rectangle
+  * @return the volume of this triangular mesh within the specified rectangle
+  * @exception NullPointerException if no triangles are found within the specified rectangle
+  */
+double GbTriangularMesh3D::getVolumeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) 
+{
+	throw UbException(UB_EXARGS,"not yet implemented");
+  //    GbPolygon2D polygon;
+  //    double      volume = 0.0;
+  //    double      area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2));
+  //    double      area2 = 0.0;
+  //    double      t1min, t1max, t2min, t2max;
+  //    double      x1, x2;
+  //    boolean     f = false;
+
+  //    for(int i=0; i<this.triangles.length; i++)
+  //    {
+		//	t1min = this.triangles[i].getX1Minimum();
+		//	t1max = this.triangles[i].getX1Maximum();
+		//	if(GbSystem.less2(t1min, t1max, p1x1, p2x1))    continue;
+		//	if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue;
+
+		//	t2min = this.triangles[i].getX2Minimum();
+		//	t2max = this.triangles[i].getX2Maximum();
+		//	if(GbSystem.less2(t2min, t2max, p1x2, p2x2))    continue;
+		//	if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue;
+
+		//	if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) &&
+		//		GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2))
+		//	{
+		//		volume += this.triangles[i].getVolume();
+		//		area2  += this.triangles[i].getArea();
+		//		f       = true;
+		//	}
+		//	else
+		//	{
+		//		polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2);
+
+		//		if(polygon != null && polygon.size() > 2)
+		//		{
+		//			try
+		//			{
+		//				x1      = polygon.getX1Centroid();
+		//				x2      = polygon.getX2Centroid();
+		//				volume += this.triangles[i].getX3Coordinate(x1, x2) * Math.abs(polygon.getArea());
+		//				area2  += Math.abs(polygon.getArea());
+		//				f       = true;
+		//			}
+		//			catch(Exception e){}
+		//		}
+		//	}
+		//	if(GbSystem.greaterEqual(area2, area1)) break;
+		//}
+  //    if(f) return(volume);
+  //    else  throw new NullPointerException();
+}
+
+/**
+ * Returns the triangles of this triangular mesh located within the specified rectangle (may be an empty array).
+ * @param p1x1 the 1st x1 coordinate of the rectangle
+ * @param p1x2 the 1st x2 coordinate of the rectangle
+ * @param p2x1 the 2nd x1 coordinate of the rectangle
+ * @param p2x2 the 2nd x2 coordinate of the rectangle
+ * @return the triangles of this triangular mesh located within the specified rectangle
+ */
+vector<GbTriangle3D*>* GbTriangularMesh3D::getTrianglesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2)
+{
+	throw UbException(UB_EXARGS,"not yet implemented");
+  //    QbList      triangleList = new QbList(GbTriangle3D.class);
+  //    GbPolygon2D polygon;
+  //    double      t1min, t1max, t2min, t2max;
+  //    double      area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2));
+  //    double      area2 = 0.0;
+
+  //    for(int i=0; i<this.triangles.length; i++)
+  //    {
+		//	t1min = this.triangles[i].getX1Minimum();
+		//	t1max = this.triangles[i].getX1Maximum();
+		//	if(GbSystem.less2(t1min, t1max, p1x1, p2x1))    continue;
+		//	if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue;
+
+		//	t2min = this.triangles[i].getX2Minimum();
+		//	t2max = this.triangles[i].getX2Maximum();
+		//	if(GbSystem.less2(t2min, t2max, p1x2, p2x2))    continue;
+		//	if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue;
+
+		//	if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) &&
+		//		GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2))
+		//	{
+		//		try { triangleList.append(this.triangles[i]); } catch(Exception e){}
+		//		area2 += this.triangles[i].getArea();
+		//	}
+		//	else
+		//	{
+		//		polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2);
+		//		if(polygon != null && polygon.size() > 2)
+		//		{
+		//			try { triangleList.append(this.triangles[i]); } catch(Exception e){}
+		//			area2 += Math.abs(polygon.getArea());
+		//		}
+		//	}
+		//	if(GbSystem.greaterEqual(area2, area1)) break;
+		//}
+  //    return((GbTriangle3D[])triangleList.getObjectArray());
+}
+/**
+ * Returns the nodes of this triangular mesh located within the specified rectangle (may be an empty array).
+ * @param p1x1 the 1st x1 coordinate of the rectangle
+ * @param p1x2 the 1st x2 coordinate of the rectangle
+ * @param p2x1 the 2nd x1 coordinate of the rectangle
+ * @param p2x2 the 2nd x2 coordinate of the rectangle
+ * @return the nodes of this triangular mesh located within the specified rectangle
+ */
+vector<GbPoint3D*>* GbTriangularMesh3D::getNodesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2)
+{
+	throw UbException(UB_EXARGS,"not implemented");
+//   QbList nodeList = new QbList(GbPoint3D.class);
+
+   //   for(int i=0; i<this.edges.length; i++)
+   //   {
+			//if(GbSystem.inClosedInterval(this.nodes[i].getX1Coordinate(), p1x1, p2x1) && GbSystem.inClosedInterval(this.nodes[i].getX2Coordinate(), p1x2, p2x2))
+			//{
+			//	try { nodeList.append(this.nodes[i]); } catch(Exception e){}
+			//}
+   //   }
+   //   return((GbPoint3D[])nodeList.getObjectArray());
+}
+
+/**
+ * Returns the difference of maximum and minimum x3 coordinates
+ * of this triangular mesh within the specified rectangle.
+ * @param p1x1 the 1st x1 coordinate of the rectangle
+ * @param p1x2 the 1st x2 coordinate of the rectangle
+ * @param p2x1 the 2nd x1 coordinate of the rectangle
+ * @param p2x2 the 2nd x2 coordinate of the rectangle
+ * @return the difference of maximum and minimum x3 coordinates of this triangular mesh within the specified rectangle
+ * @exception NullPointerException if no triangles are found within the specified rectangle
+ */
+double GbTriangularMesh3D::getX3RangeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) 
+{
+	throw UbException(UB_EXARGS,"not implemented");
+ //     GbPolygon3D polygon;
+ //     boolean     f     = false;
+ //     double      x3min = 0.0;
+ //     double      x3max = 0.0;
+ //     double      t1min, t1max, t2min, t2max;
+ //     double      area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2));
+ //     double      area2 = 0.0;
+
+ //     for(int i=0; i<this.triangles.length; i++)
+ //     {
+	// t1min = this.triangles[i].getX1Minimum();
+	// t1max = this.triangles[i].getX1Maximum();
+	// if(GbSystem.less2(t1min, t1max, p1x1, p2x1))    continue;
+	// if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue;
+
+	// t2min = this.triangles[i].getX2Minimum();
+	// t2max = this.triangles[i].getX2Maximum();
+	// if(GbSystem.less2(t2min, t2max, p1x2, p2x2))    continue;
+	// if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue;
+
+	// if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) &&
+	//    GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2))
+	// {
+	//    if(f)
+	//    {
+	//       if(this.triangles[i].getX3Minimum() < x3min) x3min = this.triangles[i].getX3Minimum();
+	//       if(this.triangles[i].getX3Maximum() > x3max) x3max = this.triangles[i].getX3Maximum();
+	//    }
+	//    else
+	//    {
+	//       x3min = this.triangles[i].getX3Minimum();
+	//       x3max = this.triangles[i].getX3Maximum();
+	//       f     = true;
+	//    }
+	//    area2 += this.triangles[i].getArea();
+	//}
+	// else
+	// {
+	//    polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2);
+
+	//    if(polygon != null && polygon.size() > 2)
+	//    {
+	//       if(f)
+	//       {
+	//          if(polygon.getX3Minimum() < x3min) x3min = polygon.getX3Minimum();
+	//          if(polygon.getX3Maximum() > x3max) x3max = polygon.getX3Maximum();
+	//       }
+	//       else
+	//       {
+	//          x3min = polygon.getX3Minimum();
+	//          x3max = polygon.getX3Maximum();
+	//          f     = true;
+	//       }
+	//       area2 += Math.abs(polygon.getArea());
+	//    }
+	// }
+	// if(GbSystem.greaterEqual(area2, area1)) break;
+ //     }
+ //     if(f) return(x3max-x3min);
+ //     else  throw new NullPointerException();
+}
+/**
+ * Returns the minimum x3 coordinates of this triangular mesh within the specified rectangle.
+ * @param p1x1 the 1st x1 coordinate of the rectangle
+ * @param p1x2 the 1st x2 coordinate of the rectangle
+ * @param p2x1 the 2nd x1 coordinate of the rectangle
+ * @param p2x2 the 2nd x2 coordinate of the rectangle
+ * @return the minimum x3 coordinates of this triangular mesh within the specified rectangle
+ * @exception NullPointerException if no triangles are found within the specified rectangle
+ */
+double GbTriangularMesh3D::getX3MinimumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) 
+{
+	throw UbException(UB_EXARGS,"not implemented");
+  //    GbPolygon3D polygon;
+  //    boolean     f     = false;
+  //    double      x3min = 0.0;
+  //    double      t1min, t1max, t2min, t2max;
+  //    double      area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2));
+  //    double      area2 = 0.0;
+
+  //    for(int i=0; i<this.triangles.length; i++)
+  //    {
+	 //t1min = this.triangles[i].getX1Minimum();
+	 //t1max = this.triangles[i].getX1Maximum();
+	 //if(GbSystem.less2(t1min, t1max, p1x1, p2x1))    continue;
+	 //if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue;
+
+	 //t2min = this.triangles[i].getX2Minimum();
+	 //t2max = this.triangles[i].getX2Maximum();
+	 //if(GbSystem.less2(t2min, t2max, p1x2, p2x2))    continue;
+	 //if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue;
+
+	 //if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) &&
+	 //   GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2))
+	 //{
+	 //   if(f)
+	 //   {
+	 //      if(this.triangles[i].getX3Minimum() < x3min) x3min = this.triangles[i].getX3Minimum();
+	 //   }
+	 //   else
+	 //   {
+	 //      x3min = this.triangles[i].getX3Minimum();
+	 //      f     = true;
+	 //   }
+	 //   area2 += this.triangles[i].getArea();
+	 //}
+	 //else
+	 //{
+	 //   polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2);
+
+	 //   if(polygon != null && polygon.size() > 2)
+	 //   {
+	 //      if(f)
+	 //      {
+	 //         if(polygon.getX3Minimum() < x3min) x3min = polygon.getX3Minimum();
+	 //      }
+	 //      else
+	 //      {
+	 //         x3min = polygon.getX3Minimum();
+	 //         f     = true;
+	 //      }
+	 //      area2 += Math.abs(polygon.getArea());
+	 //   }
+	 //}
+	 //if(GbSystem.greaterEqual(area2, area1)) break;
+  //    }
+  //    if(f) return(x3min);
+  //    else  throw new NullPointerException();
+}
+/**
+ * Returns the maximum x3 coordinates of this triangular mesh within the specified rectangle.
+ * @param p1x1 the 1st x1 coordinate of the rectangle
+ * @param p1x2 the 1st x2 coordinate of the rectangle
+ * @param p2x1 the 2nd x1 coordinate of the rectangle
+ * @param p2x2 the 2nd x2 coordinate of the rectangle
+ * @return the maximum x3 coordinates of this triangular mesh within the specified rectangle
+ * @exception NullPointerException if no triangles are found within the specified rectangle
+ */
+double GbTriangularMesh3D::getX3MaximumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) 
+{
+   throw UbException(UB_EXARGS,"not implemented");
+  //    GbPolygon3D polygon;
+  //    boolean     f     = false;
+  //    double      x3max = 0.0;
+  //    double      t1min, t1max, t2min, t2max;
+  //    double      area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2));
+  //    double      area2 = 0.0;
+
+  //    for(int i=0; i<this.triangles.length; i++)
+  //    {
+	 //t1min = this.triangles[i].getX1Minimum();
+	 //t1max = this.triangles[i].getX1Maximum();
+	 //if(GbSystem.less2(t1min, t1max, p1x1, p2x1))    continue;
+	 //if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue;
+
+	 //t2min = this.triangles[i].getX2Minimum();
+	 //t2max = this.triangles[i].getX2Maximum();
+	 //if(GbSystem.less2(t2min, t2max, p1x2, p2x2))    continue;
+	 //if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue;
+
+	 //if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) &&
+	 //   GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2))
+	 //{
+	 //   if(f)
+	 //   {
+	 //      if(this.triangles[i].getX3Maximum() < x3max) x3max = this.triangles[i].getX3Maximum();
+	 //   }
+	 //   else
+	 //   {
+	 //      x3max = this.triangles[i].getX3Maximum();
+	 //      f     = true;
+	 //   }
+	 //   area2 += this.triangles[i].getArea();
+	 //}
+	 //else
+	 //{
+	 //   polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2);
+
+	 //   if(polygon != null && polygon.size() > 2)
+	 //   {
+	 //      if(f)
+	 //      {
+	 //         if(polygon.getX3Maximum() < x3max) x3max = polygon.getX3Maximum();
+	 //      }
+	 //      else
+	 //      {
+	 //         x3max = polygon.getX3Maximum();
+	 //         f     = true;
+	 //      }
+	 //      area2 += Math.abs(polygon.getArea());
+	 //   }
+	 //}
+	 //if(GbSystem.greaterEqual(area2, area1)) break;
+  //    }
+  //    if(f) return(x3max);
+  //    else  throw new NullPointerException();
+}
+/*======================================================================*/
+vector<GbTriangle3D*> GbTriangularMesh3D::getSurfaceTriangleSet()
+{
+   vector<GbTriangle3D*> tris;
+   GbTriangle3D* triangle;
+   GbPoint3D* p1;
+   GbPoint3D* p2;
+   GbPoint3D* p3;
+   int size = (int)this->triangles->size();
+   for(int u=0; u<size;u++)
+   {
+      triangle = (*this->triangles)[u];
+      p1 = new GbPoint3D(triangle->getPoint1());
+      p2 = new GbPoint3D(triangle->getPoint2());
+      p3 = new GbPoint3D(triangle->getPoint3());
+      tris.push_back(new GbTriangle3D(p1, p2, p3));
+   }
+   return tris;
+}
+/*======================================================================*/
+/*
+* Function to determine if the point is inside the polyhedron defined as a 3D object
+* using the Halfspace algorithm
+* @param xp the x-coordinate of the point
+* @param yp the y-coordinate of the point
+* @param zp the z-coordinate of the point
+* @return true if point is inside else return false
+*/
+bool GbTriangularMesh3D::isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp)
+{ 
+   vector<GbTriangle3D*> *Triangles = this->triangles;
+   int Trianglesize = (int)Triangles->size();
+   //GbPoint3D Point(xp,yp,zp);
+   for (int i=0; i<Trianglesize; i++)
+   {
+      //GbPoint3D* point1 = (*Triangles)[i]->getPoint1();
+      //GbPoint3D* point2 = (*Triangles)[i]->getPoint2();
+      //GbPoint3D* point3 = (*Triangles)[i]->getPoint3();
+
+      //GbHalfSpace3D halfspace(point1, point2, point3);
+      GbHalfSpace3D halfspace((*Triangles)[i]);
+      if (halfspace.ptInside(xp,yp,zp)) return false;
+   }
+   return true;
+}
+/*======================================================================*/
+bool GbTriangularMesh3D::isPointInObject3DRayCrossing(const double& xp, const double& yp, const double& zp, int radius, int numVertices, int numTriangles)
+{
+   GbVector3D point(xp,yp,zp);
+
+   if ( this->InPolyhedron(numTriangles, point, radius) ) return true;
+   else                                                   return false;
+   
+}
+/*======================================================================*/
+bool GbTriangularMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3)
+{
+   double xmin=this->getX1Minimum();	double xmax=this->getX1Maximum();
+   double ymin=this->getX2Minimum();	double ymax=this->getX2Maximum();
+   double zmin=this->getX3Minimum();	double zmax=this->getX3Maximum();
+   double dX = (xmax-xmin)/100.;
+   double dY = (ymax-ymin)/100.;
+   double dZ = (zmax-zmin)/100.;
+   GbCuboid3D boundingCube(xmin-dX, ymin-dY, zmin-dZ, xmax+dX, ymax+dY, zmax+dZ);
+   if(!boundingCube.isPointInGbObject3D(x1, x2, x3)) { boundingCube.finalize(); return false; }
+
+   // Halfspace algorithm, Area of spherical polygons algorithm or Ray crossing algorithm
+   GbVector3D bMin(boundingCube.getPoint1());
+   GbVector3D bMax(boundingCube.getPoint2());
+
+   boundingCube.finalize();
+
+   bMin = bMax.Subtract(bMin);
+   int radius = (int)(bMin.Length()+1)+1;
+
+   if(this->pointinobjecttest == HALFSPACE)        return this->isPointInObject3DHalfSpace(x1,x2,x3);
+   else if(this->pointinobjecttest == RAYCROSSING) return this->isPointInObject3DRayCrossing(x1,x2,x3,radius,(int)this->nodes->size(),(int)this->triangles->size());
+   else throw UbException(UB_EXARGS,"no ptInObjTest");
+}
+/*======================================================================*/
+bool GbTriangularMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)
+{
+    throw UbException(UB_EXARGS,"not implemented");
+}
+/*======================================================================*/
+GbLine3D* GbTriangularMesh3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
+{
+   throw UbException(UB_EXARGS,"not implemented");
+}
+/*======================================================================*/
+void GbTriangularMesh3D::writeMesh(string filename, WbWriter* writer, bool writeNormals) 
+{
+   vector<UbTupleFloat3 > nodes(triangles->size()*3);
+   vector<UbTupleInt3 >   tris(triangles->size());
+
+   for(size_t i=0; i<triangles->size(); i++)
+   {
+      GbTriangle3D&  tri = *((*triangles)[i]);
+      GbPoint3D&   node1 = *tri.getPoint(0);
+      GbPoint3D&   node2 = *tri.getPoint(1);
+      GbPoint3D&   node3 = *tri.getPoint(2);
+      
+      nodes[i*3  ] = makeUbTuple( (float)node1.getX1Coordinate()
+                                 ,(float)node1.getX2Coordinate()  
+                                 ,(float)node1.getX3Coordinate());
+      nodes[i*3+1] = makeUbTuple( (float)node2.getX1Coordinate()
+                                 ,(float)node2.getX2Coordinate()  
+                                 ,(float)node2.getX3Coordinate());
+      nodes[i*3+2] = makeUbTuple( (float)node3.getX1Coordinate()
+                                 ,(float)node3.getX2Coordinate()  
+                                 ,(float)node3.getX3Coordinate());
+
+      tris[i] = makeUbTuple((int)i*3,(int)i*3+1,(int)i*3+2);
+   }
+   writer->writeTriangles(filename,nodes,tris);
+   
+   if(writeNormals)
+   {
+      vector<UbTupleFloat3 > lineNodes(triangles->size()*2);
+      vector<UbTupleInt2 >   lines(triangles->size());
+      for(size_t i=0; i<triangles->size(); i++)
+      {
+         GbVector3D vec = (*triangles)[i]->getNormal();
+         lineNodes[i*2  ] = makeUbTuple( (float)(*triangles)[i]->getX1Centroid()
+                                        ,(float)(*triangles)[i]->getX2Centroid()  
+                                        ,(float)(*triangles)[i]->getX3Centroid());
+         lineNodes[i*2+1] = makeUbTuple( (float)((*triangles)[i]->getX1Centroid()+vec.X1())
+                                        ,(float)((*triangles)[i]->getX2Centroid()+vec.X2())  
+                                        ,(float)((*triangles)[i]->getX3Centroid()+vec.X3()));
+
+         lines[i] = makeUbTuple((int)i*2,(int)i*2+1);
+      }
+      writer->writeLines(filename+"_normals",lineNodes,lines);
+   }
+}
+/*======================================================================*/
+void GbTriangularMesh3D::writeAVSMesh(UbFileOutput *out, bool normals) 
+{
+   cout<<" - write_ucd ("<<out->getFileName()<<") -> ";
+   if(!out)
+   {
+      cout<<"GbTriangularMesh3D::writeAVSMesh() - File konnte nicht geschrieben werden: "<<endl;
+      return;
+   }
+   out->writeLine("# UCD-File created by GbTriangularMesh3D");
+   //vector<GbPoint3D*>     *nodes    = this->getNodes();
+   vector<GbTriangle3D*> *triangles = this->getTriangles();
+   //int nodesize     = (int)nodes->size();
+   int trianglesize = (int)triangles->size();
+   int nodesize     = trianglesize*3;
+   if(normals) 
+   {
+      out->writeInteger(nodesize+trianglesize*2);
+      out->writeInteger(trianglesize*2);
+   }
+   else
+   {
+      out->writeInteger(nodesize);
+      out->writeInteger(trianglesize);
+   }
+   out->writeInteger(0);
+   out->writeInteger(0);
+   out->writeInteger(0);
+   out->writeLine();
+   int nr=1;
+   GbPoint3D *node;
+   for(int i=0;i<trianglesize; i++)
+   {
+      node = (*triangles)[i]->getPoint(0); 
+      out->writeInteger(nr++);
+      out->writeDouble(node->getX1Coordinate());
+      out->writeDouble(node->getX2Coordinate());
+      out->writeDouble(node->getX3Coordinate());
+      out->writeLine();
+      node = (GbPoint3D*)(*triangles)[i]->getPoint(1); 
+      out->writeInteger(nr++);
+      out->writeDouble(node->getX1Coordinate());
+      out->writeDouble(node->getX2Coordinate());
+      out->writeDouble(node->getX3Coordinate());
+      out->writeLine();
+      node = (GbPoint3D*)(*triangles)[i]->getPoint(2); 
+      out->writeInteger(nr++);
+      out->writeDouble(node->getX1Coordinate());
+      out->writeDouble(node->getX2Coordinate());
+      out->writeDouble(node->getX3Coordinate());
+      out->writeLine();
+   }
+
+   if(normals) 
+   {
+      for(int i=0;i<trianglesize; i++)
+      {
+         GbVector3D vec = (*triangles)[i]->getNormal();
+         out->writeInteger(nr++);
+         out->writeDouble((*triangles)[i]->getX1Centroid());
+         out->writeDouble((*triangles)[i]->getX2Centroid());
+         out->writeDouble((*triangles)[i]->getX3Centroid());
+         out->writeLine();
+         out->writeInteger(nr++);
+         out->writeDouble((*triangles)[i]->getX1Centroid()+vec.X1());
+         out->writeDouble((*triangles)[i]->getX2Centroid()+vec.X2());
+         out->writeDouble((*triangles)[i]->getX3Centroid()+vec.X3());
+         out->writeLine();
+      }
+   }
+   nr=1;
+   int el=1;
+   for(int i=0;i<trianglesize; i++)
+   {
+      nr = 3*el-2;
+      out->writeInteger(el);
+      out->writeInteger(2);
+      out->writeString("tri");
+      out->writeInteger(nr);
+      out->writeInteger(nr+1);
+      out->writeInteger(nr+2);
+      out->writeLine();
+      el++;
+   }
+   if(normals)
+   {
+      nr = trianglesize*3+1;
+      for(int i=trianglesize;i<2*trianglesize; i++)
+      {
+         out->writeInteger(el);
+         out->writeInteger(2);
+         out->writeString("line");
+         out->writeInteger(nr++);
+         out->writeInteger(nr++);
+         out->writeLine();
+         el++;
+      }
+   }
+   cout<<"done\n";
+}
+
+/*======================================================================*/
+/*
+This function returns a char:
+'V': the query point a coincides with a Vertex of polyhedron P.
+'E': the query point a is in the relative interior of an Edge of polyhedron P.
+'F': the query point a is in the relative interior of a Face of polyhedron P.
+'i': the query point a is strictly interior to polyhedron P.
+'o': the query point a is strictly exterior to( or outside of) polyhedron P.
+*/
+bool GbTriangularMesh3D::InPolyhedron( int F, GbVector3D& q, int radius )
+{
+   GbVector3D r;  /* Ray endpoint. */
+   GbVector3D p;  /* Intersection point; not used. */
+   int f, k = 0, crossings = 0;
+   char code = '?';
+
+   while( k++ < F ) 
+   {
+      crossings = 0;
+
+      RandomRay( r, radius ); 
+      r = q.Add(r);
+      // printf("Ray endpoint: (%d,%d,%d)\n", r[0],r[1],r[2] );
+
+      for ( f = 0; f < F; f++ )  /* Begin check each face */
+      {
+          if( BoxTest( (*this->triangles)[f], q, r ) == false ) code = '0'; // printf("BoxTest = 0!\n");
+         else                                                  code = SegTriInt( (*this->triangles)[f], q, r, p );// printf( "Face = %d: BoxTest/SegTriInt returns %c\n\n", f, code );
+
+         /* If ray is degenerate, then goto outer while to generate another. */
+         if( code=='p' || code=='v' || code=='e' ) break; //goto LOOP; //printf("Degenerate ray\n");
+         /* If ray hits face at interior point, increment crossings. */
+         else if ( code=='f' ) crossings++; // printf( "crossings = %d\n", crossings );
+         /* If query endpoint q sits on a V/E/F, return that code. */
+         else if ( code=='V' || code=='E' || code=='F' ) return true;
+         /* If ray misses triangle, do nothing. */
+         else if ( code=='0' ) { /*nothing to do*/ }
+         else throw UbException(UB_EXARGS,"Error" );
+      } /* End check each face */
+
+      /* No degeneracies encountered: ray is generic, so finished. */
+      if(f>=F) break;
+   } /* End while loop */
+
+   //   printf( "Crossings = %d\n", crossings );
+   /* q strictly interior to polyhedron iff an odd number of crossings. */
+   if( (crossings%2) == 1 ) return true;
+   
+   return false;
+}
+
+/* Return a random ray endpoint */
+void GbTriangularMesh3D::RandomRay( GbVector3D& ray, int radius )
+{
+   double x, y, z, w, t;
+
+   double MAX_INT = 2147483647;
+   /* Generate a random point on a sphere of radius 1. */
+   /* the sphere is sliced at z, and a random point at angle t
+   generated on the circle of intersection. */
+   z = 2.0 * (double) rand() / MAX_INT - 1.0;
+   t = 2.0 * UbMath::PI * (double) rand() / MAX_INT;
+   w = sqrt( 1 - z*z );
+   x = w * cos( t );
+   y = w * sin( t );
+
+   ray[0] = radius * x;
+   ray[1] = radius * y;
+   ray[2] = radius * z;
+
+   /*printf( "RandomRay returns %6d %6d %6d\n", ray[X], ray[Y], ray[Z] );*/
+}
+
+/*---------------------------------------------------------------------
+'p': The segment lies wholly within the plane.
+'q': The q endpoint is on the plane (but not 'p').
+'r': The r endpoint is on the plane (but not 'p').
+'0': The segment lies strictly to one side or the other of the plane.
+'1': The segement intersects the plane, and 'p' does not hold.
+---------------------------------------------------------------------*/
+char	GbTriangularMesh3D::SegPlaneInt( GbTriangle3D* T, GbVector3D& q, GbVector3D& r, GbVector3D& p, int *m)
+{
+  // cout<<"SegPlaneInt..\n";
+   GbVector3D N; double D;
+   GbVector3D rq;
+   double num, denom, t;
+   int i;
+
+   *m = PlaneCoeff( T, N, &D );
+   /*printf("m=%d; plane=(%lf,%lf,%lf,%lf)\n", m, N[X],N[Y],N[Z],D);*/
+   num = D - q.Dot( N );
+   rq = r.Subtract( q );
+   denom = rq.Dot( N );
+   /*printf("SegPlaneInt: num=%lf, denom=%lf\n", num, denom );*/
+
+   if ( denom == 0.0 ) {  /* Segment is parallel to plane. */
+      if ( num == 0.0 )   /* q is on plane. */
+   //if (UbMath::zero(denom)) {  /* Segment is parallel to plane. */
+   //   if ( UbMath::zero(num))   /* q is on plane. */
+         return 'p';
+      else
+         return '0';
+   }
+   else
+      t = num / denom;
+   /*printf("SegPlaneInt: t=%lf \n", t );*/
+
+   for( i = 0; i < 3; i++ )
+      p[i] = q[i] + t * ( r[i] - q[i] );
+
+   if ( (0.0 < t) && (t < 1.0) )
+      return '1';
+   else if ( num == 0.0 )   /* t == 0 */
+      return 'q';
+   else if ( num == denom ) /* t == 1 */
+      return 'r';
+   else return '0';
+
+   //if ( (0.0 < t) && (t < 1.0) )
+   //   return '1';
+   //else if ( UbMath::zero(num))   /* t == 0 */
+   //   return 'q';
+   //else if ( UbMath::equal(num , denom) ) /* t == 1 */
+   //   return 'r';
+   //else return '0';
+
+}
+/*---------------------------------------------------------------------
+Computes N & D and returns index m of largest component.
+---------------------------------------------------------------------*/
+int	GbTriangularMesh3D::PlaneCoeff( GbTriangle3D* T, GbVector3D& N, double *D )
+{
+   int i;
+   double t;              /* Temp storage */
+   double biggest = 0.0;  /* Largest component of normal vector. */
+   int m = 0;             /* Index of largest component. */
+
+   N = T->getNormal();
+   /*printf("PlaneCoeff: N=(%lf,%lf,%lf)\n", N[X],N[Y],N[Z]);*/
+   GbVector3D a(T->getPoint1());
+
+   *D = a.Dot( N );
+
+   /* Find the largest component of N. */
+   for ( i = 0; i < 3; i++ )
+   {
+      t = std::fabs( N[i] );
+      if ( t > biggest ) 
+      {
+         biggest = t;
+         m = i;
+      }
+   }
+   return m;
+}
+
+/* Assumption: p lies in the plane containing T.
+Returns a char:
+'V': the query point p coincides with a Vertex of triangle T.
+'E': the query point p is in the relative interior of an Edge of triangle T.
+'F': the query point p is in the relative interior of a Face of triangle T.
+'0': the query point p does not intersect (misses) triangle T.
+*/
+
+char 	GbTriangularMesh3D::InTri3D( GbTriangle3D* T, int m, GbVector3D& p )
+{
+//   int i;           /* Index for X,Y,Z           */
+   int j;           /* Index for X,Y             */
+//   int k;           /* Index for triangle vertex */
+   GbVector3D pp;      /* projected p */
+   GbVector3D Tp[3];   /* projected T: three new vertices */
+
+   /* Project out coordinate m in both p and the triangular face */
+   //j = 0;
+   //for ( i = 0; i < 3; i++ ) {
+   //   if ( i != m ) {    /* skip largest coordinate */
+   //      pp[j] = p[i];
+   //      //for ( k = 0; k < 3; k++ )
+   //         std::cout<<"aachtung###############################################";
+   //      //            Tp[k][j] = Vertices[T[k]][i];
+   //      j++;
+   //   }
+   //}
+   j=0;
+   if(m!=0)
+   {
+      Tp[0][j] = T->getPoint1()->getX1Coordinate();
+      Tp[1][j] = T->getPoint2()->getX1Coordinate();
+      Tp[2][j] = T->getPoint3()->getX1Coordinate();
+      j++;
+   }
+   if(m!=1)
+   {
+      Tp[0][j] = T->getPoint1()->getX2Coordinate();
+      Tp[1][j] = T->getPoint2()->getX2Coordinate();
+      Tp[2][j] = T->getPoint3()->getX2Coordinate();
+      j++;
+   }
+   if(m!=2)
+   {
+      Tp[0][j] = T->getPoint1()->getX3Coordinate();
+      Tp[1][j] = T->getPoint2()->getX3Coordinate();
+      Tp[2][j] = T->getPoint3()->getX3Coordinate();
+      j++;
+   }
+
+   return( InTri2D( Tp, pp ) );
+}
+
+char 	GbTriangularMesh3D::InTri2D( GbVector3D Tp[3], GbVector3D& pp )
+{
+   double area0, area1, area2;
+
+   /* compute three AreaSign() values for pp w.r.t. each edge of the face in 2D */
+   area0 = AreaSign( pp, Tp[0], Tp[1] );
+   area1 = AreaSign( pp, Tp[1], Tp[2] );
+   area2 = AreaSign( pp, Tp[2], Tp[0] );
+ //  printf("area0=%f  area1=%f  area2=%f\n",area0,area1,area2);
+
+   if ( ( area0 == 0. ) && ( area1 > 0. ) && ( area2 > 0. ) ||
+      ( area1 == 0. ) && ( area0 > 0. ) && ( area2 > 0. ) ||
+      ( area2 == 0. ) && ( area0 > 0. ) && ( area1 > 0. ) ) 
+      return 'E';
+ 
+   if ( ( area0 == 0. ) && ( area1 < 0. ) && ( area2 < 0. ) ||
+      ( area1 == 0. ) && ( area0 < 0. ) && ( area2 < 0. ) ||
+      ( area2 == 0. ) && ( area0 < 0. ) && ( area1 < 0. ) )
+      return 'E';                 
+
+   if ( ( area0 >  0. ) && ( area1 > 0. ) && ( area2 > 0. ) ||
+      ( area0 <  0. ) && ( area1 < 0. ) && ( area2 < 0. ) )
+      return 'F';
+
+   if ( ( area0 == 0.0 ) && ( area1 == 0.0 ) && ( area2 == 0.0 ) )
+      fprintf( stderr, "Error in InTriD\n" ), exit(EXIT_FAILURE);
+
+   if ( ( area0 == 0. ) && ( area1 == 0. ) ||
+      ( area0 == 0. ) && ( area2 == 0. ) ||
+      ( area1 == 0. ) && ( area2 == 0. ) )
+      return 'V';
+
+   else  
+      return '0';  
+}
+
+double GbTriangularMesh3D::AreaSign( GbVector3D& a, GbVector3D& b, GbVector3D& c )  
+{
+   double area2;
+
+   area2 = ( b[0] - a[0] ) * ( c[1] - a[1] ) -
+           ( c[0] - a[0] ) * ( b[1] - a[1] );
+
+   return area2;
+   /* The area should be an integer. */
+   if      ( area2 >  0.5 ) return  1;
+   else if ( area2 < -0.5 ) return -1;
+   else                     return  0;
+}                            
+
+char    GbTriangularMesh3D::SegTriInt( GbTriangle3D* T, GbVector3D& q, GbVector3D& r, GbVector3D& p )
+{
+   int code = '?';
+   int m = -1;
+
+   code = SegPlaneInt( T, q, r, p, &m );
+   //  printf("SegPlaneInt code=%c, m=%d; p=(%lf,%lf,%lf)\n", code,m,p[0],p[1],p[2]);
+
+   if      ( code == '0')  return '0';
+   else if ( code == 'q')  return InTri3D( T, m, q );
+   else if ( code == 'r')  return InTri3D( T, m, r );
+   else if ( code == 'p' ) return InPlane( T, m, q, r, p );
+   else if ( code == '1' ) return SegTriCross( T, q, r );
+   else /* Error */        return code;
+}
+
+char	GbTriangularMesh3D::InPlane( GbTriangle3D* T, int m, GbVector3D& q, GbVector3D& r, GbVector3D& p)
+{
+  // cout<<"inplane\n";
+   /* NOT IMPLEMENTED */
+   return 'p';
+}
+
+/*---------------------------------------------------------------------
+The signed volumes of three tetrahedra are computed, determined
+by the segment qr, and each edge of the triangle.  
+Returns a char:
+'v': the open segment includes a vertex of T.
+'e': the open segment includes a point in the relative interior of an edge
+of T.
+'f': the open segment includes a point in the relative interior of a face
+of T.
+'0': the open segment does not intersect triangle T.
+---------------------------------------------------------------------*/
+
+char GbTriangularMesh3D::SegTriCross( GbTriangle3D* T, GbVector3D& q, GbVector3D& r )
+{
+  // cout<<"SegTriCross\n";
+   double vol0, vol1, vol2;
+   GbVector3D vert0(T->getPoint1());
+   GbVector3D vert1(T->getPoint2());
+   GbVector3D vert2(T->getPoint3());
+
+   vol0 = VolumeSign( q, vert0, vert1, r ); 
+   vol1 = VolumeSign( q, vert1, vert2, r ); 
+   vol2 = VolumeSign( q, vert2, vert0, r );
+
+   //  printf( "SegTriCross:  vol0 = %d; vol1 = %d; vol2 = %d\n", vol0, vol1, vol2 ); 
+
+   /* Same sign: segment intersects interior of triangle. */
+   if ( ( ( vol0 > 0. ) && ( vol1 > 0. ) && ( vol2 > 0. ) ) || 
+      ( ( vol0 < 0. ) && ( vol1 < 0. ) && ( vol2 < 0. ) ) )
+   //if ( ( UbMath::greater(vol0, 0. ) && UbMath::greater(vol1 , 0. ) && UbMath::greater(vol2 , 0. ) ) || 
+   //     ( UbMath::less(vol0, 0. ) && UbMath::less(vol1, 0. ) && UbMath::less(vol2, 0. ) ) )
+   {
+      return 'f';
+   }
+
+   /* Opposite sign: no intersection between segment and triangle */
+   if ( ( ( vol0 > 0. ) || ( vol1 > 0. ) || ( vol2 > 0. ) ) &&
+      ( ( vol0 < 0. ) || ( vol1 < 0. ) || ( vol2 < 0. ) ) )
+   {
+      return '0';
+   }
+   else if ( ( vol0 == 0.0 ) && ( vol1 == 0.0 ) && ( vol2 == 0.0 ) )
+   {
+      std::cout<<vol0<<" "<<vol1<<" "<<vol2<<std::endl;
+      fprintf( stderr, "Error 1 in SegTriCross\n" ), exit(EXIT_FAILURE);
+   }
+
+   /* Two zeros: segment intersects vertex. */
+   else if ( ( ( vol0 == 0. ) && ( vol1 == 0. ) ) || 
+      ( ( vol0 == 0. ) && ( vol2 == 0. ) ) || 
+      ( ( vol1 == 0. ) && ( vol2 == 0. ) ) )
+   {
+      return 'v';
+   }
+
+   /* One zero: segment intersects edge. */
+   else if ( ( vol0 == 0. ) || ( vol1 == 0. ) || ( vol2 == 0. ) )
+   {
+      return 'e';
+   }
+   
+   throw UbException(UB_EXARGS,"fprintf( stderr, Error 2 in SegTriCross\n ), exit(EXIT_FAILURE);");
+}
+
+
+double GbTriangularMesh3D::VolumeSign( GbVector3D& a, GbVector3D& b, GbVector3D& c, GbVector3D& d )
+{ 
+   double vol;
+   double ax, ay, az, bx, by, bz, cx, cy, cz, dx, dy, dz;
+   double bxdx, bydy, bzdz, cxdx, cydy, czdz;
+
+   ax = a[0];   ay = a[1];   az = a[2];
+   bx = b[0];   by = b[1];   bz = b[2];
+   cx = c[0];   cy = c[1];   cz = c[2];
+   dx = d[0];   dy = d[1];   dz = d[2];
+
+   bxdx=bx-dx;
+   bydy=by-dy;
+   bzdz=bz-dz;
+   cxdx=cx-dx;
+   cydy=cy-dy;
+   czdz=cz-dz;
+   vol = (az-dz) * (bxdx*cydy - bydy*cxdx)
+      + (ay-dy) * (bzdz*cxdx - bxdx*czdz)
+      + (ax-dx) * (bydy*czdz - bzdz*cydy);
+
+   //std::cout<< vol<<std::endl;
+   return vol;
+
+
+   /* The volume should be an integer. */
+   if      ( vol > 0.5 )   return  1;
+   else if ( vol < -0.5 )  return -1;
+   else                    return  0;
+}
+
+bool GbTriangularMesh3D::BoxTest(GbTriangle3D* triangle, GbVector3D& PointQ, GbVector3D& PointR)
+{
+   double minX1 = triangle->getX1Minimum();
+   double minX2 = triangle->getX2Minimum();
+   double minX3 = triangle->getX3Minimum();
+
+   double maxX1 = triangle->getX1Maximum();
+   double maxX2 = triangle->getX2Maximum();
+   double maxX3 = triangle->getX3Maximum();
+
+   if((PointQ.X1() < minX1) && (PointR.X1() < minX1)) return false;
+   if((PointQ.X2() < minX2) && (PointR.X2() < minX2)) return false;
+   if((PointQ.X3() < minX3) && (PointR.X3() < minX3)) return false;
+   if((PointQ.X1() > maxX1) && (PointR.X1() > maxX1)) return false;
+   if((PointQ.X2() > maxX2) && (PointR.X2() > maxX2)) return false;
+   if((PointQ.X3() > maxX3) && (PointR.X3() > maxX3)) return false;
+
+   return true;
+}
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbTriangularMesh3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbTriangularMesh3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbTriangularMesh3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbTriangularMesh3D.h
index 91e0312ac92ed526bbd0844408c30fd3022e7b08..8f3b6a46e2c2bb3cbe72551ed232696628f29367 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbTriangularMesh3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbTriangularMesh3D.h
@@ -1,179 +1,179 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBTRIANGULARMESH_H
-#define GBTRIANGULARMESH_H
-
-#include <sstream>
-#include <iostream>
-
-
-#include <numerics/geometry3d/GbLine3D.h>
-#include <numerics/geometry3d/GbPoint3D.h>                
-#include <numerics/geometry3d/GbTriangle3D.h>
-#include <numerics/geometry3d/GbVector3D.h>
-
-#include <basics/writer/WbWriter.h>
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-#include <PointerDefinitions.h>
-
-/*=========================================================================*/
-/* GbTriangularMesh3D                                                                  */
-/*                                                                         */
-/**
- * This Class provides the triangular meshes.
- * Note, that up to now no methods for checking consistency are included.
- * in this context this class describes facettes from an 3D-object !!!
-*/
-class GbTriangularMesh3D : public GbObject3D 
-{                             
-public:
-   enum POINTINOBJECTTEST { RAYCROSSING, HALFSPACE};
-
-   GbTriangularMesh3D();
-	GbTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbTriangle3D*> *triangles);
-   GbTriangularMesh3D(std::string name, std::vector<GbTriangle3D*> *triangles);
-   GbTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbLine3D*> *edges, std::vector<GbTriangle3D*> *triangles);
-	~GbTriangularMesh3D();   
-   GbTriangularMesh3D* clone() { throw UbException(UB_EXARGS,"not implemented"); }
-   void finalize()
-   {
-      throw UbException("GbTriangularMesh3D::finalize() - toDo");
-   }
-   void setPointInObjectTest(POINTINOBJECTTEST mode) { this->pointinobjecttest = mode; }
-
-   std::string getClassName() {return "GbTriangularMesh3D"; }
-
-   std::string toString();
-   //std::string getName();
-   std::vector<GbPoint3D*>*    getNodes();
-   std::vector<GbTriangle3D*>* getTriangles();
-   double getX1Centroid();
-   double getX2Centroid();
-	double getX3Centroid();
-   double getX1Minimum();
-   double getX1Maximum();
-   double getX2Minimum();
-   double getX2Maximum();
-   double getX3Minimum();
-   double getX3Maximum();
-
-   void rotate(const double& alpha, const double& beta, const double& gamma);
-   void translate(const double& x1, const double& x2, const double& x3);
-
-   void calculateValues();
-   void deleteRedundantNodes();
-   
-   UbTupleDouble6 calculateMomentOfInertia(double rhoP);
-   UbTupleDouble3 calculateCenterOfGravity();
-   
-   double getArea();
-   double getVolume();
-   double getVolumeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2);
-   std::vector<GbTriangle3D*>* getTrianglesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2);
-   std::vector<GbPoint3D*>* getNodesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2);
-   double getX3RangeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2);
-   double getX3MinimumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2);
-   double getX3MaximumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2); 
-
-   virtual bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3);
-
-   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary);
-
-   bool isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp);    //based on Halfspace algorithm
-   bool isPointInObject3DSpherical(const double& xp, const double& yp, const double& zp, int numTriangles);    //based on Spherical polygon area method        
-
-   //should be checked !!!                       
-   bool isPointInObject3DRayCrossing(const double& xp, const double& yp, const double& zp, int radius, int numVertices, int numTriangles);  //based on Ray tracing algorithm
-
-   bool   InPolyhedron( int F, GbVector3D& q, int radius );
-   void   RandomRay( GbVector3D& ray, int radius );
-   char	 SegPlaneInt( GbTriangle3D* Tri, GbVector3D& q, GbVector3D& r, GbVector3D& p, int *m);
-   int	 PlaneCoeff( GbTriangle3D* Tri, GbVector3D& Normal, double *D );
-   char 	 InTri3D( GbTriangle3D* T, int m, GbVector3D& p );
-   char 	 InTri2D( GbVector3D Tp[3], GbVector3D& pp );
-   double AreaSign( GbVector3D& a, GbVector3D& b, GbVector3D& c );
-   char   SegTriInt(GbTriangle3D* Tri, GbVector3D& q, GbVector3D& r, GbVector3D& p );
-   char	 InPlane( GbTriangle3D* T, int m, GbVector3D& q, GbVector3D& r, GbVector3D& p);
-   char   SegTriCross( GbTriangle3D* T, GbVector3D& q, GbVector3D& r );
-   double VolumeSign( GbVector3D& a, GbVector3D& b, GbVector3D& c, GbVector3D& d );
-   bool   BoxTest ( GbTriangle3D* triangle, GbVector3D& PointQ, GbVector3D& PointR);
-   //till here !!!
-
-
-   virtual GbLine3D* createClippedLine3D (GbPoint3D &point1,GbPoint3D &point2);
-   virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet();     
-   virtual ObObjectCreator* getCreator();
-
-   virtual void write(UbFileOutput* out) { std::cout<<"GbTriangularMesh3D::write - sorry not implemented\n"; }
-   virtual void read(UbFileInput* in)    { std::cout<<"GbTriangularMesh3D::read  - sorry not implemented\n"; }
-
-   void writeMesh(std::string filename, WbWriter* writer, bool writeNormals=false);
-   void writeAVSMesh(UbFileOutput* out, bool normals=false);
-
-   /*======================================================================*/
-   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void SF_SERIALIZE(Archive & ar)
-   {
-      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
-      ar & triangles;
-      if(ArchiveTools::isWriting(ar))
-      {
-         for(std::size_t t=0; t<triangles->size(); t++)
-         {
-            nodes->push_back((*triangles)[t]->getPoint(0));
-            nodes->push_back((*triangles)[t]->getPoint(1));
-            nodes->push_back((*triangles)[t]->getPoint(2));
-         }
-      }
-      //ar & nodes; //<- problem redundanz
-      //ar & edges;
-      ar & pointinobjecttest;
-      ar & x1min;
-      ar & x1max;
-      ar & x2min;
-      ar & x2max;
-      ar & x3min;
-      ar & x3max;
-      ar & consistent;
-   }
-#endif //CAB_RCF
-
-protected:
-   std::vector<GbPoint3D*>*    nodes;
-   std::vector<GbLine3D*>*     edges;
-   std::vector<GbTriangle3D*>* triangles;
-
-private:
-   POINTINOBJECTTEST pointinobjecttest;
-   void init();
-   /*======================================================================*/
-   double      x1min;
-   double      x1max;
-   double      x2min;
-   double      x2max;
-   double      x3min;
-   double      x3max;
-   bool        consistent;
-};
-/*=========================================================================*/
-
-#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
-   #if CAB_RCF <= 903 
-      SF_SERIALIZE_ENUM(GbTriangularMesh3D::POINTINOBJECTTEST) //bei klassen ausserhalb der klasse;-)
-   #endif
-   UB_AUTO_RUN_NAMED(   SF::registerType<GbTriangularMesh3D >("GbTriangularMesh3D ")    , SF_GbTriangularMesh3D     );
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbTriangularMesh3D >() ), SF_GbTriangularMesh3D_BD1 );
-#endif //RCF_USE_SF_SERIALIZATION
-
-#endif
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBTRIANGULARMESH_H
+#define GBTRIANGULARMESH_H
+
+#include <sstream>
+#include <iostream>
+
+
+#include <numerics/geometry3d/GbLine3D.h>
+#include <numerics/geometry3d/GbPoint3D.h>                
+#include <numerics/geometry3d/GbTriangle3D.h>
+#include <numerics/geometry3d/GbVector3D.h>
+
+#include <basics/writer/WbWriter.h>
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+#include <PointerDefinitions.h>
+
+/*=========================================================================*/
+/* GbTriangularMesh3D                                                                  */
+/*                                                                         */
+/**
+ * This Class provides the triangular meshes.
+ * Note, that up to now no methods for checking consistency are included.
+ * in this context this class describes facettes from an 3D-object !!!
+*/
+class GbTriangularMesh3D : public GbObject3D 
+{                             
+public:
+   enum POINTINOBJECTTEST { RAYCROSSING, HALFSPACE};
+
+   GbTriangularMesh3D();
+	GbTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbTriangle3D*> *triangles);
+   GbTriangularMesh3D(std::string name, std::vector<GbTriangle3D*> *triangles);
+   GbTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbLine3D*> *edges, std::vector<GbTriangle3D*> *triangles);
+	~GbTriangularMesh3D();   
+   GbTriangularMesh3D* clone() { throw UbException(UB_EXARGS,"not implemented"); }
+   void finalize()
+   {
+      throw UbException("GbTriangularMesh3D::finalize() - toDo");
+   }
+   void setPointInObjectTest(POINTINOBJECTTEST mode) { this->pointinobjecttest = mode; }
+
+   std::string getClassName() {return "GbTriangularMesh3D"; }
+
+   std::string toString();
+   //std::string getName();
+   std::vector<GbPoint3D*>*    getNodes();
+   std::vector<GbTriangle3D*>* getTriangles();
+   double getX1Centroid();
+   double getX2Centroid();
+	double getX3Centroid();
+   double getX1Minimum();
+   double getX1Maximum();
+   double getX2Minimum();
+   double getX2Maximum();
+   double getX3Minimum();
+   double getX3Maximum();
+
+   void rotate(const double& alpha, const double& beta, const double& gamma);
+   void translate(const double& x1, const double& x2, const double& x3);
+
+   void calculateValues();
+   void deleteRedundantNodes();
+   
+   UbTupleDouble6 calculateMomentOfInertia(double rhoP);
+   UbTupleDouble3 calculateCenterOfGravity();
+   
+   double getArea();
+   double getVolume();
+   double getVolumeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2);
+   std::vector<GbTriangle3D*>* getTrianglesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2);
+   std::vector<GbPoint3D*>* getNodesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2);
+   double getX3RangeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2);
+   double getX3MinimumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2);
+   double getX3MaximumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2); 
+
+   virtual bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3);
+
+   bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary);
+
+   bool isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp);    //based on Halfspace algorithm
+   bool isPointInObject3DSpherical(const double& xp, const double& yp, const double& zp, int numTriangles);    //based on Spherical polygon area method        
+
+   //should be checked !!!                       
+   bool isPointInObject3DRayCrossing(const double& xp, const double& yp, const double& zp, int radius, int numVertices, int numTriangles);  //based on Ray tracing algorithm
+
+   bool   InPolyhedron( int F, GbVector3D& q, int radius );
+   void   RandomRay( GbVector3D& ray, int radius );
+   char	 SegPlaneInt( GbTriangle3D* Tri, GbVector3D& q, GbVector3D& r, GbVector3D& p, int *m);
+   int	 PlaneCoeff( GbTriangle3D* Tri, GbVector3D& Normal, double *D );
+   char 	 InTri3D( GbTriangle3D* T, int m, GbVector3D& p );
+   char 	 InTri2D( GbVector3D Tp[3], GbVector3D& pp );
+   double AreaSign( GbVector3D& a, GbVector3D& b, GbVector3D& c );
+   char   SegTriInt(GbTriangle3D* Tri, GbVector3D& q, GbVector3D& r, GbVector3D& p );
+   char	 InPlane( GbTriangle3D* T, int m, GbVector3D& q, GbVector3D& r, GbVector3D& p);
+   char   SegTriCross( GbTriangle3D* T, GbVector3D& q, GbVector3D& r );
+   double VolumeSign( GbVector3D& a, GbVector3D& b, GbVector3D& c, GbVector3D& d );
+   bool   BoxTest ( GbTriangle3D* triangle, GbVector3D& PointQ, GbVector3D& PointR);
+   //till here !!!
+
+
+   virtual GbLine3D* createClippedLine3D (GbPoint3D &point1,GbPoint3D &point2);
+   virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet();     
+   virtual ObObjectCreator* getCreator();
+
+   virtual void write(UbFileOutput* out) { std::cout<<"GbTriangularMesh3D::write - sorry not implemented\n"; }
+   virtual void read(UbFileInput* in)    { std::cout<<"GbTriangularMesh3D::read  - sorry not implemented\n"; }
+
+   void writeMesh(std::string filename, WbWriter* writer, bool writeNormals=false);
+   void writeAVSMesh(UbFileOutput* out, bool normals=false);
+
+   /*======================================================================*/
+   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void SF_SERIALIZE(Archive & ar)
+   {
+      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
+      ar & triangles;
+      if(ArchiveTools::isWriting(ar))
+      {
+         for(std::size_t t=0; t<triangles->size(); t++)
+         {
+            nodes->push_back((*triangles)[t]->getPoint(0));
+            nodes->push_back((*triangles)[t]->getPoint(1));
+            nodes->push_back((*triangles)[t]->getPoint(2));
+         }
+      }
+      //ar & nodes; //<- problem redundanz
+      //ar & edges;
+      ar & pointinobjecttest;
+      ar & x1min;
+      ar & x1max;
+      ar & x2min;
+      ar & x2max;
+      ar & x3min;
+      ar & x3max;
+      ar & consistent;
+   }
+#endif //CAB_RCF
+
+protected:
+   std::vector<GbPoint3D*>*    nodes;
+   std::vector<GbLine3D*>*     edges;
+   std::vector<GbTriangle3D*>* triangles;
+
+private:
+   POINTINOBJECTTEST pointinobjecttest;
+   void init();
+   /*======================================================================*/
+   double      x1min;
+   double      x1max;
+   double      x2min;
+   double      x2max;
+   double      x3min;
+   double      x3max;
+   bool        consistent;
+};
+/*=========================================================================*/
+
+#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
+   #if CAB_RCF <= 903 
+      SF_SERIALIZE_ENUM(GbTriangularMesh3D::POINTINOBJECTTEST) //bei klassen ausserhalb der klasse;-)
+   #endif
+   UB_AUTO_RUN_NAMED(   SF::registerType<GbTriangularMesh3D >("GbTriangularMesh3D ")    , SF_GbTriangularMesh3D     );
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbTriangularMesh3D >() ), SF_GbTriangularMesh3D_BD1 );
+#endif //RCF_USE_SF_SERIALIZATION
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbVector3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbVector3D.cpp
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/GbVector3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbVector3D.cpp
index 7012909d2376a91a0eb399711cb5b3f81c3f8ed0..4283ddfc50f75b08cc47fd574c8520f2e3f0cfd8 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbVector3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbVector3D.cpp
@@ -1,643 +1,643 @@
-#include <numerics/geometry3d/GbVector3D.h>
-
-#include <basics/utilities/UbMath.h>
-#include <basics/utilities/UbInfinity.h>
-#include <numerics/geometry3d/GbPoint3D.h>
-                                
-using namespace std;
-
-
-const GbVector3D GbVector3D::ZERO(0.0,0.0,0.0);
-const GbVector3D GbVector3D::UNIT_X1(1.0,0.0,0.0);
-const GbVector3D GbVector3D::UNIT_X2(0.0,1.0,0.0);
-const GbVector3D GbVector3D::UNIT_X3(0.0,0.0,1.0);
-
-//----------------------------------------------------------------------------
-GbVector3D::GbVector3D () 
-{                                      
-   m_afTuple[0] = 0.0;
-   m_afTuple[1] = 0.0;
-   m_afTuple[2] = 0.0;
-}
-//----------------------------------------------------------------------------
-GbVector3D::GbVector3D (const double& fX, const double& fY, const double& fZ) 
-{
-   m_afTuple[0] = fX;
-   m_afTuple[1] = fY;
-   m_afTuple[2] = fZ;
-}
-//----------------------------------------------------------------------------
-GbVector3D::GbVector3D (const GbVector3D& rkV) 
-{
-   m_afTuple[0] = rkV.m_afTuple[0];
-   m_afTuple[1] = rkV.m_afTuple[1];
-   m_afTuple[2] = rkV.m_afTuple[2];
-}
-//----------------------------------------------------------------------------
-
-GbVector3D::GbVector3D (const GbPoint3D& point) 
-{
-   m_afTuple[0] = point.x1;
-   m_afTuple[1] = point.x2;
-   m_afTuple[2] = point.x3;
-}
-
-//----------------------------------------------------------------------------
-string GbVector3D::toString()
-{
-   std::stringstream ss;
-   ss<< "GbVector3D["<<m_afTuple[0]<<","<<m_afTuple[1]<<","<<m_afTuple[2]<<"]";
-   ss<<endl;
-   return((ss.str()).c_str());
-}
-//----------------------------------------------------------------------------
-GbVector3D::operator const double* () const
-{
-   return m_afTuple;
-}
-//----------------------------------------------------------------------------
-GbVector3D::operator double* ()
-{
-   return m_afTuple;
-}
-//----------------------------------------------------------------------------
-double GbVector3D::operator[] (int i) const
-{
-   assert( 0 <= i && i <= 2 );
-   if ( i < 0 )
-      i = 0;
-   else if ( i > 2 )
-      i = 2;
-
-   return m_afTuple[i];
-}
-//----------------------------------------------------------------------------
-double& GbVector3D::operator[] (int i)
-{
-   assert( 0 <= i && i <= 2 );
-   if ( i < 0 )
-      i = 0;
-   else if ( i > 2 )
-      i = 2;
-
-   return m_afTuple[i];
-}
-//----------------------------------------------------------------------------
-double GbVector3D::X1 () const
-{
-   return m_afTuple[0];
-}
-//----------------------------------------------------------------------------
-double& GbVector3D::X1 ()
-{
-   return m_afTuple[0];
-}
-//----------------------------------------------------------------------------
-double GbVector3D::X2 () const
-{
-   return m_afTuple[1];
-}
-//----------------------------------------------------------------------------
-double& GbVector3D::X2 ()
-{
-   return m_afTuple[1];
-}
-//----------------------------------------------------------------------------
-double GbVector3D::X3 () const
-{
-   return m_afTuple[2];
-}
-//----------------------------------------------------------------------------
-double& GbVector3D::X3 ()
-{
-   return m_afTuple[2];
-}
-//----------------------------------------------------------------------------
-GbVector3D& GbVector3D::operator= (const GbVector3D& rkV)
-{
-   m_afTuple[0] = rkV.m_afTuple[0];
-   m_afTuple[1] = rkV.m_afTuple[1];
-   m_afTuple[2] = rkV.m_afTuple[2];
-   return *this;
-}
-//----------------------------------------------------------------------------
-int GbVector3D::CompareArrays (const GbVector3D& rkV) const
-{
-   return memcmp(m_afTuple,rkV.m_afTuple,3*sizeof(double));
-}
-//----------------------------------------------------------------------------
-bool GbVector3D::operator== (const GbVector3D& rkV) const
-{
-   return CompareArrays(rkV) == 0;
-}
-//----------------------------------------------------------------------------
-bool GbVector3D::operator!= (const GbVector3D& rkV) const
-{
-   return CompareArrays(rkV) != 0;
-}
-//----------------------------------------------------------------------------
-bool GbVector3D::operator< (const GbVector3D& rkV) const
-{
-   return CompareArrays(rkV) < 0;
-}
-//----------------------------------------------------------------------------
-bool GbVector3D::operator<= (const GbVector3D& rkV) const
-{
-   return CompareArrays(rkV) <= 0;
-}
-//----------------------------------------------------------------------------
-bool GbVector3D::operator> (const GbVector3D& rkV) const
-{
-   return CompareArrays(rkV) > 0;
-}
-//----------------------------------------------------------------------------
-bool GbVector3D::operator>= (const GbVector3D& rkV) const
-{
-   return CompareArrays(rkV) >= 0;
-}
-//----------------------------------------------------------------------------
-GbVector3D GbVector3D::operator+ (const GbVector3D& rkV) const
-{
-   return GbVector3D(
-      m_afTuple[0]+rkV.m_afTuple[0],
-      m_afTuple[1]+rkV.m_afTuple[1],
-      m_afTuple[2]+rkV.m_afTuple[2]);
-}
-//----------------------------------------------------------------------------
-GbVector3D GbVector3D::Add(GbVector3D& vector)
-{
-   return GbVector3D(
-      m_afTuple[0]+vector.m_afTuple[0],
-      m_afTuple[1]+vector.m_afTuple[1],
-      m_afTuple[2]+vector.m_afTuple[2]);
-}
-
-//----------------------------------------------------------------------------
-GbVector3D GbVector3D::operator- (const GbVector3D& rkV) const
-{
-   return GbVector3D(
-      m_afTuple[0]-rkV.m_afTuple[0],
-      m_afTuple[1]-rkV.m_afTuple[1],
-      m_afTuple[2]-rkV.m_afTuple[2]);
-}
-//----------------------------------------------------------------------------
-GbVector3D GbVector3D::Subtract(GbVector3D& vector)
-{
-   return GbVector3D(
-      m_afTuple[0]-vector.m_afTuple[0],
-      m_afTuple[1]-vector.m_afTuple[1],
-      m_afTuple[2]-vector.m_afTuple[2]);
-}
-//----------------------------------------------------------------------------
-GbVector3D GbVector3D::operator* (const double& fScalar) const
-{
-   return GbVector3D( fScalar*m_afTuple[0],
-                      fScalar*m_afTuple[1],
-                      fScalar*m_afTuple[2]);
-}
-//----------------------------------------------------------------------------
-GbVector3D GbVector3D::operator/ (const double& fScalar) const
-{
-   GbVector3D kQuot;
-
-   if ( fScalar != 0.0 )
-   {
-      double fInvScalar = 1.0/fScalar;
-      kQuot.m_afTuple[0] = fInvScalar*m_afTuple[0];
-      kQuot.m_afTuple[1] = fInvScalar*m_afTuple[1];
-      kQuot.m_afTuple[2] = fInvScalar*m_afTuple[2];
-   }
-   else
-   {
-      kQuot.m_afTuple[0] = Ub::inf;
-      kQuot.m_afTuple[1] = Ub::inf;
-      kQuot.m_afTuple[2] = Ub::inf;
-   }
-
-   return kQuot;
-}
-//----------------------------------------------------------------------------
-GbVector3D GbVector3D::operator- () const
-{
-   return GbVector3D(
-      -m_afTuple[0],
-      -m_afTuple[1],
-      -m_afTuple[2]);
-}
-//----------------------------------------------------------------------------
-GbVector3D operator* (const double& fScalar, const GbVector3D& rkV)
-{
-   return GbVector3D(
-      fScalar*rkV[0],
-      fScalar*rkV[1],
-      fScalar*rkV[2]);
-}
-//----------------------------------------------------------------------------
-GbVector3D& GbVector3D::operator+= (const GbVector3D& rkV)
-{
-   m_afTuple[0] += rkV.m_afTuple[0];
-   m_afTuple[1] += rkV.m_afTuple[1];
-   m_afTuple[2] += rkV.m_afTuple[2];
-   return *this;
-}
-//----------------------------------------------------------------------------
-GbVector3D& GbVector3D::operator-= (const GbVector3D& rkV)
-{
-   m_afTuple[0] -= rkV.m_afTuple[0];
-   m_afTuple[1] -= rkV.m_afTuple[1];
-   m_afTuple[2] -= rkV.m_afTuple[2];
-   return *this;
-}
-//----------------------------------------------------------------------------
-GbVector3D& GbVector3D::operator*= (const double& fScalar)
-{
-   m_afTuple[0] *= fScalar;
-   m_afTuple[1] *= fScalar;
-   m_afTuple[2] *= fScalar;
-   return *this;
-}
-//----------------------------------------------------------------------------
-GbVector3D& GbVector3D::operator/= (const double& fScalar)
-{
-   if ( fScalar != (double)0.0 )
-   {
-      double fInvScalar = ((double)1.0)/fScalar;
-      m_afTuple[0] *= fInvScalar;
-      m_afTuple[1] *= fInvScalar;
-      m_afTuple[2] *= fInvScalar;
-   }
-   else
-   {
-      m_afTuple[0] = Ub::inf;
-      m_afTuple[1] = Ub::inf;
-      m_afTuple[2] = Ub::inf;
-   }
-
-   return *this;
-}
-//----------------------------------------------------------------------------
-GbVector3D GbVector3D::Scale(const double& x)
-{
-   GbVector3D PointA(0.0,0.0,0.0);
-   PointA.m_afTuple[0] = x * m_afTuple[0];
-   PointA.m_afTuple[1] = x * m_afTuple[1];
-   PointA.m_afTuple[2] = x * m_afTuple[2];
-   return PointA;	
-}
-
-//----------------------------------------------------------------------------
-double GbVector3D::Length () const
-{
-   return std::sqrt(
-      m_afTuple[0]*m_afTuple[0] +
-      m_afTuple[1]*m_afTuple[1] +
-      m_afTuple[2]*m_afTuple[2]);
-}
-//----------------------------------------------------------------------------
-double GbVector3D::SquaredLength () const
-{
-   return
-      m_afTuple[0]*m_afTuple[0] +
-      m_afTuple[1]*m_afTuple[1] +
-      m_afTuple[2]*m_afTuple[2];
-}
-//----------------------------------------------------------------------------
-double GbVector3D::Dot (const GbVector3D& rkV) const
-{
-   return
-      m_afTuple[0]*rkV.m_afTuple[0] +
-      m_afTuple[1]*rkV.m_afTuple[1] +
-      m_afTuple[2]*rkV.m_afTuple[2];
-}
-//----------------------------------------------------------------------------
-double GbVector3D::Normalize ()
-{
-   double fLength = Length();
-
-   if ( fLength > UbMath::Epsilon<double>::val() )
-   {
-      double fInvLength = ((double)1.0)/fLength;
-      m_afTuple[0] *= fInvLength;
-      m_afTuple[1] *= fInvLength;
-      m_afTuple[2] *= fInvLength;
-   }
-   else
-   {
-      fLength = 0.0;
-      m_afTuple[0] = 0.0;
-      m_afTuple[1] = 0.0;
-      m_afTuple[2] = 0.0;
-   }
-
-   return fLength;
-}
-//----------------------------------------------------------------------------
-GbVector3D GbVector3D::Cross (const GbVector3D& rkV) const
-{
-   return GbVector3D(
-      m_afTuple[1]*rkV.m_afTuple[2] - m_afTuple[2]*rkV.m_afTuple[1],
-      m_afTuple[2]*rkV.m_afTuple[0] - m_afTuple[0]*rkV.m_afTuple[2],
-      m_afTuple[0]*rkV.m_afTuple[1] - m_afTuple[1]*rkV.m_afTuple[0]);
-}
-
-//----------------------------------------------------------------------------
-
-GbVector3D GbVector3D::UnitCross (const GbVector3D& rkV) const
-{
-   GbVector3D kCross(
-      m_afTuple[1]*rkV.m_afTuple[2] - m_afTuple[2]*rkV.m_afTuple[1],
-      m_afTuple[2]*rkV.m_afTuple[0] - m_afTuple[0]*rkV.m_afTuple[2],
-      m_afTuple[0]*rkV.m_afTuple[1] - m_afTuple[1]*rkV.m_afTuple[0]);
-   kCross.Normalize();
-   return kCross;
-}
-//----------------------------------------------------------------------------
-void GbVector3D::GetBarycentrics (const GbVector3D& rkV0,
-                                  const GbVector3D& rkV1, const GbVector3D& rkV2,
-                                  const GbVector3D& rkV3, double afBary[4]) const
-{
-   // compute the vectors relative to V3 of the tetrahedron
-   GbVector3D akDiff[4] =
-   {
-      rkV0 - rkV3,
-         rkV1 - rkV3,
-         rkV2 - rkV3,
-         *this - rkV3
-   };
-
-   // If the vertices have large magnitude, the linear system of
-   // equations for computing barycentric coordinates can be
-   // ill-conditioned.  To avoid this, uniformly scale the tetrahedron
-   // edges to be of order 1.  The scaling of all differences does not
-   // change the barycentric coordinates.
-   double fMax = (double)0.0;
-   int i;
-   for (i = 0; i < 3; i++)
-   {
-      for (int j = 0; j < 3; j++)
-      {
-         double fValue = std::fabs(akDiff[i][j]);
-         if ( fValue > fMax )
-            fMax = fValue;
-      }
-   }
-
-   // scale down only large data
-   if ( fMax > (double)1.0 )
-   {
-      double fInvMax = ((double)1.0)/fMax;
-      for (i = 0; i < 4; i++)
-         akDiff[i] *= fInvMax;
-   }
-
-   double fDet = akDiff[0].Dot(akDiff[1].Cross(akDiff[2]));
-   GbVector3D kE1cE2 = akDiff[1].Cross(akDiff[2]);
-   GbVector3D kE2cE0 = akDiff[2].Cross(akDiff[0]);
-   GbVector3D kE0cE1 = akDiff[0].Cross(akDiff[1]);
-   if ( std::fabs(fDet) > UbMath::Epsilon<double>::val() )
-   {
-      double fInvDet = ((double)1.0)/fDet;
-      afBary[0] = akDiff[3].Dot(kE1cE2)*fInvDet;
-      afBary[1] = akDiff[3].Dot(kE2cE0)*fInvDet;
-      afBary[2] = akDiff[3].Dot(kE0cE1)*fInvDet;
-      afBary[3] = (double)1.0 - afBary[0] - afBary[1] - afBary[2];
-   }
-   else
-   {
-      // The tetrahedron is potentially flat.  Determine the face of
-      // maximum area and compute barycentric coordinates with respect
-      // to that face.
-      GbVector3D kE02 = rkV0 - rkV2;
-      GbVector3D kE12 = rkV1 - rkV2;
-      GbVector3D kE02cE12 = kE02.Cross(kE12);
-      double fMaxSqrArea = kE02cE12.SquaredLength();
-      int iMaxIndex = 3;
-      double fSqrArea = kE0cE1.SquaredLength();
-      if ( fSqrArea > fMaxSqrArea )
-      {
-         iMaxIndex = 0;
-         fMaxSqrArea = fSqrArea;
-      }
-      fSqrArea = kE1cE2.SquaredLength();
-      if ( fSqrArea > fMaxSqrArea )
-      {
-         iMaxIndex = 1;
-         fMaxSqrArea = fSqrArea;
-      }
-      fSqrArea = kE2cE0.SquaredLength();
-      if ( fSqrArea > fMaxSqrArea )
-      {
-         iMaxIndex = 2;
-         fMaxSqrArea = fSqrArea;
-      }
-
-      if ( fMaxSqrArea > UbMath::Epsilon<double>::val() )
-      {
-         double fInvSqrArea = ((double)1.0)/fMaxSqrArea;
-         GbVector3D kTmp;
-         if ( iMaxIndex == 0 )
-         {
-            kTmp = akDiff[3].Cross(akDiff[1]);
-            afBary[0] = kE0cE1.Dot(kTmp)*fInvSqrArea;
-            kTmp = akDiff[0].Cross(akDiff[3]);
-            afBary[1] = kE0cE1.Dot(kTmp)*fInvSqrArea;
-            afBary[2] = (double)0.0;
-            afBary[3] = (double)1.0 - afBary[0] - afBary[1];
-         }
-         else if ( iMaxIndex == 1 )
-         {
-            afBary[0] = (double)0.0;
-            kTmp = akDiff[3].Cross(akDiff[2]);
-            afBary[1] = kE1cE2.Dot(kTmp)*fInvSqrArea;
-            kTmp = akDiff[1].Cross(akDiff[3]);
-            afBary[2] = kE1cE2.Dot(kTmp)*fInvSqrArea;
-            afBary[3] = (double)1.0 - afBary[1] - afBary[2];
-         }
-         else if ( iMaxIndex == 2 )
-         {
-            kTmp = akDiff[2].Cross(akDiff[3]);
-            afBary[0] = kE2cE0.Dot(kTmp)*fInvSqrArea;
-            afBary[1] = (double)0.0;
-            kTmp = akDiff[3].Cross(akDiff[0]);
-            afBary[2] = kE2cE0.Dot(kTmp)*fInvSqrArea;
-            afBary[3] = (double)1.0 - afBary[0] - afBary[2];
-         }
-         else
-         {
-            akDiff[3] = *this - rkV2;
-            kTmp = akDiff[3].Cross(kE12);
-            afBary[0] = kE02cE12.Dot(kTmp)*fInvSqrArea;
-            kTmp = kE02.Cross(akDiff[3]);
-            afBary[1] = kE02cE12.Dot(kTmp)*fInvSqrArea;
-            afBary[2] = (double)1.0 - afBary[0] - afBary[1];
-            afBary[3] = (double)0.0;
-         }
-      }
-      else
-      {
-         // The tetrahedron is potentially a sliver.  Determine the edge of
-         // maximum length and compute barycentric coordinates with respect
-         // to that edge.
-         double fMaxSqrLength = akDiff[0].SquaredLength();
-         iMaxIndex = 0;  // <V0,V3>
-         double fSqrLength = akDiff[1].SquaredLength();
-         if ( fSqrLength > fMaxSqrLength )
-         {
-            iMaxIndex = 1;  // <V1,V3>
-            fMaxSqrLength = fSqrLength;
-         }
-         fSqrLength = akDiff[2].SquaredLength();
-         if ( fSqrLength > fMaxSqrLength )
-         {
-            iMaxIndex = 2;  // <V2,V3>
-            fMaxSqrLength = fSqrLength;
-         }
-         fSqrLength = kE02.SquaredLength();
-         if ( fSqrLength > fMaxSqrLength )
-         {
-            iMaxIndex = 3;  // <V0,V2>
-            fMaxSqrLength = fSqrLength;
-         }
-         fSqrLength = kE12.SquaredLength();
-         if ( fSqrLength > fMaxSqrLength )
-         {
-            iMaxIndex = 4;  // <V1,V2>
-            fMaxSqrLength = fSqrLength;
-         }
-         GbVector3D kE01 = rkV0 - rkV1;
-         fSqrLength = kE01.SquaredLength();
-         if ( fSqrLength > fMaxSqrLength )
-         {
-            iMaxIndex = 5;  // <V0,V1>
-            fMaxSqrLength = fSqrLength;
-         }
-
-         if ( fMaxSqrLength > UbMath::Epsilon<double>::val() )
-         {
-            double fInvSqrLength = ((double)1.0)/fMaxSqrLength;
-            if ( iMaxIndex == 0 )
-            {
-               // P-V3 = t*(V0-V3)
-               afBary[0] = akDiff[3].Dot(akDiff[0])*fInvSqrLength;
-               afBary[1] = (double)0.0;
-               afBary[2] = (double)0.0;
-               afBary[3] = (double)1.0 - afBary[0];
-            }
-            else if ( iMaxIndex == 1 )
-            {
-               // P-V3 = t*(V1-V3)
-               afBary[0] = (double)0.0;
-               afBary[1] = akDiff[3].Dot(akDiff[1])*fInvSqrLength;
-               afBary[2] = (double)0.0;
-               afBary[3] = (double)1.0 - afBary[1];
-            }
-            else if ( iMaxIndex == 2 )
-            {
-               // P-V3 = t*(V2-V3)
-               afBary[0] = (double)0.0;
-               afBary[1] = (double)0.0;
-               afBary[2] = akDiff[3].Dot(akDiff[2])*fInvSqrLength;
-               afBary[3] = (double)1.0 - afBary[2];
-            }
-            else if ( iMaxIndex == 3 )
-            {
-               // P-V2 = t*(V0-V2)
-               akDiff[3] = *this - rkV2;
-               afBary[0] = akDiff[3].Dot(kE02)*fInvSqrLength;
-               afBary[1] = (double)0.0;
-               afBary[2] = (double)1.0 - afBary[0];
-               afBary[3] = (double)0.0;
-            }
-            else if ( iMaxIndex == 4 )
-            {
-               // P-V2 = t*(V1-V2)
-               akDiff[3] = *this - rkV2;
-               afBary[0] = (double)0.0;
-               afBary[1] = akDiff[3].Dot(kE12)*fInvSqrLength;
-               afBary[2] = (double)1.0 - afBary[1];
-               afBary[3] = (double)0.0;
-            }
-            else
-            {
-               // P-V1 = t*(V0-V1)
-               akDiff[3] = *this - rkV1;
-               afBary[0] = akDiff[3].Dot(kE01)*fInvSqrLength;
-               afBary[1] = (double)1.0 - afBary[0];
-               afBary[2] = (double)0.0;
-               afBary[3] = (double)0.0;
-            }
-         }
-         else
-         {
-            // tetrahedron is a nearly a point, just return equal weights
-            afBary[0] = (double)0.25;
-            afBary[1] = afBary[0];
-            afBary[2] = afBary[0];
-            afBary[3] = afBary[0];
-         }
-      }
-   }
-}
-//----------------------------------------------------------------------------
-void GbVector3D::Orthonormalize (GbVector3D& rkU, GbVector3D& rkV, GbVector3D& rkW)
-{
-   // If the input vectors are v0, v1, and v2, then the Gram-Schmidt
-   // orthonormalization produces vectors u0, u1, and u2 as follows,
-   //
-   //   u0 = v0/|v0|
-   //   u1 = (v1-(u0*v1)u0)/|v1-(u0*v1)u0|
-   //   u2 = (v2-(u0*v2)u0-(u1*v2)u1)/|v2-(u0*v2)u0-(u1*v2)u1|
-   //
-   // where |A| indicates length of vector A and A*B indicates dot
-   // product of vectors A and B.
-
-   // compute u0
-   rkU.Normalize();
-
-   // compute u1
-   double fDot0 = rkU.Dot(rkV); 
-   rkV -= fDot0*rkU;
-   rkV.Normalize();
-
-   // compute u2
-   double fDot1 = rkV.Dot(rkW);
-   fDot0 = rkU.Dot(rkW);
-   rkW -= fDot0*rkU + fDot1*rkV;
-   rkW.Normalize();
-}
-//----------------------------------------------------------------------------
-void GbVector3D::Orthonormalize (GbVector3D* akV)
-{
-   Orthonormalize(akV[0],akV[1],akV[2]);
-}
-//----------------------------------------------------------------------------
-void GbVector3D::GenerateOrthonormalBasis (GbVector3D& rkU, GbVector3D& rkV,
-                                           GbVector3D& rkW, bool bUnitLengthW)
-{
-   if ( !bUnitLengthW )
-      rkW.Normalize();
-
-   double fInvLength;
-
-   if ( std::fabs(rkW.m_afTuple[0]) >=
-      std::fabs(rkW.m_afTuple[1]) )
-   {
-      // W.x or W.z is the largest magnitude component, swap them
-      fInvLength = UbMath::invSqrt(rkW.m_afTuple[0]*rkW.m_afTuple[0] + rkW.m_afTuple[2]*rkW.m_afTuple[2]);
-      rkU.m_afTuple[0] = -rkW.m_afTuple[2]*fInvLength;
-      rkU.m_afTuple[1] = (double)0.0;
-      rkU.m_afTuple[2] = +rkW.m_afTuple[0]*fInvLength;
-   }
-   else
-   {
-      // W.y or W.z is the largest magnitude component, swap them
-      fInvLength = UbMath::invSqrt(rkW.m_afTuple[1]*rkW.m_afTuple[1] + rkW.m_afTuple[2]*rkW.m_afTuple[2]);
-      rkU.m_afTuple[0] = (double)0.0;
-      rkU.m_afTuple[1] = +rkW.m_afTuple[2]*fInvLength;
-      rkU.m_afTuple[2] = -rkW.m_afTuple[1]*fInvLength;
-   }
-
-   rkV = rkW.Cross(rkU);
-}
-//----------------------------------------------------------------------------
-
+#include <numerics/geometry3d/GbVector3D.h>
+
+#include <basics/utilities/UbMath.h>
+#include <basics/utilities/UbInfinity.h>
+#include <numerics/geometry3d/GbPoint3D.h>
+                                
+using namespace std;
+
+
+const GbVector3D GbVector3D::ZERO(0.0,0.0,0.0);
+const GbVector3D GbVector3D::UNIT_X1(1.0,0.0,0.0);
+const GbVector3D GbVector3D::UNIT_X2(0.0,1.0,0.0);
+const GbVector3D GbVector3D::UNIT_X3(0.0,0.0,1.0);
+
+//----------------------------------------------------------------------------
+GbVector3D::GbVector3D () 
+{                                      
+   m_afTuple[0] = 0.0;
+   m_afTuple[1] = 0.0;
+   m_afTuple[2] = 0.0;
+}
+//----------------------------------------------------------------------------
+GbVector3D::GbVector3D (const double& fX, const double& fY, const double& fZ) 
+{
+   m_afTuple[0] = fX;
+   m_afTuple[1] = fY;
+   m_afTuple[2] = fZ;
+}
+//----------------------------------------------------------------------------
+GbVector3D::GbVector3D (const GbVector3D& rkV) 
+{
+   m_afTuple[0] = rkV.m_afTuple[0];
+   m_afTuple[1] = rkV.m_afTuple[1];
+   m_afTuple[2] = rkV.m_afTuple[2];
+}
+//----------------------------------------------------------------------------
+
+GbVector3D::GbVector3D (const GbPoint3D& point) 
+{
+   m_afTuple[0] = point.x1;
+   m_afTuple[1] = point.x2;
+   m_afTuple[2] = point.x3;
+}
+
+//----------------------------------------------------------------------------
+string GbVector3D::toString()
+{
+   std::stringstream ss;
+   ss<< "GbVector3D["<<m_afTuple[0]<<","<<m_afTuple[1]<<","<<m_afTuple[2]<<"]";
+   ss<<endl;
+   return((ss.str()).c_str());
+}
+//----------------------------------------------------------------------------
+GbVector3D::operator const double* () const
+{
+   return m_afTuple;
+}
+//----------------------------------------------------------------------------
+GbVector3D::operator double* ()
+{
+   return m_afTuple;
+}
+//----------------------------------------------------------------------------
+double GbVector3D::operator[] (int i) const
+{
+   assert( 0 <= i && i <= 2 );
+   if ( i < 0 )
+      i = 0;
+   else if ( i > 2 )
+      i = 2;
+
+   return m_afTuple[i];
+}
+//----------------------------------------------------------------------------
+double& GbVector3D::operator[] (int i)
+{
+   assert( 0 <= i && i <= 2 );
+   if ( i < 0 )
+      i = 0;
+   else if ( i > 2 )
+      i = 2;
+
+   return m_afTuple[i];
+}
+//----------------------------------------------------------------------------
+double GbVector3D::X1 () const
+{
+   return m_afTuple[0];
+}
+//----------------------------------------------------------------------------
+double& GbVector3D::X1 ()
+{
+   return m_afTuple[0];
+}
+//----------------------------------------------------------------------------
+double GbVector3D::X2 () const
+{
+   return m_afTuple[1];
+}
+//----------------------------------------------------------------------------
+double& GbVector3D::X2 ()
+{
+   return m_afTuple[1];
+}
+//----------------------------------------------------------------------------
+double GbVector3D::X3 () const
+{
+   return m_afTuple[2];
+}
+//----------------------------------------------------------------------------
+double& GbVector3D::X3 ()
+{
+   return m_afTuple[2];
+}
+//----------------------------------------------------------------------------
+GbVector3D& GbVector3D::operator= (const GbVector3D& rkV)
+{
+   m_afTuple[0] = rkV.m_afTuple[0];
+   m_afTuple[1] = rkV.m_afTuple[1];
+   m_afTuple[2] = rkV.m_afTuple[2];
+   return *this;
+}
+//----------------------------------------------------------------------------
+int GbVector3D::CompareArrays (const GbVector3D& rkV) const
+{
+   return memcmp(m_afTuple,rkV.m_afTuple,3*sizeof(double));
+}
+//----------------------------------------------------------------------------
+bool GbVector3D::operator== (const GbVector3D& rkV) const
+{
+   return CompareArrays(rkV) == 0;
+}
+//----------------------------------------------------------------------------
+bool GbVector3D::operator!= (const GbVector3D& rkV) const
+{
+   return CompareArrays(rkV) != 0;
+}
+//----------------------------------------------------------------------------
+bool GbVector3D::operator< (const GbVector3D& rkV) const
+{
+   return CompareArrays(rkV) < 0;
+}
+//----------------------------------------------------------------------------
+bool GbVector3D::operator<= (const GbVector3D& rkV) const
+{
+   return CompareArrays(rkV) <= 0;
+}
+//----------------------------------------------------------------------------
+bool GbVector3D::operator> (const GbVector3D& rkV) const
+{
+   return CompareArrays(rkV) > 0;
+}
+//----------------------------------------------------------------------------
+bool GbVector3D::operator>= (const GbVector3D& rkV) const
+{
+   return CompareArrays(rkV) >= 0;
+}
+//----------------------------------------------------------------------------
+GbVector3D GbVector3D::operator+ (const GbVector3D& rkV) const
+{
+   return GbVector3D(
+      m_afTuple[0]+rkV.m_afTuple[0],
+      m_afTuple[1]+rkV.m_afTuple[1],
+      m_afTuple[2]+rkV.m_afTuple[2]);
+}
+//----------------------------------------------------------------------------
+GbVector3D GbVector3D::Add(GbVector3D& vector)
+{
+   return GbVector3D(
+      m_afTuple[0]+vector.m_afTuple[0],
+      m_afTuple[1]+vector.m_afTuple[1],
+      m_afTuple[2]+vector.m_afTuple[2]);
+}
+
+//----------------------------------------------------------------------------
+GbVector3D GbVector3D::operator- (const GbVector3D& rkV) const
+{
+   return GbVector3D(
+      m_afTuple[0]-rkV.m_afTuple[0],
+      m_afTuple[1]-rkV.m_afTuple[1],
+      m_afTuple[2]-rkV.m_afTuple[2]);
+}
+//----------------------------------------------------------------------------
+GbVector3D GbVector3D::Subtract(GbVector3D& vector)
+{
+   return GbVector3D(
+      m_afTuple[0]-vector.m_afTuple[0],
+      m_afTuple[1]-vector.m_afTuple[1],
+      m_afTuple[2]-vector.m_afTuple[2]);
+}
+//----------------------------------------------------------------------------
+GbVector3D GbVector3D::operator* (const double& fScalar) const
+{
+   return GbVector3D( fScalar*m_afTuple[0],
+                      fScalar*m_afTuple[1],
+                      fScalar*m_afTuple[2]);
+}
+//----------------------------------------------------------------------------
+GbVector3D GbVector3D::operator/ (const double& fScalar) const
+{
+   GbVector3D kQuot;
+
+   if ( fScalar != 0.0 )
+   {
+      double fInvScalar = 1.0/fScalar;
+      kQuot.m_afTuple[0] = fInvScalar*m_afTuple[0];
+      kQuot.m_afTuple[1] = fInvScalar*m_afTuple[1];
+      kQuot.m_afTuple[2] = fInvScalar*m_afTuple[2];
+   }
+   else
+   {
+      kQuot.m_afTuple[0] = Ub::inf;
+      kQuot.m_afTuple[1] = Ub::inf;
+      kQuot.m_afTuple[2] = Ub::inf;
+   }
+
+   return kQuot;
+}
+//----------------------------------------------------------------------------
+GbVector3D GbVector3D::operator- () const
+{
+   return GbVector3D(
+      -m_afTuple[0],
+      -m_afTuple[1],
+      -m_afTuple[2]);
+}
+//----------------------------------------------------------------------------
+GbVector3D operator* (const double& fScalar, const GbVector3D& rkV)
+{
+   return GbVector3D(
+      fScalar*rkV[0],
+      fScalar*rkV[1],
+      fScalar*rkV[2]);
+}
+//----------------------------------------------------------------------------
+GbVector3D& GbVector3D::operator+= (const GbVector3D& rkV)
+{
+   m_afTuple[0] += rkV.m_afTuple[0];
+   m_afTuple[1] += rkV.m_afTuple[1];
+   m_afTuple[2] += rkV.m_afTuple[2];
+   return *this;
+}
+//----------------------------------------------------------------------------
+GbVector3D& GbVector3D::operator-= (const GbVector3D& rkV)
+{
+   m_afTuple[0] -= rkV.m_afTuple[0];
+   m_afTuple[1] -= rkV.m_afTuple[1];
+   m_afTuple[2] -= rkV.m_afTuple[2];
+   return *this;
+}
+//----------------------------------------------------------------------------
+GbVector3D& GbVector3D::operator*= (const double& fScalar)
+{
+   m_afTuple[0] *= fScalar;
+   m_afTuple[1] *= fScalar;
+   m_afTuple[2] *= fScalar;
+   return *this;
+}
+//----------------------------------------------------------------------------
+GbVector3D& GbVector3D::operator/= (const double& fScalar)
+{
+   if ( fScalar != (double)0.0 )
+   {
+      double fInvScalar = ((double)1.0)/fScalar;
+      m_afTuple[0] *= fInvScalar;
+      m_afTuple[1] *= fInvScalar;
+      m_afTuple[2] *= fInvScalar;
+   }
+   else
+   {
+      m_afTuple[0] = Ub::inf;
+      m_afTuple[1] = Ub::inf;
+      m_afTuple[2] = Ub::inf;
+   }
+
+   return *this;
+}
+//----------------------------------------------------------------------------
+GbVector3D GbVector3D::Scale(const double& x)
+{
+   GbVector3D PointA(0.0,0.0,0.0);
+   PointA.m_afTuple[0] = x * m_afTuple[0];
+   PointA.m_afTuple[1] = x * m_afTuple[1];
+   PointA.m_afTuple[2] = x * m_afTuple[2];
+   return PointA;	
+}
+
+//----------------------------------------------------------------------------
+double GbVector3D::Length () const
+{
+   return std::sqrt(
+      m_afTuple[0]*m_afTuple[0] +
+      m_afTuple[1]*m_afTuple[1] +
+      m_afTuple[2]*m_afTuple[2]);
+}
+//----------------------------------------------------------------------------
+double GbVector3D::SquaredLength () const
+{
+   return
+      m_afTuple[0]*m_afTuple[0] +
+      m_afTuple[1]*m_afTuple[1] +
+      m_afTuple[2]*m_afTuple[2];
+}
+//----------------------------------------------------------------------------
+double GbVector3D::Dot (const GbVector3D& rkV) const
+{
+   return
+      m_afTuple[0]*rkV.m_afTuple[0] +
+      m_afTuple[1]*rkV.m_afTuple[1] +
+      m_afTuple[2]*rkV.m_afTuple[2];
+}
+//----------------------------------------------------------------------------
+double GbVector3D::Normalize ()
+{
+   double fLength = Length();
+
+   if ( fLength > UbMath::Epsilon<double>::val() )
+   {
+      double fInvLength = ((double)1.0)/fLength;
+      m_afTuple[0] *= fInvLength;
+      m_afTuple[1] *= fInvLength;
+      m_afTuple[2] *= fInvLength;
+   }
+   else
+   {
+      fLength = 0.0;
+      m_afTuple[0] = 0.0;
+      m_afTuple[1] = 0.0;
+      m_afTuple[2] = 0.0;
+   }
+
+   return fLength;
+}
+//----------------------------------------------------------------------------
+GbVector3D GbVector3D::Cross (const GbVector3D& rkV) const
+{
+   return GbVector3D(
+      m_afTuple[1]*rkV.m_afTuple[2] - m_afTuple[2]*rkV.m_afTuple[1],
+      m_afTuple[2]*rkV.m_afTuple[0] - m_afTuple[0]*rkV.m_afTuple[2],
+      m_afTuple[0]*rkV.m_afTuple[1] - m_afTuple[1]*rkV.m_afTuple[0]);
+}
+
+//----------------------------------------------------------------------------
+
+GbVector3D GbVector3D::UnitCross (const GbVector3D& rkV) const
+{
+   GbVector3D kCross(
+      m_afTuple[1]*rkV.m_afTuple[2] - m_afTuple[2]*rkV.m_afTuple[1],
+      m_afTuple[2]*rkV.m_afTuple[0] - m_afTuple[0]*rkV.m_afTuple[2],
+      m_afTuple[0]*rkV.m_afTuple[1] - m_afTuple[1]*rkV.m_afTuple[0]);
+   kCross.Normalize();
+   return kCross;
+}
+//----------------------------------------------------------------------------
+void GbVector3D::GetBarycentrics (const GbVector3D& rkV0,
+                                  const GbVector3D& rkV1, const GbVector3D& rkV2,
+                                  const GbVector3D& rkV3, double afBary[4]) const
+{
+   // compute the vectors relative to V3 of the tetrahedron
+   GbVector3D akDiff[4] =
+   {
+      rkV0 - rkV3,
+         rkV1 - rkV3,
+         rkV2 - rkV3,
+         *this - rkV3
+   };
+
+   // If the vertices have large magnitude, the linear system of
+   // equations for computing barycentric coordinates can be
+   // ill-conditioned.  To avoid this, uniformly scale the tetrahedron
+   // edges to be of order 1.  The scaling of all differences does not
+   // change the barycentric coordinates.
+   double fMax = (double)0.0;
+   int i;
+   for (i = 0; i < 3; i++)
+   {
+      for (int j = 0; j < 3; j++)
+      {
+         double fValue = std::fabs(akDiff[i][j]);
+         if ( fValue > fMax )
+            fMax = fValue;
+      }
+   }
+
+   // scale down only large data
+   if ( fMax > (double)1.0 )
+   {
+      double fInvMax = ((double)1.0)/fMax;
+      for (i = 0; i < 4; i++)
+         akDiff[i] *= fInvMax;
+   }
+
+   double fDet = akDiff[0].Dot(akDiff[1].Cross(akDiff[2]));
+   GbVector3D kE1cE2 = akDiff[1].Cross(akDiff[2]);
+   GbVector3D kE2cE0 = akDiff[2].Cross(akDiff[0]);
+   GbVector3D kE0cE1 = akDiff[0].Cross(akDiff[1]);
+   if ( std::fabs(fDet) > UbMath::Epsilon<double>::val() )
+   {
+      double fInvDet = ((double)1.0)/fDet;
+      afBary[0] = akDiff[3].Dot(kE1cE2)*fInvDet;
+      afBary[1] = akDiff[3].Dot(kE2cE0)*fInvDet;
+      afBary[2] = akDiff[3].Dot(kE0cE1)*fInvDet;
+      afBary[3] = (double)1.0 - afBary[0] - afBary[1] - afBary[2];
+   }
+   else
+   {
+      // The tetrahedron is potentially flat.  Determine the face of
+      // maximum area and compute barycentric coordinates with respect
+      // to that face.
+      GbVector3D kE02 = rkV0 - rkV2;
+      GbVector3D kE12 = rkV1 - rkV2;
+      GbVector3D kE02cE12 = kE02.Cross(kE12);
+      double fMaxSqrArea = kE02cE12.SquaredLength();
+      int iMaxIndex = 3;
+      double fSqrArea = kE0cE1.SquaredLength();
+      if ( fSqrArea > fMaxSqrArea )
+      {
+         iMaxIndex = 0;
+         fMaxSqrArea = fSqrArea;
+      }
+      fSqrArea = kE1cE2.SquaredLength();
+      if ( fSqrArea > fMaxSqrArea )
+      {
+         iMaxIndex = 1;
+         fMaxSqrArea = fSqrArea;
+      }
+      fSqrArea = kE2cE0.SquaredLength();
+      if ( fSqrArea > fMaxSqrArea )
+      {
+         iMaxIndex = 2;
+         fMaxSqrArea = fSqrArea;
+      }
+
+      if ( fMaxSqrArea > UbMath::Epsilon<double>::val() )
+      {
+         double fInvSqrArea = ((double)1.0)/fMaxSqrArea;
+         GbVector3D kTmp;
+         if ( iMaxIndex == 0 )
+         {
+            kTmp = akDiff[3].Cross(akDiff[1]);
+            afBary[0] = kE0cE1.Dot(kTmp)*fInvSqrArea;
+            kTmp = akDiff[0].Cross(akDiff[3]);
+            afBary[1] = kE0cE1.Dot(kTmp)*fInvSqrArea;
+            afBary[2] = (double)0.0;
+            afBary[3] = (double)1.0 - afBary[0] - afBary[1];
+         }
+         else if ( iMaxIndex == 1 )
+         {
+            afBary[0] = (double)0.0;
+            kTmp = akDiff[3].Cross(akDiff[2]);
+            afBary[1] = kE1cE2.Dot(kTmp)*fInvSqrArea;
+            kTmp = akDiff[1].Cross(akDiff[3]);
+            afBary[2] = kE1cE2.Dot(kTmp)*fInvSqrArea;
+            afBary[3] = (double)1.0 - afBary[1] - afBary[2];
+         }
+         else if ( iMaxIndex == 2 )
+         {
+            kTmp = akDiff[2].Cross(akDiff[3]);
+            afBary[0] = kE2cE0.Dot(kTmp)*fInvSqrArea;
+            afBary[1] = (double)0.0;
+            kTmp = akDiff[3].Cross(akDiff[0]);
+            afBary[2] = kE2cE0.Dot(kTmp)*fInvSqrArea;
+            afBary[3] = (double)1.0 - afBary[0] - afBary[2];
+         }
+         else
+         {
+            akDiff[3] = *this - rkV2;
+            kTmp = akDiff[3].Cross(kE12);
+            afBary[0] = kE02cE12.Dot(kTmp)*fInvSqrArea;
+            kTmp = kE02.Cross(akDiff[3]);
+            afBary[1] = kE02cE12.Dot(kTmp)*fInvSqrArea;
+            afBary[2] = (double)1.0 - afBary[0] - afBary[1];
+            afBary[3] = (double)0.0;
+         }
+      }
+      else
+      {
+         // The tetrahedron is potentially a sliver.  Determine the edge of
+         // maximum length and compute barycentric coordinates with respect
+         // to that edge.
+         double fMaxSqrLength = akDiff[0].SquaredLength();
+         iMaxIndex = 0;  // <V0,V3>
+         double fSqrLength = akDiff[1].SquaredLength();
+         if ( fSqrLength > fMaxSqrLength )
+         {
+            iMaxIndex = 1;  // <V1,V3>
+            fMaxSqrLength = fSqrLength;
+         }
+         fSqrLength = akDiff[2].SquaredLength();
+         if ( fSqrLength > fMaxSqrLength )
+         {
+            iMaxIndex = 2;  // <V2,V3>
+            fMaxSqrLength = fSqrLength;
+         }
+         fSqrLength = kE02.SquaredLength();
+         if ( fSqrLength > fMaxSqrLength )
+         {
+            iMaxIndex = 3;  // <V0,V2>
+            fMaxSqrLength = fSqrLength;
+         }
+         fSqrLength = kE12.SquaredLength();
+         if ( fSqrLength > fMaxSqrLength )
+         {
+            iMaxIndex = 4;  // <V1,V2>
+            fMaxSqrLength = fSqrLength;
+         }
+         GbVector3D kE01 = rkV0 - rkV1;
+         fSqrLength = kE01.SquaredLength();
+         if ( fSqrLength > fMaxSqrLength )
+         {
+            iMaxIndex = 5;  // <V0,V1>
+            fMaxSqrLength = fSqrLength;
+         }
+
+         if ( fMaxSqrLength > UbMath::Epsilon<double>::val() )
+         {
+            double fInvSqrLength = ((double)1.0)/fMaxSqrLength;
+            if ( iMaxIndex == 0 )
+            {
+               // P-V3 = t*(V0-V3)
+               afBary[0] = akDiff[3].Dot(akDiff[0])*fInvSqrLength;
+               afBary[1] = (double)0.0;
+               afBary[2] = (double)0.0;
+               afBary[3] = (double)1.0 - afBary[0];
+            }
+            else if ( iMaxIndex == 1 )
+            {
+               // P-V3 = t*(V1-V3)
+               afBary[0] = (double)0.0;
+               afBary[1] = akDiff[3].Dot(akDiff[1])*fInvSqrLength;
+               afBary[2] = (double)0.0;
+               afBary[3] = (double)1.0 - afBary[1];
+            }
+            else if ( iMaxIndex == 2 )
+            {
+               // P-V3 = t*(V2-V3)
+               afBary[0] = (double)0.0;
+               afBary[1] = (double)0.0;
+               afBary[2] = akDiff[3].Dot(akDiff[2])*fInvSqrLength;
+               afBary[3] = (double)1.0 - afBary[2];
+            }
+            else if ( iMaxIndex == 3 )
+            {
+               // P-V2 = t*(V0-V2)
+               akDiff[3] = *this - rkV2;
+               afBary[0] = akDiff[3].Dot(kE02)*fInvSqrLength;
+               afBary[1] = (double)0.0;
+               afBary[2] = (double)1.0 - afBary[0];
+               afBary[3] = (double)0.0;
+            }
+            else if ( iMaxIndex == 4 )
+            {
+               // P-V2 = t*(V1-V2)
+               akDiff[3] = *this - rkV2;
+               afBary[0] = (double)0.0;
+               afBary[1] = akDiff[3].Dot(kE12)*fInvSqrLength;
+               afBary[2] = (double)1.0 - afBary[1];
+               afBary[3] = (double)0.0;
+            }
+            else
+            {
+               // P-V1 = t*(V0-V1)
+               akDiff[3] = *this - rkV1;
+               afBary[0] = akDiff[3].Dot(kE01)*fInvSqrLength;
+               afBary[1] = (double)1.0 - afBary[0];
+               afBary[2] = (double)0.0;
+               afBary[3] = (double)0.0;
+            }
+         }
+         else
+         {
+            // tetrahedron is a nearly a point, just return equal weights
+            afBary[0] = (double)0.25;
+            afBary[1] = afBary[0];
+            afBary[2] = afBary[0];
+            afBary[3] = afBary[0];
+         }
+      }
+   }
+}
+//----------------------------------------------------------------------------
+void GbVector3D::Orthonormalize (GbVector3D& rkU, GbVector3D& rkV, GbVector3D& rkW)
+{
+   // If the input vectors are v0, v1, and v2, then the Gram-Schmidt
+   // orthonormalization produces vectors u0, u1, and u2 as follows,
+   //
+   //   u0 = v0/|v0|
+   //   u1 = (v1-(u0*v1)u0)/|v1-(u0*v1)u0|
+   //   u2 = (v2-(u0*v2)u0-(u1*v2)u1)/|v2-(u0*v2)u0-(u1*v2)u1|
+   //
+   // where |A| indicates length of vector A and A*B indicates dot
+   // product of vectors A and B.
+
+   // compute u0
+   rkU.Normalize();
+
+   // compute u1
+   double fDot0 = rkU.Dot(rkV); 
+   rkV -= fDot0*rkU;
+   rkV.Normalize();
+
+   // compute u2
+   double fDot1 = rkV.Dot(rkW);
+   fDot0 = rkU.Dot(rkW);
+   rkW -= fDot0*rkU + fDot1*rkV;
+   rkW.Normalize();
+}
+//----------------------------------------------------------------------------
+void GbVector3D::Orthonormalize (GbVector3D* akV)
+{
+   Orthonormalize(akV[0],akV[1],akV[2]);
+}
+//----------------------------------------------------------------------------
+void GbVector3D::GenerateOrthonormalBasis (GbVector3D& rkU, GbVector3D& rkV,
+                                           GbVector3D& rkW, bool bUnitLengthW)
+{
+   if ( !bUnitLengthW )
+      rkW.Normalize();
+
+   double fInvLength;
+
+   if ( std::fabs(rkW.m_afTuple[0]) >=
+      std::fabs(rkW.m_afTuple[1]) )
+   {
+      // W.x or W.z is the largest magnitude component, swap them
+      fInvLength = UbMath::invSqrt(rkW.m_afTuple[0]*rkW.m_afTuple[0] + rkW.m_afTuple[2]*rkW.m_afTuple[2]);
+      rkU.m_afTuple[0] = -rkW.m_afTuple[2]*fInvLength;
+      rkU.m_afTuple[1] = (double)0.0;
+      rkU.m_afTuple[2] = +rkW.m_afTuple[0]*fInvLength;
+   }
+   else
+   {
+      // W.y or W.z is the largest magnitude component, swap them
+      fInvLength = UbMath::invSqrt(rkW.m_afTuple[1]*rkW.m_afTuple[1] + rkW.m_afTuple[2]*rkW.m_afTuple[2]);
+      rkU.m_afTuple[0] = (double)0.0;
+      rkU.m_afTuple[1] = +rkW.m_afTuple[2]*fInvLength;
+      rkU.m_afTuple[2] = -rkW.m_afTuple[1]*fInvLength;
+   }
+
+   rkV = rkW.Cross(rkU);
+}
+//----------------------------------------------------------------------------
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbVector3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbVector3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbVector3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbVector3D.h
index 5dc91d9458b66ac28c9aa9a9ca69947bed780c24..538ead81269d2614b7b6954889fdee09d22d59c1 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbVector3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbVector3D.h
@@ -1,132 +1,132 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBVECTOR3D_H
-#define GBVECTOR3D_H
-                                                                   
-#include <cfloat>                               
-#include <cassert> 
-#include <string>
-
-#ifdef CAB_RCF
-   #include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-#include <PointerDefinitions.h>
-
-class GbPoint3D;
-
-class GbVector3D 
-{
-public:
-   // construction
-    GbVector3D (); 
-    GbVector3D (const double& fX1, const double& fX2, const double& fX3);
-    GbVector3D (const GbVector3D& rkV);
-    GbVector3D (const GbPoint3D& rkV);
-
-    std::string toString();
-
-    // coordinate access
-    operator const double* () const;
-    operator double* ();
-    double operator[] (int i) const;
-    double& operator[] (int i);
-    double X1 () const;
-    double& X1 ();
-    double X2 () const;
-    double& X2 ();                                    
-    double X3 () const;
-    double& X3 ();
-
-    // assignment
-    GbVector3D& operator= (const GbVector3D& rkV);
-
-    // comparison
-    bool operator== (const GbVector3D& rkV) const;
-    bool operator!= (const GbVector3D& rkV) const;
-    bool operator<  (const GbVector3D& rkV) const;
-    bool operator<= (const GbVector3D& rkV) const;
-    bool operator>  (const GbVector3D& rkV) const;
-    bool operator>= (const GbVector3D& rkV) const;
-
-    // arithmetic operations
-    GbVector3D operator+ (const GbVector3D& rkV) const;
-    GbVector3D operator- (const GbVector3D& rkV) const;
-    GbVector3D operator* (const double& fScalar) const;
-    GbVector3D operator/ (const double& fScalar) const;
-    GbVector3D operator- () const;
-
-    // arithmetic updates
-    GbVector3D& operator+= (const GbVector3D& rkV);
-    GbVector3D& operator-= (const GbVector3D& rkV);
-    GbVector3D& operator*= (const double& fScalar);
-    GbVector3D& operator/= (const double& fScalar);
-
-    GbVector3D Add(GbVector3D& vector);
-    GbVector3D Subtract(GbVector3D& vector);
-    GbVector3D Scale(const double& x);
-
-    // vector operations
-    double Length () const;
-    double SquaredLength () const;
-    double Dot (const GbVector3D& rkV) const;
-    double Normalize ();
-
-    // The cross products are computed using the right-handed rule.  Be aware
-    // that some graphics APIs use a left-handed rule.  If you have to compute
-    // a cross product with these functions and send the result to the API
-    // that expects left-handed, you will need to change sign on the vector
-    // (replace each component value c by -c).
-    GbVector3D Cross (const GbVector3D& rkV) const;
-    GbVector3D UnitCross (const GbVector3D& rkV) const;
-
-    // Compute the barycentric coordinates of the point with respect to the
-    // tetrahedron <V0,V1,V2,V3>, P = b0*V0 + b1*V1 + b2*V2 + b3*V3, where
-    // b0 + b1 + b2 + b3 = 1.
-    void GetBarycentrics (const GbVector3D& rkV0,
-                          const GbVector3D& rkV1, const GbVector3D& rkV2,
-                          const GbVector3D& rkV3, double afBary[4]) const;
-
-    // Gram-Schmidt orthonormalization.  Take linearly independent vectors
-    // U, V, and W and compute an orthonormal set (unit length, mutually
-    // perpendicular).
-    static void Orthonormalize (GbVector3D& rkU, GbVector3D& rkV, GbVector3D& rkW);
-    static void Orthonormalize (GbVector3D* akV);
-
-    // Input W must be initialized to a nonzero vector, output is {U,V,W},
-    // an orthonormal basis.  A hint is provided about whether or not W
-    // is already unit length.
-    static void GenerateOrthonormalBasis (GbVector3D& rkU, GbVector3D& rkV,
-                                          GbVector3D& rkW, bool bUnitLengthW);
-
-    // special vectors
-    static const GbVector3D ZERO;
-    static const GbVector3D UNIT_X1;
-    static const GbVector3D UNIT_X2;
-    static const GbVector3D UNIT_X3;
-
-#ifdef CAB_RCF
-    template<class Archive>
-    void SF_SERIALIZE(Archive & ar)
-    {
-       ar & m_afTuple;
-    }
-#endif //CAB_RCF
-private:
-    // support for comparisons
-    int CompareArrays (const GbVector3D& rkV) const;
-
-    double m_afTuple[3];
-};
-
-GbVector3D operator* (const double& fScalar, const GbVector3D& rkV);
-
-#ifdef RCF_USE_SF_SERIALIZATION
-   UB_AUTO_RUN_NAMED(   SF::registerType<GbVector3D  >("GbVector3D  "), SF_GbVector3D     );
-#endif //RCF_USE_SF_SERIALIZATION
-
-#endif //GBVECTOR3D_H
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBVECTOR3D_H
+#define GBVECTOR3D_H
+                                                                   
+#include <cfloat>                               
+#include <cassert> 
+#include <string>
+
+#ifdef CAB_RCF
+   #include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+#include <PointerDefinitions.h>
+
+class GbPoint3D;
+
+class GbVector3D 
+{
+public:
+   // construction
+    GbVector3D (); 
+    GbVector3D (const double& fX1, const double& fX2, const double& fX3);
+    GbVector3D (const GbVector3D& rkV);
+    GbVector3D (const GbPoint3D& rkV);
+
+    std::string toString();
+
+    // coordinate access
+    operator const double* () const;
+    operator double* ();
+    double operator[] (int i) const;
+    double& operator[] (int i);
+    double X1 () const;
+    double& X1 ();
+    double X2 () const;
+    double& X2 ();                                    
+    double X3 () const;
+    double& X3 ();
+
+    // assignment
+    GbVector3D& operator= (const GbVector3D& rkV);
+
+    // comparison
+    bool operator== (const GbVector3D& rkV) const;
+    bool operator!= (const GbVector3D& rkV) const;
+    bool operator<  (const GbVector3D& rkV) const;
+    bool operator<= (const GbVector3D& rkV) const;
+    bool operator>  (const GbVector3D& rkV) const;
+    bool operator>= (const GbVector3D& rkV) const;
+
+    // arithmetic operations
+    GbVector3D operator+ (const GbVector3D& rkV) const;
+    GbVector3D operator- (const GbVector3D& rkV) const;
+    GbVector3D operator* (const double& fScalar) const;
+    GbVector3D operator/ (const double& fScalar) const;
+    GbVector3D operator- () const;
+
+    // arithmetic updates
+    GbVector3D& operator+= (const GbVector3D& rkV);
+    GbVector3D& operator-= (const GbVector3D& rkV);
+    GbVector3D& operator*= (const double& fScalar);
+    GbVector3D& operator/= (const double& fScalar);
+
+    GbVector3D Add(GbVector3D& vector);
+    GbVector3D Subtract(GbVector3D& vector);
+    GbVector3D Scale(const double& x);
+
+    // vector operations
+    double Length () const;
+    double SquaredLength () const;
+    double Dot (const GbVector3D& rkV) const;
+    double Normalize ();
+
+    // The cross products are computed using the right-handed rule.  Be aware
+    // that some graphics APIs use a left-handed rule.  If you have to compute
+    // a cross product with these functions and send the result to the API
+    // that expects left-handed, you will need to change sign on the vector
+    // (replace each component value c by -c).
+    GbVector3D Cross (const GbVector3D& rkV) const;
+    GbVector3D UnitCross (const GbVector3D& rkV) const;
+
+    // Compute the barycentric coordinates of the point with respect to the
+    // tetrahedron <V0,V1,V2,V3>, P = b0*V0 + b1*V1 + b2*V2 + b3*V3, where
+    // b0 + b1 + b2 + b3 = 1.
+    void GetBarycentrics (const GbVector3D& rkV0,
+                          const GbVector3D& rkV1, const GbVector3D& rkV2,
+                          const GbVector3D& rkV3, double afBary[4]) const;
+
+    // Gram-Schmidt orthonormalization.  Take linearly independent vectors
+    // U, V, and W and compute an orthonormal set (unit length, mutually
+    // perpendicular).
+    static void Orthonormalize (GbVector3D& rkU, GbVector3D& rkV, GbVector3D& rkW);
+    static void Orthonormalize (GbVector3D* akV);
+
+    // Input W must be initialized to a nonzero vector, output is {U,V,W},
+    // an orthonormal basis.  A hint is provided about whether or not W
+    // is already unit length.
+    static void GenerateOrthonormalBasis (GbVector3D& rkU, GbVector3D& rkV,
+                                          GbVector3D& rkW, bool bUnitLengthW);
+
+    // special vectors
+    static const GbVector3D ZERO;
+    static const GbVector3D UNIT_X1;
+    static const GbVector3D UNIT_X2;
+    static const GbVector3D UNIT_X3;
+
+#ifdef CAB_RCF
+    template<class Archive>
+    void SF_SERIALIZE(Archive & ar)
+    {
+       ar & m_afTuple;
+    }
+#endif //CAB_RCF
+private:
+    // support for comparisons
+    int CompareArrays (const GbVector3D& rkV) const;
+
+    double m_afTuple[3];
+};
+
+GbVector3D operator* (const double& fScalar, const GbVector3D& rkV);
+
+#ifdef RCF_USE_SF_SERIALIZATION
+   UB_AUTO_RUN_NAMED(   SF::registerType<GbVector3D  >("GbVector3D  "), SF_GbVector3D     );
+#endif //RCF_USE_SF_SERIALIZATION
+
+#endif //GBVECTOR3D_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/GbVoxelMatrix3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbVoxelMatrix3D.cpp
index 7b19711c8669d23089378aa84d9897979259eb37..bb55918a918ddb29ac20ced952ee4b48a70c9534 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbVoxelMatrix3D.cpp
@@ -1,1109 +1,1109 @@
-#include <numerics/geometry3d/GbVoxelMatrix3D.h>
-
-#include <basics/utilities/UbMath.h>
-#include <basics/utilities/UbFileInputASCII.h>
-#include <numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h>
-#include <numerics/geometry3d/GbTriangle3D.h>
-#include <basics/utilities/UbFileOutputASCII.h>
-#include <numerics/geometry3d/CoordinateTransformation3D.h>
-
-#include <basics/utilities/UbSystem.h>
-
-#ifdef MC_CUBES
-#include <MarchingCubes/MarchingCubes.h>
-#endif // MC_CUBES
-
-using namespace std;
-
-const float GbVoxelMatrix3D::SOLID = 1.0f;
-const float GbVoxelMatrix3D::FLUID = 0.0f;
-
-
-/*=======================================================*/
-ObObjectCreator* GbVoxelMatrix3D::getCreator()
-{
-   return GbVoxelMatrix3DCreator::getInstance();
-}
-/*=======================================================*/
-// Konstruktor
-GbVoxelMatrix3D::GbVoxelMatrix3D(int nx1, int nx2, int nx3, float initVal, double lowerThreshold, double upperThreshold)
-   : GbObject3D()
-   , minX1(0.0)
-   , minX2(0.0)
-   , minX3(0.0)
-   , lowerThreshold(lowerThreshold)
-   , upperThreshold(upperThreshold)
-   , nodesX1(nx1)
-   , nodesX2(nx2)
-   , nodesX3(nx3)
-   , deltaX1(1.0)
-   , deltaX2(1.0)
-   , deltaX3(1.0)
-   , transferViaFilename(false)
-   , addSurfaceTriangleSetFlag(true)
-   , voxelMatrix(Matrix3D(nx1, nx2, nx3, initVal))
-{
-   this->setName("VoxelMatrix3D");
-}
-/*=======================================================*/
-GbVoxelMatrix3D::GbVoxelMatrix3D()
-   : GbObject3D()
-   , minX1(0.0)
-   , minX2(0.0)
-   , minX3(0.0)
-   , nodesX1(0)
-   , nodesX2(0)
-   , nodesX3(0)
-   , lowerThreshold(0.0)
-   , upperThreshold(0.0)
-   , deltaX1(1.0)
-   , deltaX2(1.0)
-   , deltaX3(1.0)
-   , transferViaFilename(false)
-   , addSurfaceTriangleSetFlag(true)
-{
-   this->setName("VoxelMatrix3D");
-}
-/*=======================================================*/
-GbVoxelMatrix3D::GbVoxelMatrix3D(const Matrix3D& voxelMatrix, double lowerThreshold, double upperThreshold)
-   : GbObject3D()
-   , minX1(0.0)
-   , minX2(0.0)
-   , minX3(0.0)
-   , nodesX1((int)voxelMatrix.getNX1())
-   , nodesX2((int)voxelMatrix.getNX2())
-   , nodesX3((int)voxelMatrix.getNX3())
-   , lowerThreshold(lowerThreshold)
-   , upperThreshold(upperThreshold)
-   , deltaX1(1.0)
-   , deltaX2(1.0)
-   , deltaX3(1.0)
-   , transferViaFilename(false)
-   , addSurfaceTriangleSetFlag(true)
-   , voxelMatrix(voxelMatrix)
-{
-   this->setName("VoxelMatrix3D");
-}
-/*=======================================================*/
-GbVoxelMatrix3D*  GbVoxelMatrix3D::clone()
-{
-   GbVoxelMatrix3D* vm = new GbVoxelMatrix3D(this->voxelMatrix, lowerThreshold, upperThreshold);
-   vm->setVoxelMatrixMininum(minX1, minX2, minX3);
-   vm->setVoxelMatrixDelta(deltaX1, deltaX2, deltaX3);
-   return  vm;
-}
-/*=======================================================*/
-void GbVoxelMatrix3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3)
-{
-   this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid());
-}
-/*=======================================================*/
-void GbVoxelMatrix3D::translate(const double& tx1, const double& tx2, const double& tx3)
-{
-   this->minX1 += tx1;
-   this->minX2 += tx2;
-   this->minX3 += tx3;
-   this->notifyObserversObjectChanged();
-}
-/*=======================================================*/
-void GbVoxelMatrix3D::setClosedVoidSpaceToSolid()
-{
-   voxelMatrixTemp = Matrix3D(nodesX1, nodesX2, nodesX3, SOLID);
-   flagMatrix = CbArray3D<char>(nodesX1, nodesX2, nodesX3, 0);
-
-   for (int x3 = 0; x3<nodesX3; x3++)
-   {
-      for (int x2 = 0; x2<nodesX2; x2++)
-      {
-         for (int x1 = 0; x1<nodesX1; x1++)
-         {
-            if (voxelMatrix(x1, x2, x3)==FLUID)
-            {
-               UBLOG(logINFO, "setClosedVoidSpaceToSolid:start");
-               x1Nbr.push_back(x1);
-               x2Nbr.push_back(x2);
-               x3Nbr.push_back(x3);
-               int size = (int)x1Nbr.size();
-               while (size>0)
-               {
-                  for (int i = 0; i<size; i++)
-                  {
-                     findFluidNeighbor(x1Nbr[i], x2Nbr[i], x3Nbr[i]);
-                  }
-
-                  swap(x1Nbr, x1NbrTemp);
-                  swap(x2Nbr, x2NbrTemp);
-                  swap(x3Nbr, x3NbrTemp);
-
-                  x1NbrTemp.clear();
-                  x2NbrTemp.clear();
-                  x3NbrTemp.clear();
-                  size = (int)x1Nbr.size();
-               }
-               UBLOG(logINFO, "setClosedVoidSpaceToSolid:end");
-               voxelMatrix = voxelMatrixTemp;
-               return;
-            }
-
-         }
-      }
-   }
-}
-/*=======================================================*/
-void GbVoxelMatrix3D::findFluidNeighbor(int x1, int x2, int x3)
-{
-   for (int k3 = -1; k3<=1; k3++)
-   {
-      for (int k2 = -1; k2<=1; k2++)
-      {
-         for (int k1 = -1; k1<=1; k1++)
-         {
-            int j1 = x1+k1;
-            int j2 = x2+k2;
-            int j3 = x3+k3;
-            if (j1>=0&&j1<nodesX1 && j2>=0&&j2<nodesX2 && j3>=0&&j3<nodesX3)
-            {
-               if (voxelMatrix(j1, j2, j3)==FLUID)
-               {
-                  if (flagMatrix(j1, j2, j3)==0)
-                  {
-                     voxelMatrixTemp(j1, j2, j3) = FLUID;
-                     flagMatrix(j1, j2, j3) = 1;
-                     x1NbrTemp.push_back(j1);
-                     x2NbrTemp.push_back(j2);
-                     x3NbrTemp.push_back(j3);
-                  }
-               }
-            }
-         }
-      }
-   }
-}
-/*=======================================================*/
-void GbVoxelMatrix3D::calculateNumberOfSolidAndFluid()
-{
-   numberOfSolid = 0;
-
-   for (int x3 = 0; x3<nodesX3; x3++)
-      for (int x2 = 0; x2<nodesX2; x2++)
-         for (int x1 = 0; x1<nodesX1; x1++)
-         {
-            if (voxelMatrix(x1, x2, x3)==GbVoxelMatrix3D::SOLID)
-            {
-               numberOfSolid++;
-            }
-         }
-
-   numberOfFluid = (long)nodesX1*(long)nodesX2*(long)nodesX3-numberOfSolid;
-}
-/*=======================================================*/
-long GbVoxelMatrix3D::getNumberOfSolid()
-{
-   return numberOfSolid;
-}
-/*=======================================================*/
-long GbVoxelMatrix3D::getNumberOfFluid()
-{
-   return numberOfFluid;
-}
-/*=======================================================*/
-double GbVoxelMatrix3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
-{
-   if (!((UbMath::equal(rx1, 0.0)||UbMath::equal(fabs(rx1), 1.0)||UbMath::equal(fabs(rx1), UbMath::one_over_sqrt2)||UbMath::equal(fabs(rx1), UbMath::one_over_sqrt3))
-      &&(UbMath::equal(rx2, 0.0)||UbMath::equal(fabs(rx2), 1.0)||UbMath::equal(fabs(rx2), UbMath::one_over_sqrt2)||UbMath::equal(fabs(rx2), UbMath::one_over_sqrt3))
-      &&(UbMath::equal(rx3, 0.0)||UbMath::equal(fabs(rx3), 1.0)||UbMath::equal(fabs(rx3), UbMath::one_over_sqrt2)||UbMath::equal(fabs(rx3), UbMath::one_over_sqrt3))))
-   {
-      throw UbException(UB_EXARGS, "nur fuer diskrete Boltzmannrichungen implementiert!!!");
-   }
-
-   //nachbarindex ermitteln
-   int ndx1 = 0, ndx2 = 0, ndx3 = 0;
-   if (UbMath::greater(rx1, 0.0)) ndx1 = 1;
-   else if (UbMath::less(rx1, 0.0)) ndx1 = -1;
-   if (UbMath::greater(rx2, 0.0)) ndx2 = 1;
-   else if (UbMath::less(rx2, 0.0)) ndx2 = -1;
-   if (UbMath::greater(rx3, 0.0)) ndx3 = 1;
-   else if (UbMath::less(rx3, 0.0)) ndx3 = -1;
-
-   int nix1 = UbMath::integerRounding((x1-minX1)/deltaX1)+ndx1;
-   int nix2 = UbMath::integerRounding((x2-minX2)/deltaX2)+ndx2;
-   int nix3 = UbMath::integerRounding((x3-minX3)/deltaX3)+ndx3;
-
-   //test ob nachbar solid
-   if (nix1>=0
-      &&nix2>=0
-      &&nix3>=0
-      &&nix1<voxelMatrix.getNX1()
-      &&nix2<voxelMatrix.getNX2()
-      &&nix3<voxelMatrix.getNX3())
-   {
-      if (UbMath::equal(voxelMatrix(nix1, nix2, nix3), SOLID))
-      {
-         //return halber abstand der beiden knoten
-         return 0.5*sqrt((ndx1*deltaX1)*(ndx1*deltaX1)
-            +(ndx2*deltaX2)*(ndx2*deltaX2)
-            +(ndx3*deltaX3)*(ndx3*deltaX3));
-      }
-   }
-
-   return 0.0;
-}
-/*=======================================================*/
-bool GbVoxelMatrix3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
-{
-   //index ermitteln
-   int ix1 = UbMath::integerRounding((x1p-minX1)/deltaX1);
-   int ix2 = UbMath::integerRounding((x2p-minX2)/deltaX2);
-   int ix3 = UbMath::integerRounding((x3p-minX3)/deltaX3);
-
-   if (ix1>=0
-      &&ix2>=0
-      &&ix3>=0
-      &&ix1<voxelMatrix.getNX1()
-      &&ix2<voxelMatrix.getNX2()
-      &&ix3<voxelMatrix.getNX3())
-   {
-      if (UbMath::equal(voxelMatrix(ix1, ix2, ix3), SOLID)) return true;
-   }
-
-   return false;
-}
-/*=======================================================*/
-bool GbVoxelMatrix3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
-{
-   pointIsOnBoundary = false;
-
-   return isPointInGbObject3D(x1p, x2p, x3p);
-}
-/*=======================================================*/
-bool GbVoxelMatrix3D::isCellInsideGbObject3D(const double& x1p1, const double& x2p1, const double& x3p1, const double& x1p2, const double& x2p2, const double& x3p2)
-{
-   return false;
-   //dass hängt von der Konfigration ab, aber meist ist der Block grösser wie etliche Poren ...
-
-      //indizes ermitteln
-   int startix1 = (int)std::floor((x1p1-minX1)/deltaX1+1E-13);
-   int startix2 = (int)std::floor((x2p1-minX2)/deltaX2+1E-13);
-   int startix3 = (int)std::floor((x3p1-minX3)/deltaX3+1E-13);
-
-   if (startix1<0) return false;
-   if (startix2<0) return false;
-   if (startix3<0) return false;
-
-   int maxiX1 = (int)voxelMatrix.getNX1()-1;
-   int maxiX2 = (int)voxelMatrix.getNX2()-1;
-   int maxiX3 = (int)voxelMatrix.getNX3()-1;
-
-   int endix1 = (int)std::ceil((x1p2-minX1)/deltaX1-1E-13);
-   int endix2 = (int)std::ceil((x2p2-minX2)/deltaX2-1E-13);
-   int endix3 = (int)std::ceil((x3p2-minX3)/deltaX3-1E-13);
-
-   if (endix1>maxiX1) return false;
-   if (endix2>maxiX2) return false;
-   if (endix3>maxiX3) return false;
-
-   for (int ix3 = startix3; ix3<=endix3; ix3++)
-      for (int ix2 = startix2; ix2<=endix2; ix2++)
-         for (int ix1 = startix1; ix1<=endix1; ix1++)
-            if (UbMath::equal(voxelMatrix(ix1, ix2, ix3), FLUID))
-               return false;
-   return true;
-}
-/*=======================================================*/
-bool GbVoxelMatrix3D::isCellCuttingGbObject3D(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b)
-//Merksatz: cell oder deren Volumen schneidet oder beinhaltet komplette oder Teile der CuboidUmrandung
-//returns true:
-//  - cell cuts  GbVoxelMatrix3D
-//  - cell boxes GbVoxelMatrix3D
-//returns false:
-//  - cell completely inside GbVoxelMatrix3D 
-//  - cell und cuboid3D haben kein gemeinsames Volumen
-{
-   //erstmal die dumm Loesung
-   if (!(this->isCellInsideGbObject3D(x1a, x2a, x3a, x1b, x2b, x3b))
-      &&this->isCellInsideOrCuttingGbObject3D(x1a, x2a, x3a, x1b, x2b, x3b))
-   {
-      return true;
-   }
-
-   return false;
-}
-/*=======================================================*/
-bool GbVoxelMatrix3D::isCellInsideOrCuttingGbObject3D(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b)
-//returns true:
-//  - cell completely inside cuboid3D ( = cuboid3D boxes cell)
-//  - cell cuts  cuboid3D
-//  - cell boxes cuboid3D
-//returns false:
-//  - cell und cuboid3D haben kein gemeinsames Volumen
-{
-   //simpler check, da unser GbCuboid3D ein AABB is:
-  //  anfA        midA         endA             anfB    midB    endB
-  //   |            x<-- dxA -->|                 |<-dxB->x       |
-  //                |<----------------- T --------------->|
-  //ist |T| <= dxA + dxB -> overlap!
-
-   if (UbMath::lessEqual(std::fabs(this->getX1Centroid()-0.5*(x1b+x1a)      /*Tx1*/)
-      , 0.5*(this->getLengthX1()+std::fabs(x1b-x1a) /*dx1A+dx1B*/))
-
-      &&UbMath::lessEqual(std::fabs(this->getX2Centroid()-0.5*(x2b+x2a)      /*Tx2*/)
-         , 0.5*(this->getLengthX2()+std::fabs(x2b-x2a) /*dx2A+dx2B*/))
-
-      &&UbMath::lessEqual(std::fabs(this->getX3Centroid()-0.5*(x3b+x3a)      /*Tx3*/)
-         , 0.5*(this->getLengthX3()+std::fabs(x3b-x3a) /*dx3A+dx3B*/)))
-   {
-      return true;
-   }
-
-   return false;
-}
-/*=======================================================*/
-vector<GbTriangle3D*> GbVoxelMatrix3D::getSurfaceTriangleSet()
-{
-   vector<GbTriangle3D*> triangles;
-
-#ifdef MC_CUBES
-   //MC
-   typedef McCubes::Matrix3DWrapper< Matrix3D >                McMatrixWrapper;
-   typedef McCubes::MarchingCubes< McMatrixWrapper >           McMarchingCubesGenerator;
-   typedef McMarchingCubesGenerator::Vertex                    McVertex;
-   typedef McMarchingCubesGenerator::Triangle                  McTriangle;
-
-   McMatrixWrapper wrapper(&voxelMatrix);//,0,0,0,voxelMatrix.getNX1()-1,voxelMatrix.getNX2()-1,voxelMatrix.getNX3()-1);
-   McMarchingCubesGenerator mc(wrapper);
-
-   mc.init_all();
-   mc.run(0.5);
-
-   //const int   nofVertices  = mc.nverts();
-   const int   nofTriangles = mc.ntrigs();
-
-   McVertex*   mcvertices = mc.vertices();
-   McTriangle* mctriangles = mc.triangles();
-
-   for (int t = 0; t<nofTriangles; t++)
-   {
-      triangles.push_back(new GbTriangle3D(new GbPoint3D(minX1+deltaX1 * (mcvertices[mctriangles[t].v1].x /*-1*/)
-         , minX2+deltaX2 * (mcvertices[mctriangles[t].v1].y /*-1*/)
-         , minX3+deltaX3 * (mcvertices[mctriangles[t].v1].z /*-1*/))
-         , new GbPoint3D(minX1+deltaX1 * (mcvertices[mctriangles[t].v2].x /*-1*/)
-            , minX2+deltaX2 * (mcvertices[mctriangles[t].v2].y /*-1*/)
-            , minX3+deltaX3 * (mcvertices[mctriangles[t].v2].z /*-1*/))
-         , new GbPoint3D(minX1+deltaX1 * (mcvertices[mctriangles[t].v3].x /*-1*/)
-            , minX2+deltaX2 * (mcvertices[mctriangles[t].v3].y /*-1*/)
-            , minX3+deltaX3 * (mcvertices[mctriangles[t].v3].z /*-1*/))));
-   }
-#else
-   cerr<<"vector<GbTriangle3D*> GbVoxelMatrix3D::getSurfaceTriangleSet() - benoetigt MARCHING_CUBE paket aus 3rdParty"<<endl;
-#endif // MC_CUBES
-
-   return triangles;
-}
-/*=======================================================*/
-void GbVoxelMatrix3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles)
-{
-   UBLOG(logINFO, " GbVoxelMatrix3D addSurfaceTriangleSet start")
-      if (!this->addSurfaceTriangleSetFlag)
-      {
-         UBLOG(logINFO, " GbVoxelMatrix3D addSurfaceTriangleSet end without TriangleSetCreation")
-            return;
-      }
-#ifdef MC_CUBES
-   UBLOG(logDEBUG1, " GbVoxelMatrix3D addSurfaceTriangleSet MC defined")
-
-      typedef McCubes::Matrix3DWrapper< Matrix3D >                McMatrixWrapper;
-   typedef McCubes::MarchingCubes< McMatrixWrapper >           McMarchingCubesGenerator;
-   typedef McMarchingCubesGenerator::Vertex                    McVertex;
-   typedef McMarchingCubesGenerator::Triangle                  McTriangle;
-
-   //MC
-   {  //standard( fuer voxelmatrix)
-      McMatrixWrapper wrapper(&voxelMatrix);
-      McMarchingCubesGenerator mc(wrapper);
-
-      UBLOG(logDEBUG1, " GbVoxelMatrix3D addSurfaceTriangleSet McMarchingCubesGenerator")
-
-         UBLOG(logDEBUG1, " GbVoxelMatrix3D addSurfaceTriangleSet mc.init")
-         mc.init_all();
-      UBLOG(logDEBUG1, " GbVoxelMatrix3D addSurfaceTriangleSet mc.run")
-         mc.run(0.5);
-      UBLOG(logDEBUG1, " GbVoxelMatrix3D addSurfaceTriangleSet mc.run done")
-
-         const int   nofVertices = mc.nverts();
-      const int   nofTriangles = mc.ntrigs();
-
-      McVertex*   mcvertices = mc.vertices();
-      McTriangle* mctriangles = mc.triangles();
-
-      UBLOG(logDEBUG1, " GbVoxelMatrix3D node tuple")
-         for (int n = 0; n<nofVertices; n++)
-            nodes.push_back(makeUbTuple((float)(minX1+deltaX1 * (mcvertices[n].x /*-1*/)),   //Anm: kein -1, da man durch manipulation der indices die dreiecke um eins versetzt bekommt
-            (float)(minX2+deltaX2 * (mcvertices[n].y /*-1*/)),
-               (float)(minX3+deltaX3 * (mcvertices[n].z /*-1*/))));
-      UBLOG(logDEBUG1, " GbVoxelMatrix3D triangles tuple")
-         for (int t = 0; t<nofTriangles; t++)
-            triangles.push_back(makeUbTuple(mctriangles[t].v1, mctriangles[t].v2, mctriangles[t].v3));
-      UBLOG(logDEBUG1, " GbVoxelMatrix3D triangles tuple done")
-   }
-
-   //false - das scheint probleme bei der asphaltprobe zu machen 1500x600x100
-   // da lief es bis C - evtl. memory voll
-   if (false)  //extension... um die raender koerrekt abzubilden muesste man eine dummy FLUID reihe um 
-   {         //die matrix legen( lsg1: temp matrix mit 2 reihen pro richtung mehr -> zuviel speicher, 500^3 = 500MB
-             // lsg2: fuer jede flaeche eine dummy matrix -> wie folgt:
-      int nx1 = (int)voxelMatrix.getNX1();
-      int nx2 = (int)voxelMatrix.getNX2();
-      int nx3 = (int)voxelMatrix.getNX3();
-      UBLOG(logINFO, " A ")
-         Matrix3D tmpX1Min(2, nx2+2, nx3+2, FLUID);
-      Matrix3D tmpX1Max(2, nx2+2, nx3+2, FLUID);
-      for (int x3 = 0; x3<nx3; x3++)
-         for (int x2 = 0; x2<nx2; x2++)
-         {
-            tmpX1Min(1, x2+1, x3+1) = voxelMatrix(0, x2, x3);
-            tmpX1Max(0, x2+1, x3+1) = voxelMatrix(nx1-1, x2, x3);
-         }
-      UBLOG(logINFO, " B")
-         Matrix3D tmpX2Min(nx1+2, 2, nx3+2, FLUID);
-      Matrix3D tmpX2Max(nx1+2, 2, nx3+2, FLUID);
-      for (int x3 = 0; x3<nx3; x3++)
-         for (int x1 = 0; x1<nx1; x1++)
-         {
-            tmpX2Min(x1+1, 1, x3+1) = voxelMatrix(x1, 0, x3);
-            tmpX2Max(x1+1, 0, x3+1) = voxelMatrix(x1, nx2-1, x3);
-         }
-      UBLOG(logINFO, " C ")
-         Matrix3D tmpX3Min(nx1+2, nx3+2, 2, FLUID);
-      Matrix3D tmpX3Max(nx1+2, nx3+2, 2, FLUID);
-      for (int x2 = 0; x2<nx2; x2++)
-         for (int x1 = 0; x1<nx1; x1++)
-         {
-            tmpX3Min(x1+1, x2+1, 1) = voxelMatrix(x1, x2, 0);
-            tmpX3Max(x1+1, x2+1, 0) = voxelMatrix(x1, x2, nx3-1);
-         }
-      UBLOG(logINFO, " D")
-         Matrix3D* matrices[] = { &tmpX1Min, &tmpX1Max, &tmpX2Min, &tmpX2Max, &tmpX3Min, &tmpX3Max };
-      int            dx1[] = { -1,     nx1-1,        -1,        -1,        -1,        -1 };
-      int            dx2[] = { -1,        -1,        -1,     nx2-1,        -1,        -1 };
-      int            dx3[] = { -1,        -1,        -1,        -1,        -1,     nx3-1 };
-      UBLOG(logINFO, " E")
-         for (int i = 0; i<6; i++)
-         {
-            McMatrixWrapper wrapper(matrices[i]);
-            McMarchingCubesGenerator mc(wrapper);
-
-            mc.init_all();
-            mc.run(0.5);
-
-            McVertex*   mcvertices = mc.vertices();
-            McTriangle* mctriangles = mc.triangles();
-
-            int deltaNodeNr = (int)nodes.size();
-            UBLOG(logINFO, " GbVoxelMatrix3D node tuple")
-               for (int n = 0; n<mc.nverts(); n++)
-                  nodes.push_back(makeUbTuple((float)(minX1+deltaX1 * (mcvertices[n].x+dx1[i])),   //Anm: kein -1, da man durch manipulation der indices die dreiecke um eins versetzt bekommt
-                  (float)(minX2+deltaX2 * (mcvertices[n].y+dx2[i])),
-                     (float)(minX3+deltaX3 * (mcvertices[n].z+dx3[i]))));
-            for (int t = 0; t<mc.ntrigs(); t++)
-               triangles.push_back(makeUbTuple(deltaNodeNr+mctriangles[t].v1, deltaNodeNr+mctriangles[t].v2, deltaNodeNr+mctriangles[t].v3));
-         }
-   }
-#else
-   cerr<<"void GbVoxelMatrix3D.addSurfaceTriangleSet  - benoetigt MARCHING_CUBE paket aus 3rdParty"<<endl;
-#endif // MC_CUBES
-
-   UBLOG(logINFO, " GbVoxelMatrix3D addSurfaceTriangleSet end")
-}
-/*=======================================================*/
-string GbVoxelMatrix3D::toString()
-{
-   return "GbVoxelMatrix3D";
-}
-/*=======================================================*/
-void GbVoxelMatrix3D::write(UbFileOutput* out)
-{
-   out->writeString(this->getCreator()->getTypeID());
-   out->writeDouble(minX1);
-   out->writeDouble(minX2);
-   out->writeDouble(minX3);
-   out->writeDouble(deltaX1);
-   out->writeDouble(deltaX2);
-   out->writeDouble(deltaX3);
-   out->writeInteger(nodesX1);
-   out->writeInteger(nodesX2);
-   out->writeInteger(nodesX3);
-   out->writeDouble(lowerThreshold);
-   out->writeDouble(upperThreshold);
-   out->writeBool(addSurfaceTriangleSetFlag);
-   out->writeBool(transferViaFilename);
-   if (!transferViaFilename)
-   {
-      throw UbException(UB_EXARGS, "void GbVoxelMatrix3D::write(UbFileOutput* out)  - geht ned");
-   }
-   else
-   {
-      out->writeString(filename);
-   }
-
-
-   //CbUniformMatrix3D<float> voxelMatrix;
-}
-/*=======================================================*/
-void GbVoxelMatrix3D::read(UbFileInput* in)
-{
-#ifdef CAB_RCF
-   try
-   {
-#endif
-      //!!! den string nimmt er vorher um das Object zu erstellen
-      //in->readString();      
-      minX1 = in->readDouble();
-      minX2 = in->readDouble();
-      minX3 = in->readDouble();
-      deltaX1 = in->readDouble();
-      deltaX2 = in->readDouble();
-      deltaX3 = in->readDouble();
-      nodesX1 = in->readInteger();
-      nodesX2 = in->readInteger();
-      nodesX3 = in->readInteger();
-      lowerThreshold = in->readDouble();
-      upperThreshold = in->readDouble();
-      addSurfaceTriangleSetFlag = in->readBool();
-      transferViaFilename = in->readBool();
-      if (!transferViaFilename)
-      {
-         throw UbException(UB_EXARGS, "void GbVoxelMatrix3D::read(UbFileOutput* out)  - geht ned");
-      }
-      else
-      {
-         filename = in->readString();
-         this->readMatrixFromVtiASCIIFile(filename);
-      }
-#ifdef CAB_RCF
-   }
-   catch (std::exception& e) { UBLOGML(logERROR, UB_FUNCTION+(std::string)e.what());        throw RCF::Exception(1002, UB_FUNCTION+(std::string)e.what()); }
-   catch (...) { UBLOGML(logERROR, UB_FUNCTION+(std::string)"unknown error"); throw RCF::Exception(1002, UB_FUNCTION+(std::string)"unknown error"); }
-#endif
-}
-/*=======================================================*/
-void GbVoxelMatrix3D::readMatrixFromVtiASCIIFile(std::string filename)
-
-{
-   //UBLOG(logINFO,"  - create GbVoxelMatrix3D");
-   UbFileInputASCII in(filename);
-   //ifstream in(filename.c_str(), ios::binary);
-   if (!in) throw UbException(UB_EXARGS, "could not open file "+filename);
-   in.readLine();
-   in.readLine();
-   in.readLine();
-   in.readLine();
-   in.readLine();
-
-   voxelMatrix = Matrix3D(nodesX1, nodesX2, nodesX3, GbVoxelMatrix3D::FLUID);
-
-   //UBLOG(logINFO,"  - init values");
-   int val;
-   int u = 0;
-   for (int x3 = 0; x3<nodesX3; x3++)
-      for (int x2 = 0; x2<nodesX2; x2++)
-         for (int x1 = 0; x1<nodesX1; x1++)
-         {
-            val = in.readInteger();
-            //if( !UbMath::equal(val, 0.0f) ) 
-            //if( UbMath::greater(val, threshold) ) 
-            if ((double)val>=lowerThreshold&&(double)val<=upperThreshold)
-            {
-               (voxelMatrix)(x1, x2, x3) = GbVoxelMatrix3D::SOLID;
-            }
-         }
-   //UBLOG(logINFO,"  - create GbVoxelMatrix3D done");
-}
-
-//////////////////////////////////////////////////////////////////////////
-void GbVoxelMatrix3D::rotate90aroundX(double cX1, double cX2, double cX3)
-{
-   double tempMinPunktX1 = minX1-cX1;
-   double tempMinPunktX2 = minX2-cX2;
-   double tempMinPunktX3 = getX3Maximum()-cX3;
-
-   double tempMinPunktX1tf = tempMinPunktX1;
-   double tempMinPunktX2tf = -tempMinPunktX3;
-   double tempMinPunktX3tf = tempMinPunktX2;
-
-   double minX1_temp = tempMinPunktX1tf+cX1;
-   double minX2_temp = tempMinPunktX2tf+cX2;
-   double minX3_temp = tempMinPunktX3tf+cX3;
-
-   minX2 = minX2_temp;
-   minX3 = minX3_temp;
-
-   int nx1 = (int)voxelMatrix.getNX1();
-   int nx2 = (int)voxelMatrix.getNX2();
-   int nx3 = (int)voxelMatrix.getNX3();
-
-   int nx1_new = nx1;
-   int nx2_new = nx3;
-   int nx3_new = nx2;
-
-   double delta_temp = deltaX2;
-   deltaX2 = deltaX3;
-   deltaX3 = delta_temp;
-
-   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1_new, nx2_new, nx3_new);
-
-   for (int x3 = 0; x3<nx3; x3++) {
-      for (int x2 = 0; x2<nx2; x2++) {
-         for (int x1 = 0; x1<nx1; x1++)
-         {
-            voxelMatrix_temp(x1, nx3-x3-1, x2) = this->voxelMatrix(x1, x2, x3);
-         }
-      }
-   }
-   std::swap(this->voxelMatrix, voxelMatrix_temp);
-}
-//////////////////////////////////////////////////////////////////////////
-void GbVoxelMatrix3D::rotate90aroundX()
-{
-   double cX1 = this->getX1Centroid();
-   double cX2 = this->getX2Centroid();
-   double cX3 = this->getX3Centroid();
-
-   rotate90aroundX(cX1, cX2, cX3);
-}
-//////////////////////////////////////////////////////////////////////////
-void GbVoxelMatrix3D::rotate90aroundY(double cX1, double cX2, double cX3)
-{
-   double tempMinPunktX1 = getX1Maximum()-cX1;
-   double tempMinPunktX2 = minX2-cX2;
-   double tempMinPunktX3 = minX3-cX3;
-
-   double tempMinPunktX1tf = tempMinPunktX3;
-   double tempMinPunktX2tf = tempMinPunktX2;
-   double tempMinPunktX3tf = -tempMinPunktX1;
-
-   double minX1_temp = tempMinPunktX1tf+cX1;
-   double minX2_temp = tempMinPunktX2tf+cX2;
-   double minX3_temp = tempMinPunktX3tf+cX3;
-
-   minX1 = minX1_temp;
-   minX3 = minX3_temp;
-
-   int nx1 = (int)voxelMatrix.getNX1();
-   int nx2 = (int)voxelMatrix.getNX2();
-   int nx3 = (int)voxelMatrix.getNX3();
-
-   int nx1_new = nx3;
-   int nx2_new = nx2;
-   int nx3_new = nx1;
-
-   double delta_temp = deltaX1;
-   deltaX1 = deltaX3;
-   deltaX3 = delta_temp;
-
-   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1_new, nx2_new, nx3_new);
-
-   for (int x3 = 0; x3<nx3; x3++) {
-      for (int x2 = 0; x2<nx2; x2++) {
-         for (int x1 = 0; x1<nx1; x1++)
-         {
-            voxelMatrix_temp(x3, x2, nx1-x1-1) = this->voxelMatrix(x1, x2, x3);
-         }
-      }
-   }
-   std::swap(this->voxelMatrix, voxelMatrix_temp);
-}
-//////////////////////////////////////////////////////////////////////////
-void GbVoxelMatrix3D::rotate90aroundY()
-{
-   double cX1 = this->getX1Centroid();
-   double cX2 = this->getX2Centroid();
-   double cX3 = this->getX3Centroid();
-
-   rotate90aroundY(cX1, cX2, cX3);
-}
-//////////////////////////////////////////////////////////////////////////
-void GbVoxelMatrix3D::rotate90aroundZ(double cX1, double cX2, double cX3)
-{
-   double tempMinPunktX1 = minX1-cX1;
-   double tempMinPunktX2 = getX2Maximum()-cX2;
-   double tempMinPunktX3 = minX3-cX3;
-
-   double tempMinPunktX1tf = -tempMinPunktX2;
-   double tempMinPunktX2tf = tempMinPunktX1;
-   double tempMinPunktX3tf = tempMinPunktX3;
-
-   double minX1_temp = tempMinPunktX1tf+cX1;
-   double minX2_temp = tempMinPunktX2tf+cX2;
-   double minX3_temp = tempMinPunktX3tf+cX3;
-
-   minX1 = minX1_temp;
-   minX2 = minX2_temp;
-
-   int nx1 = (int)voxelMatrix.getNX1();
-   int nx2 = (int)voxelMatrix.getNX2();
-   int nx3 = (int)voxelMatrix.getNX3();
-
-   int nx1_new = nx2;
-   int nx2_new = nx1;
-   int nx3_new = nx3;
-
-   double delta_temp = deltaX1;
-   deltaX1 = deltaX2;
-   deltaX2 = delta_temp;
-
-   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1_new, nx2_new, nx3_new);
-
-   for (int x3 = 0; x3<nx3; x3++) {
-      for (int x2 = 0; x2<nx2; x2++) {
-         for (int x1 = 0; x1<nx1; x1++)
-         {
-            voxelMatrix_temp(nx2-x2-1, x1, x3) = this->voxelMatrix(x1, x2, x3);
-         }
-      }
-   }
-   std::swap(this->voxelMatrix, voxelMatrix_temp);
-}
-//////////////////////////////////////////////////////////////////////////
-void GbVoxelMatrix3D::rotate90aroundZ()
-{
-   double cX1 = this->getX1Centroid();
-   double cX2 = this->getX2Centroid();
-   double cX3 = this->getX3Centroid();
-
-   rotate90aroundZ(cX1, cX2, cX3);
-}
-//////////////////////////////////////////////////////////////////////////
-void GbVoxelMatrix3D::mirrorX()
-{
-   int nx1 = (int)voxelMatrix.getNX1();
-   int nx2 = (int)voxelMatrix.getNX2();
-   int nx3 = (int)voxelMatrix.getNX3();
-
-   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3);
-
-   for (int x3 = 0; x3<nx3; x3++) {
-      for (int x2 = 0; x2<nx2; x2++) {
-         for (int x1 = 0; x1<nx1; x1++)
-         {
-            voxelMatrix_temp(nx1-x1-1, x2, x3) = this->voxelMatrix(x1, x2, x3);
-         }
-      }
-   }
-   std::swap(this->voxelMatrix, voxelMatrix_temp);
-}
-//////////////////////////////////////////////////////////////////////////
-void GbVoxelMatrix3D::mirrorY()
-{
-   int nx1 = (int)voxelMatrix.getNX1();
-   int nx2 = (int)voxelMatrix.getNX2();
-   int nx3 = (int)voxelMatrix.getNX3();
-
-   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3);
-
-   for (int x3 = 0; x3<nx3; x3++) {
-      for (int x2 = 0; x2<nx2; x2++) {
-         for (int x1 = 0; x1<nx1; x1++)
-         {
-            voxelMatrix_temp(x1, nx2-x2-1, x3) = this->voxelMatrix(x1, x2, x3);
-         }
-      }
-   }
-   std::swap(this->voxelMatrix, voxelMatrix_temp);
-}
-//////////////////////////////////////////////////////////////////////////
-void GbVoxelMatrix3D::mirrorZ()
-{
-   int nx1 = (int)voxelMatrix.getNX1();
-   int nx2 = (int)voxelMatrix.getNX2();
-   int nx3 = (int)voxelMatrix.getNX3();
-
-   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3);
-
-   for (int x3 = 0; x3<nx3; x3++) {
-      for (int x2 = 0; x2<nx2; x2++) {
-         for (int x1 = 0; x1<nx1; x1++)
-         {
-            voxelMatrix_temp(x1, x2, nx3-x3-1) = this->voxelMatrix(x1, x2, x3);
-         }
-      }
-   }
-   std::swap(this->voxelMatrix, voxelMatrix_temp);
-}
-//////////////////////////////////////////////////////////////////////////
-void GbVoxelMatrix3D::rotateAroundY(double theta)
-{
-   int nx1 = (int)voxelMatrix.getNX1();
-   int nx2 = (int)voxelMatrix.getNX2();
-   int nx3 = (int)voxelMatrix.getNX3();
-
-   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3, FLUID);
-
-   double newMinX1 = cos(theta)*minX1+sin(theta)*minX3;
-   double newMinX3 = -sin(theta)*minX1+cos(theta)*minX3;
-
-   for (int x3 = 0; x3<nx3; x3++) {
-      for (int x2 = 0; x2<nx2; x2++) {
-         for (int x1 = 0; x1<nx1; x1++)
-         {
-            if (voxelMatrix(x1, x2, x3)==SOLID)
-            {
-               double rcX1 = minX1+deltaX1*x1;
-               double rcX3 = minX3+deltaX3*x3;
-
-               double nrcX1 = cos(theta)*rcX1+sin(theta)*rcX3;
-               double nrcX3 = -sin(theta)*rcX1+cos(theta)*rcX3;
-
-               int newX1 = UbMath::integerRounding((nrcX1-minX1)/deltaX1);
-               int newX2 = x2;
-               int newX3 = UbMath::integerRounding((nrcX3-minX3)/deltaX3);
-
-               if (newX1 < 0)
-               {
-                  int test=1;
-               }
-
-               if (newX1>0 && newX3>0 && newX1<nx1 && newX3<nx3)
-               {
-                  voxelMatrix_temp(newX1, newX2, newX3) = voxelMatrix(x1, x2, x3);
-               }
-
-               //int ix1, ix2, ix3;
-               //double ixx1 = (abs(nrcX1-minX1)/deltaX1);
-               //ix2 = x2;
-               //double ixx3 = (abs(nrcX3-minX3)/deltaX3);
-               //if (ixx1-(int)ixx1>.9999999999) ix1 = (int)ixx1+1; else ix1 = (int)ixx1;
-               ////if (ixx2-(int)ixx2>.9999999999) ix2 = (int)ixx2+1; else ix2 = (int)ixx2;
-               //if (ixx3-(int)ixx3>.9999999999) ix3 = (int)ixx3+1; else ix3 = (int)ixx3;
-
-               //if (ix1>=0 && ix3>=0 && ix1<nx1 && ix3<nx3)
-               //{
-               //   voxelMatrix_temp(ix1, ix2, ix3) = voxelMatrix(x1, x2, x3);
-               //}
-            }
-
-         }
-      }
-   }
-   std::swap(voxelMatrix, voxelMatrix_temp);
-
-   for (int x3 = 0; x3<nx3; x3++)
-      for (int x2 = 0; x2<nx2; x2++)
-         for (int x1 = 0; x1<nx1; x1++)
-         {
-            int count = 0;
-            for (int k3 = -1; k3<=1; k3++)
-               for (int k1 = -1; k1<=1; k1++)
-               {
-                  int j1 = x1+k1;
-                  int j3 = x3+k3;
-                  if (j1>=0 && j3>=0 && j1<nx1 && j3<nx3)
-                  {
-                     if (voxelMatrix(j1, x2, j3)==SOLID)
-                     {
-                        count++;
-                     }
-                  }
-
-               }
-            if (count == 8)
-            {
-               voxelMatrix(x1, x2, x3) = SOLID;
-            }
-         }
-}
-//////////////////////////////////////////////////////////////////////////
-void GbVoxelMatrix3D::writeToLegacyVTKASCII(const std::string& fileName)
-{
-   string fn = fileName+".ascii.vtk";
-
-   FILE *file;
-   file = fopen(fn.c_str(), "w");
-
-   if (file==NULL)
-   {
-      std::string pathf = UbSystem::getPathFromString(fn);
-      if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); }
-      if (file==NULL) throw UbException(UB_EXARGS, "can not open "+fn);
-   }
-
-   if (file==NULL)
-      throw UbException(UB_EXARGS, "can not open "+fn);
-
-   int nx1 = (int)voxelMatrix.getNX1();
-   int nx2 = (int)voxelMatrix.getNX2();
-   int nx3 = (int)voxelMatrix.getNX3();
-
-   int nn = nx1*nx2*nx3;
-
-   fprintf(file, "# vtk DataFile Version 2.0\n");
-   fprintf(file, "vtk output\n");
-   fprintf(file, "ASCII\n");
-   fprintf(file, "DATASET STRUCTURED_POINTS\n");
-   fprintf(file, "DIMENSIONS %d %d %d\n", nx1, nx2, nx3);
-   fprintf(file, "ORIGIN %g %g %g\n", minX1, minX2, minX3);
-   fprintf(file, "SPACING %g %g %g\n", deltaX1, deltaX2, deltaX3);
-   fprintf(file, "POINT_DATA %d\n", nn);
-   fprintf(file, "SCALARS Geo float\n");
-   fprintf(file, "LOOKUP_TABLE default\n");
-
-   for (int k = 0; k<nx3; k++) {
-      for (int j = 0; j<nx2; j++) {
-         for (int i = 0; i<nx1; i++) {
-            fprintf(file, "%g ", voxelMatrix(i, j, k));
-         }
-      }
-   }
-
-   fprintf(file, "\n");
-
-   fclose(file);
-}
-//////////////////////////////////////////////////////////////////////////
-void GbVoxelMatrix3D::writeToLegacyVTKBinary(const std::string& fileName)
-{
-   string fn = fileName+".binary.vtk";
-
-   FILE *file;
-   file = fopen(fn.c_str(), "w");
-
-   if (file==NULL)
-   {
-      std::string pathf = UbSystem::getPathFromString(fn);
-      if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); }
-      if (file==NULL) throw UbException(UB_EXARGS, "can not open "+fn);
-   }
-
-   int nx1 = (int)voxelMatrix.getNX1();
-   int nx2 = (int)voxelMatrix.getNX2();
-   int nx3 = (int)voxelMatrix.getNX3();
-
-   int nn = nx1*nx2*nx3;
-
-   char LF = 0x0A;
-
-   fprintf(file, "# vtk DataFile Version 3.0\n");
-   fprintf(file, "vtk output\n");
-   fprintf(file, "BINARY\n");
-   fprintf(file, "DATASET STRUCTURED_POINTS\n");
-   fprintf(file, "DIMENSIONS %d %d %d\n", nx1, nx2, nx3);
-   fprintf(file, "ORIGIN %g %g %g\n", minX1, minX2, minX3);
-   fprintf(file, "SPACING %g %g %g\n", deltaX1, deltaX2, deltaX3);
-   fprintf(file, "POINT_DATA %d\n", nn);
-   fprintf(file, "SCALARS Geo float\n");
-   fprintf(file, "LOOKUP_TABLE default");
-   fclose(file);
-
-   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3);
-
-   if (UbSystem::isLittleEndian())
-   {
-      for (int x3 = 0; x3<nx3; x3++) {
-         for (int x2 = 0; x2<nx2; x2++) {
-            for (int x1 = 0; x1<nx1; x1++)
-            {
-               float tmp = this->voxelMatrix(x1, x2, x3);
-               UbSystem::swapByteOrder((unsigned char*)(&(tmp)), sizeof(float));
-               voxelMatrix_temp(x1, x2, x3) = tmp;
-            }
-         }
-      }
-   }
-
-   file = fopen(fn.c_str(), "ab");
-
-   fwrite(&LF, sizeof(char), 1, file);
-   fwrite(voxelMatrix_temp.getStartAdressOfSortedArray(0, 0, 0), sizeof(float), voxelMatrix_temp.getDataVector().size(), file);
-   fwrite(&LF, sizeof(char), 1, file);
-   fclose(file);
-}
-//////////////////////////////////////////////////////////////////////////
-void GbVoxelMatrix3D::writeToVTKImageDataASCII(const std::string& fileName)
-{
-   int nx1 = (int)voxelMatrix.getNX1();
-   int nx2 = (int)voxelMatrix.getNX2();
-   int nx3 = (int)voxelMatrix.getNX3();
-
-   string fn = fileName+".ascii.vti";
-
-   FILE *file;
-   file = fopen(fn.c_str(), "w");
-
-   if (file==NULL)
-   {
-      std::string pathf = UbSystem::getPathFromString(fn);
-      if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); }
-      if (file==NULL) throw UbException(UB_EXARGS, "can not open "+fn);
-   }
-
-   fprintf(file, "<VTKFile type=\"ImageData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n"); //paraview 4.1
-   //fprintf(file,"<VTKFile type=\"ImageData\" version=\"0.1\" byte_order=\"LittleEndian\">\n"); //paraview 3.1
-   fprintf(file, "  <ImageData WholeExtent=\"%d %d %d %d %d %d\" Origin=\"%g %g %g\" Spacing=\"%g %g %g\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1, minX1, minX2, minX3, deltaX1, deltaX2, deltaX3);
-   fprintf(file, "  <Piece Extent=\"%d %d %d %d %d %d\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1);
-   fprintf(file, "    <PointData Scalars=\"VoxelMatrix\">\n");
-   fprintf(file, "      <DataArray type=\"Float32\" Name=\"VoxelMatrix\" format=\"ascii\" RangeMin=\"0\" RangeMax=\"1\">\n        ");
-
-   for (int k = 0; k<nx3; k++) {
-      for (int j = 0; j<nx2; j++) {
-         for (int i = 0; i<nx1; i++) {
-            fprintf(file, "%g ", voxelMatrix(i, j, k));
-         }
-      }
-   }
-
-   fprintf(file, "\n      </DataArray>\n");
-   fprintf(file, "    </PointData>\n");
-   fprintf(file, "    <CellData>\n");
-   fprintf(file, "    </CellData>\n");
-   fprintf(file, "  </Piece>\n");
-   fprintf(file, "  </ImageData>\n");
-   fprintf(file, "</VTKFile>\n");
-
-   fclose(file);
-}
-//////////////////////////////////////////////////////////////////////////
-void GbVoxelMatrix3D::writeToVTKImageDataAppended(const std::string& fileName)
-{
-   int nx1 = (int)voxelMatrix.getNX1();
-   int nx2 = (int)voxelMatrix.getNX2();
-   int nx3 = (int)voxelMatrix.getNX3();
-
-   string fn = fileName+".appended.vti";
-
-   FILE *file;
-   file = fopen(fn.c_str(), "w");
-
-   if (file==NULL)
-   {
-      std::string pathf = UbSystem::getPathFromString(fn);
-      if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); }
-      if (file==NULL) throw UbException(UB_EXARGS, "can not open "+fn);
-   }
-
-   fprintf(file, "<VTKFile type=\"ImageData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n"); //paraview 4.1
-   fprintf(file, "  <ImageData WholeExtent=\"%d %d %d %d %d %d\" Origin=\"%g %g %g\" Spacing=\"%g %g %g\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1, minX1, minX2, minX3, deltaX1, deltaX2, deltaX3);
-   fprintf(file, "  <Piece Extent=\"%d %d %d %d %d %d\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1);
-   fprintf(file, "    <PointData Scalars=\"VoxelMatrix\">\n");
-   fprintf(file, "      <DataArray type=\"Float32\" Name=\"VoxelMatrix\" format=\"appended\" RangeMin=\"0\" RangeMax=\"1\" offset=\"0\" />\n");
-   fprintf(file, "    </PointData>\n");
-   fprintf(file, "    <CellData>\n");
-   fprintf(file, "    </CellData>\n");
-   fprintf(file, "  </Piece>\n");
-   fprintf(file, "  </ImageData>\n");
-   fprintf(file, "  <AppendedData encoding=\"raw\">\n");
-   fprintf(file, "   _");
-   fclose(file);
-
-   file = fopen(fn.c_str(), "ab");
-   int size = (int)voxelMatrix.getDataVector().size()*sizeof(float);
-   fwrite(&size, sizeof(int), 1, file);
-   fwrite(voxelMatrix.getStartAdressOfSortedArray(0, 0, 0), sizeof(float), voxelMatrix.getDataVector().size(), file);
-   fclose(file);
-
-   file = fopen(fn.c_str(), "a");
-   fprintf(file, "\n");
-   fprintf(file, "  </AppendedData>\n");
-   fprintf(file, "</VTKFile>\n");
-   fclose(file);
-}
-
-
+#include <numerics/geometry3d/GbVoxelMatrix3D.h>
+
+#include <basics/utilities/UbMath.h>
+#include <basics/utilities/UbFileInputASCII.h>
+#include <numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h>
+#include <numerics/geometry3d/GbTriangle3D.h>
+#include <basics/utilities/UbFileOutputASCII.h>
+#include <numerics/geometry3d/CoordinateTransformation3D.h>
+
+#include <basics/utilities/UbSystem.h>
+
+#ifdef MC_CUBES
+#include <MarchingCubes/MarchingCubes.h>
+#endif // MC_CUBES
+
+using namespace std;
+
+const float GbVoxelMatrix3D::SOLID = 1.0f;
+const float GbVoxelMatrix3D::FLUID = 0.0f;
+
+
+/*=======================================================*/
+ObObjectCreator* GbVoxelMatrix3D::getCreator()
+{
+   return GbVoxelMatrix3DCreator::getInstance();
+}
+/*=======================================================*/
+// Konstruktor
+GbVoxelMatrix3D::GbVoxelMatrix3D(int nx1, int nx2, int nx3, float initVal, double lowerThreshold, double upperThreshold)
+   : GbObject3D()
+   , minX1(0.0)
+   , minX2(0.0)
+   , minX3(0.0)
+   , lowerThreshold(lowerThreshold)
+   , upperThreshold(upperThreshold)
+   , nodesX1(nx1)
+   , nodesX2(nx2)
+   , nodesX3(nx3)
+   , deltaX1(1.0)
+   , deltaX2(1.0)
+   , deltaX3(1.0)
+   , transferViaFilename(false)
+   , addSurfaceTriangleSetFlag(true)
+   , voxelMatrix(Matrix3D(nx1, nx2, nx3, initVal))
+{
+   this->setName("VoxelMatrix3D");
+}
+/*=======================================================*/
+GbVoxelMatrix3D::GbVoxelMatrix3D()
+   : GbObject3D()
+   , minX1(0.0)
+   , minX2(0.0)
+   , minX3(0.0)
+   , nodesX1(0)
+   , nodesX2(0)
+   , nodesX3(0)
+   , lowerThreshold(0.0)
+   , upperThreshold(0.0)
+   , deltaX1(1.0)
+   , deltaX2(1.0)
+   , deltaX3(1.0)
+   , transferViaFilename(false)
+   , addSurfaceTriangleSetFlag(true)
+{
+   this->setName("VoxelMatrix3D");
+}
+/*=======================================================*/
+GbVoxelMatrix3D::GbVoxelMatrix3D(const Matrix3D& voxelMatrix, double lowerThreshold, double upperThreshold)
+   : GbObject3D()
+   , minX1(0.0)
+   , minX2(0.0)
+   , minX3(0.0)
+   , nodesX1((int)voxelMatrix.getNX1())
+   , nodesX2((int)voxelMatrix.getNX2())
+   , nodesX3((int)voxelMatrix.getNX3())
+   , lowerThreshold(lowerThreshold)
+   , upperThreshold(upperThreshold)
+   , deltaX1(1.0)
+   , deltaX2(1.0)
+   , deltaX3(1.0)
+   , transferViaFilename(false)
+   , addSurfaceTriangleSetFlag(true)
+   , voxelMatrix(voxelMatrix)
+{
+   this->setName("VoxelMatrix3D");
+}
+/*=======================================================*/
+GbVoxelMatrix3D*  GbVoxelMatrix3D::clone()
+{
+   GbVoxelMatrix3D* vm = new GbVoxelMatrix3D(this->voxelMatrix, lowerThreshold, upperThreshold);
+   vm->setVoxelMatrixMininum(minX1, minX2, minX3);
+   vm->setVoxelMatrixDelta(deltaX1, deltaX2, deltaX3);
+   return  vm;
+}
+/*=======================================================*/
+void GbVoxelMatrix3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3)
+{
+   this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid());
+}
+/*=======================================================*/
+void GbVoxelMatrix3D::translate(const double& tx1, const double& tx2, const double& tx3)
+{
+   this->minX1 += tx1;
+   this->minX2 += tx2;
+   this->minX3 += tx3;
+   this->notifyObserversObjectChanged();
+}
+/*=======================================================*/
+void GbVoxelMatrix3D::setClosedVoidSpaceToSolid()
+{
+   voxelMatrixTemp = Matrix3D(nodesX1, nodesX2, nodesX3, SOLID);
+   flagMatrix = CbArray3D<char>(nodesX1, nodesX2, nodesX3, 0);
+
+   for (int x3 = 0; x3<nodesX3; x3++)
+   {
+      for (int x2 = 0; x2<nodesX2; x2++)
+      {
+         for (int x1 = 0; x1<nodesX1; x1++)
+         {
+            if (voxelMatrix(x1, x2, x3)==FLUID)
+            {
+               UBLOG(logINFO, "setClosedVoidSpaceToSolid:start");
+               x1Nbr.push_back(x1);
+               x2Nbr.push_back(x2);
+               x3Nbr.push_back(x3);
+               int size = (int)x1Nbr.size();
+               while (size>0)
+               {
+                  for (int i = 0; i<size; i++)
+                  {
+                     findFluidNeighbor(x1Nbr[i], x2Nbr[i], x3Nbr[i]);
+                  }
+
+                  swap(x1Nbr, x1NbrTemp);
+                  swap(x2Nbr, x2NbrTemp);
+                  swap(x3Nbr, x3NbrTemp);
+
+                  x1NbrTemp.clear();
+                  x2NbrTemp.clear();
+                  x3NbrTemp.clear();
+                  size = (int)x1Nbr.size();
+               }
+               UBLOG(logINFO, "setClosedVoidSpaceToSolid:end");
+               voxelMatrix = voxelMatrixTemp;
+               return;
+            }
+
+         }
+      }
+   }
+}
+/*=======================================================*/
+void GbVoxelMatrix3D::findFluidNeighbor(int x1, int x2, int x3)
+{
+   for (int k3 = -1; k3<=1; k3++)
+   {
+      for (int k2 = -1; k2<=1; k2++)
+      {
+         for (int k1 = -1; k1<=1; k1++)
+         {
+            int j1 = x1+k1;
+            int j2 = x2+k2;
+            int j3 = x3+k3;
+            if (j1>=0&&j1<nodesX1 && j2>=0&&j2<nodesX2 && j3>=0&&j3<nodesX3)
+            {
+               if (voxelMatrix(j1, j2, j3)==FLUID)
+               {
+                  if (flagMatrix(j1, j2, j3)==0)
+                  {
+                     voxelMatrixTemp(j1, j2, j3) = FLUID;
+                     flagMatrix(j1, j2, j3) = 1;
+                     x1NbrTemp.push_back(j1);
+                     x2NbrTemp.push_back(j2);
+                     x3NbrTemp.push_back(j3);
+                  }
+               }
+            }
+         }
+      }
+   }
+}
+/*=======================================================*/
+void GbVoxelMatrix3D::calculateNumberOfSolidAndFluid()
+{
+   numberOfSolid = 0;
+
+   for (int x3 = 0; x3<nodesX3; x3++)
+      for (int x2 = 0; x2<nodesX2; x2++)
+         for (int x1 = 0; x1<nodesX1; x1++)
+         {
+            if (voxelMatrix(x1, x2, x3)==GbVoxelMatrix3D::SOLID)
+            {
+               numberOfSolid++;
+            }
+         }
+
+   numberOfFluid = (long)nodesX1*(long)nodesX2*(long)nodesX3-numberOfSolid;
+}
+/*=======================================================*/
+long GbVoxelMatrix3D::getNumberOfSolid()
+{
+   return numberOfSolid;
+}
+/*=======================================================*/
+long GbVoxelMatrix3D::getNumberOfFluid()
+{
+   return numberOfFluid;
+}
+/*=======================================================*/
+double GbVoxelMatrix3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
+{
+   if (!((UbMath::equal(rx1, 0.0)||UbMath::equal(fabs(rx1), 1.0)||UbMath::equal(fabs(rx1), UbMath::one_over_sqrt2)||UbMath::equal(fabs(rx1), UbMath::one_over_sqrt3))
+      &&(UbMath::equal(rx2, 0.0)||UbMath::equal(fabs(rx2), 1.0)||UbMath::equal(fabs(rx2), UbMath::one_over_sqrt2)||UbMath::equal(fabs(rx2), UbMath::one_over_sqrt3))
+      &&(UbMath::equal(rx3, 0.0)||UbMath::equal(fabs(rx3), 1.0)||UbMath::equal(fabs(rx3), UbMath::one_over_sqrt2)||UbMath::equal(fabs(rx3), UbMath::one_over_sqrt3))))
+   {
+      throw UbException(UB_EXARGS, "nur fuer diskrete Boltzmannrichungen implementiert!!!");
+   }
+
+   //nachbarindex ermitteln
+   int ndx1 = 0, ndx2 = 0, ndx3 = 0;
+   if (UbMath::greater(rx1, 0.0)) ndx1 = 1;
+   else if (UbMath::less(rx1, 0.0)) ndx1 = -1;
+   if (UbMath::greater(rx2, 0.0)) ndx2 = 1;
+   else if (UbMath::less(rx2, 0.0)) ndx2 = -1;
+   if (UbMath::greater(rx3, 0.0)) ndx3 = 1;
+   else if (UbMath::less(rx3, 0.0)) ndx3 = -1;
+
+   int nix1 = UbMath::integerRounding((x1-minX1)/deltaX1)+ndx1;
+   int nix2 = UbMath::integerRounding((x2-minX2)/deltaX2)+ndx2;
+   int nix3 = UbMath::integerRounding((x3-minX3)/deltaX3)+ndx3;
+
+   //test ob nachbar solid
+   if (nix1>=0
+      &&nix2>=0
+      &&nix3>=0
+      &&nix1<voxelMatrix.getNX1()
+      &&nix2<voxelMatrix.getNX2()
+      &&nix3<voxelMatrix.getNX3())
+   {
+      if (UbMath::equal(voxelMatrix(nix1, nix2, nix3), SOLID))
+      {
+         //return halber abstand der beiden knoten
+         return 0.5*sqrt((ndx1*deltaX1)*(ndx1*deltaX1)
+            +(ndx2*deltaX2)*(ndx2*deltaX2)
+            +(ndx3*deltaX3)*(ndx3*deltaX3));
+      }
+   }
+
+   return 0.0;
+}
+/*=======================================================*/
+bool GbVoxelMatrix3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
+{
+   //index ermitteln
+   int ix1 = UbMath::integerRounding((x1p-minX1)/deltaX1);
+   int ix2 = UbMath::integerRounding((x2p-minX2)/deltaX2);
+   int ix3 = UbMath::integerRounding((x3p-minX3)/deltaX3);
+
+   if (ix1>=0
+      &&ix2>=0
+      &&ix3>=0
+      &&ix1<voxelMatrix.getNX1()
+      &&ix2<voxelMatrix.getNX2()
+      &&ix3<voxelMatrix.getNX3())
+   {
+      if (UbMath::equal(voxelMatrix(ix1, ix2, ix3), SOLID)) return true;
+   }
+
+   return false;
+}
+/*=======================================================*/
+bool GbVoxelMatrix3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
+{
+   pointIsOnBoundary = false;
+
+   return isPointInGbObject3D(x1p, x2p, x3p);
+}
+/*=======================================================*/
+bool GbVoxelMatrix3D::isCellInsideGbObject3D(const double& x1p1, const double& x2p1, const double& x3p1, const double& x1p2, const double& x2p2, const double& x3p2)
+{
+   return false;
+   //dass hängt von der Konfigration ab, aber meist ist der Block grösser wie etliche Poren ...
+
+      //indizes ermitteln
+   int startix1 = (int)std::floor((x1p1-minX1)/deltaX1+1E-13);
+   int startix2 = (int)std::floor((x2p1-minX2)/deltaX2+1E-13);
+   int startix3 = (int)std::floor((x3p1-minX3)/deltaX3+1E-13);
+
+   if (startix1<0) return false;
+   if (startix2<0) return false;
+   if (startix3<0) return false;
+
+   int maxiX1 = (int)voxelMatrix.getNX1()-1;
+   int maxiX2 = (int)voxelMatrix.getNX2()-1;
+   int maxiX3 = (int)voxelMatrix.getNX3()-1;
+
+   int endix1 = (int)std::ceil((x1p2-minX1)/deltaX1-1E-13);
+   int endix2 = (int)std::ceil((x2p2-minX2)/deltaX2-1E-13);
+   int endix3 = (int)std::ceil((x3p2-minX3)/deltaX3-1E-13);
+
+   if (endix1>maxiX1) return false;
+   if (endix2>maxiX2) return false;
+   if (endix3>maxiX3) return false;
+
+   for (int ix3 = startix3; ix3<=endix3; ix3++)
+      for (int ix2 = startix2; ix2<=endix2; ix2++)
+         for (int ix1 = startix1; ix1<=endix1; ix1++)
+            if (UbMath::equal(voxelMatrix(ix1, ix2, ix3), FLUID))
+               return false;
+   return true;
+}
+/*=======================================================*/
+bool GbVoxelMatrix3D::isCellCuttingGbObject3D(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b)
+//Merksatz: cell oder deren Volumen schneidet oder beinhaltet komplette oder Teile der CuboidUmrandung
+//returns true:
+//  - cell cuts  GbVoxelMatrix3D
+//  - cell boxes GbVoxelMatrix3D
+//returns false:
+//  - cell completely inside GbVoxelMatrix3D 
+//  - cell und cuboid3D haben kein gemeinsames Volumen
+{
+   //erstmal die dumm Loesung
+   if (!(this->isCellInsideGbObject3D(x1a, x2a, x3a, x1b, x2b, x3b))
+      &&this->isCellInsideOrCuttingGbObject3D(x1a, x2a, x3a, x1b, x2b, x3b))
+   {
+      return true;
+   }
+
+   return false;
+}
+/*=======================================================*/
+bool GbVoxelMatrix3D::isCellInsideOrCuttingGbObject3D(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b)
+//returns true:
+//  - cell completely inside cuboid3D ( = cuboid3D boxes cell)
+//  - cell cuts  cuboid3D
+//  - cell boxes cuboid3D
+//returns false:
+//  - cell und cuboid3D haben kein gemeinsames Volumen
+{
+   //simpler check, da unser GbCuboid3D ein AABB is:
+  //  anfA        midA         endA             anfB    midB    endB
+  //   |            x<-- dxA -->|                 |<-dxB->x       |
+  //                |<----------------- T --------------->|
+  //ist |T| <= dxA + dxB -> overlap!
+
+   if (UbMath::lessEqual(std::fabs(this->getX1Centroid()-0.5*(x1b+x1a)      /*Tx1*/)
+      , 0.5*(this->getLengthX1()+std::fabs(x1b-x1a) /*dx1A+dx1B*/))
+
+      &&UbMath::lessEqual(std::fabs(this->getX2Centroid()-0.5*(x2b+x2a)      /*Tx2*/)
+         , 0.5*(this->getLengthX2()+std::fabs(x2b-x2a) /*dx2A+dx2B*/))
+
+      &&UbMath::lessEqual(std::fabs(this->getX3Centroid()-0.5*(x3b+x3a)      /*Tx3*/)
+         , 0.5*(this->getLengthX3()+std::fabs(x3b-x3a) /*dx3A+dx3B*/)))
+   {
+      return true;
+   }
+
+   return false;
+}
+/*=======================================================*/
+vector<GbTriangle3D*> GbVoxelMatrix3D::getSurfaceTriangleSet()
+{
+   vector<GbTriangle3D*> triangles;
+
+#ifdef MC_CUBES
+   //MC
+   typedef McCubes::Matrix3DWrapper< Matrix3D >                McMatrixWrapper;
+   typedef McCubes::MarchingCubes< McMatrixWrapper >           McMarchingCubesGenerator;
+   typedef McMarchingCubesGenerator::Vertex                    McVertex;
+   typedef McMarchingCubesGenerator::Triangle                  McTriangle;
+
+   McMatrixWrapper wrapper(&voxelMatrix);//,0,0,0,voxelMatrix.getNX1()-1,voxelMatrix.getNX2()-1,voxelMatrix.getNX3()-1);
+   McMarchingCubesGenerator mc(wrapper);
+
+   mc.init_all();
+   mc.run(0.5);
+
+   //const int   nofVertices  = mc.nverts();
+   const int   nofTriangles = mc.ntrigs();
+
+   McVertex*   mcvertices = mc.vertices();
+   McTriangle* mctriangles = mc.triangles();
+
+   for (int t = 0; t<nofTriangles; t++)
+   {
+      triangles.push_back(new GbTriangle3D(new GbPoint3D(minX1+deltaX1 * (mcvertices[mctriangles[t].v1].x /*-1*/)
+         , minX2+deltaX2 * (mcvertices[mctriangles[t].v1].y /*-1*/)
+         , minX3+deltaX3 * (mcvertices[mctriangles[t].v1].z /*-1*/))
+         , new GbPoint3D(minX1+deltaX1 * (mcvertices[mctriangles[t].v2].x /*-1*/)
+            , minX2+deltaX2 * (mcvertices[mctriangles[t].v2].y /*-1*/)
+            , minX3+deltaX3 * (mcvertices[mctriangles[t].v2].z /*-1*/))
+         , new GbPoint3D(minX1+deltaX1 * (mcvertices[mctriangles[t].v3].x /*-1*/)
+            , minX2+deltaX2 * (mcvertices[mctriangles[t].v3].y /*-1*/)
+            , minX3+deltaX3 * (mcvertices[mctriangles[t].v3].z /*-1*/))));
+   }
+#else
+   cerr<<"vector<GbTriangle3D*> GbVoxelMatrix3D::getSurfaceTriangleSet() - benoetigt MARCHING_CUBE paket aus 3rdParty"<<endl;
+#endif // MC_CUBES
+
+   return triangles;
+}
+/*=======================================================*/
+void GbVoxelMatrix3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles)
+{
+   UBLOG(logINFO, " GbVoxelMatrix3D addSurfaceTriangleSet start")
+      if (!this->addSurfaceTriangleSetFlag)
+      {
+         UBLOG(logINFO, " GbVoxelMatrix3D addSurfaceTriangleSet end without TriangleSetCreation")
+            return;
+      }
+#ifdef MC_CUBES
+   UBLOG(logDEBUG1, " GbVoxelMatrix3D addSurfaceTriangleSet MC defined")
+
+      typedef McCubes::Matrix3DWrapper< Matrix3D >                McMatrixWrapper;
+   typedef McCubes::MarchingCubes< McMatrixWrapper >           McMarchingCubesGenerator;
+   typedef McMarchingCubesGenerator::Vertex                    McVertex;
+   typedef McMarchingCubesGenerator::Triangle                  McTriangle;
+
+   //MC
+   {  //standard( fuer voxelmatrix)
+      McMatrixWrapper wrapper(&voxelMatrix);
+      McMarchingCubesGenerator mc(wrapper);
+
+      UBLOG(logDEBUG1, " GbVoxelMatrix3D addSurfaceTriangleSet McMarchingCubesGenerator")
+
+         UBLOG(logDEBUG1, " GbVoxelMatrix3D addSurfaceTriangleSet mc.init")
+         mc.init_all();
+      UBLOG(logDEBUG1, " GbVoxelMatrix3D addSurfaceTriangleSet mc.run")
+         mc.run(0.5);
+      UBLOG(logDEBUG1, " GbVoxelMatrix3D addSurfaceTriangleSet mc.run done")
+
+         const int   nofVertices = mc.nverts();
+      const int   nofTriangles = mc.ntrigs();
+
+      McVertex*   mcvertices = mc.vertices();
+      McTriangle* mctriangles = mc.triangles();
+
+      UBLOG(logDEBUG1, " GbVoxelMatrix3D node tuple")
+         for (int n = 0; n<nofVertices; n++)
+            nodes.push_back(makeUbTuple((float)(minX1+deltaX1 * (mcvertices[n].x /*-1*/)),   //Anm: kein -1, da man durch manipulation der indices die dreiecke um eins versetzt bekommt
+            (float)(minX2+deltaX2 * (mcvertices[n].y /*-1*/)),
+               (float)(minX3+deltaX3 * (mcvertices[n].z /*-1*/))));
+      UBLOG(logDEBUG1, " GbVoxelMatrix3D triangles tuple")
+         for (int t = 0; t<nofTriangles; t++)
+            triangles.push_back(makeUbTuple(mctriangles[t].v1, mctriangles[t].v2, mctriangles[t].v3));
+      UBLOG(logDEBUG1, " GbVoxelMatrix3D triangles tuple done")
+   }
+
+   //false - das scheint probleme bei der asphaltprobe zu machen 1500x600x100
+   // da lief es bis C - evtl. memory voll
+   if (false)  //extension... um die raender koerrekt abzubilden muesste man eine dummy FLUID reihe um 
+   {         //die matrix legen( lsg1: temp matrix mit 2 reihen pro richtung mehr -> zuviel speicher, 500^3 = 500MB
+             // lsg2: fuer jede flaeche eine dummy matrix -> wie folgt:
+      int nx1 = (int)voxelMatrix.getNX1();
+      int nx2 = (int)voxelMatrix.getNX2();
+      int nx3 = (int)voxelMatrix.getNX3();
+      UBLOG(logINFO, " A ")
+         Matrix3D tmpX1Min(2, nx2+2, nx3+2, FLUID);
+      Matrix3D tmpX1Max(2, nx2+2, nx3+2, FLUID);
+      for (int x3 = 0; x3<nx3; x3++)
+         for (int x2 = 0; x2<nx2; x2++)
+         {
+            tmpX1Min(1, x2+1, x3+1) = voxelMatrix(0, x2, x3);
+            tmpX1Max(0, x2+1, x3+1) = voxelMatrix(nx1-1, x2, x3);
+         }
+      UBLOG(logINFO, " B")
+         Matrix3D tmpX2Min(nx1+2, 2, nx3+2, FLUID);
+      Matrix3D tmpX2Max(nx1+2, 2, nx3+2, FLUID);
+      for (int x3 = 0; x3<nx3; x3++)
+         for (int x1 = 0; x1<nx1; x1++)
+         {
+            tmpX2Min(x1+1, 1, x3+1) = voxelMatrix(x1, 0, x3);
+            tmpX2Max(x1+1, 0, x3+1) = voxelMatrix(x1, nx2-1, x3);
+         }
+      UBLOG(logINFO, " C ")
+         Matrix3D tmpX3Min(nx1+2, nx3+2, 2, FLUID);
+      Matrix3D tmpX3Max(nx1+2, nx3+2, 2, FLUID);
+      for (int x2 = 0; x2<nx2; x2++)
+         for (int x1 = 0; x1<nx1; x1++)
+         {
+            tmpX3Min(x1+1, x2+1, 1) = voxelMatrix(x1, x2, 0);
+            tmpX3Max(x1+1, x2+1, 0) = voxelMatrix(x1, x2, nx3-1);
+         }
+      UBLOG(logINFO, " D")
+         Matrix3D* matrices[] = { &tmpX1Min, &tmpX1Max, &tmpX2Min, &tmpX2Max, &tmpX3Min, &tmpX3Max };
+      int            dx1[] = { -1,     nx1-1,        -1,        -1,        -1,        -1 };
+      int            dx2[] = { -1,        -1,        -1,     nx2-1,        -1,        -1 };
+      int            dx3[] = { -1,        -1,        -1,        -1,        -1,     nx3-1 };
+      UBLOG(logINFO, " E")
+         for (int i = 0; i<6; i++)
+         {
+            McMatrixWrapper wrapper(matrices[i]);
+            McMarchingCubesGenerator mc(wrapper);
+
+            mc.init_all();
+            mc.run(0.5);
+
+            McVertex*   mcvertices = mc.vertices();
+            McTriangle* mctriangles = mc.triangles();
+
+            int deltaNodeNr = (int)nodes.size();
+            UBLOG(logINFO, " GbVoxelMatrix3D node tuple")
+               for (int n = 0; n<mc.nverts(); n++)
+                  nodes.push_back(makeUbTuple((float)(minX1+deltaX1 * (mcvertices[n].x+dx1[i])),   //Anm: kein -1, da man durch manipulation der indices die dreiecke um eins versetzt bekommt
+                  (float)(minX2+deltaX2 * (mcvertices[n].y+dx2[i])),
+                     (float)(minX3+deltaX3 * (mcvertices[n].z+dx3[i]))));
+            for (int t = 0; t<mc.ntrigs(); t++)
+               triangles.push_back(makeUbTuple(deltaNodeNr+mctriangles[t].v1, deltaNodeNr+mctriangles[t].v2, deltaNodeNr+mctriangles[t].v3));
+         }
+   }
+#else
+   cerr<<"void GbVoxelMatrix3D.addSurfaceTriangleSet  - benoetigt MARCHING_CUBE paket aus 3rdParty"<<endl;
+#endif // MC_CUBES
+
+   UBLOG(logINFO, " GbVoxelMatrix3D addSurfaceTriangleSet end")
+}
+/*=======================================================*/
+string GbVoxelMatrix3D::toString()
+{
+   return "GbVoxelMatrix3D";
+}
+/*=======================================================*/
+void GbVoxelMatrix3D::write(UbFileOutput* out)
+{
+   out->writeString(this->getCreator()->getTypeID());
+   out->writeDouble(minX1);
+   out->writeDouble(minX2);
+   out->writeDouble(minX3);
+   out->writeDouble(deltaX1);
+   out->writeDouble(deltaX2);
+   out->writeDouble(deltaX3);
+   out->writeInteger(nodesX1);
+   out->writeInteger(nodesX2);
+   out->writeInteger(nodesX3);
+   out->writeDouble(lowerThreshold);
+   out->writeDouble(upperThreshold);
+   out->writeBool(addSurfaceTriangleSetFlag);
+   out->writeBool(transferViaFilename);
+   if (!transferViaFilename)
+   {
+      throw UbException(UB_EXARGS, "void GbVoxelMatrix3D::write(UbFileOutput* out)  - geht ned");
+   }
+   else
+   {
+      out->writeString(filename);
+   }
+
+
+   //CbUniformMatrix3D<float> voxelMatrix;
+}
+/*=======================================================*/
+void GbVoxelMatrix3D::read(UbFileInput* in)
+{
+#ifdef CAB_RCF
+   try
+   {
+#endif
+      //!!! den string nimmt er vorher um das Object zu erstellen
+      //in->readString();      
+      minX1 = in->readDouble();
+      minX2 = in->readDouble();
+      minX3 = in->readDouble();
+      deltaX1 = in->readDouble();
+      deltaX2 = in->readDouble();
+      deltaX3 = in->readDouble();
+      nodesX1 = in->readInteger();
+      nodesX2 = in->readInteger();
+      nodesX3 = in->readInteger();
+      lowerThreshold = in->readDouble();
+      upperThreshold = in->readDouble();
+      addSurfaceTriangleSetFlag = in->readBool();
+      transferViaFilename = in->readBool();
+      if (!transferViaFilename)
+      {
+         throw UbException(UB_EXARGS, "void GbVoxelMatrix3D::read(UbFileOutput* out)  - geht ned");
+      }
+      else
+      {
+         filename = in->readString();
+         this->readMatrixFromVtiASCIIFile(filename);
+      }
+#ifdef CAB_RCF
+   }
+   catch (std::exception& e) { UBLOGML(logERROR, UB_FUNCTION+(std::string)e.what());        throw RCF::Exception(1002, UB_FUNCTION+(std::string)e.what()); }
+   catch (...) { UBLOGML(logERROR, UB_FUNCTION+(std::string)"unknown error"); throw RCF::Exception(1002, UB_FUNCTION+(std::string)"unknown error"); }
+#endif
+}
+/*=======================================================*/
+void GbVoxelMatrix3D::readMatrixFromVtiASCIIFile(std::string filename)
+
+{
+   //UBLOG(logINFO,"  - create GbVoxelMatrix3D");
+   UbFileInputASCII in(filename);
+   //ifstream in(filename.c_str(), ios::binary);
+   if (!in) throw UbException(UB_EXARGS, "could not open file "+filename);
+   in.readLine();
+   in.readLine();
+   in.readLine();
+   in.readLine();
+   in.readLine();
+
+   voxelMatrix = Matrix3D(nodesX1, nodesX2, nodesX3, GbVoxelMatrix3D::FLUID);
+
+   //UBLOG(logINFO,"  - init values");
+   int val;
+   int u = 0;
+   for (int x3 = 0; x3<nodesX3; x3++)
+      for (int x2 = 0; x2<nodesX2; x2++)
+         for (int x1 = 0; x1<nodesX1; x1++)
+         {
+            val = in.readInteger();
+            //if( !UbMath::equal(val, 0.0f) ) 
+            //if( UbMath::greater(val, threshold) ) 
+            if ((double)val>=lowerThreshold&&(double)val<=upperThreshold)
+            {
+               (voxelMatrix)(x1, x2, x3) = GbVoxelMatrix3D::SOLID;
+            }
+         }
+   //UBLOG(logINFO,"  - create GbVoxelMatrix3D done");
+}
+
+//////////////////////////////////////////////////////////////////////////
+void GbVoxelMatrix3D::rotate90aroundX(double cX1, double cX2, double cX3)
+{
+   double tempMinPunktX1 = minX1-cX1;
+   double tempMinPunktX2 = minX2-cX2;
+   double tempMinPunktX3 = getX3Maximum()-cX3;
+
+   double tempMinPunktX1tf = tempMinPunktX1;
+   double tempMinPunktX2tf = -tempMinPunktX3;
+   double tempMinPunktX3tf = tempMinPunktX2;
+
+   double minX1_temp = tempMinPunktX1tf+cX1;
+   double minX2_temp = tempMinPunktX2tf+cX2;
+   double minX3_temp = tempMinPunktX3tf+cX3;
+
+   minX2 = minX2_temp;
+   minX3 = minX3_temp;
+
+   int nx1 = (int)voxelMatrix.getNX1();
+   int nx2 = (int)voxelMatrix.getNX2();
+   int nx3 = (int)voxelMatrix.getNX3();
+
+   int nx1_new = nx1;
+   int nx2_new = nx3;
+   int nx3_new = nx2;
+
+   double delta_temp = deltaX2;
+   deltaX2 = deltaX3;
+   deltaX3 = delta_temp;
+
+   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1_new, nx2_new, nx3_new);
+
+   for (int x3 = 0; x3<nx3; x3++) {
+      for (int x2 = 0; x2<nx2; x2++) {
+         for (int x1 = 0; x1<nx1; x1++)
+         {
+            voxelMatrix_temp(x1, nx3-x3-1, x2) = this->voxelMatrix(x1, x2, x3);
+         }
+      }
+   }
+   std::swap(this->voxelMatrix, voxelMatrix_temp);
+}
+//////////////////////////////////////////////////////////////////////////
+void GbVoxelMatrix3D::rotate90aroundX()
+{
+   double cX1 = this->getX1Centroid();
+   double cX2 = this->getX2Centroid();
+   double cX3 = this->getX3Centroid();
+
+   rotate90aroundX(cX1, cX2, cX3);
+}
+//////////////////////////////////////////////////////////////////////////
+void GbVoxelMatrix3D::rotate90aroundY(double cX1, double cX2, double cX3)
+{
+   double tempMinPunktX1 = getX1Maximum()-cX1;
+   double tempMinPunktX2 = minX2-cX2;
+   double tempMinPunktX3 = minX3-cX3;
+
+   double tempMinPunktX1tf = tempMinPunktX3;
+   double tempMinPunktX2tf = tempMinPunktX2;
+   double tempMinPunktX3tf = -tempMinPunktX1;
+
+   double minX1_temp = tempMinPunktX1tf+cX1;
+   double minX2_temp = tempMinPunktX2tf+cX2;
+   double minX3_temp = tempMinPunktX3tf+cX3;
+
+   minX1 = minX1_temp;
+   minX3 = minX3_temp;
+
+   int nx1 = (int)voxelMatrix.getNX1();
+   int nx2 = (int)voxelMatrix.getNX2();
+   int nx3 = (int)voxelMatrix.getNX3();
+
+   int nx1_new = nx3;
+   int nx2_new = nx2;
+   int nx3_new = nx1;
+
+   double delta_temp = deltaX1;
+   deltaX1 = deltaX3;
+   deltaX3 = delta_temp;
+
+   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1_new, nx2_new, nx3_new);
+
+   for (int x3 = 0; x3<nx3; x3++) {
+      for (int x2 = 0; x2<nx2; x2++) {
+         for (int x1 = 0; x1<nx1; x1++)
+         {
+            voxelMatrix_temp(x3, x2, nx1-x1-1) = this->voxelMatrix(x1, x2, x3);
+         }
+      }
+   }
+   std::swap(this->voxelMatrix, voxelMatrix_temp);
+}
+//////////////////////////////////////////////////////////////////////////
+void GbVoxelMatrix3D::rotate90aroundY()
+{
+   double cX1 = this->getX1Centroid();
+   double cX2 = this->getX2Centroid();
+   double cX3 = this->getX3Centroid();
+
+   rotate90aroundY(cX1, cX2, cX3);
+}
+//////////////////////////////////////////////////////////////////////////
+void GbVoxelMatrix3D::rotate90aroundZ(double cX1, double cX2, double cX3)
+{
+   double tempMinPunktX1 = minX1-cX1;
+   double tempMinPunktX2 = getX2Maximum()-cX2;
+   double tempMinPunktX3 = minX3-cX3;
+
+   double tempMinPunktX1tf = -tempMinPunktX2;
+   double tempMinPunktX2tf = tempMinPunktX1;
+   double tempMinPunktX3tf = tempMinPunktX3;
+
+   double minX1_temp = tempMinPunktX1tf+cX1;
+   double minX2_temp = tempMinPunktX2tf+cX2;
+   double minX3_temp = tempMinPunktX3tf+cX3;
+
+   minX1 = minX1_temp;
+   minX2 = minX2_temp;
+
+   int nx1 = (int)voxelMatrix.getNX1();
+   int nx2 = (int)voxelMatrix.getNX2();
+   int nx3 = (int)voxelMatrix.getNX3();
+
+   int nx1_new = nx2;
+   int nx2_new = nx1;
+   int nx3_new = nx3;
+
+   double delta_temp = deltaX1;
+   deltaX1 = deltaX2;
+   deltaX2 = delta_temp;
+
+   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1_new, nx2_new, nx3_new);
+
+   for (int x3 = 0; x3<nx3; x3++) {
+      for (int x2 = 0; x2<nx2; x2++) {
+         for (int x1 = 0; x1<nx1; x1++)
+         {
+            voxelMatrix_temp(nx2-x2-1, x1, x3) = this->voxelMatrix(x1, x2, x3);
+         }
+      }
+   }
+   std::swap(this->voxelMatrix, voxelMatrix_temp);
+}
+//////////////////////////////////////////////////////////////////////////
+void GbVoxelMatrix3D::rotate90aroundZ()
+{
+   double cX1 = this->getX1Centroid();
+   double cX2 = this->getX2Centroid();
+   double cX3 = this->getX3Centroid();
+
+   rotate90aroundZ(cX1, cX2, cX3);
+}
+//////////////////////////////////////////////////////////////////////////
+void GbVoxelMatrix3D::mirrorX()
+{
+   int nx1 = (int)voxelMatrix.getNX1();
+   int nx2 = (int)voxelMatrix.getNX2();
+   int nx3 = (int)voxelMatrix.getNX3();
+
+   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3);
+
+   for (int x3 = 0; x3<nx3; x3++) {
+      for (int x2 = 0; x2<nx2; x2++) {
+         for (int x1 = 0; x1<nx1; x1++)
+         {
+            voxelMatrix_temp(nx1-x1-1, x2, x3) = this->voxelMatrix(x1, x2, x3);
+         }
+      }
+   }
+   std::swap(this->voxelMatrix, voxelMatrix_temp);
+}
+//////////////////////////////////////////////////////////////////////////
+void GbVoxelMatrix3D::mirrorY()
+{
+   int nx1 = (int)voxelMatrix.getNX1();
+   int nx2 = (int)voxelMatrix.getNX2();
+   int nx3 = (int)voxelMatrix.getNX3();
+
+   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3);
+
+   for (int x3 = 0; x3<nx3; x3++) {
+      for (int x2 = 0; x2<nx2; x2++) {
+         for (int x1 = 0; x1<nx1; x1++)
+         {
+            voxelMatrix_temp(x1, nx2-x2-1, x3) = this->voxelMatrix(x1, x2, x3);
+         }
+      }
+   }
+   std::swap(this->voxelMatrix, voxelMatrix_temp);
+}
+//////////////////////////////////////////////////////////////////////////
+void GbVoxelMatrix3D::mirrorZ()
+{
+   int nx1 = (int)voxelMatrix.getNX1();
+   int nx2 = (int)voxelMatrix.getNX2();
+   int nx3 = (int)voxelMatrix.getNX3();
+
+   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3);
+
+   for (int x3 = 0; x3<nx3; x3++) {
+      for (int x2 = 0; x2<nx2; x2++) {
+         for (int x1 = 0; x1<nx1; x1++)
+         {
+            voxelMatrix_temp(x1, x2, nx3-x3-1) = this->voxelMatrix(x1, x2, x3);
+         }
+      }
+   }
+   std::swap(this->voxelMatrix, voxelMatrix_temp);
+}
+//////////////////////////////////////////////////////////////////////////
+void GbVoxelMatrix3D::rotateAroundY(double theta)
+{
+   int nx1 = (int)voxelMatrix.getNX1();
+   int nx2 = (int)voxelMatrix.getNX2();
+   int nx3 = (int)voxelMatrix.getNX3();
+
+   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3, FLUID);
+
+   double newMinX1 = cos(theta)*minX1+sin(theta)*minX3;
+   double newMinX3 = -sin(theta)*minX1+cos(theta)*minX3;
+
+   for (int x3 = 0; x3<nx3; x3++) {
+      for (int x2 = 0; x2<nx2; x2++) {
+         for (int x1 = 0; x1<nx1; x1++)
+         {
+            if (voxelMatrix(x1, x2, x3)==SOLID)
+            {
+               double rcX1 = minX1+deltaX1*x1;
+               double rcX3 = minX3+deltaX3*x3;
+
+               double nrcX1 = cos(theta)*rcX1+sin(theta)*rcX3;
+               double nrcX3 = -sin(theta)*rcX1+cos(theta)*rcX3;
+
+               int newX1 = UbMath::integerRounding((nrcX1-minX1)/deltaX1);
+               int newX2 = x2;
+               int newX3 = UbMath::integerRounding((nrcX3-minX3)/deltaX3);
+
+               if (newX1 < 0)
+               {
+                  int test=1;
+               }
+
+               if (newX1>0 && newX3>0 && newX1<nx1 && newX3<nx3)
+               {
+                  voxelMatrix_temp(newX1, newX2, newX3) = voxelMatrix(x1, x2, x3);
+               }
+
+               //int ix1, ix2, ix3;
+               //double ixx1 = (abs(nrcX1-minX1)/deltaX1);
+               //ix2 = x2;
+               //double ixx3 = (abs(nrcX3-minX3)/deltaX3);
+               //if (ixx1-(int)ixx1>.9999999999) ix1 = (int)ixx1+1; else ix1 = (int)ixx1;
+               ////if (ixx2-(int)ixx2>.9999999999) ix2 = (int)ixx2+1; else ix2 = (int)ixx2;
+               //if (ixx3-(int)ixx3>.9999999999) ix3 = (int)ixx3+1; else ix3 = (int)ixx3;
+
+               //if (ix1>=0 && ix3>=0 && ix1<nx1 && ix3<nx3)
+               //{
+               //   voxelMatrix_temp(ix1, ix2, ix3) = voxelMatrix(x1, x2, x3);
+               //}
+            }
+
+         }
+      }
+   }
+   std::swap(voxelMatrix, voxelMatrix_temp);
+
+   for (int x3 = 0; x3<nx3; x3++)
+      for (int x2 = 0; x2<nx2; x2++)
+         for (int x1 = 0; x1<nx1; x1++)
+         {
+            int count = 0;
+            for (int k3 = -1; k3<=1; k3++)
+               for (int k1 = -1; k1<=1; k1++)
+               {
+                  int j1 = x1+k1;
+                  int j3 = x3+k3;
+                  if (j1>=0 && j3>=0 && j1<nx1 && j3<nx3)
+                  {
+                     if (voxelMatrix(j1, x2, j3)==SOLID)
+                     {
+                        count++;
+                     }
+                  }
+
+               }
+            if (count == 8)
+            {
+               voxelMatrix(x1, x2, x3) = SOLID;
+            }
+         }
+}
+//////////////////////////////////////////////////////////////////////////
+void GbVoxelMatrix3D::writeToLegacyVTKASCII(const std::string& fileName)
+{
+   string fn = fileName+".ascii.vtk";
+
+   FILE *file;
+   file = fopen(fn.c_str(), "w");
+
+   if (file==NULL)
+   {
+      std::string pathf = UbSystem::getPathFromString(fn);
+      if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); }
+      if (file==NULL) throw UbException(UB_EXARGS, "can not open "+fn);
+   }
+
+   if (file==NULL)
+      throw UbException(UB_EXARGS, "can not open "+fn);
+
+   int nx1 = (int)voxelMatrix.getNX1();
+   int nx2 = (int)voxelMatrix.getNX2();
+   int nx3 = (int)voxelMatrix.getNX3();
+
+   int nn = nx1*nx2*nx3;
+
+   fprintf(file, "# vtk DataFile Version 2.0\n");
+   fprintf(file, "vtk output\n");
+   fprintf(file, "ASCII\n");
+   fprintf(file, "DATASET STRUCTURED_POINTS\n");
+   fprintf(file, "DIMENSIONS %d %d %d\n", nx1, nx2, nx3);
+   fprintf(file, "ORIGIN %g %g %g\n", minX1, minX2, minX3);
+   fprintf(file, "SPACING %g %g %g\n", deltaX1, deltaX2, deltaX3);
+   fprintf(file, "POINT_DATA %d\n", nn);
+   fprintf(file, "SCALARS Geo float\n");
+   fprintf(file, "LOOKUP_TABLE default\n");
+
+   for (int k = 0; k<nx3; k++) {
+      for (int j = 0; j<nx2; j++) {
+         for (int i = 0; i<nx1; i++) {
+            fprintf(file, "%g ", voxelMatrix(i, j, k));
+         }
+      }
+   }
+
+   fprintf(file, "\n");
+
+   fclose(file);
+}
+//////////////////////////////////////////////////////////////////////////
+void GbVoxelMatrix3D::writeToLegacyVTKBinary(const std::string& fileName)
+{
+   string fn = fileName+".binary.vtk";
+
+   FILE *file;
+   file = fopen(fn.c_str(), "w");
+
+   if (file==NULL)
+   {
+      std::string pathf = UbSystem::getPathFromString(fn);
+      if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); }
+      if (file==NULL) throw UbException(UB_EXARGS, "can not open "+fn);
+   }
+
+   int nx1 = (int)voxelMatrix.getNX1();
+   int nx2 = (int)voxelMatrix.getNX2();
+   int nx3 = (int)voxelMatrix.getNX3();
+
+   int nn = nx1*nx2*nx3;
+
+   char LF = 0x0A;
+
+   fprintf(file, "# vtk DataFile Version 3.0\n");
+   fprintf(file, "vtk output\n");
+   fprintf(file, "BINARY\n");
+   fprintf(file, "DATASET STRUCTURED_POINTS\n");
+   fprintf(file, "DIMENSIONS %d %d %d\n", nx1, nx2, nx3);
+   fprintf(file, "ORIGIN %g %g %g\n", minX1, minX2, minX3);
+   fprintf(file, "SPACING %g %g %g\n", deltaX1, deltaX2, deltaX3);
+   fprintf(file, "POINT_DATA %d\n", nn);
+   fprintf(file, "SCALARS Geo float\n");
+   fprintf(file, "LOOKUP_TABLE default");
+   fclose(file);
+
+   GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3);
+
+   if (UbSystem::isLittleEndian())
+   {
+      for (int x3 = 0; x3<nx3; x3++) {
+         for (int x2 = 0; x2<nx2; x2++) {
+            for (int x1 = 0; x1<nx1; x1++)
+            {
+               float tmp = this->voxelMatrix(x1, x2, x3);
+               UbSystem::swapByteOrder((unsigned char*)(&(tmp)), sizeof(float));
+               voxelMatrix_temp(x1, x2, x3) = tmp;
+            }
+         }
+      }
+   }
+
+   file = fopen(fn.c_str(), "ab");
+
+   fwrite(&LF, sizeof(char), 1, file);
+   fwrite(voxelMatrix_temp.getStartAdressOfSortedArray(0, 0, 0), sizeof(float), voxelMatrix_temp.getDataVector().size(), file);
+   fwrite(&LF, sizeof(char), 1, file);
+   fclose(file);
+}
+//////////////////////////////////////////////////////////////////////////
+void GbVoxelMatrix3D::writeToVTKImageDataASCII(const std::string& fileName)
+{
+   int nx1 = (int)voxelMatrix.getNX1();
+   int nx2 = (int)voxelMatrix.getNX2();
+   int nx3 = (int)voxelMatrix.getNX3();
+
+   string fn = fileName+".ascii.vti";
+
+   FILE *file;
+   file = fopen(fn.c_str(), "w");
+
+   if (file==NULL)
+   {
+      std::string pathf = UbSystem::getPathFromString(fn);
+      if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); }
+      if (file==NULL) throw UbException(UB_EXARGS, "can not open "+fn);
+   }
+
+   fprintf(file, "<VTKFile type=\"ImageData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n"); //paraview 4.1
+   //fprintf(file,"<VTKFile type=\"ImageData\" version=\"0.1\" byte_order=\"LittleEndian\">\n"); //paraview 3.1
+   fprintf(file, "  <ImageData WholeExtent=\"%d %d %d %d %d %d\" Origin=\"%g %g %g\" Spacing=\"%g %g %g\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1, minX1, minX2, minX3, deltaX1, deltaX2, deltaX3);
+   fprintf(file, "  <Piece Extent=\"%d %d %d %d %d %d\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1);
+   fprintf(file, "    <PointData Scalars=\"VoxelMatrix\">\n");
+   fprintf(file, "      <DataArray type=\"Float32\" Name=\"VoxelMatrix\" format=\"ascii\" RangeMin=\"0\" RangeMax=\"1\">\n        ");
+
+   for (int k = 0; k<nx3; k++) {
+      for (int j = 0; j<nx2; j++) {
+         for (int i = 0; i<nx1; i++) {
+            fprintf(file, "%g ", voxelMatrix(i, j, k));
+         }
+      }
+   }
+
+   fprintf(file, "\n      </DataArray>\n");
+   fprintf(file, "    </PointData>\n");
+   fprintf(file, "    <CellData>\n");
+   fprintf(file, "    </CellData>\n");
+   fprintf(file, "  </Piece>\n");
+   fprintf(file, "  </ImageData>\n");
+   fprintf(file, "</VTKFile>\n");
+
+   fclose(file);
+}
+//////////////////////////////////////////////////////////////////////////
+void GbVoxelMatrix3D::writeToVTKImageDataAppended(const std::string& fileName)
+{
+   int nx1 = (int)voxelMatrix.getNX1();
+   int nx2 = (int)voxelMatrix.getNX2();
+   int nx3 = (int)voxelMatrix.getNX3();
+
+   string fn = fileName+".appended.vti";
+
+   FILE *file;
+   file = fopen(fn.c_str(), "w");
+
+   if (file==NULL)
+   {
+      std::string pathf = UbSystem::getPathFromString(fn);
+      if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); }
+      if (file==NULL) throw UbException(UB_EXARGS, "can not open "+fn);
+   }
+
+   fprintf(file, "<VTKFile type=\"ImageData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n"); //paraview 4.1
+   fprintf(file, "  <ImageData WholeExtent=\"%d %d %d %d %d %d\" Origin=\"%g %g %g\" Spacing=\"%g %g %g\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1, minX1, minX2, minX3, deltaX1, deltaX2, deltaX3);
+   fprintf(file, "  <Piece Extent=\"%d %d %d %d %d %d\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1);
+   fprintf(file, "    <PointData Scalars=\"VoxelMatrix\">\n");
+   fprintf(file, "      <DataArray type=\"Float32\" Name=\"VoxelMatrix\" format=\"appended\" RangeMin=\"0\" RangeMax=\"1\" offset=\"0\" />\n");
+   fprintf(file, "    </PointData>\n");
+   fprintf(file, "    <CellData>\n");
+   fprintf(file, "    </CellData>\n");
+   fprintf(file, "  </Piece>\n");
+   fprintf(file, "  </ImageData>\n");
+   fprintf(file, "  <AppendedData encoding=\"raw\">\n");
+   fprintf(file, "   _");
+   fclose(file);
+
+   file = fopen(fn.c_str(), "ab");
+   int size = (int)voxelMatrix.getDataVector().size()*sizeof(float);
+   fwrite(&size, sizeof(int), 1, file);
+   fwrite(voxelMatrix.getStartAdressOfSortedArray(0, 0, 0), sizeof(float), voxelMatrix.getDataVector().size(), file);
+   fclose(file);
+
+   file = fopen(fn.c_str(), "a");
+   fprintf(file, "\n");
+   fprintf(file, "  </AppendedData>\n");
+   fprintf(file, "</VTKFile>\n");
+   fclose(file);
+}
+
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/GbVoxelMatrix3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/GbVoxelMatrix3D.h
index 33e7a20133a3885706a5fc1bc317acd19d2f6e72..626803b7e6a994923e66dab3567e11b9dfe9a7fd 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/GbVoxelMatrix3D.h
@@ -1,341 +1,341 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef GBVOXELMATRIX3D_H
-#define GBVOXELMATRIX3D_H
-
-#ifdef CAB_RCF
-#include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-#include <vector>
-#include <cmath>
-
-#include <numerics/geometry3d/GbObject3D.h>
-#include <basics/utilities/UbObserver.h>
-#include <basics/container/CbArray3D.h>
-
-#include <PointerDefinitions.h>
-
-class GbLine3D;
-class GbTriangle3D;
-class GbObject3DCreator;
-
-class GbVoxelMatrix3D : public GbObject3D, public UbObserver
-{
-public:
-   typedef CbArray3D<float> Matrix3D;
-   static const float SOLID;
-   static const float FLUID;
-   enum  Endian { BigEndian, LittleEndian };
-
-   GbVoxelMatrix3D();
-   GbVoxelMatrix3D(int nx1, int nx2, int nx3, float initVal, double lowerThreshold = 0, double upperThreshold = 0);
-   GbVoxelMatrix3D(const Matrix3D& voxelMatrix, double lowerThreshold = 0, double upperThreshold = 0);
-   ~GbVoxelMatrix3D() {}
-
-   void finalize() {};
-   GbVoxelMatrix3D* clone();
-
-   /*=======================================================================*/
-   Matrix3D::reference operator() (const Matrix3D::size_type& x1, const Matrix3D::size_type& x2, const Matrix3D::size_type& x3)
-   {
-      return voxelMatrix(x1, x2, x3);
-   }
-   /*=======================================================================*/
-   Matrix3D::const_reference operator() (const Matrix3D::size_type& x1, const Matrix3D::size_type& x2, const Matrix3D::size_type& x3)	const
-   {
-      return voxelMatrix(x1, x2, x3);
-   }
-   /*=======================================================================*/
-   void setTransferViaFilename(bool transferViaFilename, std::string filename)
-   {
-      this->filename = filename;
-      this->transferViaFilename = transferViaFilename;
-   }
-   void setThreshold(double lowerThreshold, double upperThreshold) { this->lowerThreshold = lowerThreshold; this->upperThreshold = upperThreshold; }
-   void setAddSurfaceTriangleSetFlag(bool flag) { this->addSurfaceTriangleSetFlag = flag; }
-
-   /*=======================================================================*/
-   void setVoxelMatrixMininum(double minX1, double minX2, double minX3) { this->minX1 = minX1; this->minX2 = minX2; this->minX3 = minX3; }
-   void setVoxelMatrixMinX1(double minX1) { this->minX1 = minX1; }
-   void setVoxelMatrixMinX2(double minX2) { this->minX2 = minX2; }
-   void setVoxelMatrixMinX3(double minX3) { this->minX3 = minX3; }
-
-   /*=======================================================================*/
-   void setVoxelMatrixDelta(double deltaX1, double deltaX2, double deltaX3) { this->deltaX1 = deltaX1; this->deltaX2 = deltaX2; this->deltaX3 = deltaX3; }
-   void setVoxelMatrixDeltaX1(double deltaX1) { this->deltaX1 = deltaX1; }
-   void setVoxelMatrixDeltaX2(double deltaX2) { this->deltaX2 = deltaX2; }
-   void setVoxelMatrixDeltaX3(double deltaX3) { this->deltaX3 = deltaX3; }
-
-   /*=======================================================================*/
-   double getX1Centroid() { return 0.5 * (minX1+this->getX1Maximum()); }
-   double getX1Minimum() { return minX1; }
-   double getX1Maximum() { return minX1+deltaX1*voxelMatrix.getNX1(); }
-
-   double getX2Centroid() { return 0.5 * (minX2+this->getX2Maximum()); }
-   double getX2Minimum() { return minX2; }
-   double getX2Maximum() { return minX2+deltaX2*voxelMatrix.getNX2(); }
-
-   double getX3Centroid() { return 0.5 * (this->getX3Minimum()+this->getX3Maximum()); }
-   double getX3Minimum() { return minX3; }
-   double getX3Maximum() { return minX3+deltaX3*voxelMatrix.getNX3(); }
-
-   double getLengthX1() { return this->getX1Maximum()-minX1; }
-   double getLengthX2() { return this->getX2Maximum()-minX2; }
-   double getLengthX3() { return this->getX3Maximum()-minX3; }
-
-   void setCenterCoordinates(const double& x1, const double& x2, const double& x3);
-   void translate(const double& tx1, const double& tx2, const double& tx3);
-
-   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary);
-   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p);
-   bool isCellInsideGbObject3D(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b);
-   bool isCellCuttingGbObject3D(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b);
-   bool isCellInsideOrCuttingGbObject3D(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b);
-   //double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-
-   GbPoint3D*  calculateInterSectionPoint3D(GbPoint3D& point1, GbPoint3D &point2) { throw UbException(__FILE__, __LINE__, UB_FUNCTION, "not implemented"); }
-   GbLine3D*   createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) { throw UbException(__FILE__, __LINE__, UB_FUNCTION, "not implemented"); }
-
-   std::vector<GbTriangle3D*> getSurfaceTriangleSet();
-   void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles);
-
-   bool hasRaytracing() { return true; }
-   /*|r| must be 1! einheitsvector!!*/
-   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
-
-   std::string toString();
-
-   ObObjectCreator* getCreator();
-   void write(UbFileOutput* out);
-   void read(UbFileInput* in);
-
-   //virtuelle Methoden von UbObserver
-   void objectChanged(UbObservable* changedObject) {}
-   void objectWillBeDeleted(UbObservable* objectForDeletion) {}
-
-   template <class T>
-   void readMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian);
-   template <class T>
-   void readBufferedMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian);
-   void readMatrixFromVtiASCIIFile(std::string filename);
-
-   void rotate90aroundX();
-   void rotate90aroundY();
-   void rotate90aroundZ();
-   void rotate90aroundX(double cX1, double cX2, double cX3);
-   void rotate90aroundY(double cX1, double cX2, double cX3);
-   void rotate90aroundZ(double cX1, double cX2, double cX3);
-   void mirrorX();
-   void mirrorY();
-   void mirrorZ();
-
-   void rotateAroundY(double theta);
-
-   void writeToLegacyVTKASCII(const std::string& fileName);
-   void writeToLegacyVTKBinary(const std::string& fileName);
-   void writeToVTKImageDataASCII(const std::string& fileName);
-   void writeToVTKImageDataAppended(const std::string& fileName);
-
-   void setClosedVoidSpaceToSolid();
-
-   void calculateNumberOfSolidAndFluid();
-   long getNumberOfSolid();
-   long getNumberOfFluid();
-
-protected:
-   void findFluidNeighbor(int cx1, int cx2, int cx3);
-   Matrix3D voxelMatrixTemp;
-   CbArray3D<char> flagMatrix;
-
-   std::vector<int> x1Nbr;
-   std::vector<int> x2Nbr;
-   std::vector<int> x3Nbr;
-
-   std::vector<int> x1NbrTemp;
-   std::vector<int> x2NbrTemp;
-   std::vector<int> x3NbrTemp;
-
-   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
-
-//#ifdef CAB_RCF
-//   template<class Archive>
-//   void SF_SERIALIZE(Archive & ar)
-//   {
-//      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
-//      ar & minX1;
-//      ar & minX2;
-//      ar & minX3;
-//      ar & deltaX1;
-//      ar & deltaX2;
-//      ar & deltaX3;
-//      ar & nodesX1;
-//      ar & nodesX2;
-//      ar & nodesX3;
-//      ar & threshold;
-//      ar & transferViaFilename;
-//      ar & addSurfaceTriangleSetFlag;
-//      if (!transferViaFilename)
-//      {
-//         ar & voxelMatrix;
-//      }
-//      else
-//      {
-//         ar & filename;
-//         if (ArchiveTools::isReading(ar))
-//         {
-//            this->readMatrixFromVtiASCIIFile(filename);
-//         }
-//      }
-//
-//   }
-//#endif //CAB_RCF
-
-protected:
-   //for transfer
-   std::string filename;
-   bool transferViaFilename;
-
-   bool addSurfaceTriangleSetFlag;
-
-   int nodesX1;
-   int nodesX2;
-   int nodesX3;
-   double lowerThreshold, upperThreshold;
-
-   double minX1;
-   double minX2;
-   double minX3;
-   double deltaX1;
-   double deltaX2;
-   double deltaX3;
-
-   Matrix3D voxelMatrix;
-
-   long numberOfSolid;
-   long numberOfFluid;
-
-};
-
-//////////////////////////////////////////////////////////////////////////
-template <class T>
-void GbVoxelMatrix3D::readMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian)
-{
-   using namespace std;
-   //UBLOG(logINFO,"GbVoxelMatrix3D::readMatrixFromFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start");
-   ifstream in(filename.c_str(), ios::binary);
-   if (!in) throw UbException(UB_EXARGS, "could not open file "+filename);
-
-   in.seekg(0, ios::end);     //Ende springen
-   fstream::off_type length = in.tellg(); //Position abfragen
-   in.seekg(0, ios::beg);    //An den Anfang springen 
-
-   //UBLOG(logINFO,"number of nodes = "<<nodesX1*nodesX2*nodesX3*sizeof(T)<<" file size = "<<(long)length);
-   //if( (nodesX1*nodesX2*nodesX3)*sizeof(float) != (long)length )
-   unsigned long long nofn = (unsigned long long)nodesX1*(unsigned long long)nodesX2*(unsigned long long)nodesX3*(unsigned long long)sizeof(T);
-   if (nofn!=(unsigned long long)length)
-   {
-      throw UbException(UB_EXARGS, "number of nodes("+UbSystem::toString(nofn)+") doesn't match file size("+UbSystem::toString((long)length)+")");
-   }
-
-   //UBLOG(logINFO,"  - create GbVoxelMatrix3D");
-   //GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID);
-   voxelMatrix = Matrix3D(nodesX1, nodesX2, nodesX3, GbVoxelMatrix3D::FLUID);
-
-   //UBLOG(logINFO,"  - init values");
-   //float val;
-   T val;
-   for (int x3 = 0; x3<nodesX3; x3++)
-      for (int x2 = 0; x2<nodesX2; x2++)
-         for (int x1 = 0; x1<nodesX1; x1++)
-         {
-            //in.read((char*)&val,sizeof(float));
-            in.read((char*)&val, sizeof(T));
-            if (endian==BigEndian)
-               UbSystem::swapByteOrder((unsigned char*)(&(val)), sizeof(T));
-            //if( UbMath::equal((double)val, threshold) ) 
-            //if( UbMath::greater((double)val, threshold) )
-            if ((double)val>=lowerThreshold&&(double)val<=upperThreshold)
-            {
-               (voxelMatrix)(x1, x2, x3) = GbVoxelMatrix3D::SOLID;
-            }
-            //(voxelMatrix)(x1, x2, x3) = (float)val;
-         }
-
-   //UBLOG(logINFO,"GbVoxelMatrix3D::readMatrixFromFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end");
-}
-
-//////////////////////////////////////////////////////////////////////////
-template <class T>
-void GbVoxelMatrix3D::readBufferedMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian)
-{
-   using namespace std;
-   UBLOG(logINFO, "GbVoxelMatrix3D::readMatrixFromRawFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start");
-
-   FILE *file;
-   file = fopen(filename.c_str(), "rb");
-   if (file==NULL)
-   {
-      throw UbException(UB_EXARGS, "Could not open file "+filename);
-   }
-
-   // obtain file size:
-   fseek(file, 0, SEEK_END);
-   unsigned long int length = ftell(file);
-   rewind(file);
-
-   UBLOG(logINFO, "number of nodes = "<<(long)nodesX1*(long)nodesX2*(long)nodesX3<<" file size = "<<length);
-
-   unsigned long int nofn = (long)nodesX1*(long)nodesX2*(long)nodesX3*(long)sizeof(T);
-   if (nofn!=length)
-   {
-      //throw UbException(UB_EXARGS, "number of nodes("+UbSystem::toString(nofn)+") doesn't match file size("+UbSystem::toString(length)+")");
-   }
-
-   UBLOG(logINFO, "  - create GbVoxelMatrix3D");
-   voxelMatrix = Matrix3D(nodesX1, nodesX2, nodesX3, GbVoxelMatrix3D::FLUID);
-
-   CbArray3D<T> readMatrix(nodesX1, nodesX2, nodesX3);
-
-   UBLOG(logINFO, "  - read file to matrix");
-   fread(readMatrix.getStartAdressOfSortedArray(0, 0, 0), sizeof(T), readMatrix.getDataVector().size(), file);
-   fclose(file);
-
-   UBLOG(logINFO, "  - init values");
-
-   numberOfSolid = 0;
-   T val;
-   for (int x3 = 0; x3<nodesX3; x3++)
-      for (int x2 = 0; x2<nodesX2; x2++)
-         for (int x1 = 0; x1<nodesX1; x1++)
-         {
-            val = readMatrix(x1, x2, x3);
-
-            if (endian==BigEndian)
-            {
-               UbSystem::swapByteOrder((unsigned char*)(&(val)), sizeof(T));
-            }
-
-            if ((double)val>=lowerThreshold&&(double)val<=upperThreshold)
-            {
-               voxelMatrix(x1, x2, x3) = GbVoxelMatrix3D::SOLID;
-            }
-         }
-
-   UBLOG(logINFO, "GbVoxelMatrix3D::readMatrixFromRawFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end");
-}
-
-
-
-//#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
-//UB_AUTO_RUN_NAMED(SF::registerType<GbVoxelMatrix3D>("GbVoxelMatrix3D"), SF_GbVoxelMatrix3D);
-//UB_AUTO_RUN_NAMED((SF::registerBaseAndDerived< GbObject3D, GbVoxelMatrix3D >()), SF_GbVoxelMatrix3D_BD1);
-//UB_AUTO_RUN_NAMED((SF::registerBaseAndDerived< UbObserver, GbVoxelMatrix3D>()), SF_GbVoxelMatrix3D_BD2);
-//#endif //RCF_USE_SF_SERIALIZATION
-
-
-#endif   
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef GBVOXELMATRIX3D_H
+#define GBVOXELMATRIX3D_H
+
+#ifdef CAB_RCF
+#include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+#include <vector>
+#include <cmath>
+
+#include <numerics/geometry3d/GbObject3D.h>
+#include <basics/utilities/UbObserver.h>
+#include <basics/container/CbArray3D.h>
+
+#include <PointerDefinitions.h>
+
+class GbLine3D;
+class GbTriangle3D;
+class GbObject3DCreator;
+
+class GbVoxelMatrix3D : public GbObject3D, public UbObserver
+{
+public:
+   typedef CbArray3D<float> Matrix3D;
+   static const float SOLID;
+   static const float FLUID;
+   enum  Endian { BigEndian, LittleEndian };
+
+   GbVoxelMatrix3D();
+   GbVoxelMatrix3D(int nx1, int nx2, int nx3, float initVal, double lowerThreshold = 0, double upperThreshold = 0);
+   GbVoxelMatrix3D(const Matrix3D& voxelMatrix, double lowerThreshold = 0, double upperThreshold = 0);
+   ~GbVoxelMatrix3D() {}
+
+   void finalize() {};
+   GbVoxelMatrix3D* clone();
+
+   /*=======================================================================*/
+   Matrix3D::reference operator() (const Matrix3D::size_type& x1, const Matrix3D::size_type& x2, const Matrix3D::size_type& x3)
+   {
+      return voxelMatrix(x1, x2, x3);
+   }
+   /*=======================================================================*/
+   Matrix3D::const_reference operator() (const Matrix3D::size_type& x1, const Matrix3D::size_type& x2, const Matrix3D::size_type& x3)	const
+   {
+      return voxelMatrix(x1, x2, x3);
+   }
+   /*=======================================================================*/
+   void setTransferViaFilename(bool transferViaFilename, std::string filename)
+   {
+      this->filename = filename;
+      this->transferViaFilename = transferViaFilename;
+   }
+   void setThreshold(double lowerThreshold, double upperThreshold) { this->lowerThreshold = lowerThreshold; this->upperThreshold = upperThreshold; }
+   void setAddSurfaceTriangleSetFlag(bool flag) { this->addSurfaceTriangleSetFlag = flag; }
+
+   /*=======================================================================*/
+   void setVoxelMatrixMininum(double minX1, double minX2, double minX3) { this->minX1 = minX1; this->minX2 = minX2; this->minX3 = minX3; }
+   void setVoxelMatrixMinX1(double minX1) { this->minX1 = minX1; }
+   void setVoxelMatrixMinX2(double minX2) { this->minX2 = minX2; }
+   void setVoxelMatrixMinX3(double minX3) { this->minX3 = minX3; }
+
+   /*=======================================================================*/
+   void setVoxelMatrixDelta(double deltaX1, double deltaX2, double deltaX3) { this->deltaX1 = deltaX1; this->deltaX2 = deltaX2; this->deltaX3 = deltaX3; }
+   void setVoxelMatrixDeltaX1(double deltaX1) { this->deltaX1 = deltaX1; }
+   void setVoxelMatrixDeltaX2(double deltaX2) { this->deltaX2 = deltaX2; }
+   void setVoxelMatrixDeltaX3(double deltaX3) { this->deltaX3 = deltaX3; }
+
+   /*=======================================================================*/
+   double getX1Centroid() { return 0.5 * (minX1+this->getX1Maximum()); }
+   double getX1Minimum() { return minX1; }
+   double getX1Maximum() { return minX1+deltaX1*voxelMatrix.getNX1(); }
+
+   double getX2Centroid() { return 0.5 * (minX2+this->getX2Maximum()); }
+   double getX2Minimum() { return minX2; }
+   double getX2Maximum() { return minX2+deltaX2*voxelMatrix.getNX2(); }
+
+   double getX3Centroid() { return 0.5 * (this->getX3Minimum()+this->getX3Maximum()); }
+   double getX3Minimum() { return minX3; }
+   double getX3Maximum() { return minX3+deltaX3*voxelMatrix.getNX3(); }
+
+   double getLengthX1() { return this->getX1Maximum()-minX1; }
+   double getLengthX2() { return this->getX2Maximum()-minX2; }
+   double getLengthX3() { return this->getX3Maximum()-minX3; }
+
+   void setCenterCoordinates(const double& x1, const double& x2, const double& x3);
+   void translate(const double& tx1, const double& tx2, const double& tx3);
+
+   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary);
+   bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p);
+   bool isCellInsideGbObject3D(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b);
+   bool isCellCuttingGbObject3D(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b);
+   bool isCellInsideOrCuttingGbObject3D(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b);
+   //double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+
+   GbPoint3D*  calculateInterSectionPoint3D(GbPoint3D& point1, GbPoint3D &point2) { throw UbException(__FILE__, __LINE__, UB_FUNCTION, "not implemented"); }
+   GbLine3D*   createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) { throw UbException(__FILE__, __LINE__, UB_FUNCTION, "not implemented"); }
+
+   std::vector<GbTriangle3D*> getSurfaceTriangleSet();
+   void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles);
+
+   bool hasRaytracing() { return true; }
+   /*|r| must be 1! einheitsvector!!*/
+   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
+
+   std::string toString();
+
+   ObObjectCreator* getCreator();
+   void write(UbFileOutput* out);
+   void read(UbFileInput* in);
+
+   //virtuelle Methoden von UbObserver
+   void objectChanged(UbObservable* changedObject) {}
+   void objectWillBeDeleted(UbObservable* objectForDeletion) {}
+
+   template <class T>
+   void readMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian);
+   template <class T>
+   void readBufferedMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian);
+   void readMatrixFromVtiASCIIFile(std::string filename);
+
+   void rotate90aroundX();
+   void rotate90aroundY();
+   void rotate90aroundZ();
+   void rotate90aroundX(double cX1, double cX2, double cX3);
+   void rotate90aroundY(double cX1, double cX2, double cX3);
+   void rotate90aroundZ(double cX1, double cX2, double cX3);
+   void mirrorX();
+   void mirrorY();
+   void mirrorZ();
+
+   void rotateAroundY(double theta);
+
+   void writeToLegacyVTKASCII(const std::string& fileName);
+   void writeToLegacyVTKBinary(const std::string& fileName);
+   void writeToVTKImageDataASCII(const std::string& fileName);
+   void writeToVTKImageDataAppended(const std::string& fileName);
+
+   void setClosedVoidSpaceToSolid();
+
+   void calculateNumberOfSolidAndFluid();
+   long getNumberOfSolid();
+   long getNumberOfFluid();
+
+protected:
+   void findFluidNeighbor(int cx1, int cx2, int cx3);
+   Matrix3D voxelMatrixTemp;
+   CbArray3D<char> flagMatrix;
+
+   std::vector<int> x1Nbr;
+   std::vector<int> x2Nbr;
+   std::vector<int> x3Nbr;
+
+   std::vector<int> x1NbrTemp;
+   std::vector<int> x2NbrTemp;
+   std::vector<int> x3NbrTemp;
+
+   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
+
+//#ifdef CAB_RCF
+//   template<class Archive>
+//   void SF_SERIALIZE(Archive & ar)
+//   {
+//      SF_SERIALIZE_PARENT<GbObject3D>(ar, *this);
+//      ar & minX1;
+//      ar & minX2;
+//      ar & minX3;
+//      ar & deltaX1;
+//      ar & deltaX2;
+//      ar & deltaX3;
+//      ar & nodesX1;
+//      ar & nodesX2;
+//      ar & nodesX3;
+//      ar & threshold;
+//      ar & transferViaFilename;
+//      ar & addSurfaceTriangleSetFlag;
+//      if (!transferViaFilename)
+//      {
+//         ar & voxelMatrix;
+//      }
+//      else
+//      {
+//         ar & filename;
+//         if (ArchiveTools::isReading(ar))
+//         {
+//            this->readMatrixFromVtiASCIIFile(filename);
+//         }
+//      }
+//
+//   }
+//#endif //CAB_RCF
+
+protected:
+   //for transfer
+   std::string filename;
+   bool transferViaFilename;
+
+   bool addSurfaceTriangleSetFlag;
+
+   int nodesX1;
+   int nodesX2;
+   int nodesX3;
+   double lowerThreshold, upperThreshold;
+
+   double minX1;
+   double minX2;
+   double minX3;
+   double deltaX1;
+   double deltaX2;
+   double deltaX3;
+
+   Matrix3D voxelMatrix;
+
+   long numberOfSolid;
+   long numberOfFluid;
+
+};
+
+//////////////////////////////////////////////////////////////////////////
+template <class T>
+void GbVoxelMatrix3D::readMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian)
+{
+   using namespace std;
+   //UBLOG(logINFO,"GbVoxelMatrix3D::readMatrixFromFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start");
+   ifstream in(filename.c_str(), ios::binary);
+   if (!in) throw UbException(UB_EXARGS, "could not open file "+filename);
+
+   in.seekg(0, ios::end);     //Ende springen
+   fstream::off_type length = in.tellg(); //Position abfragen
+   in.seekg(0, ios::beg);    //An den Anfang springen 
+
+   //UBLOG(logINFO,"number of nodes = "<<nodesX1*nodesX2*nodesX3*sizeof(T)<<" file size = "<<(long)length);
+   //if( (nodesX1*nodesX2*nodesX3)*sizeof(float) != (long)length )
+   unsigned long long nofn = (unsigned long long)nodesX1*(unsigned long long)nodesX2*(unsigned long long)nodesX3*(unsigned long long)sizeof(T);
+   if (nofn!=(unsigned long long)length)
+   {
+      throw UbException(UB_EXARGS, "number of nodes("+UbSystem::toString(nofn)+") doesn't match file size("+UbSystem::toString((long)length)+")");
+   }
+
+   //UBLOG(logINFO,"  - create GbVoxelMatrix3D");
+   //GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID);
+   voxelMatrix = Matrix3D(nodesX1, nodesX2, nodesX3, GbVoxelMatrix3D::FLUID);
+
+   //UBLOG(logINFO,"  - init values");
+   //float val;
+   T val;
+   for (int x3 = 0; x3<nodesX3; x3++)
+      for (int x2 = 0; x2<nodesX2; x2++)
+         for (int x1 = 0; x1<nodesX1; x1++)
+         {
+            //in.read((char*)&val,sizeof(float));
+            in.read((char*)&val, sizeof(T));
+            if (endian==BigEndian)
+               UbSystem::swapByteOrder((unsigned char*)(&(val)), sizeof(T));
+            //if( UbMath::equal((double)val, threshold) ) 
+            //if( UbMath::greater((double)val, threshold) )
+            if ((double)val>=lowerThreshold&&(double)val<=upperThreshold)
+            {
+               (voxelMatrix)(x1, x2, x3) = GbVoxelMatrix3D::SOLID;
+            }
+            //(voxelMatrix)(x1, x2, x3) = (float)val;
+         }
+
+   //UBLOG(logINFO,"GbVoxelMatrix3D::readMatrixFromFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end");
+}
+
+//////////////////////////////////////////////////////////////////////////
+template <class T>
+void GbVoxelMatrix3D::readBufferedMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian)
+{
+   using namespace std;
+   UBLOG(logINFO, "GbVoxelMatrix3D::readMatrixFromRawFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start");
+
+   FILE *file;
+   file = fopen(filename.c_str(), "rb");
+   if (file==NULL)
+   {
+      throw UbException(UB_EXARGS, "Could not open file "+filename);
+   }
+
+   // obtain file size:
+   fseek(file, 0, SEEK_END);
+   unsigned long int length = ftell(file);
+   rewind(file);
+
+   UBLOG(logINFO, "number of nodes = "<<(long)nodesX1*(long)nodesX2*(long)nodesX3<<" file size = "<<length);
+
+   unsigned long int nofn = (long)nodesX1*(long)nodesX2*(long)nodesX3*(long)sizeof(T);
+   if (nofn!=length)
+   {
+      //throw UbException(UB_EXARGS, "number of nodes("+UbSystem::toString(nofn)+") doesn't match file size("+UbSystem::toString(length)+")");
+   }
+
+   UBLOG(logINFO, "  - create GbVoxelMatrix3D");
+   voxelMatrix = Matrix3D(nodesX1, nodesX2, nodesX3, GbVoxelMatrix3D::FLUID);
+
+   CbArray3D<T> readMatrix(nodesX1, nodesX2, nodesX3);
+
+   UBLOG(logINFO, "  - read file to matrix");
+   fread(readMatrix.getStartAdressOfSortedArray(0, 0, 0), sizeof(T), readMatrix.getDataVector().size(), file);
+   fclose(file);
+
+   UBLOG(logINFO, "  - init values");
+
+   numberOfSolid = 0;
+   T val;
+   for (int x3 = 0; x3<nodesX3; x3++)
+      for (int x2 = 0; x2<nodesX2; x2++)
+         for (int x1 = 0; x1<nodesX1; x1++)
+         {
+            val = readMatrix(x1, x2, x3);
+
+            if (endian==BigEndian)
+            {
+               UbSystem::swapByteOrder((unsigned char*)(&(val)), sizeof(T));
+            }
+
+            if ((double)val>=lowerThreshold&&(double)val<=upperThreshold)
+            {
+               voxelMatrix(x1, x2, x3) = GbVoxelMatrix3D::SOLID;
+            }
+         }
+
+   UBLOG(logINFO, "GbVoxelMatrix3D::readMatrixFromRawFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end");
+}
+
+
+
+//#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
+//UB_AUTO_RUN_NAMED(SF::registerType<GbVoxelMatrix3D>("GbVoxelMatrix3D"), SF_GbVoxelMatrix3D);
+//UB_AUTO_RUN_NAMED((SF::registerBaseAndDerived< GbObject3D, GbVoxelMatrix3D >()), SF_GbVoxelMatrix3D_BD1);
+//UB_AUTO_RUN_NAMED((SF::registerBaseAndDerived< UbObserver, GbVoxelMatrix3D>()), SF_GbVoxelMatrix3D_BD2);
+//#endif //RCF_USE_SF_SERIALIZATION
+
+
+#endif   
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/CMakePackage.txt b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/CMakePackage.txt
similarity index 98%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/CMakePackage.txt
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/CMakePackage.txt
index 8d2943620ae0f1b9f1a22b47979b2a23b2523256..ee319a16825781b852530b91a9094bbe1df6ceb9 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/KdTree/CMakePackage.txt
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/CMakePackage.txt
@@ -1,4 +1,4 @@
-GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
-COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR}                      ALL_SOURCES)
-COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR}/splitalgorithms      ALL_SOURCES)
-COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR}/intersectionhandler ALL_SOURCES)
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR}                      ALL_SOURCES)
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR}/splitalgorithms      ALL_SOURCES)
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR}/intersectionhandler ALL_SOURCES)
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/KdNode.h b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdNode.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/KdNode.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdNode.h
index 0b38011b10a124ad1962f39680479d3142249e5d..724ed9e08412f9e2d6fc41f289b9b8e265e53aab 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/KdTree/KdNode.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdNode.h
@@ -1,284 +1,284 @@
-#ifndef KDNODE_H
-#define KDNODE_H
-
-#include <basics/memory/MbSmartPtr.h>
-
-#include <basics/utilities/UbMath.h>
-#include <basics/utilities/UbTuple.h>
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbKeys.h>
-
-#include <numerics/geometry3d/GbTriFaceMesh3D.h>
-#include <numerics/geometry3d/KdTree/KdUtilities.h>
-#include <numerics/geometry3d/KdTree/KdRay.h>
-#include <numerics/geometry3d/KdTree/KdSplitCandidate.h>
-#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h>
-#include <numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h>
-#include <numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h>
-
-
-#include <vector>
-#include <string>
-
-namespace Kd
-{
-   template< typename T >
-   class Node 
-   {
-   public:
-      Node(  const T& x1, const T& y1, const T& z1
-           , const T& x2, const T& y2, const T& z2
-           , const MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFaces
-           , std::vector<GbTriFaceMesh3D::Vertex>* ptrNodes ) 
-         : child1(NULL)
-         , child2(NULL)
-         , triFaces(triFaces)
-         , ptrNodes(ptrNodes)
-      {
-         if( x1 < x2 ) { this->x[0] = x1; this->x[1] = x2; }
-         else          { this->x[0] = x2; this->x[1] = x1; }
-
-         if( y1 < y2 ) { this->y[0] = y1; this->y[1] = y2; }
-         else          { this->y[0] = y2; this->y[1] = y1; }
-
-         if( z1 < z2 ) { this->z[0] = z1; this->z[1] = z2; }
-         else          { this->z[0] = z2; this->z[1] = z1; }
-      }
-      /* ======================================================================================= */
-      ~Node()
-      {
-         if(child1) { delete child1; child1 = NULL;  }
-         if(child2) { delete child2; child2 = NULL;  }
-      }
-      /* ======================================================================================= */
-      bool isLeaf() 
-      {
-         return child1 == NULL && child2 == NULL;
-      }
-      /* ======================================================================================= */
-      void deleteTriFaces() 
-      {
-         triFaces = MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> >();
-      }
-      /* ======================================================================================= */
-      const MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> >& getTriFaces() 
-      {
-         return triFaces;
-      }
-      /* ======================================================================================= */
-      std::vector<GbTriFaceMesh3D::Vertex>& getNodes() 
-      {
-         if(!ptrNodes) throw UbException(UB_EXARGS,"ups,no nodes");
-         return *ptrNodes;
-      }
-
-      /* ======================================================================================= */
-      void buildTree(const int& level, const int& maxLevel, const SplitAlgorithm<T>& splitAlg) 
-      {
-         SplitCandidate<T> splitCandidate = splitAlg.findBestSplitCandidate(level, maxLevel, *this);
-
-         if( splitCandidate.isValid ) 
-         {
-
-            MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFacesForChild1( new std::vector<GbTriFaceMesh3D::TriFace> );
-            MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFacesForChild2( new std::vector<GbTriFaceMesh3D::TriFace> );
-
-            splitAlg.distributeTriFaces(splitCandidate, *triFacesForChild1, *triFacesForChild2, *this);
-
-            //////////////////////////////////////////////////////////////////////////
-            // calculate center points and edges of new child nodes
-            T x1_l = x[0], y1_l = y[0], z1_l = z[0];
-            T x2_l = x[1], y2_l = y[1], z2_l = z[1];
-            T x1_r = x[0], y1_r = y[0], z1_r = z[0];
-            T x2_r = x[1], y2_r = y[1], z2_r = z[1];
-
-            if (splitCandidate.axis == Axis::X) 
-            {
-               x2_l = splitCandidate.position;
-               x1_r = splitCandidate.position;
-            } 
-            else if (splitCandidate.axis == Axis::Y)
-            {
-               y2_l = splitCandidate.position;
-               y1_r = splitCandidate.position;
-            } 
-            else 
-            {
-               z2_l = splitCandidate.position;
-               z1_r = splitCandidate.position;
-            }
-            // ----------------------------------------------------------------------
-            // ----------------------------------------------------------------------
-
-            if (triFacesForChild1->size() > 0) 
-            {
-               if( this->child1 ) delete this->child1;
-               this->child1 = new Node(x1_l, y1_l, z1_l, x2_l, y2_l, z2_l, triFacesForChild1, ptrNodes);
-               this->child1->buildTree(level + 1, maxLevel, splitAlg);
-            }
-            
-            if (triFacesForChild2->size() > 0) 
-            {
-               if( this->child2 ) delete this->child2;
-               this->child2 = new Node(x1_r, y1_r, z1_r, x2_r, y2_r, z2_r, triFacesForChild2, ptrNodes);
-               this->child2->buildTree(level + 1, maxLevel, splitAlg);
-            }
-         }
-      }
-      /* ======================================================================================= */
-      int intersectLineBoundingBox(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2) 
-      {
-         const T& n1X = val<1>(n1);
-         const T& n1Y = val<2>(n1);
-         const T& n1Z = val<3>(n1);
-
-         const T& n2X = val<1>(n2);
-         const T& n2Y = val<2>(n2);
-         const T& n2Z = val<3>(n2);
-
-         double t_nah  = UbMath::max(  ( (n1X <= n2X ? x[0] : x[1]) - n1X) / (n2X - n1X)
-                                     , ( (n1Y <= n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y)
-                                     , ( (n1Z <= n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) );
-
-         double t_fern = UbMath::min(  ( (n1X >  n2X ? x[0] : x[1]) - n1X) / (n2X - n1X)
-                                     , ( (n1Y >  n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y)
-                                     , ( (n1Z >  n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) );
-
-         if ( UbMath::greater(  UbMath::max(  ( (n1X <= n2X ? x[0] : x[1]) - n1X) / (n2X - n1X)
-                                            , ( (n1Y <= n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y)
-                                            , ( (n1Z <= n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) )
-                              , UbMath::min(  ( (n1X >  n2X ? x[0] : x[1]) - n1X) / (n2X - n1X)
-                                            , ( (n1Y >  n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y)
-                                            , ( (n1Z >  n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) ) ) )
-         {
-            return Intersection::NO_INTERSECTION;
-         } 
-         else
-         {
-            return Intersection::INTERSECTION;
-         }
-      }
-      /* ======================================================================================= */
-      int intersectRayBoundingBox(const Ray<T>& ray) 
-      {
-         T tmin  = (x[  ray.signX] - ray.originX) * ray.inv_directionX;
-         T tmax  = (x[1-ray.signX] - ray.originX) * ray.inv_directionX;
-        
-         T tymin = (y[  ray.signY] - ray.originY) * ray.inv_directionY;
-         T tymax = (y[1-ray.signY] - ray.originY) * ray.inv_directionY;
-         
-         if( (tmin > tymax) || (tymin > tmax) ) 
-         {
-            return false;
-         }
-         if( tymin > tmin ) tmin = tymin;
-         if( tymax < tmax ) tmax = tymax;
-
-         T tzmin = (z[  ray.signZ] - ray.originZ) * ray.inv_directionZ;
-         T tzmax = (z[1-ray.signZ] - ray.originZ) * ray.inv_directionZ;
-         
-         //if( (UbMath::greater( tmin, tzmax) ) || ( UbMath::greater( tzmin, tmax) ) ) 
-         if( ( tmin > tzmax) || ( tzmin > tmax)  ) 
-         {
-            return false;
-         }
-         //if(tzmin > tmin) tmin = tzmin;
-         if(tzmax < tmax) tmax = tzmax;
-         
-         //return ( (tmin =< t1) && (tmax >= t0) );
-         if( UbMath::greaterEqual( tmax, T(0.0) ) )   
-         {
-            return Intersection::INTERSECTION;
-         }
-         else
-         {
-            return Intersection::NO_INTERSECTION;
-         }
-      }
-      /* ======================================================================================= */
-      bool intersectLine(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2, const LineIntersectionHandler<T>& iHandler) 
-      {
-         return iHandler.intersectLine(n1, n2, *this, child1, child2);
-      }
-      /* ======================================================================================= */
-      int intersectRay(const Ray<T>& ray, const RayIntersectionHandler<T>& iHandler, std::set< UbKeys::Key3<int> >& mailbox) 
-      {
-         return iHandler.intersectRay(ray, *this, child1, child2, mailbox);
-      }
-      /* ======================================================================================= */
-      int getNumOfTriFaces()
-      {
-         if(!child1 && !child2)
-         {  
-            if(triFaces) return (int)triFaces->size();
-            else         return 0;
-         } 
-         else 
-         {
-            int sum = 0;
-
-            if(child1) sum += child1->getNumOfTriFaces();
-            if(child2) sum += child2->getNumOfTriFaces();
-
-            return sum;
-         }
-      }
-      /* ======================================================================================= */
-      int getNumOfNodes()
-      {
-         if( !child1 && !child2) 
-         {
-            return 1;
-         } 
-         else
-         {
-            int sum = 0;
-            if(child1) sum += child1->getNumOfNodes();
-            if(child2) sum += child2->getNumOfNodes();
-
-            return 1 + sum;
-         }
-      }
-      /* ======================================================================================= */
-      std::string toString()
-      {
-         return "";//"[" + x1 + "," + y1 + "," + z1 + "]  -" + "  [" + x2 + "," + y2 + "," + z2 + "]";
-      }
-      /* ======================================================================================= */
-      void addCubeInfo(std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata)
-      {
-         nodes.push_back( makeUbTuple(float(x[0]), float(y[0]), float(z[0]) ) );
-         nodes.push_back( makeUbTuple(float(x[1]), float(y[0]), float(z[0]) ) );
-         nodes.push_back( makeUbTuple(float(x[1]), float(y[1]), float(z[0]) ) );
-         nodes.push_back( makeUbTuple(float(x[0]), float(y[1]), float(z[0]) ) );
-         
-         nodes.push_back( makeUbTuple(float(x[0]), float(y[0]), float(z[1]) ) );
-         nodes.push_back( makeUbTuple(float(x[1]), float(y[0]), float(z[1]) ) );
-         nodes.push_back( makeUbTuple(float(x[1]), float(y[1]), float(z[1]) ) );
-         nodes.push_back( makeUbTuple(float(x[0]), float(y[1]), float(z[1]) ) );
-
-         cells.push_back( makeUbTuple( int(nodes.size()-8), int(nodes.size()-7), int(nodes.size()-6), int(nodes.size()-5), 
-                                       int(nodes.size()-4), int(nodes.size()-3), int(nodes.size()-2), int(nodes.size()-1) ) );
-         datanames.resize(1);
-         datanames[0] = "childs";
-         celldata.resize( datanames.size() );
-         if     ( child1 && child2 ) celldata[0].push_back(2);
-         else if( child1 || child2 ) celldata[0].push_back(1);
-         else                        celldata[0].push_back(0);
-
-         if(child1) child1->addCubeInfo(nodes, cells, datanames, celldata);
-         if(child2) child2->addCubeInfo(nodes, cells, datanames, celldata);
-      }
-
-   public:
-      T x[2], y[2], z[2];
-
-   private:
-      Node* child1;
-      Node* child2;
-
-      MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFaces;
-      std::vector<GbTriFaceMesh3D::Vertex>*               ptrNodes;  //lediglich für Zugriff auf die Knoten!!!
-   };
-}
-#endif //KDNODE_H
+#ifndef KDNODE_H
+#define KDNODE_H
+
+#include <basics/memory/MbSmartPtr.h>
+
+#include <basics/utilities/UbMath.h>
+#include <basics/utilities/UbTuple.h>
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbKeys.h>
+
+#include <numerics/geometry3d/GbTriFaceMesh3D.h>
+#include <numerics/geometry3d/KdTree/KdUtilities.h>
+#include <numerics/geometry3d/KdTree/KdRay.h>
+#include <numerics/geometry3d/KdTree/KdSplitCandidate.h>
+#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h>
+#include <numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h>
+#include <numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h>
+
+
+#include <vector>
+#include <string>
+
+namespace Kd
+{
+   template< typename T >
+   class Node 
+   {
+   public:
+      Node(  const T& x1, const T& y1, const T& z1
+           , const T& x2, const T& y2, const T& z2
+           , const MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFaces
+           , std::vector<GbTriFaceMesh3D::Vertex>* ptrNodes ) 
+         : child1(NULL)
+         , child2(NULL)
+         , triFaces(triFaces)
+         , ptrNodes(ptrNodes)
+      {
+         if( x1 < x2 ) { this->x[0] = x1; this->x[1] = x2; }
+         else          { this->x[0] = x2; this->x[1] = x1; }
+
+         if( y1 < y2 ) { this->y[0] = y1; this->y[1] = y2; }
+         else          { this->y[0] = y2; this->y[1] = y1; }
+
+         if( z1 < z2 ) { this->z[0] = z1; this->z[1] = z2; }
+         else          { this->z[0] = z2; this->z[1] = z1; }
+      }
+      /* ======================================================================================= */
+      ~Node()
+      {
+         if(child1) { delete child1; child1 = NULL;  }
+         if(child2) { delete child2; child2 = NULL;  }
+      }
+      /* ======================================================================================= */
+      bool isLeaf() 
+      {
+         return child1 == NULL && child2 == NULL;
+      }
+      /* ======================================================================================= */
+      void deleteTriFaces() 
+      {
+         triFaces = MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> >();
+      }
+      /* ======================================================================================= */
+      const MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> >& getTriFaces() 
+      {
+         return triFaces;
+      }
+      /* ======================================================================================= */
+      std::vector<GbTriFaceMesh3D::Vertex>& getNodes() 
+      {
+         if(!ptrNodes) throw UbException(UB_EXARGS,"ups,no nodes");
+         return *ptrNodes;
+      }
+
+      /* ======================================================================================= */
+      void buildTree(const int& level, const int& maxLevel, const SplitAlgorithm<T>& splitAlg) 
+      {
+         SplitCandidate<T> splitCandidate = splitAlg.findBestSplitCandidate(level, maxLevel, *this);
+
+         if( splitCandidate.isValid ) 
+         {
+
+            MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFacesForChild1( new std::vector<GbTriFaceMesh3D::TriFace> );
+            MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFacesForChild2( new std::vector<GbTriFaceMesh3D::TriFace> );
+
+            splitAlg.distributeTriFaces(splitCandidate, *triFacesForChild1, *triFacesForChild2, *this);
+
+            //////////////////////////////////////////////////////////////////////////
+            // calculate center points and edges of new child nodes
+            T x1_l = x[0], y1_l = y[0], z1_l = z[0];
+            T x2_l = x[1], y2_l = y[1], z2_l = z[1];
+            T x1_r = x[0], y1_r = y[0], z1_r = z[0];
+            T x2_r = x[1], y2_r = y[1], z2_r = z[1];
+
+            if (splitCandidate.axis == Axis::X) 
+            {
+               x2_l = splitCandidate.position;
+               x1_r = splitCandidate.position;
+            } 
+            else if (splitCandidate.axis == Axis::Y)
+            {
+               y2_l = splitCandidate.position;
+               y1_r = splitCandidate.position;
+            } 
+            else 
+            {
+               z2_l = splitCandidate.position;
+               z1_r = splitCandidate.position;
+            }
+            // ----------------------------------------------------------------------
+            // ----------------------------------------------------------------------
+
+            if (triFacesForChild1->size() > 0) 
+            {
+               if( this->child1 ) delete this->child1;
+               this->child1 = new Node(x1_l, y1_l, z1_l, x2_l, y2_l, z2_l, triFacesForChild1, ptrNodes);
+               this->child1->buildTree(level + 1, maxLevel, splitAlg);
+            }
+            
+            if (triFacesForChild2->size() > 0) 
+            {
+               if( this->child2 ) delete this->child2;
+               this->child2 = new Node(x1_r, y1_r, z1_r, x2_r, y2_r, z2_r, triFacesForChild2, ptrNodes);
+               this->child2->buildTree(level + 1, maxLevel, splitAlg);
+            }
+         }
+      }
+      /* ======================================================================================= */
+      int intersectLineBoundingBox(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2) 
+      {
+         const T& n1X = val<1>(n1);
+         const T& n1Y = val<2>(n1);
+         const T& n1Z = val<3>(n1);
+
+         const T& n2X = val<1>(n2);
+         const T& n2Y = val<2>(n2);
+         const T& n2Z = val<3>(n2);
+
+         double t_nah  = UbMath::max(  ( (n1X <= n2X ? x[0] : x[1]) - n1X) / (n2X - n1X)
+                                     , ( (n1Y <= n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y)
+                                     , ( (n1Z <= n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) );
+
+         double t_fern = UbMath::min(  ( (n1X >  n2X ? x[0] : x[1]) - n1X) / (n2X - n1X)
+                                     , ( (n1Y >  n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y)
+                                     , ( (n1Z >  n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) );
+
+         if ( UbMath::greater(  UbMath::max(  ( (n1X <= n2X ? x[0] : x[1]) - n1X) / (n2X - n1X)
+                                            , ( (n1Y <= n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y)
+                                            , ( (n1Z <= n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) )
+                              , UbMath::min(  ( (n1X >  n2X ? x[0] : x[1]) - n1X) / (n2X - n1X)
+                                            , ( (n1Y >  n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y)
+                                            , ( (n1Z >  n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) ) ) )
+         {
+            return Intersection::NO_INTERSECTION;
+         } 
+         else
+         {
+            return Intersection::INTERSECTION;
+         }
+      }
+      /* ======================================================================================= */
+      int intersectRayBoundingBox(const Ray<T>& ray) 
+      {
+         T tmin  = (x[  ray.signX] - ray.originX) * ray.inv_directionX;
+         T tmax  = (x[1-ray.signX] - ray.originX) * ray.inv_directionX;
+        
+         T tymin = (y[  ray.signY] - ray.originY) * ray.inv_directionY;
+         T tymax = (y[1-ray.signY] - ray.originY) * ray.inv_directionY;
+         
+         if( (tmin > tymax) || (tymin > tmax) ) 
+         {
+            return false;
+         }
+         if( tymin > tmin ) tmin = tymin;
+         if( tymax < tmax ) tmax = tymax;
+
+         T tzmin = (z[  ray.signZ] - ray.originZ) * ray.inv_directionZ;
+         T tzmax = (z[1-ray.signZ] - ray.originZ) * ray.inv_directionZ;
+         
+         //if( (UbMath::greater( tmin, tzmax) ) || ( UbMath::greater( tzmin, tmax) ) ) 
+         if( ( tmin > tzmax) || ( tzmin > tmax)  ) 
+         {
+            return false;
+         }
+         //if(tzmin > tmin) tmin = tzmin;
+         if(tzmax < tmax) tmax = tzmax;
+         
+         //return ( (tmin =< t1) && (tmax >= t0) );
+         if( UbMath::greaterEqual( tmax, T(0.0) ) )   
+         {
+            return Intersection::INTERSECTION;
+         }
+         else
+         {
+            return Intersection::NO_INTERSECTION;
+         }
+      }
+      /* ======================================================================================= */
+      bool intersectLine(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2, const LineIntersectionHandler<T>& iHandler) 
+      {
+         return iHandler.intersectLine(n1, n2, *this, child1, child2);
+      }
+      /* ======================================================================================= */
+      int intersectRay(const Ray<T>& ray, const RayIntersectionHandler<T>& iHandler, std::set< UbKeys::Key3<int> >& mailbox) 
+      {
+         return iHandler.intersectRay(ray, *this, child1, child2, mailbox);
+      }
+      /* ======================================================================================= */
+      int getNumOfTriFaces()
+      {
+         if(!child1 && !child2)
+         {  
+            if(triFaces) return (int)triFaces->size();
+            else         return 0;
+         } 
+         else 
+         {
+            int sum = 0;
+
+            if(child1) sum += child1->getNumOfTriFaces();
+            if(child2) sum += child2->getNumOfTriFaces();
+
+            return sum;
+         }
+      }
+      /* ======================================================================================= */
+      int getNumOfNodes()
+      {
+         if( !child1 && !child2) 
+         {
+            return 1;
+         } 
+         else
+         {
+            int sum = 0;
+            if(child1) sum += child1->getNumOfNodes();
+            if(child2) sum += child2->getNumOfNodes();
+
+            return 1 + sum;
+         }
+      }
+      /* ======================================================================================= */
+      std::string toString()
+      {
+         return "";//"[" + x1 + "," + y1 + "," + z1 + "]  -" + "  [" + x2 + "," + y2 + "," + z2 + "]";
+      }
+      /* ======================================================================================= */
+      void addCubeInfo(std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata)
+      {
+         nodes.push_back( makeUbTuple(float(x[0]), float(y[0]), float(z[0]) ) );
+         nodes.push_back( makeUbTuple(float(x[1]), float(y[0]), float(z[0]) ) );
+         nodes.push_back( makeUbTuple(float(x[1]), float(y[1]), float(z[0]) ) );
+         nodes.push_back( makeUbTuple(float(x[0]), float(y[1]), float(z[0]) ) );
+         
+         nodes.push_back( makeUbTuple(float(x[0]), float(y[0]), float(z[1]) ) );
+         nodes.push_back( makeUbTuple(float(x[1]), float(y[0]), float(z[1]) ) );
+         nodes.push_back( makeUbTuple(float(x[1]), float(y[1]), float(z[1]) ) );
+         nodes.push_back( makeUbTuple(float(x[0]), float(y[1]), float(z[1]) ) );
+
+         cells.push_back( makeUbTuple( int(nodes.size()-8), int(nodes.size()-7), int(nodes.size()-6), int(nodes.size()-5), 
+                                       int(nodes.size()-4), int(nodes.size()-3), int(nodes.size()-2), int(nodes.size()-1) ) );
+         datanames.resize(1);
+         datanames[0] = "childs";
+         celldata.resize( datanames.size() );
+         if     ( child1 && child2 ) celldata[0].push_back(2);
+         else if( child1 || child2 ) celldata[0].push_back(1);
+         else                        celldata[0].push_back(0);
+
+         if(child1) child1->addCubeInfo(nodes, cells, datanames, celldata);
+         if(child2) child2->addCubeInfo(nodes, cells, datanames, celldata);
+      }
+
+   public:
+      T x[2], y[2], z[2];
+
+   private:
+      Node* child1;
+      Node* child2;
+
+      MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFaces;
+      std::vector<GbTriFaceMesh3D::Vertex>*               ptrNodes;  //lediglich für Zugriff auf die Knoten!!!
+   };
+}
+#endif //KDNODE_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/KdRay.h b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdRay.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/KdRay.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdRay.h
index c53dfa93fc5b0b99f9adb40cd556cce5756433aa..8465b83083ddc06fc1c1f965e02c74987cb02e2d 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/KdTree/KdRay.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdRay.h
@@ -1,69 +1,69 @@
-#ifndef KDRAY_H
-#define KDRAY_H
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbMath.h>
-
-
-namespace Kd
-{
-   /*
-   * Ray class, for use with the optimized ray-box intersection test
-   * described in:
-   *
-   *      Amy Williams, Steve Barrus, R. Keith Morley, and Peter Shirley
-   *      "An Efficient and Robust Ray-Box Intersection Algorithm"
-   *      Journal of graphics tools, 10(1):49-54, 2005
-   * 
-   */
-   template< typename T>
-   class Ray 
-   {
-   public:
-      Ray(  const T& originX   , const T& originY   , const T& originZ
-          , const T& directionX, const T& directionY, const T& directionZ ) 
-      {
-         this->originX        = originX;
-         this->originY        = originY;
-         this->originZ        = originZ;
-
-         //normierung (fuer ray-triangle-intersection)
-         T oneOverLength = T(1.0/std::sqrt(  directionX*directionX 
-                                            + directionY*directionY 
-                                            + directionZ*directionZ ) );
-
-         this->directionX     = directionX*oneOverLength;
-         this->directionY     = directionY*oneOverLength;
-         this->directionZ     = directionZ*oneOverLength;
-
-         this->inv_directionX = T(1.0/this->directionX);   //ACHTUNG: BEWUSST KEINE ==0 Abfrage
-         this->inv_directionY = T(1.0/this->directionY);   //Alg verwendet exlitzit INF
-         this->inv_directionZ = T(1.0/this->directionZ);
-         
-         if(this->inv_directionX < 0.0) this->signX = 1;
-         else                           this->signX = 0;
-         if(this->inv_directionY < 0.0) this->signY = 1;
-         else                           this->signY = 0;
-         if(this->inv_directionZ < 0.0) this->signZ = 1;
-         else                           this->signZ = 0;
-      }
-
-      T   originX;
-      T   originY;
-      T   originZ;
-        
-      T   directionX;
-      T   directionY;
-      T   directionZ;
-        
-      T   inv_directionX;
-      T   inv_directionY;
-      T   inv_directionZ;
-      
-      int signX;
-      int signY;
-      int signZ;
-   };
-} //namespace Kd
-
-#endif //KDRAY_H
+#ifndef KDRAY_H
+#define KDRAY_H
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbMath.h>
+
+
+namespace Kd
+{
+   /*
+   * Ray class, for use with the optimized ray-box intersection test
+   * described in:
+   *
+   *      Amy Williams, Steve Barrus, R. Keith Morley, and Peter Shirley
+   *      "An Efficient and Robust Ray-Box Intersection Algorithm"
+   *      Journal of graphics tools, 10(1):49-54, 2005
+   * 
+   */
+   template< typename T>
+   class Ray 
+   {
+   public:
+      Ray(  const T& originX   , const T& originY   , const T& originZ
+          , const T& directionX, const T& directionY, const T& directionZ ) 
+      {
+         this->originX        = originX;
+         this->originY        = originY;
+         this->originZ        = originZ;
+
+         //normierung (fuer ray-triangle-intersection)
+         T oneOverLength = T(1.0/std::sqrt(  directionX*directionX 
+                                            + directionY*directionY 
+                                            + directionZ*directionZ ) );
+
+         this->directionX     = directionX*oneOverLength;
+         this->directionY     = directionY*oneOverLength;
+         this->directionZ     = directionZ*oneOverLength;
+
+         this->inv_directionX = T(1.0/this->directionX);   //ACHTUNG: BEWUSST KEINE ==0 Abfrage
+         this->inv_directionY = T(1.0/this->directionY);   //Alg verwendet exlitzit INF
+         this->inv_directionZ = T(1.0/this->directionZ);
+         
+         if(this->inv_directionX < 0.0) this->signX = 1;
+         else                           this->signX = 0;
+         if(this->inv_directionY < 0.0) this->signY = 1;
+         else                           this->signY = 0;
+         if(this->inv_directionZ < 0.0) this->signZ = 1;
+         else                           this->signZ = 0;
+      }
+
+      T   originX;
+      T   originY;
+      T   originZ;
+        
+      T   directionX;
+      T   directionY;
+      T   directionZ;
+        
+      T   inv_directionX;
+      T   inv_directionY;
+      T   inv_directionZ;
+      
+      int signX;
+      int signY;
+      int signZ;
+   };
+} //namespace Kd
+
+#endif //KDRAY_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/KdSplitCandidate.h b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdSplitCandidate.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/KdSplitCandidate.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdSplitCandidate.h
index 361550555498cf4d5eae0ef00d68a720895055ab..9fe19c0657d01b4867020c99e0f16cdc7b453bc6 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/KdTree/KdSplitCandidate.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdSplitCandidate.h
@@ -1,68 +1,68 @@
-#ifndef KDSPLITCANDIDATE_H
-#define KDSPLITCANDIDATE_H
-
-#include <basics/utilities/UbMath.h>
-
-namespace Kd
-{
-   template< typename T >
-   class SplitCandidate   
-   {
-   public:
-      SplitCandidate() 
-         :  axis(0)
-          , position(0.0)
-          , starting(0)
-          , ending(0)
-          , np_left(false)
-          , np_right(false)
-          , Cn(0.0)
-          , nr(0)
-          , nl(0)  
-          , isValid(false)
-      {
-
-      }
-      /* ======================================================================================= */
-      SplitCandidate(const int& axis, const T& position, const int& starting, const int& ending, const int& insidePlane)
-         : np_left(false)
-         , np_right(false)
-         , axis(axis)
-         , position(position)
-         , starting(starting)
-         , ending(ending)
-         , np(insidePlane)
-         , Cn(0.0) 
-         , nr(0)  
-         , nl(0)  
-         , isValid(true)
-      {
-      }
-      /* ======================================================================================= */
-      bool operator!() const
-      {
-         return isValid; 
-      }
-      /* ======================================================================================= */
-      friend inline bool operator< (const SplitCandidate& lhs, const SplitCandidate& rhs)  
-      {
-         return  lhs.position < rhs.position;
-      }
-      /* ======================================================================================= */
-
-   public:
-      int     axis;
-      T       Cn;
-      T       position;
-      int     nl;
-      int     nr;
-      int     np;
-      int     starting;
-      int     ending;
-      bool    np_left;
-      bool    np_right;
-      bool    isValid;
-   };
-}
-
-#endif //KDSPLITCANDIDATE_H
+#ifndef KDSPLITCANDIDATE_H
+#define KDSPLITCANDIDATE_H
+
+#include <basics/utilities/UbMath.h>
+
+namespace Kd
+{
+   template< typename T >
+   class SplitCandidate   
+   {
+   public:
+      SplitCandidate() 
+         :  axis(0)
+          , position(0.0)
+          , starting(0)
+          , ending(0)
+          , np_left(false)
+          , np_right(false)
+          , Cn(0.0)
+          , nr(0)
+          , nl(0)  
+          , isValid(false)
+      {
+
+      }
+      /* ======================================================================================= */
+      SplitCandidate(const int& axis, const T& position, const int& starting, const int& ending, const int& insidePlane)
+         : np_left(false)
+         , np_right(false)
+         , axis(axis)
+         , position(position)
+         , starting(starting)
+         , ending(ending)
+         , np(insidePlane)
+         , Cn(0.0) 
+         , nr(0)  
+         , nl(0)  
+         , isValid(true)
+      {
+      }
+      /* ======================================================================================= */
+      bool operator!() const
+      {
+         return isValid; 
+      }
+      /* ======================================================================================= */
+      friend inline bool operator< (const SplitCandidate& lhs, const SplitCandidate& rhs)  
+      {
+         return  lhs.position < rhs.position;
+      }
+      /* ======================================================================================= */
+
+   public:
+      int     axis;
+      T       Cn;
+      T       position;
+      int     nl;
+      int     nr;
+      int     np;
+      int     starting;
+      int     ending;
+      bool    np_left;
+      bool    np_right;
+      bool    isValid;
+   };
+}
+
+#endif //KDSPLITCANDIDATE_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/KdSplitCandidateManager.h b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdSplitCandidateManager.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/KdSplitCandidateManager.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdSplitCandidateManager.h
index 0278807f8dd3b97e8303f0935205060852adc6d4..2849def3ab60b8c9e350688ff249e8f329ea31b7 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/KdTree/KdSplitCandidateManager.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdSplitCandidateManager.h
@@ -1,75 +1,75 @@
-#ifndef KDSPLITCANDIDATEMANAGER_H
-#define KDSPLITCANDIDATEMANAGER_H
-
-#include <numerics/geometry3d/KdTree/KdSplitCandidate.h>
-
-#include <map>
-#include <vector>
-#include <algorithm>
-
-
-namespace Kd
-{
-   template< typename T >
-   class SplitCandidateManager  
-   {
-   public:
-      SplitCandidateManager()
-         : objects_starting_outside_left(0)
-         , objects_fully_outside_node(0)
-      {
-
-      }
-      /* ======================================================================================= */
-      SplitCandidate<T>& operator[] (const int& i) 
-      { 
-         #ifdef DEBUG
-            return splitCandidatesVec.at(i);
-         #else
-            return splitCandidatesVec[i];
-         #endif  
-      }
-      /* ======================================================================================= */
-      typename std::vector< SplitCandidate< T > >::size_type size()
-      { 
-         return splitCandidatesVec.size();
-      }
-      /* ======================================================================================= */
-      void add(const T& pos, const int& axis, const int& starting, const int& ending, const int& np)
-      {
-         typename std::map<T, SplitCandidate<T> >::iterator it = splitCandidates.find(pos); 
-         if ( it != splitCandidates.end() )   //split candidate is already available -> increase parameter (starting, ending and np)
-         {
-            SplitCandidate<T>& sc = it->second;
-            sc.np       += np;
-            sc.starting += starting;
-            sc.ending   += ending;
-         } 
-         else // split candidate is not available -> add new split candidate
-         {
-            this->splitCandidates[pos] = SplitCandidate<T>(axis, pos, starting, ending, np);
-         }
-      }
-      /* ======================================================================================= */
-      void createSortedArray()
-      {
-         splitCandidatesVec.clear();
-         typename std::map<T, SplitCandidate<T> >::iterator it;
-         for( it=splitCandidates.begin(); it!=splitCandidates.end(); ++it)
-            splitCandidatesVec.push_back(it->second);
-         splitCandidates.clear();
-         std::sort(splitCandidatesVec.begin(), splitCandidatesVec.end(), std::less< SplitCandidate<T> >() );
-      }
-      /* ======================================================================================= */
-
-   public:
-      int objects_starting_outside_left;
-      int objects_fully_outside_node;
-
-   private:
-      std::map<T, SplitCandidate<T> > splitCandidates;
-      std::vector< SplitCandidate<T> >    splitCandidatesVec;
-   };
-}
-
-#endif //KDSPLITCANDIDATEMANAGER_H
+#ifndef KDSPLITCANDIDATEMANAGER_H
+#define KDSPLITCANDIDATEMANAGER_H
+
+#include <numerics/geometry3d/KdTree/KdSplitCandidate.h>
+
+#include <map>
+#include <vector>
+#include <algorithm>
+
+
+namespace Kd
+{
+   template< typename T >
+   class SplitCandidateManager  
+   {
+   public:
+      SplitCandidateManager()
+         : objects_starting_outside_left(0)
+         , objects_fully_outside_node(0)
+      {
+
+      }
+      /* ======================================================================================= */
+      SplitCandidate<T>& operator[] (const int& i) 
+      { 
+         #ifdef DEBUG
+            return splitCandidatesVec.at(i);
+         #else
+            return splitCandidatesVec[i];
+         #endif  
+      }
+      /* ======================================================================================= */
+      typename std::vector< SplitCandidate< T > >::size_type size()
+      { 
+         return splitCandidatesVec.size();
+      }
+      /* ======================================================================================= */
+      void add(const T& pos, const int& axis, const int& starting, const int& ending, const int& np)
+      {
+         typename std::map<T, SplitCandidate<T> >::iterator it = splitCandidates.find(pos); 
+         if ( it != splitCandidates.end() )   //split candidate is already available -> increase parameter (starting, ending and np)
+         {
+            SplitCandidate<T>& sc = it->second;
+            sc.np       += np;
+            sc.starting += starting;
+            sc.ending   += ending;
+         } 
+         else // split candidate is not available -> add new split candidate
+         {
+            this->splitCandidates[pos] = SplitCandidate<T>(axis, pos, starting, ending, np);
+         }
+      }
+      /* ======================================================================================= */
+      void createSortedArray()
+      {
+         splitCandidatesVec.clear();
+         typename std::map<T, SplitCandidate<T> >::iterator it;
+         for( it=splitCandidates.begin(); it!=splitCandidates.end(); ++it)
+            splitCandidatesVec.push_back(it->second);
+         splitCandidates.clear();
+         std::sort(splitCandidatesVec.begin(), splitCandidatesVec.end(), std::less< SplitCandidate<T> >() );
+      }
+      /* ======================================================================================= */
+
+   public:
+      int objects_starting_outside_left;
+      int objects_fully_outside_node;
+
+   private:
+      std::map<T, SplitCandidate<T> > splitCandidates;
+      std::vector< SplitCandidate<T> >    splitCandidatesVec;
+   };
+}
+
+#endif //KDSPLITCANDIDATEMANAGER_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/KdTree.h b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdTree.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/KdTree.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdTree.h
index 83c33266cca0d38e5fbce8094bc2c30c07687f45..7bf58a31526bbc0b47af1118dc7646df07b53f98 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/KdTree/KdTree.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdTree.h
@@ -1,100 +1,100 @@
-#ifndef KDTREE_H
-#define KDTREE_H
-
-#include <basics/memory/MbSmartPtr.h>
-#include <basics/writer/WbWriterVtkXmlBinary.h>
-#include <numerics/geometry3d/GbTriFaceMesh3D.h>
-#include <basics/utilities/UbKeys.h>
-
-#include <numerics/geometry3d/KdTree/KdNode.h>
-#include <numerics/geometry3d/KdTree/KdRay.h>
-#include <numerics/geometry3d/KdTree/KdSplitCandidate.h>
-#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h>
-
-#include <string>
-
-namespace Kd
-{
-   template< typename T >
-   class Tree 
-   {
-   public:
-      /* ======================================================================================= */
-      Tree(GbTriFaceMesh3D& mesh, const SplitAlgorithm<T>& splitAlg) 
-         : rootNode(NULL)
-      {
-         this->buildTree(mesh, splitAlg);
-      }
-      /* ======================================================================================= */
-      ~Tree()
-      {
-         if(rootNode)  { delete rootNode; rootNode = NULL; }
-      }
-      /* ======================================================================================= */
-      // the IntersectionHandler specifies how to handle the intersection
-      bool intersectLine(const UbTuple< T, T, T >& n1, const UbTuple< T, T, T >& n2, const LineIntersectionHandler<T>& iHandler) 
-      {
-         return rootNode->intersectLine(n1, n2, iHandler);
-      }
-      /* ======================================================================================= */
-      // the IntersectionHandler specifies how to handle the intersection
-      int intersectRay(const Ray<T>& ray, const RayIntersectionHandler<T>& iHandler) 
-      {
-         std::set< UbKeys::Key3<int> > mailbox;
-         return rootNode->intersectRay(ray, iHandler, mailbox);
-      }
-      /* ======================================================================================= */
-      int getNumOfNodes() 
-      {                                               
-         if(rootNode) return rootNode->getNumOfNodes();
-         return 0;
-      }
-      /* ======================================================================================= */
-      int getNumOfTriFaces() 
-      {
-         if(rootNode) return rootNode->getNumOfTriFaces();
-         return 0;
-      }
-      /* ======================================================================================= */
-      std::string toString() 
-      {
-         return "";//Tree:: num of nodes: " + rootNode.getNumOfNodes() + ", primitives:" + rootNode.getNumOfPrimitives() + ", root_primitives:" + getNumOfPrimitives() + ", max_level:" + max_level;
-      }
-      /* ======================================================================================= */
-      void buildTree(GbTriFaceMesh3D& mesh, const SplitAlgorithm<T>& splitAlg ) 
-      {
-         if(rootNode) delete rootNode;
-          
-         // create a copy of triangles 
-         MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFaces(new std::vector<GbTriFaceMesh3D::TriFace>(*mesh.getTriangles() ) );
-         
-         int maxLevel = (int)(8.0 + 1.3 * std::log( (double)triFaces->size() ) + 0.5);
-
-         rootNode = new Node<T>(   T( mesh.getX1Minimum() )
-                                 , T( mesh.getX2Minimum() )
-                                 , T( mesh.getX3Minimum() )
-                                 , T( mesh.getX1Maximum() )
-                                 , T( mesh.getX2Maximum() )
-                                 , T( mesh.getX3Maximum() )
-                                 , triFaces, mesh.getNodes() );
-
-         rootNode->buildTree(0, maxLevel, splitAlg);
-      }
-      void writeTree(const std::string& filename, WbWriter* writer = WbWriterVtkXmlBinary::getInstance())
-      {
-         if(rootNode)
-         {
-            std::vector<UbTupleFloat3 >        nodes;
-            std::vector<UbTupleInt8 >          cubes;
-            std::vector<std::string >          datanames;
-            std::vector<std::vector<double > > cubesdata;
-            rootNode->addCubeInfo(nodes, cubes, datanames, cubesdata);
-            writer->writeOctsWithCellData(filename,nodes,cubes,datanames,cubesdata);
-         }
-      }
-   private:
-      Node<T>* rootNode;    
-   };
-}
-
-#endif //KDTREE_H
+#ifndef KDTREE_H
+#define KDTREE_H
+
+#include <basics/memory/MbSmartPtr.h>
+#include <basics/writer/WbWriterVtkXmlBinary.h>
+#include <numerics/geometry3d/GbTriFaceMesh3D.h>
+#include <basics/utilities/UbKeys.h>
+
+#include <numerics/geometry3d/KdTree/KdNode.h>
+#include <numerics/geometry3d/KdTree/KdRay.h>
+#include <numerics/geometry3d/KdTree/KdSplitCandidate.h>
+#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h>
+
+#include <string>
+
+namespace Kd
+{
+   template< typename T >
+   class Tree 
+   {
+   public:
+      /* ======================================================================================= */
+      Tree(GbTriFaceMesh3D& mesh, const SplitAlgorithm<T>& splitAlg) 
+         : rootNode(NULL)
+      {
+         this->buildTree(mesh, splitAlg);
+      }
+      /* ======================================================================================= */
+      ~Tree()
+      {
+         if(rootNode)  { delete rootNode; rootNode = NULL; }
+      }
+      /* ======================================================================================= */
+      // the IntersectionHandler specifies how to handle the intersection
+      bool intersectLine(const UbTuple< T, T, T >& n1, const UbTuple< T, T, T >& n2, const LineIntersectionHandler<T>& iHandler) 
+      {
+         return rootNode->intersectLine(n1, n2, iHandler);
+      }
+      /* ======================================================================================= */
+      // the IntersectionHandler specifies how to handle the intersection
+      int intersectRay(const Ray<T>& ray, const RayIntersectionHandler<T>& iHandler) 
+      {
+         std::set< UbKeys::Key3<int> > mailbox;
+         return rootNode->intersectRay(ray, iHandler, mailbox);
+      }
+      /* ======================================================================================= */
+      int getNumOfNodes() 
+      {                                               
+         if(rootNode) return rootNode->getNumOfNodes();
+         return 0;
+      }
+      /* ======================================================================================= */
+      int getNumOfTriFaces() 
+      {
+         if(rootNode) return rootNode->getNumOfTriFaces();
+         return 0;
+      }
+      /* ======================================================================================= */
+      std::string toString() 
+      {
+         return "";//Tree:: num of nodes: " + rootNode.getNumOfNodes() + ", primitives:" + rootNode.getNumOfPrimitives() + ", root_primitives:" + getNumOfPrimitives() + ", max_level:" + max_level;
+      }
+      /* ======================================================================================= */
+      void buildTree(GbTriFaceMesh3D& mesh, const SplitAlgorithm<T>& splitAlg ) 
+      {
+         if(rootNode) delete rootNode;
+          
+         // create a copy of triangles 
+         MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFaces(new std::vector<GbTriFaceMesh3D::TriFace>(*mesh.getTriangles() ) );
+         
+         int maxLevel = (int)(8.0 + 1.3 * std::log( (double)triFaces->size() ) + 0.5);
+
+         rootNode = new Node<T>(   T( mesh.getX1Minimum() )
+                                 , T( mesh.getX2Minimum() )
+                                 , T( mesh.getX3Minimum() )
+                                 , T( mesh.getX1Maximum() )
+                                 , T( mesh.getX2Maximum() )
+                                 , T( mesh.getX3Maximum() )
+                                 , triFaces, mesh.getNodes() );
+
+         rootNode->buildTree(0, maxLevel, splitAlg);
+      }
+      void writeTree(const std::string& filename, WbWriter* writer = WbWriterVtkXmlBinary::getInstance())
+      {
+         if(rootNode)
+         {
+            std::vector<UbTupleFloat3 >        nodes;
+            std::vector<UbTupleInt8 >          cubes;
+            std::vector<std::string >          datanames;
+            std::vector<std::vector<double > > cubesdata;
+            rootNode->addCubeInfo(nodes, cubes, datanames, cubesdata);
+            writer->writeOctsWithCellData(filename,nodes,cubes,datanames,cubesdata);
+         }
+      }
+   private:
+      Node<T>* rootNode;    
+   };
+}
+
+#endif //KDTREE_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/KdUtilities.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdUtilities.cpp
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/KdUtilities.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdUtilities.cpp
index efbdd580caa25bb09f8278bec078da6b0c4fecfb..f0b7115b6175b9afdc3b42f0ce758eab54457422 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/KdTree/KdUtilities.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdUtilities.cpp
@@ -1,13 +1,13 @@
-#include <numerics/geometry3d/KdTree/KdUtilities.h>
-
-namespace Kd
-{
-   const int Axis::X = 0;
-   const int Axis::Y = 1;
-   const int Axis::Z = 2;
-
-   const int Intersection::ON_BOUNDARY     = -2;
-   const int Intersection::INTERSECT_EDGE  = -1;
-   const int Intersection::INTERSECTION    =  1;
-const int Intersection::NO_INTERSECTION =  0;
-} //namespace Kd
+#include <numerics/geometry3d/KdTree/KdUtilities.h>
+
+namespace Kd
+{
+   const int Axis::X = 0;
+   const int Axis::Y = 1;
+   const int Axis::Z = 2;
+
+   const int Intersection::ON_BOUNDARY     = -2;
+   const int Intersection::INTERSECT_EDGE  = -1;
+   const int Intersection::INTERSECTION    =  1;
+const int Intersection::NO_INTERSECTION =  0;
+} //namespace Kd
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/KdUtilities.h b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdUtilities.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/KdUtilities.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdUtilities.h
index 39a700cc4e216e6349f5d15ddc28c4b6f93c663e..177893950a7a0ee087a1c3f74fe38b15c41285a1 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/KdTree/KdUtilities.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/KdUtilities.h
@@ -1,164 +1,164 @@
-#ifndef KDUTILIES_H
-#define KDUTILIES_H
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbTuple.h>
-#include <basics/utilities/UbMath.h>
-
-#include <numerics/geometry3d/GbTriFaceMesh3D.h>
-
-#include <algorithm>
-#include <vector>
-
-namespace Kd
-{
-   struct  Axis 
-   {
-      static const int X;// = 0;
-      static const int Y;// = 1;
-      static const int Z;// = 2;
-   };
-   /* ======================================================================================= */
-   struct Intersection 
-   {
-      static const int ON_BOUNDARY;    // = -2;
-      static const int INTERSECT_EDGE; // = -1;
-      static const int INTERSECTION;   // = 1;
-      static const int NO_INTERSECTION;// = 0;
-   };
-   /* ======================================================================================= */
-   template< typename T>
-   inline void project2Axis(GbTriFaceMesh3D::TriFace& triFace, std::vector<GbTriFaceMesh3D::Vertex>& nodes, const int& axis, std::vector<T>& projection) 
-   {
-      projection.resize(3);
-   
-      if(axis==Axis::X)
-      {
-         projection[0] = triFace.getV1x(nodes);
-         projection[1] = triFace.getV2x(nodes);
-         projection[2] = triFace.getV3x(nodes);
-      }
-      else if(axis==Axis::Y)
-      {
-         projection[0] = triFace.getV1y(nodes);
-         projection[1] = triFace.getV2y(nodes);
-         projection[2] = triFace.getV3y(nodes);
-      }
-      else if(axis==Axis::Z)
-      {
-         projection[0] = triFace.getV1z(nodes);
-         projection[1] = triFace.getV2z(nodes);
-         projection[2] = triFace.getV3z(nodes);
-      }
-      else throw UbException(UB_EXARGS,"unknown axis");
-      
-      std::sort( projection.begin(), projection.end(), std::less<double>() );
-   }
-   /* ======================================================================================= */
-   template< typename T>
-   inline bool isPointOnPlane(const T& px, const T& py, const T& pz, const T& precision, GbTriFaceMesh3D::Vertex& pointOfTriFace, GbTriFaceMesh3D::TriFace& triFace) 
-   {
-      return std::fabs( (px - pointOfTriFace.x) * triFace.nx + (py - pointOfTriFace.y) * triFace.ny + (pz - pointOfTriFace.z) * triFace.nz ) < precision;
-   }
-   /* ======================================================================================= */
-   template< typename T>
-   inline bool isPointOnTriangle( const T& px, const T& py, const T& pz, const T& precision
-                               , GbTriFaceMesh3D::Vertex& p1, GbTriFaceMesh3D::Vertex& p2, GbTriFaceMesh3D::Vertex& p3
-                               , GbTriFaceMesh3D::TriFace& triFace  ) 
-   {
-      if( Kd::isPointOnPlane(px, py, pz, precision, p1, triFace) ) 
-      {
-         T a_x = p1.x - px;
-         T a_y = p1.y - py;
-         T a_z = p1.z - pz;
-         T b_x = p2.x - px;
-         T b_y = p2.y - py;
-         T b_z = p2.z - pz;
-         T c_x = p3.x - px;
-         T c_y = p3.y - py;
-         T c_z = p3.z - pz;
-
-         const T factor = 0.5;
-         T Q1_x = (a_y * b_z - a_z * b_y) * factor;
-         T Q1_y = (a_z * b_x - a_x * b_z) * factor;
-         T Q1_z = (a_x * b_y - a_y * b_x) * factor;
-
-         T Q2_x = (b_y * c_z - b_z * c_y) * factor;
-         T Q2_y = (b_z * c_x - b_x * c_z) * factor;
-         T Q2_z = (b_x * c_y - b_y * c_x) * factor;
-
-         T Q3_x = (c_y * a_z - c_z * a_y) * factor;
-         T Q3_y = (c_z * a_x - c_x * a_z) * factor;
-         T Q3_z = (c_x * a_y - c_y * a_x) * factor;
-
-         T Q_x = Q1_x + Q2_x + Q3_x;
-         T Q_y = Q1_y + Q2_y + Q3_y;
-         T Q_z = Q1_z + Q2_z + Q3_z;
-
-
-         if     ( UbMath::zero(Q_x * Q1_x + Q_y * Q1_y + Q_z * Q1_z         ) ) return true;
-         else if( UbMath::zero(Q_x * Q2_x + Q_y * Q2_y + Q_z * Q2_z         ) ) return true;
-         else if( UbMath::zero(Q_x * Q3_x + Q_y * Q3_y + Q_z * Q3_z         ) ) return true;
-         else if( UbMath::less(Q_x * Q1_x + Q_y * Q1_y + Q_z * Q1_z, T(0.0) ) ) return false;
-         else if( UbMath::less(Q_x * Q2_x + Q_y * Q2_y + Q_z * Q2_z, T(0.0) ) ) return false;
-         else if( UbMath::less(Q_x * Q3_x + Q_y * Q3_y + Q_z * Q3_z, T(0.0) ) ) return false;
-
-         return true;
-      } 
-      
-      return false;
-   }
-   /* ======================================================================================= */
-   template< typename T>
-   inline bool intersectLine(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2, GbTriFaceMesh3D::TriFace& triFace, std::vector<GbTriFaceMesh3D::Vertex>& nodes) 
-   {
-      GbTriFaceMesh3D::Vertex& p0=triFace.getNode(0,nodes);
-      
-      const T& n1X = val<1>(n1);
-      const T& n1Y = val<2>(n1);
-      const T& n1Z = val<3>(n1);
-
-      const T& n2X = val<1>(n2);
-      const T& n2Y = val<2>(n2);
-      const T& n2Z = val<3>(n2);
-
-      //if(   Kd::isPointOnPlane(n1X, n1Y, n1Z, T(1.0E-6), p0, triFace) 
-      //   && Kd::isPointOnPlane(n2X, n2Y, n2Z, T(1.0E-6), p0, triFace)) 
-      //{
-      //   return true;
-      //}
-
-         T denom = ( n2X - n1X ) * triFace.nx + ( n2Y - n1Y ) * triFace.ny + ( n2Z - n1Z ) * triFace.nz;
-
-         if( UbMath::zero( denom ) )  //line does not intersect the plane of the triangle !
-         {
-         return false;
-         } 
-         else 
-         {
-            T d  = - triFace.nx * p0.x - triFace.ny * p0.y - triFace.nz * p0.z;
-            T mu = T(-1.0 * (d + n1X * triFace.nx + n1Y * triFace.ny + n1Z * triFace.nz ) / denom);
-
-            if( !UbMath::inClosedInterval( mu, T(0.0), T(1.0)) )  // Point of intersection of line and plane does not lie on the triangle
-            {
-            return false;
-            } 
-            else 
-            {
-               // intersection with plane
- 
-               //Test whether Point lies inside the triangle or not
-            GbTriFaceMesh3D::Vertex& p1=triFace.getNode(1,nodes);
-            GbTriFaceMesh3D::Vertex& p2=triFace.getNode(2,nodes);
-               
-               return Kd::isPointOnTriangle(  n1X + ( (n2X - n1X) * mu )   //intersectionPointX
-                                            , n1Y + ( (n2Y - n1Y) * mu )   //intersectionPointY
-                                            , n1Z + ( (n2Z - n1Z) * mu )   //intersectionPointZ
-                                            , T(0.001)
-                                            , p0, p1, p2, triFace );
-            }
-         }
-      } 
-} //namespace Kd
-
-#endif //KDUTILIES_H
+#ifndef KDUTILIES_H
+#define KDUTILIES_H
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbTuple.h>
+#include <basics/utilities/UbMath.h>
+
+#include <numerics/geometry3d/GbTriFaceMesh3D.h>
+
+#include <algorithm>
+#include <vector>
+
+namespace Kd
+{
+   struct  Axis 
+   {
+      static const int X;// = 0;
+      static const int Y;// = 1;
+      static const int Z;// = 2;
+   };
+   /* ======================================================================================= */
+   struct Intersection 
+   {
+      static const int ON_BOUNDARY;    // = -2;
+      static const int INTERSECT_EDGE; // = -1;
+      static const int INTERSECTION;   // = 1;
+      static const int NO_INTERSECTION;// = 0;
+   };
+   /* ======================================================================================= */
+   template< typename T>
+   inline void project2Axis(GbTriFaceMesh3D::TriFace& triFace, std::vector<GbTriFaceMesh3D::Vertex>& nodes, const int& axis, std::vector<T>& projection) 
+   {
+      projection.resize(3);
+   
+      if(axis==Axis::X)
+      {
+         projection[0] = triFace.getV1x(nodes);
+         projection[1] = triFace.getV2x(nodes);
+         projection[2] = triFace.getV3x(nodes);
+      }
+      else if(axis==Axis::Y)
+      {
+         projection[0] = triFace.getV1y(nodes);
+         projection[1] = triFace.getV2y(nodes);
+         projection[2] = triFace.getV3y(nodes);
+      }
+      else if(axis==Axis::Z)
+      {
+         projection[0] = triFace.getV1z(nodes);
+         projection[1] = triFace.getV2z(nodes);
+         projection[2] = triFace.getV3z(nodes);
+      }
+      else throw UbException(UB_EXARGS,"unknown axis");
+      
+      std::sort( projection.begin(), projection.end(), std::less<double>() );
+   }
+   /* ======================================================================================= */
+   template< typename T>
+   inline bool isPointOnPlane(const T& px, const T& py, const T& pz, const T& precision, GbTriFaceMesh3D::Vertex& pointOfTriFace, GbTriFaceMesh3D::TriFace& triFace) 
+   {
+      return std::fabs( (px - pointOfTriFace.x) * triFace.nx + (py - pointOfTriFace.y) * triFace.ny + (pz - pointOfTriFace.z) * triFace.nz ) < precision;
+   }
+   /* ======================================================================================= */
+   template< typename T>
+   inline bool isPointOnTriangle( const T& px, const T& py, const T& pz, const T& precision
+                               , GbTriFaceMesh3D::Vertex& p1, GbTriFaceMesh3D::Vertex& p2, GbTriFaceMesh3D::Vertex& p3
+                               , GbTriFaceMesh3D::TriFace& triFace  ) 
+   {
+      if( Kd::isPointOnPlane(px, py, pz, precision, p1, triFace) ) 
+      {
+         T a_x = p1.x - px;
+         T a_y = p1.y - py;
+         T a_z = p1.z - pz;
+         T b_x = p2.x - px;
+         T b_y = p2.y - py;
+         T b_z = p2.z - pz;
+         T c_x = p3.x - px;
+         T c_y = p3.y - py;
+         T c_z = p3.z - pz;
+
+         const T factor = 0.5;
+         T Q1_x = (a_y * b_z - a_z * b_y) * factor;
+         T Q1_y = (a_z * b_x - a_x * b_z) * factor;
+         T Q1_z = (a_x * b_y - a_y * b_x) * factor;
+
+         T Q2_x = (b_y * c_z - b_z * c_y) * factor;
+         T Q2_y = (b_z * c_x - b_x * c_z) * factor;
+         T Q2_z = (b_x * c_y - b_y * c_x) * factor;
+
+         T Q3_x = (c_y * a_z - c_z * a_y) * factor;
+         T Q3_y = (c_z * a_x - c_x * a_z) * factor;
+         T Q3_z = (c_x * a_y - c_y * a_x) * factor;
+
+         T Q_x = Q1_x + Q2_x + Q3_x;
+         T Q_y = Q1_y + Q2_y + Q3_y;
+         T Q_z = Q1_z + Q2_z + Q3_z;
+
+
+         if     ( UbMath::zero(Q_x * Q1_x + Q_y * Q1_y + Q_z * Q1_z         ) ) return true;
+         else if( UbMath::zero(Q_x * Q2_x + Q_y * Q2_y + Q_z * Q2_z         ) ) return true;
+         else if( UbMath::zero(Q_x * Q3_x + Q_y * Q3_y + Q_z * Q3_z         ) ) return true;
+         else if( UbMath::less(Q_x * Q1_x + Q_y * Q1_y + Q_z * Q1_z, T(0.0) ) ) return false;
+         else if( UbMath::less(Q_x * Q2_x + Q_y * Q2_y + Q_z * Q2_z, T(0.0) ) ) return false;
+         else if( UbMath::less(Q_x * Q3_x + Q_y * Q3_y + Q_z * Q3_z, T(0.0) ) ) return false;
+
+         return true;
+      } 
+      
+      return false;
+   }
+   /* ======================================================================================= */
+   template< typename T>
+   inline bool intersectLine(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2, GbTriFaceMesh3D::TriFace& triFace, std::vector<GbTriFaceMesh3D::Vertex>& nodes) 
+   {
+      GbTriFaceMesh3D::Vertex& p0=triFace.getNode(0,nodes);
+      
+      const T& n1X = val<1>(n1);
+      const T& n1Y = val<2>(n1);
+      const T& n1Z = val<3>(n1);
+
+      const T& n2X = val<1>(n2);
+      const T& n2Y = val<2>(n2);
+      const T& n2Z = val<3>(n2);
+
+      //if(   Kd::isPointOnPlane(n1X, n1Y, n1Z, T(1.0E-6), p0, triFace) 
+      //   && Kd::isPointOnPlane(n2X, n2Y, n2Z, T(1.0E-6), p0, triFace)) 
+      //{
+      //   return true;
+      //}
+
+         T denom = ( n2X - n1X ) * triFace.nx + ( n2Y - n1Y ) * triFace.ny + ( n2Z - n1Z ) * triFace.nz;
+
+         if( UbMath::zero( denom ) )  //line does not intersect the plane of the triangle !
+         {
+         return false;
+         } 
+         else 
+         {
+            T d  = - triFace.nx * p0.x - triFace.ny * p0.y - triFace.nz * p0.z;
+            T mu = T(-1.0 * (d + n1X * triFace.nx + n1Y * triFace.ny + n1Z * triFace.nz ) / denom);
+
+            if( !UbMath::inClosedInterval( mu, T(0.0), T(1.0)) )  // Point of intersection of line and plane does not lie on the triangle
+            {
+            return false;
+            } 
+            else 
+            {
+               // intersection with plane
+ 
+               //Test whether Point lies inside the triangle or not
+            GbTriFaceMesh3D::Vertex& p1=triFace.getNode(1,nodes);
+            GbTriFaceMesh3D::Vertex& p2=triFace.getNode(2,nodes);
+               
+               return Kd::isPointOnTriangle(  n1X + ( (n2X - n1X) * mu )   //intersectionPointX
+                                            , n1Y + ( (n2Y - n1Y) * mu )   //intersectionPointY
+                                            , n1Z + ( (n2Z - n1Z) * mu )   //intersectionPointZ
+                                            , T(0.001)
+                                            , p0, p1, p2, triFace );
+            }
+         }
+      } 
+} //namespace Kd
+
+#endif //KDUTILIES_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt
index 1b2fd9ad9cd9a3ca227dce4499cb7d665289945a..77bce42648967f39ec63be5d35d5b93cf3fef400 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt
@@ -1,39 +1,39 @@
-cmake_minimum_required(VERSION 2.6)
-
-PROJECT(kdtree_pioTest)
-
-#################################################################
-# MACHINE_SPECIFIC CMAKE_CONFIG_FILE
-#################################################################
-INCLUDE("../../../../../CMake/CMakeCABMacros.txt")
-
-#################################################################
-###   PACKAGES                                               ###
-#################################################################
-INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/3rdParty/dirstream/CMakePackage.txt)
-
-INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/basics/container/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/basics/writer/CMakePackage.txt)
-
-INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/KdTree/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/fem/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakePackage.txt)
-
-#################################################################
-###   OWN DEFINES 						###
-#################################################################
-FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h
-                         ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 
-
-SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES})
-SOURCE_GROUP(z_main FILES ${SPECIFIC_FILES})
-
-#################################################################
-###  PROJECT ERSTELLEN                                        ###
-#################################################################
-CREATE_CAB_PROJECT(${PROJECT_NAME} BINARY)
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(kdtree_pioTest)
+
+#################################################################
+# MACHINE_SPECIFIC CMAKE_CONFIG_FILE
+#################################################################
+INCLUDE("../../../../../CMake/CMakeCABMacros.txt")
+
+#################################################################
+###   PACKAGES                                               ###
+#################################################################
+INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/3rdParty/dirstream/CMakePackage.txt)
+
+INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/basics/container/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/basics/writer/CMakePackage.txt)
+
+INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/KdTree/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/fem/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakePackage.txt)
+
+#################################################################
+###   OWN DEFINES 						###
+#################################################################
+FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h
+                         ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 
+
+SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES})
+SOURCE_GROUP(z_main FILES ${SPECIFIC_FILES})
+
+#################################################################
+###  PROJECT ERSTELLEN                                        ###
+#################################################################
+CREATE_CAB_PROJECT(${PROJECT_NAME} BINARY)
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp
index 0c0b9454745a3554ab32b7d81f6639749dd45545..e608f44c46ee511a29064836051c2755380e5f55 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp
@@ -1,542 +1,542 @@
-#include <basics/utilities/UbTiming.h>
-#include <basics/utilities/UbRandom.h>
-#include <basics/utilities/UbTuple.h>
-
-#include <basics/writer/WbWriterAvsASCII.h>
-#include <basics/writer/WbWriterAvsBinary.h>
-#include <basics/writer/WbWriterVtkXmlBinary.h>
-#include <basics/writer/WbWriterVtkXmlASCII.h>
-
-#include <basics/container/CbUniformMatrix3D.h>
-
-#include <numerics/geometry3d/GbTriFaceMesh3D.h>
-#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h>
-#include <numerics/geometry3d/GbHalfSpace3D.h>
-
-#include <numerics/geometry3d/KdTree/KdTree.h>
-#include <numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h>
-#include <numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h>
-#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h>
-#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h>
-
-#include <stack>
-#include <list>
-
-using namespace std;
-
-void createGrid(std::string meshfile, int maxNofPointsPerDir, Kd::SplitAlgorithm<float>& splitAlg, bool writeFiles = true, std::string outpath = "g:/temp");
-void recursiveGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type);
-void iterativeGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type);
-
-#include <3rdParty/dirstream/dirstream.h>
-#include <3rdParty/dirstream/filter_utils.h>  // enthält die Definiton der bool'schen Ops für Filter
-
-
-using namespace std;
-
-int main()
-{
-   try
-   {
-//       //////////////////////////////////////////////////////////////////////////
-//       //STL File auswaehlen
-//       //////////////////////////////////////////////////////////////////////////
-//       string pathname = "c:/temp";
-//       string stlPath = "c:/temp";
-//       dirstr::dirstream str(stlPath.c_str(), dirstr::op(dirstr::pattern_f("*.stl")) 
-//                            || dirstr::op(dirstr::pattern_f("*.ply"))  || dirstr::op(dirstr::pattern_f("*.inp"))
-//                            || dirstr::op(dirstr::pattern_f("*.mesh")));
-// 
-// //      UbLog::setReportingLevel(logDEBUG5);
-//       UbLog::setReportingLevel(logINFO);
-// 
-//       vector<string> filenames;
-//       for(string entry; str >> entry;)
-//       {
-//          GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(entry,"mesh");
-// 
-//          string fn = UbSystem::getFilenameFromString(entry);
-//          mesh->writeMeshPly(pathname+"/"+fn+".ply");
-// 
-//          delete mesh;
-//       }
-// 
-//       exit(0);
-
-      //createGrid("c:/temp/clumps.stl", 200, Kd::SAHSplit<float>() , true, "g:/temp");
-      //createGrid("c:/temp/50spheres.inp", 200, Kd::SAHSplit<float>() , true, "g:/temp");
-      //createGrid("c:/temp/Sphere5040.inp", 200, Kd::SAHSplit<float>() , true, "g:/temp");
-      //createGrid("c:/temp/cooling_2.inp", 400, Kd::SAHSplit<float>() , true, "g:/temp");
-      //createGrid("c:/temp/NDR-Konzertsaal.inp", 100, Kd::SAHSplit<float>() , true, "g:/temp");
-      
-      //createGrid("c:/temp/Campus-Details-W3.inp", 200, Kd::SAHSplit<float>() , true, "g:/temp");
-      //createGrid("c:/temp/Boein707.mesh", 100, Kd::SAHSplit<float>() , true, "g:/temp");
-      
-      //createGrid("c:/temp/dolphin.mesh", 400, Kd::SAHSplit<float>() , true, "g:/temp");
-      //createGrid("c:/temp/box.ply", 10, Kd::SAHSplit<float>() , true, "g:/temp");
-      //createGrid("c:/temp/bodyRight.stl", 200, Kd::SAHSplit<float>() , true, "g:/temp");
-      //createGrid("c:/temp/flamingo.mesh", 200, Kd::SAHSplit<float>() , true, "g:/temp");
-      
-      //createGrid("c:/temp/torus.inp", 256, Kd::SAHSplit<float>() , true, "g:/temp");
-      createGrid("c:/temp/xzx_dragon.stl", 512, Kd::SAHSplit<float>() , true, "g:/temp");
-//       createGrid("c:/temp/bunny_ascii.ply", 256, Kd::SAHSplit<float>() , true, "g:/temp");
-//       createGrid("c:/temp/dragon_ascii.ply", 256, Kd::SAHSplit<float>() , true, "g:/temp");
-//       createGrid("c:/temp/budda_ascii.ply", 256, Kd::SAHSplit<float>() , true, "g:/temp");
-      //createGridWithLines("c:/temp/box.ply", 10, Kd::SAHSplit<float>() , true, "g:/temp");
-      
-//       createGrid("c:/temp/beatle.mesh",200, Kd::SAHSplit<float>(), true, "g:/temp");
-//       createGrid("c:/temp/atrium-30000tri.inp",200, Kd::SAHSplit<float>(), true, "g:/temp");
-//       createGrid("c:/temp/Buero.inp",200, Kd::SAHSplit<float>(), true, "g:/temp");
-//       createGrid("c:/temp/office_space.inp",200, Kd::SAHSplit<float>(), true, "g:/temp");
-
-      //createGrid("d:/meshes/50spheres.inp",200, Kd::SAHSplit<float>(), true, "d:/temp");
-
-      //createGrid("c:/temp/torus.inp",200, Kd::SAHSplit<float>(), true, "g:/temp");
-      //createGrid("c:/temp/bodyRight.stl", 200, Kd::SAHSplit<float>() , true, "g:/temp");
-
-      //createGrid("c:/temp/jetta.stl", 200, GbTriFaceMesh3D::KDTREE_SPATIALSPLIT , true, "g:/temp");
-      //createGrid("c:/temp/jetta.stl", 200, Kd::SAHSplit<float>(), true, "g:/temp");
-      //createGrid("c:/temp/VW_body.ply", 200, Kd::SAHSplit<float>() , true, "g:/temp");
-      //createGrid("c:/temp/kugel.stl", 50, Kd::SAHSplit<float>() , true, "g:/temp");
-      //createGrid("c:/temp/ship-2.mesh", 100, Kd::SAHSplit<float>() , true, "g:/temp/schiff2");                                                   
-   }
-   catch(const std::exception& e)
-   {
-      UBLOG2(  logERROR, std::cerr, "Caught exception:");
-      UBLOG2(  logERROR, std::cerr, "Type: " << typeid(e).name() );
-      UBLOG2ML(logERROR, std::cerr, "What: " << e.what() );
-   }
-   catch(...)
-   {
-      UBLOG2(logERROR, std::cerr, "unknown exception occurs in "<< UB_FUNCTION)
-   }
-}
-
-namespace Flag
-{
-   const short UNDEF = 2;
-   const short SOLID = 1;
-   const short FLUID = 0;
-}
-
-//////////////////////////////////////////////////////////////////////
-void createGrid(std::string meshfile, int maxNofPointsPerDir, Kd::SplitAlgorithm<float>& splitAlg, bool writeFiles, std::string outpath)
-{
-   UbLog::setReportingLevel(logDEBUG5);
-   std::string filename = UbSystem::getFilenameFromString(meshfile);
-
-   std::list< UbTuple<string, double> > timerVals;
-   UbTimer timer;
-   timer.start();
-   GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(meshfile,"mesh",GbTriFaceMesh3D::KDTREE_SAHPLIT);
-   timerVals.push_back( UbTuple<string, double>("mesh", timer.stop() ) );
-   UBLOG( logINFO, "read mesh in "<<val<2>(timerVals.back())<<"s" );
-   
-   timer.start();
-   Kd::Tree<float> kdTree( *mesh, splitAlg  );
-   timerVals.push_back( UbTuple<string, double>("kdTree", timer.stop() ) );
-   UBLOG( logINFO, "build tree in "<<val<2>(timerVals.back())<<"s" );
-
-   UBLOG(logINFO, "############################################################");
-   UBLOG(logINFO, "nodes of TriFaceMesh....... "<<mesh->getNodes()->size()      );
-   UBLOG(logINFO, "triFaces of TriFaceMesh.... "<<mesh->getTriangles()->size()  );
-   UBLOG(logINFO, "triFace copies in KdTree... "<<kdTree.getNumOfTriFaces()     );
-   UBLOG(logINFO, "nodes of kdNodes of KdTree. "<<kdTree.getNumOfNodes()        );
-   UBLOG(logINFO, "");
-
-   //////////////////////////////////////////////////////////////////////////
-   // Ausgangs 3-D_Feld erstellen
-   //////////////////////////////////////////////////////////////////////////
-   const float percentOverLap = 0.05f; //=5%
-   const float maxLength = (1.0f+percentOverLap)*(float)UbMath::max( mesh->getLengthX1(), mesh->getLengthX2(), mesh->getLengthX3() );
-   const float dx1 = maxLength/(maxNofPointsPerDir-1);
-   const float dx2 = dx1;
-   const float dx3 = dx1;
-
-   const int nx1 = 1 + int( std::ceil(mesh->getLengthX1()*(1.0f+percentOverLap)/dx1)+0.5 );
-   const int nx2 = 1 + int( std::ceil(mesh->getLengthX2()*(1.0f+percentOverLap)/dx2)+0.5 );
-   const int nx3 = 1 + int( std::ceil(mesh->getLengthX3()*(1.0f+percentOverLap)/dx3)+0.5 );
-
-   CbUniformMatrix3D<short> solids(nx1,nx2,nx3,Flag::UNDEF);
-
-   //////////////////////////////////////////////////////////////////////////
-   // Knoten typisieren
-   //////////////////////////////////////////////////////////////////////////
-   const float orgx1 = (float)( -0.5*percentOverLap*mesh->getLengthX1()+mesh->getX1Minimum() );
-   const float orgx2 = (float)( -0.5*percentOverLap*mesh->getLengthX2()+mesh->getX2Minimum() );
-   const float orgx3 = (float)( -0.5*percentOverLap*mesh->getLengthX3()+mesh->getX3Minimum() );
-
-   std::vector<GbTriFaceMesh3D::TriFace>& triFaces = *mesh->getTriangles();
-   std::vector<GbTriFaceMesh3D::Vertex>&  vertices = *mesh->getNodes();
-
-   float x1center = float( mesh->getX1Centroid() );
-   float x2center = float( mesh->getX2Centroid() );
-   float x3center = float( mesh->getX3Centroid() );
-
-   UBLOG( logINFO, "performing point-in-object(PIO)-tests");
-   long  counter1=0, counter2 = 0;
-   float x1w, x2w, x3w;
-   int   x1Min, x2Min, x3Min, x1Max, x2Max, x3Max;
-   float einflussBereichKnoten_sq = dx1*dx1+dx2*dx2+dx3*dx3;
-
-   timer.start();
-   for(size_t t=0; t<triFaces.size(); t++)   
-   {
-      GbTriFaceMesh3D::TriFace& triangle = triFaces[t];
-      GbTriFaceMesh3D::Vertex& v1 = vertices[triangle.v1];
-      GbTriFaceMesh3D::Vertex& v2 = vertices[triangle.v2];
-      GbTriFaceMesh3D::Vertex& v3 = vertices[triangle.v3];
-
-      //////////////////////////////////////////////////////////////////////////
-      // AABB riangle
-      //////////////////////////////////////////////////////////////////////////
-      x1Min = /*UbMath::integerRounding*/( std::floor( ( UbMath::min( v1.x, v2.x, v3.x ) - orgx1) / dx1 ) );
-      x2Min = /*UbMath::integerRounding*/( std::floor( ( UbMath::min( v1.y, v2.y, v3.y ) - orgx2) / dx2 ) );
-      x3Min = /*UbMath::integerRounding*/( std::floor( ( UbMath::min( v1.z, v2.z, v3.z ) - orgx3) / dx3 ) );
-
-      x1Max = /*UbMath::integerRounding*/( std::ceil(  ( UbMath::max( v1.x, v2.x, v3.x ) - orgx1) / dx1 ) );
-      x2Max = /*UbMath::integerRounding*/( std::ceil(  ( UbMath::max( v1.y, v2.y, v3.y ) - orgx2) / dx2 ) );
-      x3Max = /*UbMath::integerRounding*/( std::ceil(  ( UbMath::max( v1.z, v2.z, v3.z ) - orgx3) / dx3 ) );
-
-      GbHalfSpace3D halfSpace(  v1.x, v1.y, v1.z, v2.x, v2.y, v2.z, v3.x, v3.y, v3.z );
-
-      for(int x3=x3Min; x3<=x3Max; x3++)
-      {
-         for(int x2=x2Min; x2<=x2Max; x2++)
-         {
-            for(int x1=x1Min; x1<=x1Max; x1++)
-            {
-               counter1++;
-               
-               short& solidVal = solids(x1,x2,x3);
-
-               if( solidVal != Flag::UNDEF )  //doppeltes Testen vermeiden
-               {
-                  continue;
-               }
- 
-               counter2++;
-               
-               //Weltkoords
-               x1w = orgx1+x1*dx1;
-               x2w = orgx2+x2*dx2;
-               x3w = orgx3+x3*dx3;
-
-               float dist = (float)halfSpace.getDistance( x1w, x2w, x3w );
-               if( UbMath::greater( dist, 0.0f) )
-               {
-                  continue;
-               }
-               if( UbMath::greater(dist*dist, einflussBereichKnoten_sq))
-               {
-                  continue;
-               }
-               
-               //eigentlicher PIO-Test
-               bool testFailed = true;
-               for(int i=0; i<100; i++ )
-               {
-                  Kd::Ray<float> ray(  x1w, x2w, x3w  //, 1, 0 ,0 );
-                                     , ( x1w < x1center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) )
-                                     , ( x2w < x2center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) )
-                                     , ( x3w < x3center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) );
-
-                  int iSec = kdTree.intersectRay( ray, Kd::CountRayIntersectionHandler<float>() );
-                  
-                  if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen
-                  {
-                     if(iSec == Kd::Intersection::ON_BOUNDARY )
-                     {
-                        solidVal = Flag::SOLID;
-                     }
-                     else
-                     {
-                        solidVal = (iSec&1);  //ungerade anzahl an schnitten --> drinnen
-                     }
-                     testFailed = false;
-                     break;
-                  }
-                  else
-                  {
-                     UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if  - an edge was hit ");
-                  }
-               }
-               if( testFailed ) throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
-             }
-         }
-      }
-   }
-   timerVals.push_back( UbTuple<string, double>("PiO-Test", timer.stop() ) );
-   UBLOG( logINFO,counter2 <<" point-in-object(PIO)-tests done in "<<val<2>(timerVals.back())<<"s" );
-   UBLOG( logINFO,counter1-counter2 <<" point-in-object(PIO)-tests uebersprungen" );
-
-   //////////////////////////////////////////////////////////////////////////
-   // FLOOD FILL
-   //////////////////////////////////////////////////////////////////////////
-
-   if( false) //using just one seed point
-   {
-      //FUELL
-      bool foundSeedPoint         = false;
-      int  seedPointSearchCounter = 0;
-      int  seedX1 = Ub::inf;
-      int  seedX2 = Ub::inf;
-      int  seedX3 = Ub::inf;
-
-      timer.start();
-      for(size_t t=0; t<triFaces.size(); t++)   
-      {
-          GbTriFaceMesh3D::TriFace& triangle = triFaces[t];
-          
-          float& nx = triangle.nx;
-          float& ny = triangle.ny;
-          float& nz = triangle.nz;
-
-          float cx1 = triangle.getX1Centroid(vertices);
-          float cx2 = triangle.getX2Centroid(vertices);
-          float cx3 = triangle.getX3Centroid(vertices);
-
-          for(int k=0; k<5; k++) 
-          {
-             seedPointSearchCounter++;
-
-             cx1 -= nx * dx1;
-             cx2 -= ny * dx2;
-             cx3 -= nz * dx3;
-
-             int ix1 = UbMath::integerRounding( (cx1-orgx1)/dx1 );
-             int ix2 = UbMath::integerRounding( (cx2-orgx2)/dx2 );
-             int ix3 = UbMath::integerRounding( (cx3-orgx3)/dx3 );
-
-             if(   solids.indicesInRange(ix1,ix2,ix3)
-                && solids(ix1, ix2, ix3 ) == Flag::UNDEF )
-             {
-                x1w = orgx1+ix1*dx1;
-                x2w = orgx2+ix2*dx2;
-                x3w = orgx3+ix3*dx3;
-
-                Kd::Ray<float> ray(  x1w, x2w, x3w  //, 1, 0 ,0 );
-                                  , ( x1w < x1center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) )
-                                  , ( x2w < x2center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) )
-                                  , ( x3w < x3center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) );
-
-                int iSec = kdTree.intersectRay( ray, Kd::CountRayIntersectionHandler<float>() );
-
-                if( iSec>0 && (iSec&1) )
-                {
-                   seedX1 = ix1;
-                   seedX2 = ix2;
-                   seedX3 = ix3;
-                   foundSeedPoint = true;
-                   break;
-                }
-              }
-          }
-          if(foundSeedPoint) break;
-      }
-      if(!foundSeedPoint)
-         throw UbException(UB_EXARGS,"fuck no seed point found");
-      timerVals.push_back( UbTuple<string, double>("Seed found in", timer.stop() ) );
-      UBLOG( logINFO,"found seed Point in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" );
-
-      cout<<nx1<<","<<nx2<<","<<nx3<<endl;
-      bool recursiveFloodFill = ( nx1*nx2*nx3 < 100*100*30 );
-      if(recursiveFloodFill)
-      {
-         timer.start();
-         recursiveGridFill(solids, seedX1, seedX2, seedX3, Flag::SOLID);
-         timerVals.push_back( UbTuple<string, double>("flood fill (r)", timer.stop() ) );
-         UBLOG( logINFO,"recursive flood fill in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" );
-
-         CbUniformMatrix3D<short> solidsCpy(solids);
-         timer.start();
-         iterativeGridFill(solidsCpy, seedX1, seedX2, seedX3, Flag::SOLID);
-         timerVals.push_back( UbTuple<string, double>("flood fill (i)", timer.stop() ) );
-         UBLOG( logINFO,"iterative flood fill in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" );
-      }
-      else
-      {
-         timer.start();
-         iterativeGridFill(solids, seedX1, seedX2, seedX3, Flag::SOLID);
-         timerVals.push_back( UbTuple<string, double>("flood fill (r)", timer.stop() ) );
-         UBLOG( logINFO,"recursive flood fill in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" );
-      }
-      
-      UBLOG(logINFO, "############################################################");
-
-   }
-   else //verifying complete arry
-   {
-      bool recursiveFloodFill = ( nx1*nx2*nx3 < 100*100*30 );
-      int solidCounter  = 0;
-
-      timer.start();
-      for(int x3=0; x3<solids.getNX3(); x3++)
-         for(int x2=0; x2<solids.getNX2(); x2++)
-            for(int x1=0; x1<solids.getNX1(); x1++)
-            {
-               if( solids(x1  ,x2  ,x3 ) == Flag::UNDEF ) 
-               {
-                  x1w = orgx1+x1*dx1;
-                  x2w = orgx2+x2*dx2;
-                  x3w = orgx3+x3*dx3;
-
-                  int iSec = -1;
-                  do{
-                     Kd::Ray<float> ray(  x1w, x2w, x3w  //, 1, 0 ,0 );
-                                       , ( x1w < x1center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) )
-                                       , ( x2w < x2center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) )
-                                       , ( x3w < x3center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) );
-
-                     iSec = kdTree.intersectRay( ray, Kd::CountRayIntersectionHandler<float>() );
-                  }while(iSec<0);
-
-                  if( iSec&1 )
-                  {
-                     if(recursiveFloodFill) recursiveGridFill(solids,x1,x2,x3,Flag::SOLID);
-                     else                   iterativeGridFill(solids,x1,x2,x3,Flag::SOLID);
-                  }
-                  else
-                  {
-                     if(recursiveFloodFill) recursiveGridFill(solids,x1,x2,x3,Flag::FLUID);
-                     else                   iterativeGridFill(solids,x1,x2,x3,Flag::FLUID);
-                  }
-               }
-            }
-      if(recursiveFloodFill) timerVals.push_back( UbTuple<string, double>("flood fill (r)", timer.stop() ) );
-      else                   timerVals.push_back( UbTuple<string, double>("flood fill (i)", timer.stop() ) );
-      UBLOG( logINFO,"recursive flood fill in "<<val<2>(timerVals.back())<<"s " );
-   }
-
-   list< UbTuple< string, double > >::iterator iter;
-   for(iter = timerVals.begin(); iter!=timerVals.end(); ++iter)
-   {
-      UBLOG( logINFO, setw(16) << val<1>(*iter) << " in " << setw(8) << setprecision(8) << val<2>(*iter) << "s" );
-   }
-
-   int solidCounter  = 0;
-   for(int x3=0; x3<solids.getNX3(); x3++)
-      for(int x2=0; x2<solids.getNX2(); x2++)
-         for(int x1=0; x1<solids.getNX1(); x1++)
-         {
-            if( solids(x1  ,x2  ,x3 ) == Flag::SOLID ) 
-            {
-               solidCounter++;
-            }
-         }
-
-   UBLOG( logINFO, "SOLIDS = " <<solidCounter);
-   UBLOG( logINFO, "SOLIDS = " <<solidCounter);
-   UBLOG( logINFO, "SOLIDS = " <<solidCounter);
-   UBLOG( logINFO, "SOLIDS = " <<solidCounter);
-
-   /* ======================================================================================= */
-   if(writeFiles) 
-   {
-      UBLOG( logINFO, "writeFiles - start");
-      string subfiledir = outpath+"/"+filename+"_solid_node_files";
-      UbSystem::makeDirectory( subfiledir );
-
-      std::vector<UbTupleFloat3 > nodes;
-      std::vector<std::string > datanames(1,"data");
-      datanames[0] = "solid";
-
-      std::vector< std::string > outFilenames;
-
-      std::vector<std::vector<double > > nodedata( datanames.size() );
-
-      for(int x3=0; x3<solids.getNX3(); x3++)
-         for(int x2=0; x2<solids.getNX2(); x2++)
-            for(int x1=0; x1<solids.getNX1(); x1++)
-            {
-               if( solids(x1  ,x2  ,x3 ) == Flag::SOLID ) 
-               {
-                  nodes.push_back( makeUbTuple(  orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3 ) );
-                  nodedata[0].push_back( solids(x1  ,x2  ,x3 ) );
-               }          
-
-               if(    nodes.size() > 2000000  
-                   || ( x1==(solids.getNX1()-1) && x2==(solids.getNX2()-1) && x3==(solids.getNX3()-1) ) ) 
-               {
-                  outFilenames.push_back( WbWriterVtkXmlBinary::getInstance()->writeNodesWithNodeData(subfiledir+"/"+filename+"_solid_nodes_"+"_part"+UbSystem::toString(outFilenames.size()+1),nodes,datanames,nodedata) );
-                  nodes.clear();
-                  nodedata.clear();
-                  nodedata.resize( datanames.size() );
-               }
-            }
-   
-      WbWriterVtkXmlBinary::getInstance()->writeCollection(outpath+"/"+filename+"_solids_nodes",outFilenames,0,false);
-      
-      
-      mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterVtkXmlBinary::getInstance());
-      kdTree.writeTree(outpath+"/"+filename+"_kdTree",WbWriterVtkXmlBinary::getInstance());
-
-      UBLOG( logINFO, "writeFiles - end")
-   }
-
-   delete mesh;
-}
-
-namespace Dirs
-{
-   const int X1[] = { 1, -1,  0,  0,  0,  0,  1, -1,  1, -1,  1, -1,  1, -1,  0,  0,  0,  0,  0 };
-   const int X2[] = { 0,  0,  1, -1,  0,  0,  1, -1, -1,  1,  0,  0,  0,  0,  1, -1,  1, -1,  0 };
-   const int X3[] = { 0,  0,  0,  0,  1, -1,  0,  0,  0,  0,  1, -1, -1,  1,  1, -1, -1,  1,  0 };
-
-   const int START = 0;
-   const int END6  = 5;
-   const int END18 = 17;
-}
-/*==================================================================*/
-bool floodFillCheck(CbUniformMatrix3D<short>& grid, const short& x, const short& y, const short& z)
-{
-   return grid.indicesInRange( x, y, z ) && grid(x,y,z)==Flag::UNDEF;
-}
-int g_counter = 0;
-void recursiveGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type)
-{
-   // Algorithmus zum Füllen eines Polyeders, ausgehend vom Saatpunkt xs,ys,zs
-
-   //Saatknoten einfärben
-   short& val = grid(xs,ys,zs);
-   if( val==Flag::UNDEF )
-   {
-      val = type;
-   }
-   if(   floodFillCheck( grid, xs+1, ys  , zs   ) ) recursiveGridFill( grid, xs+1, ys  , zs  , type );
-   if(   floodFillCheck( grid, xs  , ys+1, zs   ) ) recursiveGridFill( grid, xs  , ys+1, zs  , type );
-   if(   floodFillCheck( grid, xs  , ys  , zs+1 ) ) recursiveGridFill( grid, xs  , ys  , zs+1, type );
-   if(   floodFillCheck( grid, xs-1, ys  , zs   ) ) recursiveGridFill( grid, xs-1, ys  , zs  , type );
-   if(   floodFillCheck( grid, xs  , ys-1, zs   ) ) recursiveGridFill( grid, xs  , ys-1, zs  , type );
-   if(   floodFillCheck( grid, xs  , ys  , zs-1 ) ) recursiveGridFill( grid, xs  , ys  , zs-1, type );
-}
-/*==================================================================*/
-void iterativeGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type)
-{
-   std::stack< UbTupleInt3 > stck;
-   stck.push( UbTupleInt3(xs,ys,zs) );
-
-   int x,y,z;
-
-   while( !stck.empty() )  
-   {
-      x = val<1>( stck.top() );
-      y = val<2>( stck.top() );
-      z = val<3>( stck.top() );
-      stck.pop();
-
-      short& flagType = grid( x, y, z );
-
-      if( flagType == Flag::UNDEF ) 
-      {     
-         flagType = type;
-
-         if ( grid.indicesInRange( x+1, y  , z   ) ) stck.push( UbTupleInt3( x+1, y  , z   ) );
-         if ( grid.indicesInRange( x  , y+1, z   ) ) stck.push( UbTupleInt3( x  , y+1, z   ) );
-         if ( grid.indicesInRange( x  , y  , z+1 ) ) stck.push( UbTupleInt3( x  , y  , z+1 ) );
-         if ( grid.indicesInRange( x-1, y  , z   ) ) stck.push( UbTupleInt3( x-1, y  , z   ) );
-         if ( grid.indicesInRange( x  , y-1, z   ) ) stck.push( UbTupleInt3( x  , y-1, z   ) );
-         if ( grid.indicesInRange( x  , y  , z-1 ) ) stck.push( UbTupleInt3( x  , y  , z-1 ) );
-      }
-   }
-}
+#include <basics/utilities/UbTiming.h>
+#include <basics/utilities/UbRandom.h>
+#include <basics/utilities/UbTuple.h>
+
+#include <basics/writer/WbWriterAvsASCII.h>
+#include <basics/writer/WbWriterAvsBinary.h>
+#include <basics/writer/WbWriterVtkXmlBinary.h>
+#include <basics/writer/WbWriterVtkXmlASCII.h>
+
+#include <basics/container/CbUniformMatrix3D.h>
+
+#include <numerics/geometry3d/GbTriFaceMesh3D.h>
+#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h>
+#include <numerics/geometry3d/GbHalfSpace3D.h>
+
+#include <numerics/geometry3d/KdTree/KdTree.h>
+#include <numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h>
+#include <numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h>
+#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h>
+#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h>
+
+#include <stack>
+#include <list>
+
+using namespace std;
+
+void createGrid(std::string meshfile, int maxNofPointsPerDir, Kd::SplitAlgorithm<float>& splitAlg, bool writeFiles = true, std::string outpath = "g:/temp");
+void recursiveGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type);
+void iterativeGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type);
+
+#include <3rdParty/dirstream/dirstream.h>
+#include <3rdParty/dirstream/filter_utils.h>  // enthält die Definiton der bool'schen Ops für Filter
+
+
+using namespace std;
+
+int main()
+{
+   try
+   {
+//       //////////////////////////////////////////////////////////////////////////
+//       //STL File auswaehlen
+//       //////////////////////////////////////////////////////////////////////////
+//       string pathname = "c:/temp";
+//       string stlPath = "c:/temp";
+//       dirstr::dirstream str(stlPath.c_str(), dirstr::op(dirstr::pattern_f("*.stl")) 
+//                            || dirstr::op(dirstr::pattern_f("*.ply"))  || dirstr::op(dirstr::pattern_f("*.inp"))
+//                            || dirstr::op(dirstr::pattern_f("*.mesh")));
+// 
+// //      UbLog::setReportingLevel(logDEBUG5);
+//       UbLog::setReportingLevel(logINFO);
+// 
+//       vector<string> filenames;
+//       for(string entry; str >> entry;)
+//       {
+//          GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(entry,"mesh");
+// 
+//          string fn = UbSystem::getFilenameFromString(entry);
+//          mesh->writeMeshPly(pathname+"/"+fn+".ply");
+// 
+//          delete mesh;
+//       }
+// 
+//       exit(0);
+
+      //createGrid("c:/temp/clumps.stl", 200, Kd::SAHSplit<float>() , true, "g:/temp");
+      //createGrid("c:/temp/50spheres.inp", 200, Kd::SAHSplit<float>() , true, "g:/temp");
+      //createGrid("c:/temp/Sphere5040.inp", 200, Kd::SAHSplit<float>() , true, "g:/temp");
+      //createGrid("c:/temp/cooling_2.inp", 400, Kd::SAHSplit<float>() , true, "g:/temp");
+      //createGrid("c:/temp/NDR-Konzertsaal.inp", 100, Kd::SAHSplit<float>() , true, "g:/temp");
+      
+      //createGrid("c:/temp/Campus-Details-W3.inp", 200, Kd::SAHSplit<float>() , true, "g:/temp");
+      //createGrid("c:/temp/Boein707.mesh", 100, Kd::SAHSplit<float>() , true, "g:/temp");
+      
+      //createGrid("c:/temp/dolphin.mesh", 400, Kd::SAHSplit<float>() , true, "g:/temp");
+      //createGrid("c:/temp/box.ply", 10, Kd::SAHSplit<float>() , true, "g:/temp");
+      //createGrid("c:/temp/bodyRight.stl", 200, Kd::SAHSplit<float>() , true, "g:/temp");
+      //createGrid("c:/temp/flamingo.mesh", 200, Kd::SAHSplit<float>() , true, "g:/temp");
+      
+      //createGrid("c:/temp/torus.inp", 256, Kd::SAHSplit<float>() , true, "g:/temp");
+      createGrid("c:/temp/xzx_dragon.stl", 512, Kd::SAHSplit<float>() , true, "g:/temp");
+//       createGrid("c:/temp/bunny_ascii.ply", 256, Kd::SAHSplit<float>() , true, "g:/temp");
+//       createGrid("c:/temp/dragon_ascii.ply", 256, Kd::SAHSplit<float>() , true, "g:/temp");
+//       createGrid("c:/temp/budda_ascii.ply", 256, Kd::SAHSplit<float>() , true, "g:/temp");
+      //createGridWithLines("c:/temp/box.ply", 10, Kd::SAHSplit<float>() , true, "g:/temp");
+      
+//       createGrid("c:/temp/beatle.mesh",200, Kd::SAHSplit<float>(), true, "g:/temp");
+//       createGrid("c:/temp/atrium-30000tri.inp",200, Kd::SAHSplit<float>(), true, "g:/temp");
+//       createGrid("c:/temp/Buero.inp",200, Kd::SAHSplit<float>(), true, "g:/temp");
+//       createGrid("c:/temp/office_space.inp",200, Kd::SAHSplit<float>(), true, "g:/temp");
+
+      //createGrid("d:/meshes/50spheres.inp",200, Kd::SAHSplit<float>(), true, "d:/temp");
+
+      //createGrid("c:/temp/torus.inp",200, Kd::SAHSplit<float>(), true, "g:/temp");
+      //createGrid("c:/temp/bodyRight.stl", 200, Kd::SAHSplit<float>() , true, "g:/temp");
+
+      //createGrid("c:/temp/jetta.stl", 200, GbTriFaceMesh3D::KDTREE_SPATIALSPLIT , true, "g:/temp");
+      //createGrid("c:/temp/jetta.stl", 200, Kd::SAHSplit<float>(), true, "g:/temp");
+      //createGrid("c:/temp/VW_body.ply", 200, Kd::SAHSplit<float>() , true, "g:/temp");
+      //createGrid("c:/temp/kugel.stl", 50, Kd::SAHSplit<float>() , true, "g:/temp");
+      //createGrid("c:/temp/ship-2.mesh", 100, Kd::SAHSplit<float>() , true, "g:/temp/schiff2");                                                   
+   }
+   catch(const std::exception& e)
+   {
+      UBLOG2(  logERROR, std::cerr, "Caught exception:");
+      UBLOG2(  logERROR, std::cerr, "Type: " << typeid(e).name() );
+      UBLOG2ML(logERROR, std::cerr, "What: " << e.what() );
+   }
+   catch(...)
+   {
+      UBLOG2(logERROR, std::cerr, "unknown exception occurs in "<< UB_FUNCTION)
+   }
+}
+
+namespace Flag
+{
+   const short UNDEF = 2;
+   const short SOLID = 1;
+   const short FLUID = 0;
+}
+
+//////////////////////////////////////////////////////////////////////
+void createGrid(std::string meshfile, int maxNofPointsPerDir, Kd::SplitAlgorithm<float>& splitAlg, bool writeFiles, std::string outpath)
+{
+   UbLog::setReportingLevel(logDEBUG5);
+   std::string filename = UbSystem::getFilenameFromString(meshfile);
+
+   std::list< UbTuple<string, double> > timerVals;
+   UbTimer timer;
+   timer.start();
+   GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(meshfile,"mesh",GbTriFaceMesh3D::KDTREE_SAHPLIT);
+   timerVals.push_back( UbTuple<string, double>("mesh", timer.stop() ) );
+   UBLOG( logINFO, "read mesh in "<<val<2>(timerVals.back())<<"s" );
+   
+   timer.start();
+   Kd::Tree<float> kdTree( *mesh, splitAlg  );
+   timerVals.push_back( UbTuple<string, double>("kdTree", timer.stop() ) );
+   UBLOG( logINFO, "build tree in "<<val<2>(timerVals.back())<<"s" );
+
+   UBLOG(logINFO, "############################################################");
+   UBLOG(logINFO, "nodes of TriFaceMesh....... "<<mesh->getNodes()->size()      );
+   UBLOG(logINFO, "triFaces of TriFaceMesh.... "<<mesh->getTriangles()->size()  );
+   UBLOG(logINFO, "triFace copies in KdTree... "<<kdTree.getNumOfTriFaces()     );
+   UBLOG(logINFO, "nodes of kdNodes of KdTree. "<<kdTree.getNumOfNodes()        );
+   UBLOG(logINFO, "");
+
+   //////////////////////////////////////////////////////////////////////////
+   // Ausgangs 3-D_Feld erstellen
+   //////////////////////////////////////////////////////////////////////////
+   const float percentOverLap = 0.05f; //=5%
+   const float maxLength = (1.0f+percentOverLap)*(float)UbMath::max( mesh->getLengthX1(), mesh->getLengthX2(), mesh->getLengthX3() );
+   const float dx1 = maxLength/(maxNofPointsPerDir-1);
+   const float dx2 = dx1;
+   const float dx3 = dx1;
+
+   const int nx1 = 1 + int( std::ceil(mesh->getLengthX1()*(1.0f+percentOverLap)/dx1)+0.5 );
+   const int nx2 = 1 + int( std::ceil(mesh->getLengthX2()*(1.0f+percentOverLap)/dx2)+0.5 );
+   const int nx3 = 1 + int( std::ceil(mesh->getLengthX3()*(1.0f+percentOverLap)/dx3)+0.5 );
+
+   CbUniformMatrix3D<short> solids(nx1,nx2,nx3,Flag::UNDEF);
+
+   //////////////////////////////////////////////////////////////////////////
+   // Knoten typisieren
+   //////////////////////////////////////////////////////////////////////////
+   const float orgx1 = (float)( -0.5*percentOverLap*mesh->getLengthX1()+mesh->getX1Minimum() );
+   const float orgx2 = (float)( -0.5*percentOverLap*mesh->getLengthX2()+mesh->getX2Minimum() );
+   const float orgx3 = (float)( -0.5*percentOverLap*mesh->getLengthX3()+mesh->getX3Minimum() );
+
+   std::vector<GbTriFaceMesh3D::TriFace>& triFaces = *mesh->getTriangles();
+   std::vector<GbTriFaceMesh3D::Vertex>&  vertices = *mesh->getNodes();
+
+   float x1center = float( mesh->getX1Centroid() );
+   float x2center = float( mesh->getX2Centroid() );
+   float x3center = float( mesh->getX3Centroid() );
+
+   UBLOG( logINFO, "performing point-in-object(PIO)-tests");
+   long  counter1=0, counter2 = 0;
+   float x1w, x2w, x3w;
+   int   x1Min, x2Min, x3Min, x1Max, x2Max, x3Max;
+   float einflussBereichKnoten_sq = dx1*dx1+dx2*dx2+dx3*dx3;
+
+   timer.start();
+   for(size_t t=0; t<triFaces.size(); t++)   
+   {
+      GbTriFaceMesh3D::TriFace& triangle = triFaces[t];
+      GbTriFaceMesh3D::Vertex& v1 = vertices[triangle.v1];
+      GbTriFaceMesh3D::Vertex& v2 = vertices[triangle.v2];
+      GbTriFaceMesh3D::Vertex& v3 = vertices[triangle.v3];
+
+      //////////////////////////////////////////////////////////////////////////
+      // AABB riangle
+      //////////////////////////////////////////////////////////////////////////
+      x1Min = /*UbMath::integerRounding*/( std::floor( ( UbMath::min( v1.x, v2.x, v3.x ) - orgx1) / dx1 ) );
+      x2Min = /*UbMath::integerRounding*/( std::floor( ( UbMath::min( v1.y, v2.y, v3.y ) - orgx2) / dx2 ) );
+      x3Min = /*UbMath::integerRounding*/( std::floor( ( UbMath::min( v1.z, v2.z, v3.z ) - orgx3) / dx3 ) );
+
+      x1Max = /*UbMath::integerRounding*/( std::ceil(  ( UbMath::max( v1.x, v2.x, v3.x ) - orgx1) / dx1 ) );
+      x2Max = /*UbMath::integerRounding*/( std::ceil(  ( UbMath::max( v1.y, v2.y, v3.y ) - orgx2) / dx2 ) );
+      x3Max = /*UbMath::integerRounding*/( std::ceil(  ( UbMath::max( v1.z, v2.z, v3.z ) - orgx3) / dx3 ) );
+
+      GbHalfSpace3D halfSpace(  v1.x, v1.y, v1.z, v2.x, v2.y, v2.z, v3.x, v3.y, v3.z );
+
+      for(int x3=x3Min; x3<=x3Max; x3++)
+      {
+         for(int x2=x2Min; x2<=x2Max; x2++)
+         {
+            for(int x1=x1Min; x1<=x1Max; x1++)
+            {
+               counter1++;
+               
+               short& solidVal = solids(x1,x2,x3);
+
+               if( solidVal != Flag::UNDEF )  //doppeltes Testen vermeiden
+               {
+                  continue;
+               }
+ 
+               counter2++;
+               
+               //Weltkoords
+               x1w = orgx1+x1*dx1;
+               x2w = orgx2+x2*dx2;
+               x3w = orgx3+x3*dx3;
+
+               float dist = (float)halfSpace.getDistance( x1w, x2w, x3w );
+               if( UbMath::greater( dist, 0.0f) )
+               {
+                  continue;
+               }
+               if( UbMath::greater(dist*dist, einflussBereichKnoten_sq))
+               {
+                  continue;
+               }
+               
+               //eigentlicher PIO-Test
+               bool testFailed = true;
+               for(int i=0; i<100; i++ )
+               {
+                  Kd::Ray<float> ray(  x1w, x2w, x3w  //, 1, 0 ,0 );
+                                     , ( x1w < x1center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) )
+                                     , ( x2w < x2center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) )
+                                     , ( x3w < x3center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) );
+
+                  int iSec = kdTree.intersectRay( ray, Kd::CountRayIntersectionHandler<float>() );
+                  
+                  if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen
+                  {
+                     if(iSec == Kd::Intersection::ON_BOUNDARY )
+                     {
+                        solidVal = Flag::SOLID;
+                     }
+                     else
+                     {
+                        solidVal = (iSec&1);  //ungerade anzahl an schnitten --> drinnen
+                     }
+                     testFailed = false;
+                     break;
+                  }
+                  else
+                  {
+                     UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if  - an edge was hit ");
+                  }
+               }
+               if( testFailed ) throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
+             }
+         }
+      }
+   }
+   timerVals.push_back( UbTuple<string, double>("PiO-Test", timer.stop() ) );
+   UBLOG( logINFO,counter2 <<" point-in-object(PIO)-tests done in "<<val<2>(timerVals.back())<<"s" );
+   UBLOG( logINFO,counter1-counter2 <<" point-in-object(PIO)-tests uebersprungen" );
+
+   //////////////////////////////////////////////////////////////////////////
+   // FLOOD FILL
+   //////////////////////////////////////////////////////////////////////////
+
+   if( false) //using just one seed point
+   {
+      //FUELL
+      bool foundSeedPoint         = false;
+      int  seedPointSearchCounter = 0;
+      int  seedX1 = Ub::inf;
+      int  seedX2 = Ub::inf;
+      int  seedX3 = Ub::inf;
+
+      timer.start();
+      for(size_t t=0; t<triFaces.size(); t++)   
+      {
+          GbTriFaceMesh3D::TriFace& triangle = triFaces[t];
+          
+          float& nx = triangle.nx;
+          float& ny = triangle.ny;
+          float& nz = triangle.nz;
+
+          float cx1 = triangle.getX1Centroid(vertices);
+          float cx2 = triangle.getX2Centroid(vertices);
+          float cx3 = triangle.getX3Centroid(vertices);
+
+          for(int k=0; k<5; k++) 
+          {
+             seedPointSearchCounter++;
+
+             cx1 -= nx * dx1;
+             cx2 -= ny * dx2;
+             cx3 -= nz * dx3;
+
+             int ix1 = UbMath::integerRounding( (cx1-orgx1)/dx1 );
+             int ix2 = UbMath::integerRounding( (cx2-orgx2)/dx2 );
+             int ix3 = UbMath::integerRounding( (cx3-orgx3)/dx3 );
+
+             if(   solids.indicesInRange(ix1,ix2,ix3)
+                && solids(ix1, ix2, ix3 ) == Flag::UNDEF )
+             {
+                x1w = orgx1+ix1*dx1;
+                x2w = orgx2+ix2*dx2;
+                x3w = orgx3+ix3*dx3;
+
+                Kd::Ray<float> ray(  x1w, x2w, x3w  //, 1, 0 ,0 );
+                                  , ( x1w < x1center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) )
+                                  , ( x2w < x2center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) )
+                                  , ( x3w < x3center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) );
+
+                int iSec = kdTree.intersectRay( ray, Kd::CountRayIntersectionHandler<float>() );
+
+                if( iSec>0 && (iSec&1) )
+                {
+                   seedX1 = ix1;
+                   seedX2 = ix2;
+                   seedX3 = ix3;
+                   foundSeedPoint = true;
+                   break;
+                }
+              }
+          }
+          if(foundSeedPoint) break;
+      }
+      if(!foundSeedPoint)
+         throw UbException(UB_EXARGS,"fuck no seed point found");
+      timerVals.push_back( UbTuple<string, double>("Seed found in", timer.stop() ) );
+      UBLOG( logINFO,"found seed Point in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" );
+
+      cout<<nx1<<","<<nx2<<","<<nx3<<endl;
+      bool recursiveFloodFill = ( nx1*nx2*nx3 < 100*100*30 );
+      if(recursiveFloodFill)
+      {
+         timer.start();
+         recursiveGridFill(solids, seedX1, seedX2, seedX3, Flag::SOLID);
+         timerVals.push_back( UbTuple<string, double>("flood fill (r)", timer.stop() ) );
+         UBLOG( logINFO,"recursive flood fill in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" );
+
+         CbUniformMatrix3D<short> solidsCpy(solids);
+         timer.start();
+         iterativeGridFill(solidsCpy, seedX1, seedX2, seedX3, Flag::SOLID);
+         timerVals.push_back( UbTuple<string, double>("flood fill (i)", timer.stop() ) );
+         UBLOG( logINFO,"iterative flood fill in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" );
+      }
+      else
+      {
+         timer.start();
+         iterativeGridFill(solids, seedX1, seedX2, seedX3, Flag::SOLID);
+         timerVals.push_back( UbTuple<string, double>("flood fill (r)", timer.stop() ) );
+         UBLOG( logINFO,"recursive flood fill in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" );
+      }
+      
+      UBLOG(logINFO, "############################################################");
+
+   }
+   else //verifying complete arry
+   {
+      bool recursiveFloodFill = ( nx1*nx2*nx3 < 100*100*30 );
+      int solidCounter  = 0;
+
+      timer.start();
+      for(int x3=0; x3<solids.getNX3(); x3++)
+         for(int x2=0; x2<solids.getNX2(); x2++)
+            for(int x1=0; x1<solids.getNX1(); x1++)
+            {
+               if( solids(x1  ,x2  ,x3 ) == Flag::UNDEF ) 
+               {
+                  x1w = orgx1+x1*dx1;
+                  x2w = orgx2+x2*dx2;
+                  x3w = orgx3+x3*dx3;
+
+                  int iSec = -1;
+                  do{
+                     Kd::Ray<float> ray(  x1w, x2w, x3w  //, 1, 0 ,0 );
+                                       , ( x1w < x1center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) )
+                                       , ( x2w < x2center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) )
+                                       , ( x3w < x3center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) );
+
+                     iSec = kdTree.intersectRay( ray, Kd::CountRayIntersectionHandler<float>() );
+                  }while(iSec<0);
+
+                  if( iSec&1 )
+                  {
+                     if(recursiveFloodFill) recursiveGridFill(solids,x1,x2,x3,Flag::SOLID);
+                     else                   iterativeGridFill(solids,x1,x2,x3,Flag::SOLID);
+                  }
+                  else
+                  {
+                     if(recursiveFloodFill) recursiveGridFill(solids,x1,x2,x3,Flag::FLUID);
+                     else                   iterativeGridFill(solids,x1,x2,x3,Flag::FLUID);
+                  }
+               }
+            }
+      if(recursiveFloodFill) timerVals.push_back( UbTuple<string, double>("flood fill (r)", timer.stop() ) );
+      else                   timerVals.push_back( UbTuple<string, double>("flood fill (i)", timer.stop() ) );
+      UBLOG( logINFO,"recursive flood fill in "<<val<2>(timerVals.back())<<"s " );
+   }
+
+   list< UbTuple< string, double > >::iterator iter;
+   for(iter = timerVals.begin(); iter!=timerVals.end(); ++iter)
+   {
+      UBLOG( logINFO, setw(16) << val<1>(*iter) << " in " << setw(8) << setprecision(8) << val<2>(*iter) << "s" );
+   }
+
+   int solidCounter  = 0;
+   for(int x3=0; x3<solids.getNX3(); x3++)
+      for(int x2=0; x2<solids.getNX2(); x2++)
+         for(int x1=0; x1<solids.getNX1(); x1++)
+         {
+            if( solids(x1  ,x2  ,x3 ) == Flag::SOLID ) 
+            {
+               solidCounter++;
+            }
+         }
+
+   UBLOG( logINFO, "SOLIDS = " <<solidCounter);
+   UBLOG( logINFO, "SOLIDS = " <<solidCounter);
+   UBLOG( logINFO, "SOLIDS = " <<solidCounter);
+   UBLOG( logINFO, "SOLIDS = " <<solidCounter);
+
+   /* ======================================================================================= */
+   if(writeFiles) 
+   {
+      UBLOG( logINFO, "writeFiles - start");
+      string subfiledir = outpath+"/"+filename+"_solid_node_files";
+      UbSystem::makeDirectory( subfiledir );
+
+      std::vector<UbTupleFloat3 > nodes;
+      std::vector<std::string > datanames(1,"data");
+      datanames[0] = "solid";
+
+      std::vector< std::string > outFilenames;
+
+      std::vector<std::vector<double > > nodedata( datanames.size() );
+
+      for(int x3=0; x3<solids.getNX3(); x3++)
+         for(int x2=0; x2<solids.getNX2(); x2++)
+            for(int x1=0; x1<solids.getNX1(); x1++)
+            {
+               if( solids(x1  ,x2  ,x3 ) == Flag::SOLID ) 
+               {
+                  nodes.push_back( makeUbTuple(  orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3 ) );
+                  nodedata[0].push_back( solids(x1  ,x2  ,x3 ) );
+               }          
+
+               if(    nodes.size() > 2000000  
+                   || ( x1==(solids.getNX1()-1) && x2==(solids.getNX2()-1) && x3==(solids.getNX3()-1) ) ) 
+               {
+                  outFilenames.push_back( WbWriterVtkXmlBinary::getInstance()->writeNodesWithNodeData(subfiledir+"/"+filename+"_solid_nodes_"+"_part"+UbSystem::toString(outFilenames.size()+1),nodes,datanames,nodedata) );
+                  nodes.clear();
+                  nodedata.clear();
+                  nodedata.resize( datanames.size() );
+               }
+            }
+   
+      WbWriterVtkXmlBinary::getInstance()->writeCollection(outpath+"/"+filename+"_solids_nodes",outFilenames,0,false);
+      
+      
+      mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterVtkXmlBinary::getInstance());
+      kdTree.writeTree(outpath+"/"+filename+"_kdTree",WbWriterVtkXmlBinary::getInstance());
+
+      UBLOG( logINFO, "writeFiles - end")
+   }
+
+   delete mesh;
+}
+
+namespace Dirs
+{
+   const int X1[] = { 1, -1,  0,  0,  0,  0,  1, -1,  1, -1,  1, -1,  1, -1,  0,  0,  0,  0,  0 };
+   const int X2[] = { 0,  0,  1, -1,  0,  0,  1, -1, -1,  1,  0,  0,  0,  0,  1, -1,  1, -1,  0 };
+   const int X3[] = { 0,  0,  0,  0,  1, -1,  0,  0,  0,  0,  1, -1, -1,  1,  1, -1, -1,  1,  0 };
+
+   const int START = 0;
+   const int END6  = 5;
+   const int END18 = 17;
+}
+/*==================================================================*/
+bool floodFillCheck(CbUniformMatrix3D<short>& grid, const short& x, const short& y, const short& z)
+{
+   return grid.indicesInRange( x, y, z ) && grid(x,y,z)==Flag::UNDEF;
+}
+int g_counter = 0;
+void recursiveGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type)
+{
+   // Algorithmus zum Füllen eines Polyeders, ausgehend vom Saatpunkt xs,ys,zs
+
+   //Saatknoten einfärben
+   short& val = grid(xs,ys,zs);
+   if( val==Flag::UNDEF )
+   {
+      val = type;
+   }
+   if(   floodFillCheck( grid, xs+1, ys  , zs   ) ) recursiveGridFill( grid, xs+1, ys  , zs  , type );
+   if(   floodFillCheck( grid, xs  , ys+1, zs   ) ) recursiveGridFill( grid, xs  , ys+1, zs  , type );
+   if(   floodFillCheck( grid, xs  , ys  , zs+1 ) ) recursiveGridFill( grid, xs  , ys  , zs+1, type );
+   if(   floodFillCheck( grid, xs-1, ys  , zs   ) ) recursiveGridFill( grid, xs-1, ys  , zs  , type );
+   if(   floodFillCheck( grid, xs  , ys-1, zs   ) ) recursiveGridFill( grid, xs  , ys-1, zs  , type );
+   if(   floodFillCheck( grid, xs  , ys  , zs-1 ) ) recursiveGridFill( grid, xs  , ys  , zs-1, type );
+}
+/*==================================================================*/
+void iterativeGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type)
+{
+   std::stack< UbTupleInt3 > stck;
+   stck.push( UbTupleInt3(xs,ys,zs) );
+
+   int x,y,z;
+
+   while( !stck.empty() )  
+   {
+      x = val<1>( stck.top() );
+      y = val<2>( stck.top() );
+      z = val<3>( stck.top() );
+      stck.pop();
+
+      short& flagType = grid( x, y, z );
+
+      if( flagType == Flag::UNDEF ) 
+      {     
+         flagType = type;
+
+         if ( grid.indicesInRange( x+1, y  , z   ) ) stck.push( UbTupleInt3( x+1, y  , z   ) );
+         if ( grid.indicesInRange( x  , y+1, z   ) ) stck.push( UbTupleInt3( x  , y+1, z   ) );
+         if ( grid.indicesInRange( x  , y  , z+1 ) ) stck.push( UbTupleInt3( x  , y  , z+1 ) );
+         if ( grid.indicesInRange( x-1, y  , z   ) ) stck.push( UbTupleInt3( x-1, y  , z   ) );
+         if ( grid.indicesInRange( x  , y-1, z   ) ) stck.push( UbTupleInt3( x  , y-1, z   ) );
+         if ( grid.indicesInRange( x  , y  , z-1 ) ) stck.push( UbTupleInt3( x  , y  , z-1 ) );
+      }
+   }
+}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt
index 98a64d3548e709895dc9e1eb8bb0e6eaa378ce7c..c6c94204a94d60a54026531ae188a6be04508e2c 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt
@@ -1,36 +1,36 @@
-cmake_minimum_required(VERSION 2.6)
-
-PROJECT(kdtree_pioTest)
-
-#################################################################
-# MACHINE_SPECIFIC CMAKE_CONFIG_FILE
-#################################################################
-INCLUDE("../../../../../CMake/CMakeCABMacros.txt")
-
-#################################################################
-###   PACKAGES                                               ###
-#################################################################
-INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/basics/container/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/basics/writer/CMakePackage.txt)
-
-INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/KdTree/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/fem/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakePackage.txt)
-
-#################################################################
-###   OWN DEFINES 						###
-#################################################################
-FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h
-                         ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 
-
-SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES})
-SOURCE_GROUP(z_main FILES ${SPECIFIC_FILES})
-
-#################################################################
-###  PROJECT ERSTELLEN                                        ###
-#################################################################
-CREATE_CAB_PROJECT(${PROJECT_NAME} BINARY)
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(kdtree_pioTest)
+
+#################################################################
+# MACHINE_SPECIFIC CMAKE_CONFIG_FILE
+#################################################################
+INCLUDE("../../../../../CMake/CMakeCABMacros.txt")
+
+#################################################################
+###   PACKAGES                                               ###
+#################################################################
+INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/basics/container/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/basics/writer/CMakePackage.txt)
+
+INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/KdTree/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/fem/CMakePackage.txt)
+INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakePackage.txt)
+
+#################################################################
+###   OWN DEFINES 						###
+#################################################################
+FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h
+                         ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 
+
+SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES})
+SOURCE_GROUP(z_main FILES ${SPECIFIC_FILES})
+
+#################################################################
+###  PROJECT ERSTELLEN                                        ###
+#################################################################
+CREATE_CAB_PROJECT(${PROJECT_NAME} BINARY)
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/examples/PIOTests/main.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/examples/PIOTests/main.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/examples/PIOTests/main.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/examples/PIOTests/main.cpp
index 265316c69c61c2c1265a4d4e6000a9f1397880cd..f24132c368b03497767f87be3927b6082ae20541 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/KdTree/examples/PIOTests/main.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/examples/PIOTests/main.cpp
@@ -1,342 +1,342 @@
-#include <basics/utilities/UbTiming.h>
-#include <basics/utilities/UbRandom.h>
-
-#include <basics/writer/WbWriterAvsASCII.h>
-#include <basics/writer/WbWriterAvsBinary.h>
-#include <basics/writer/WbWriterVtkXmlBinary.h>
-#include <basics/writer/WbWriterVtkXmlASCII.h>
-
-#include <basics/container/CbUniformMatrix4D.h>
-
-#include <numerics/geometry3d/GbTriFaceMesh3D.h>
-#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h>
-
-#include <numerics/geometry3d/KdTree/KdTree.h>
-#include <numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h>
-#include <numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h>
-#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h>
-#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h>
-
-using namespace std;
-
-void KdTreeTest         (std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles = true, std::string outpath = "g:/temp");
-void KdTreeTestWithLines(std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles = true, std::string outpath = "g:/temp");
-
-int main()
-{
-   try
-   {
-      //KdTreeTest("c:/temp/clumps.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-      //KdTreeTest("c:/temp/50spheres.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-      //KdTreeTest("c:/temp/Sphere5040.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-      //KdTreeTest("c:/temp/cooling_2.inp", 400, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-      //KdTreeTest("c:/temp/NDR-Konzertsaal.inp", 100, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-      
-      //KdTreeTest("c:/temp/Campus-Details-W3.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-      //KdTreeTest("c:/temp/Boein707.mesh", 100, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-      
-      //KdTreeTest("c:/temp/dolphin.mesh", 400, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-      //KdTreeTest("c:/temp/box.ply", 10, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-      //KdTreeTest("c:/temp/bodyRight.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-      //KdTreeTest("c:/temp/flamingo.mesh", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-      
-      //KdTreeTest("c:/temp/torus.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-      //KdTreeTestWithLines("c:/temp/box.ply", 10, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-      
-      KdTreeTest("c:/temp/doppelwandbox.ply", 100, GbTriFaceMesh3D::KDTREE_SPATIALSPLIT, true, "g:/temp");
-      
-      //KdTreeTestWithLines("c:/temp/torus.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT, true, "g:/temp");
-
-      //KdTreeTestWithLines("c:/temp/bodyRight.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-
-      //KdTreeTest("c:/temp/jetta.stl", 200, GbTriFaceMesh3D::KDTREE_SPATIALSPLIT , true, "g:/temp");
-      //KdTreeTest("c:/temp/jetta.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT, true, "g:/temp");
-      //KdTreeTest("c:/temp/VW_body.ply", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-      //KdTreeTest("c:/temp/kugel.stl", 50, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
-      //KdTreeTest("c:/temp/ship-2.mesh", 100, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp/schiff2");                                                   
-   }
-   catch(const std::exception& e)
-   {
-      UBLOG2(  logERROR, std::cerr, "Caught exception:");
-      UBLOG2(  logERROR, std::cerr, "Type: " << typeid(e).name() );
-      UBLOG2ML(logERROR, std::cerr, "What: " << e.what() );
-   }
-   catch(...)
-   {
-      UBLOG2(logERROR, std::cerr, "unknown exception occurs in "<< UB_FUNCTION)
-   }
-
-
-
-  
-}
-
-//////////////////////////////////////////////////////////////////////
-void KdTreeTest(std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles, std::string outpath)
-{
-   UbLog::setReportingLevel(logDEBUG5);
-   std::string filename = UbSystem::getFilenameFromString(meshfile);
-
-   GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(meshfile,"mesh",pio);
-   mesh->scale(10000,10000,10000);
-   //dummy test, damit der baum erstellt wird
-   mesh->isPointInGbObject3D(0,0,0);
-
-   UBLOG(logINFO, "############################################################");
-   UBLOG(logINFO, "nodes of TriFaceMesh....... "<<mesh->getNodes()->size()              );
-   UBLOG(logINFO, "triFaces of TriFaceMesh.... "<<mesh->getTriangles()->size()          );
-   UBLOG(logINFO, "triFace copies in KdTree... "<<mesh->getKdTree()->getNumOfTriFaces() );
-   UBLOG(logINFO, "nodes of kdNodes of KdTree. "<<mesh->getKdTree()->getNumOfNodes()   );
-   UBLOG(logINFO, "");
-
-
-   const float percentOverLap = 0.05f; //=5%
-   const float maxLength = (1.0f+percentOverLap)*UbMath::max( mesh->getLengthX1(), mesh->getLengthX2(), mesh->getLengthX3() );
-   const float dx1 = maxLength/(maxNofPointsPerDir-1);
-   const float dx2 = dx1;
-   const float dx3 = dx1;
-
-   const int nx1 = 1 + int( std::ceil(mesh->getLengthX1()*(1.0f+percentOverLap)/dx1)+0.5 );
-   const int nx2 = 1 + int( std::ceil(mesh->getLengthX2()*(1.0f+percentOverLap)/dx2)+0.5 );
-   const int nx3 = 1 + int( std::ceil(mesh->getLengthX3()*(1.0f+percentOverLap)/dx3)+0.5 );
-
-   CbUniformMatrix4D<int> solids(nx1,nx2,nx3,1,0);
-
-   const float orgx1 = -0.5*percentOverLap*mesh->getLengthX1()+mesh->getX1Minimum();
-   const float orgx2 = -0.5*percentOverLap*mesh->getLengthX2()+mesh->getX2Minimum();
-   const float orgx3 = -0.5*percentOverLap*mesh->getLengthX3()+mesh->getX3Minimum();
-
-   const float outX1 = 2*mesh->getX1Maximum();
-   const float outX2 = 0;//2*mesh->getX2Maximum();
-   const float outX3 = 0;//2*mesh->getX3Maximum();
-
-   UBLOG( logINFO, "performing " << nx1*nx2*nx3  <<" point-in-object(PIO)-tests");
-   UbTimer ff;
-   ff.start();
-   for(int x3=0; x3<solids.getNX3(); x3++)
-      for(int x2=0; x2<solids.getNX2(); x2++)
-         for(int x1=0; x1<solids.getNX1(); x1++)
-         {
-            solids(x1,x2,x3,0) = mesh->isPointInGbObject3D(orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3);
-         }
-   UBLOG( logINFO, nx1*nx2*nx3 <<" point-in-object(PIO)-tests done in "<<ff.stop()<<"s" );
-   UBLOG(logINFO, "############################################################");
-
-
-   /* ======================================================================================= */
-   if(writeFiles) 
-   {
-      UBLOG( logINFO, "writeFiles - start");
-      string subfiledir = outpath+"/"+filename+"_solid_node_files";
-      UbSystem::makeDirectory( subfiledir );
-
-      std::vector<UbTupleFloat3 > nodes;
-      std::vector<std::string > datanames(solids.getNX4(),"data");
-      datanames[0] = "solid";
-      //datanames[1] = "solid";
-
-      std::vector< std::string > outFilenames;
-
-      std::vector<std::vector<double > > nodedata( datanames.size() );
-      for(int x3=0; x3<solids.getNX3(); x3++)
-         for(int x2=0; x2<solids.getNX2(); x2++)
-            for(int x1=0; x1<solids.getNX1(); x1++)
-            {
-               if( solids(x1  ,x2  ,x3  , 0)  ) 
-               {
-                  nodes.push_back( makeUbTuple(  orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3 ) );
-
-                  for(int i=0; i<solids.getNX4(); i++)
-                  {
-                     nodedata[i].push_back( solids(x1  ,x2  ,x3  ,i) );
-                  }
-               }          
-
-               if(    nodes.size() > 2000000  
-                   || ( x1==(solids.getNX1()-1) && x2==(solids.getNX2()-1) && x3==(solids.getNX3()-1) ) ) 
-               {
-                  outFilenames.push_back( WbWriterVtkXmlBinary::getInstance()->writeNodesWithNodeData(subfiledir+"/"+filename+"_solid_nodes_"+"_part"+UbSystem::toString(outFilenames.size()+1),nodes,datanames,nodedata) );
-                  nodes.clear();
-                  nodedata.clear();
-                  nodedata.resize( datanames.size() );
-               }
-            }
-            
-      WbWriterVtkXmlBinary::getInstance()->writeCollection(outpath+"/"+filename+"_solids_nodes",outFilenames,0,false);
-      
-      
-      mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterVtkXmlBinary::getInstance(),true);
-      mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterAvsASCII::getInstance(),true);
-      mesh->getKdTree()->writeTree(outpath+"/"+filename+"_kdTree",WbWriterVtkXmlBinary::getInstance());
-
-      UBLOG( logINFO, "writeFiles - end")
-   }
-}
-
-//////////////////////////////////////////////////////////////////////
-void KdTreeTestWithLines(std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles, std::string outpath)
-{
-   UbLog::setReportingLevel(logDEBUG5);
-   std::string filename = UbSystem::getFilenameFromString(meshfile);
-
-   GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(meshfile,"mesh",pio);
-
-   //dummy test, damit der baum erstellt wird
-   mesh->isPointInGbObject3D(0,0,0);
-
-   UBLOG(logINFO, "############################################################");
-   UBLOG(logINFO, "nodes of TriFaceMesh....... "<<mesh->getNodes()->size()              );
-   UBLOG(logINFO, "triFaces of TriFaceMesh.... "<<mesh->getTriangles()->size()          );
-   UBLOG(logINFO, "triFace copies in KdTree... "<<mesh->getKdTree()->getNumOfTriFaces() );
-   UBLOG(logINFO, "nodes of kdNodes of KdTree. "<<mesh->getKdTree()->getNumOfNodes()   );
-   UBLOG(logINFO, "");
-
-
-   const float percentOverLap = 0.05f; //=5%
-   const float maxLength = (1.0f+percentOverLap)*UbMath::max( mesh->getLengthX1(), mesh->getLengthX2(), mesh->getLengthX3() );
-   const float dx1 = maxLength/(maxNofPointsPerDir-1);
-   const float dx2 = dx1;
-   const float dx3 = dx1;
-
-   const int nx1 = 1 + /*UbMath::integerRounding*/( std::ceil(mesh->getLengthX1()*(1.0f+percentOverLap)/dx1) );
-   const int nx2 = 1 + /*UbMath::integerRounding*/( std::ceil(mesh->getLengthX2()*(1.0f+percentOverLap)/dx2) );
-   const int nx3 = 1 + /*UbMath::integerRounding*/( std::ceil(mesh->getLengthX3()*(1.0f+percentOverLap)/dx3) );
-
-   CbUniformMatrix4D<int> solids(nx1,nx2,nx3,2,0);
-
-   const float orgx1 = -0.5*percentOverLap*mesh->getLengthX1()+mesh->getX1Minimum();
-   const float orgx2 = -0.5*percentOverLap*mesh->getLengthX2()+mesh->getX2Minimum();
-   const float orgx3 = -0.5*percentOverLap*mesh->getLengthX3()+mesh->getX3Minimum();
-
-//    const float outX1 = 2*mesh->getX1Maximum();
-//    const float outX2 = 2*mesh->getX2Maximum();
-//    const float outX3 = 2*mesh->getX3Maximum();
-
-   
-   Kd::Tree<double>* kdTree = mesh->getKdTree();
-   
-   std::vector<GbTriFaceMesh3D::TriFace>& triFaces = *mesh->getTriangles();
-   std::vector<GbTriFaceMesh3D::Vertex>&  vertices = *mesh->getNodes();
-
-   float x1center = float( mesh->getX1Centroid() );
-   float x2center = float( mesh->getX2Centroid() );
-   float x3center = float( mesh->getX3Centroid() );
-
-   UBLOG( logINFO, "performing point-in-object(PIO)-tests");
-   UbTimer ff;
-   ff.start();
-   long counter1=0, counter2 = 0;
-   for(size_t t=0; t<triFaces.size(); t++)   
-   {
-      int x1Min = /*UbMath::integerRounding*/( std::floor( (triFaces[t].getMinX(vertices)-orgx1) / dx1 ) );
-      int x2Min = /*UbMath::integerRounding*/( std::floor( (triFaces[t].getMinY(vertices)-orgx2) / dx2 ) );
-      int x3Min = /*UbMath::integerRounding*/( std::floor( (triFaces[t].getMinZ(vertices)-orgx3) / dx3 ) );
-
-      int x1Max = /*UbMath::integerRounding*/( std::ceil(  (triFaces[t].getMaxX(vertices)-orgx1) / dx1 ) );
-      int x2Max = /*UbMath::integerRounding*/( std::ceil(  (triFaces[t].getMaxY(vertices)-orgx2) / dx2 ) );
-      int x3Max = /*UbMath::integerRounding*/( std::ceil(  (triFaces[t].getMaxZ(vertices)-orgx3) / dx3 ) );
-
-      for(int x3=x3Min; x3<=x3Max; x3++)
-         for(int x2=x2Min; x2<=x2Max; x2++)
-            for(int x1=x1Min; x1<=x1Max; x1++)
-            {
-               counter1++;
-               
-               if( !solids.indicesInRange(x1,x2,x3,0) 
-                  || solids(x1,x2,x3,1) == 1 )  //doppeltes Testeb vermeiden
-               {
-                  continue;
-               }
-
-               counter2++;
-               
-               double x1w = orgx1+x1*dx1;
-               double x2w = orgx2+x2*dx2;
-               double x3w = orgx3+x3*dx3;
-
-               //eigentlicher PIO-Test
-               bool testFailed = true;
-               for(int i=0; i<100; i++)
-               {
-                  UbTupleDouble3 n1(x1w, x2w, x3w);
-                  UbTupleDouble3 n2(  double( x1w < x1center ? mesh->getX1Minimum()-UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX1() : mesh->getX1Maximum()+UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX1() )
-                                    , double( x2w < x2center ? mesh->getX2Minimum()-UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX2() : mesh->getX2Maximum()+UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX2() )
-                                    , double( x3w < x3center ? mesh->getX3Minimum()-UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX3() : mesh->getX3Maximum()+UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX3() ) );
-
-                  int iSec = kdTree->intersectLine( n1, n2, Kd::CountLineIntersectionHandler<double>() );
-                  
-                  if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen
-                  {
-                     if(iSec == Kd::Intersection::ON_BOUNDARY )
-                     {
-                        solids(x1,x2,x3,0) = true;
-                     }
-                     else
-                     {
-                        solids(x1,x2,x3,0) = (iSec&1);  //ungerade anzahl an schnitten --> drinnen
-                     }
-                     testFailed = false;
-                     break;
-                  }
-                  else
-                  {
-                     UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if  - an edge was hit ");
-                  }
-               }
-               if( testFailed ) throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
-               solids(x1,x2,x3,1) = 1;
-             }
-   }
-   UBLOG( logINFO,counter2 <<" point-in-object(PIO)-tests done in "<<ff.stop()<<"s" );
-   UBLOG( logINFO,counter1-counter2 <<" point-in-object(PIO)-tests uebersprungen" );
-   UBLOG(logINFO, "############################################################");
-
-   /* ======================================================================================= */
-   if(writeFiles) 
-   {
-      UBLOG( logINFO, "writeFiles - start");
-      string subfiledir = outpath+"/"+filename+"_solid_node_files";
-      UbSystem::makeDirectory( subfiledir );
-
-      std::vector<UbTupleFloat3 > nodes;
-      std::vector<std::string > datanames(solids.getNX4(),"data");
-      datanames[0] = "solid";
-      //datanames[1] = "solid";
-
-      std::vector< std::string > outFilenames;
-
-      std::vector<std::vector<double > > nodedata( datanames.size() );
-      for(int x3=0; x3<solids.getNX3(); x3++)
-         for(int x2=0; x2<solids.getNX2(); x2++)
-            for(int x1=0; x1<solids.getNX1(); x1++)
-            {
-               if( solids(x1  ,x2  ,x3  , 0)  ) 
-               {
-                  nodes.push_back( makeUbTuple(  orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3 ) );
-
-                  for(int i=0; i<solids.getNX4(); i++)
-                  {
-                     nodedata[i].push_back( solids(x1  ,x2  ,x3  ,i) );
-                  }
-               }          
-
-               if(    nodes.size() > 2000000  
-                   || ( x1==(solids.getNX1()-1) && x2==(solids.getNX2()-1) && x3==(solids.getNX3()-1) ) ) 
-               {
-                  outFilenames.push_back( WbWriterVtkXmlBinary::getInstance()->writeNodesWithNodeData(subfiledir+"/"+filename+"_solid_nodes_"+"_part"+UbSystem::toString(outFilenames.size()+1),nodes,datanames,nodedata) );
-                  nodes.clear();
-                  nodedata.clear();
-                  nodedata.resize( datanames.size() );
-               }
-            }
-   
-      WbWriterVtkXmlBinary::getInstance()->writeCollection(outpath+"/"+filename+"_solids_nodes",outFilenames,0,false);
-      
-      
-      mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterVtkXmlBinary::getInstance());
-      mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterAvsASCII::getInstance());
-      mesh->getKdTree()->writeTree(outpath+"/"+filename+"_kdTree",WbWriterVtkXmlBinary::getInstance());
-
-      UBLOG( logINFO, "writeFiles - end")
-   }
-}
+#include <basics/utilities/UbTiming.h>
+#include <basics/utilities/UbRandom.h>
+
+#include <basics/writer/WbWriterAvsASCII.h>
+#include <basics/writer/WbWriterAvsBinary.h>
+#include <basics/writer/WbWriterVtkXmlBinary.h>
+#include <basics/writer/WbWriterVtkXmlASCII.h>
+
+#include <basics/container/CbUniformMatrix4D.h>
+
+#include <numerics/geometry3d/GbTriFaceMesh3D.h>
+#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h>
+
+#include <numerics/geometry3d/KdTree/KdTree.h>
+#include <numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h>
+#include <numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h>
+#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h>
+#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h>
+
+using namespace std;
+
+void KdTreeTest         (std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles = true, std::string outpath = "g:/temp");
+void KdTreeTestWithLines(std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles = true, std::string outpath = "g:/temp");
+
+int main()
+{
+   try
+   {
+      //KdTreeTest("c:/temp/clumps.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+      //KdTreeTest("c:/temp/50spheres.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+      //KdTreeTest("c:/temp/Sphere5040.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+      //KdTreeTest("c:/temp/cooling_2.inp", 400, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+      //KdTreeTest("c:/temp/NDR-Konzertsaal.inp", 100, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+      
+      //KdTreeTest("c:/temp/Campus-Details-W3.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+      //KdTreeTest("c:/temp/Boein707.mesh", 100, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+      
+      //KdTreeTest("c:/temp/dolphin.mesh", 400, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+      //KdTreeTest("c:/temp/box.ply", 10, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+      //KdTreeTest("c:/temp/bodyRight.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+      //KdTreeTest("c:/temp/flamingo.mesh", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+      
+      //KdTreeTest("c:/temp/torus.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+      //KdTreeTestWithLines("c:/temp/box.ply", 10, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+      
+      KdTreeTest("c:/temp/doppelwandbox.ply", 100, GbTriFaceMesh3D::KDTREE_SPATIALSPLIT, true, "g:/temp");
+      
+      //KdTreeTestWithLines("c:/temp/torus.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT, true, "g:/temp");
+
+      //KdTreeTestWithLines("c:/temp/bodyRight.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+
+      //KdTreeTest("c:/temp/jetta.stl", 200, GbTriFaceMesh3D::KDTREE_SPATIALSPLIT , true, "g:/temp");
+      //KdTreeTest("c:/temp/jetta.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT, true, "g:/temp");
+      //KdTreeTest("c:/temp/VW_body.ply", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+      //KdTreeTest("c:/temp/kugel.stl", 50, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp");
+      //KdTreeTest("c:/temp/ship-2.mesh", 100, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp/schiff2");                                                   
+   }
+   catch(const std::exception& e)
+   {
+      UBLOG2(  logERROR, std::cerr, "Caught exception:");
+      UBLOG2(  logERROR, std::cerr, "Type: " << typeid(e).name() );
+      UBLOG2ML(logERROR, std::cerr, "What: " << e.what() );
+   }
+   catch(...)
+   {
+      UBLOG2(logERROR, std::cerr, "unknown exception occurs in "<< UB_FUNCTION)
+   }
+
+
+
+  
+}
+
+//////////////////////////////////////////////////////////////////////
+void KdTreeTest(std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles, std::string outpath)
+{
+   UbLog::setReportingLevel(logDEBUG5);
+   std::string filename = UbSystem::getFilenameFromString(meshfile);
+
+   GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(meshfile,"mesh",pio);
+   mesh->scale(10000,10000,10000);
+   //dummy test, damit der baum erstellt wird
+   mesh->isPointInGbObject3D(0,0,0);
+
+   UBLOG(logINFO, "############################################################");
+   UBLOG(logINFO, "nodes of TriFaceMesh....... "<<mesh->getNodes()->size()              );
+   UBLOG(logINFO, "triFaces of TriFaceMesh.... "<<mesh->getTriangles()->size()          );
+   UBLOG(logINFO, "triFace copies in KdTree... "<<mesh->getKdTree()->getNumOfTriFaces() );
+   UBLOG(logINFO, "nodes of kdNodes of KdTree. "<<mesh->getKdTree()->getNumOfNodes()   );
+   UBLOG(logINFO, "");
+
+
+   const float percentOverLap = 0.05f; //=5%
+   const float maxLength = (1.0f+percentOverLap)*UbMath::max( mesh->getLengthX1(), mesh->getLengthX2(), mesh->getLengthX3() );
+   const float dx1 = maxLength/(maxNofPointsPerDir-1);
+   const float dx2 = dx1;
+   const float dx3 = dx1;
+
+   const int nx1 = 1 + int( std::ceil(mesh->getLengthX1()*(1.0f+percentOverLap)/dx1)+0.5 );
+   const int nx2 = 1 + int( std::ceil(mesh->getLengthX2()*(1.0f+percentOverLap)/dx2)+0.5 );
+   const int nx3 = 1 + int( std::ceil(mesh->getLengthX3()*(1.0f+percentOverLap)/dx3)+0.5 );
+
+   CbUniformMatrix4D<int> solids(nx1,nx2,nx3,1,0);
+
+   const float orgx1 = -0.5*percentOverLap*mesh->getLengthX1()+mesh->getX1Minimum();
+   const float orgx2 = -0.5*percentOverLap*mesh->getLengthX2()+mesh->getX2Minimum();
+   const float orgx3 = -0.5*percentOverLap*mesh->getLengthX3()+mesh->getX3Minimum();
+
+   const float outX1 = 2*mesh->getX1Maximum();
+   const float outX2 = 0;//2*mesh->getX2Maximum();
+   const float outX3 = 0;//2*mesh->getX3Maximum();
+
+   UBLOG( logINFO, "performing " << nx1*nx2*nx3  <<" point-in-object(PIO)-tests");
+   UbTimer ff;
+   ff.start();
+   for(int x3=0; x3<solids.getNX3(); x3++)
+      for(int x2=0; x2<solids.getNX2(); x2++)
+         for(int x1=0; x1<solids.getNX1(); x1++)
+         {
+            solids(x1,x2,x3,0) = mesh->isPointInGbObject3D(orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3);
+         }
+   UBLOG( logINFO, nx1*nx2*nx3 <<" point-in-object(PIO)-tests done in "<<ff.stop()<<"s" );
+   UBLOG(logINFO, "############################################################");
+
+
+   /* ======================================================================================= */
+   if(writeFiles) 
+   {
+      UBLOG( logINFO, "writeFiles - start");
+      string subfiledir = outpath+"/"+filename+"_solid_node_files";
+      UbSystem::makeDirectory( subfiledir );
+
+      std::vector<UbTupleFloat3 > nodes;
+      std::vector<std::string > datanames(solids.getNX4(),"data");
+      datanames[0] = "solid";
+      //datanames[1] = "solid";
+
+      std::vector< std::string > outFilenames;
+
+      std::vector<std::vector<double > > nodedata( datanames.size() );
+      for(int x3=0; x3<solids.getNX3(); x3++)
+         for(int x2=0; x2<solids.getNX2(); x2++)
+            for(int x1=0; x1<solids.getNX1(); x1++)
+            {
+               if( solids(x1  ,x2  ,x3  , 0)  ) 
+               {
+                  nodes.push_back( makeUbTuple(  orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3 ) );
+
+                  for(int i=0; i<solids.getNX4(); i++)
+                  {
+                     nodedata[i].push_back( solids(x1  ,x2  ,x3  ,i) );
+                  }
+               }          
+
+               if(    nodes.size() > 2000000  
+                   || ( x1==(solids.getNX1()-1) && x2==(solids.getNX2()-1) && x3==(solids.getNX3()-1) ) ) 
+               {
+                  outFilenames.push_back( WbWriterVtkXmlBinary::getInstance()->writeNodesWithNodeData(subfiledir+"/"+filename+"_solid_nodes_"+"_part"+UbSystem::toString(outFilenames.size()+1),nodes,datanames,nodedata) );
+                  nodes.clear();
+                  nodedata.clear();
+                  nodedata.resize( datanames.size() );
+               }
+            }
+            
+      WbWriterVtkXmlBinary::getInstance()->writeCollection(outpath+"/"+filename+"_solids_nodes",outFilenames,0,false);
+      
+      
+      mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterVtkXmlBinary::getInstance(),true);
+      mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterAvsASCII::getInstance(),true);
+      mesh->getKdTree()->writeTree(outpath+"/"+filename+"_kdTree",WbWriterVtkXmlBinary::getInstance());
+
+      UBLOG( logINFO, "writeFiles - end")
+   }
+}
+
+//////////////////////////////////////////////////////////////////////
+void KdTreeTestWithLines(std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles, std::string outpath)
+{
+   UbLog::setReportingLevel(logDEBUG5);
+   std::string filename = UbSystem::getFilenameFromString(meshfile);
+
+   GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(meshfile,"mesh",pio);
+
+   //dummy test, damit der baum erstellt wird
+   mesh->isPointInGbObject3D(0,0,0);
+
+   UBLOG(logINFO, "############################################################");
+   UBLOG(logINFO, "nodes of TriFaceMesh....... "<<mesh->getNodes()->size()              );
+   UBLOG(logINFO, "triFaces of TriFaceMesh.... "<<mesh->getTriangles()->size()          );
+   UBLOG(logINFO, "triFace copies in KdTree... "<<mesh->getKdTree()->getNumOfTriFaces() );
+   UBLOG(logINFO, "nodes of kdNodes of KdTree. "<<mesh->getKdTree()->getNumOfNodes()   );
+   UBLOG(logINFO, "");
+
+
+   const float percentOverLap = 0.05f; //=5%
+   const float maxLength = (1.0f+percentOverLap)*UbMath::max( mesh->getLengthX1(), mesh->getLengthX2(), mesh->getLengthX3() );
+   const float dx1 = maxLength/(maxNofPointsPerDir-1);
+   const float dx2 = dx1;
+   const float dx3 = dx1;
+
+   const int nx1 = 1 + /*UbMath::integerRounding*/( std::ceil(mesh->getLengthX1()*(1.0f+percentOverLap)/dx1) );
+   const int nx2 = 1 + /*UbMath::integerRounding*/( std::ceil(mesh->getLengthX2()*(1.0f+percentOverLap)/dx2) );
+   const int nx3 = 1 + /*UbMath::integerRounding*/( std::ceil(mesh->getLengthX3()*(1.0f+percentOverLap)/dx3) );
+
+   CbUniformMatrix4D<int> solids(nx1,nx2,nx3,2,0);
+
+   const float orgx1 = -0.5*percentOverLap*mesh->getLengthX1()+mesh->getX1Minimum();
+   const float orgx2 = -0.5*percentOverLap*mesh->getLengthX2()+mesh->getX2Minimum();
+   const float orgx3 = -0.5*percentOverLap*mesh->getLengthX3()+mesh->getX3Minimum();
+
+//    const float outX1 = 2*mesh->getX1Maximum();
+//    const float outX2 = 2*mesh->getX2Maximum();
+//    const float outX3 = 2*mesh->getX3Maximum();
+
+   
+   Kd::Tree<double>* kdTree = mesh->getKdTree();
+   
+   std::vector<GbTriFaceMesh3D::TriFace>& triFaces = *mesh->getTriangles();
+   std::vector<GbTriFaceMesh3D::Vertex>&  vertices = *mesh->getNodes();
+
+   float x1center = float( mesh->getX1Centroid() );
+   float x2center = float( mesh->getX2Centroid() );
+   float x3center = float( mesh->getX3Centroid() );
+
+   UBLOG( logINFO, "performing point-in-object(PIO)-tests");
+   UbTimer ff;
+   ff.start();
+   long counter1=0, counter2 = 0;
+   for(size_t t=0; t<triFaces.size(); t++)   
+   {
+      int x1Min = /*UbMath::integerRounding*/( std::floor( (triFaces[t].getMinX(vertices)-orgx1) / dx1 ) );
+      int x2Min = /*UbMath::integerRounding*/( std::floor( (triFaces[t].getMinY(vertices)-orgx2) / dx2 ) );
+      int x3Min = /*UbMath::integerRounding*/( std::floor( (triFaces[t].getMinZ(vertices)-orgx3) / dx3 ) );
+
+      int x1Max = /*UbMath::integerRounding*/( std::ceil(  (triFaces[t].getMaxX(vertices)-orgx1) / dx1 ) );
+      int x2Max = /*UbMath::integerRounding*/( std::ceil(  (triFaces[t].getMaxY(vertices)-orgx2) / dx2 ) );
+      int x3Max = /*UbMath::integerRounding*/( std::ceil(  (triFaces[t].getMaxZ(vertices)-orgx3) / dx3 ) );
+
+      for(int x3=x3Min; x3<=x3Max; x3++)
+         for(int x2=x2Min; x2<=x2Max; x2++)
+            for(int x1=x1Min; x1<=x1Max; x1++)
+            {
+               counter1++;
+               
+               if( !solids.indicesInRange(x1,x2,x3,0) 
+                  || solids(x1,x2,x3,1) == 1 )  //doppeltes Testeb vermeiden
+               {
+                  continue;
+               }
+
+               counter2++;
+               
+               double x1w = orgx1+x1*dx1;
+               double x2w = orgx2+x2*dx2;
+               double x3w = orgx3+x3*dx3;
+
+               //eigentlicher PIO-Test
+               bool testFailed = true;
+               for(int i=0; i<100; i++)
+               {
+                  UbTupleDouble3 n1(x1w, x2w, x3w);
+                  UbTupleDouble3 n2(  double( x1w < x1center ? mesh->getX1Minimum()-UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX1() : mesh->getX1Maximum()+UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX1() )
+                                    , double( x2w < x2center ? mesh->getX2Minimum()-UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX2() : mesh->getX2Maximum()+UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX2() )
+                                    , double( x3w < x3center ? mesh->getX3Minimum()-UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX3() : mesh->getX3Maximum()+UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX3() ) );
+
+                  int iSec = kdTree->intersectLine( n1, n2, Kd::CountLineIntersectionHandler<double>() );
+                  
+                  if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen
+                  {
+                     if(iSec == Kd::Intersection::ON_BOUNDARY )
+                     {
+                        solids(x1,x2,x3,0) = true;
+                     }
+                     else
+                     {
+                        solids(x1,x2,x3,0) = (iSec&1);  //ungerade anzahl an schnitten --> drinnen
+                     }
+                     testFailed = false;
+                     break;
+                  }
+                  else
+                  {
+                     UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if  - an edge was hit ");
+                  }
+               }
+               if( testFailed ) throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis");
+               solids(x1,x2,x3,1) = 1;
+             }
+   }
+   UBLOG( logINFO,counter2 <<" point-in-object(PIO)-tests done in "<<ff.stop()<<"s" );
+   UBLOG( logINFO,counter1-counter2 <<" point-in-object(PIO)-tests uebersprungen" );
+   UBLOG(logINFO, "############################################################");
+
+   /* ======================================================================================= */
+   if(writeFiles) 
+   {
+      UBLOG( logINFO, "writeFiles - start");
+      string subfiledir = outpath+"/"+filename+"_solid_node_files";
+      UbSystem::makeDirectory( subfiledir );
+
+      std::vector<UbTupleFloat3 > nodes;
+      std::vector<std::string > datanames(solids.getNX4(),"data");
+      datanames[0] = "solid";
+      //datanames[1] = "solid";
+
+      std::vector< std::string > outFilenames;
+
+      std::vector<std::vector<double > > nodedata( datanames.size() );
+      for(int x3=0; x3<solids.getNX3(); x3++)
+         for(int x2=0; x2<solids.getNX2(); x2++)
+            for(int x1=0; x1<solids.getNX1(); x1++)
+            {
+               if( solids(x1  ,x2  ,x3  , 0)  ) 
+               {
+                  nodes.push_back( makeUbTuple(  orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3 ) );
+
+                  for(int i=0; i<solids.getNX4(); i++)
+                  {
+                     nodedata[i].push_back( solids(x1  ,x2  ,x3  ,i) );
+                  }
+               }          
+
+               if(    nodes.size() > 2000000  
+                   || ( x1==(solids.getNX1()-1) && x2==(solids.getNX2()-1) && x3==(solids.getNX3()-1) ) ) 
+               {
+                  outFilenames.push_back( WbWriterVtkXmlBinary::getInstance()->writeNodesWithNodeData(subfiledir+"/"+filename+"_solid_nodes_"+"_part"+UbSystem::toString(outFilenames.size()+1),nodes,datanames,nodedata) );
+                  nodes.clear();
+                  nodedata.clear();
+                  nodedata.resize( datanames.size() );
+               }
+            }
+   
+      WbWriterVtkXmlBinary::getInstance()->writeCollection(outpath+"/"+filename+"_solids_nodes",outFilenames,0,false);
+      
+      
+      mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterVtkXmlBinary::getInstance());
+      mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterAvsASCII::getInstance());
+      mesh->getKdTree()->writeTree(outpath+"/"+filename+"_kdTree",WbWriterVtkXmlBinary::getInstance());
+
+      UBLOG( logINFO, "writeFiles - end")
+   }
+}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h
index eccfde3058e028c2239bcc81de1ebfe0f3306e99..025a913cfb02d6f3fa723ca0c36c3114a6437ea2 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h
@@ -1,56 +1,56 @@
-#ifndef KDCOUNTLINEINTERSECTIONHANDLER_H
-#define KDCOUNTLINEINTERSECTIONHANDLER_H
-
-#include <basics/utilities/UbTuple.h>
-#include <basics/utilities/UbKeys.h>
-
-#include <numerics/geometry3d/GbTriFaceMesh3D.h>
-
-#include <numerics/geometry3d/KdTree/KdNode.h>
-#include <numerics/geometry3d/KdTree/KdUtilities.h>
-#include <numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h>
-
-#include <set>
-
-namespace Kd
-{
-   template< typename T >
-   class CountLineIntersectionHandler : public LineIntersectionHandler<T> 
-   {
-   public:
-      bool intersectLine(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2, Node<T>& parent, Node<T>*& child1, Node<T>*& child2) const
-      {
-         if( parent.intersectLineBoundingBox(n1, n2)  == Intersection::INTERSECTION)
-         {
-            if( parent.isLeaf() ) 
-            {
-               std::vector<GbTriFaceMesh3D::TriFace>& triFaces = *parent.getTriFaces();
-               std::vector<GbTriFaceMesh3D::Vertex>& nodes = parent.getNodes();
-
-         for( std::size_t i=0; i<triFaces.size(); i++ )
-         {
-            GbTriFaceMesh3D::TriFace& triFace = triFaces[i];
-
-                  if( Kd::intersectLine(n1, n2, triFace, nodes) ) return true;
-               }
-               return false;
-               }
-            else
-               {
-               if( child1 )
-               {
-                  if (child1->intersectLine(n1, n2, *this)) return true;
-               }
-               if( child2 ) 
-               {
-                  if (child2->intersectLine(n1, n2, *this)) return true;
-               }
-            }
-         }
-         return false;
-      }
-      /* ======================================================================================= */
-   };
-}
-
-#endif //KDCOUNTLINEINTERSECTIONHANDLER_H
+#ifndef KDCOUNTLINEINTERSECTIONHANDLER_H
+#define KDCOUNTLINEINTERSECTIONHANDLER_H
+
+#include <basics/utilities/UbTuple.h>
+#include <basics/utilities/UbKeys.h>
+
+#include <numerics/geometry3d/GbTriFaceMesh3D.h>
+
+#include <numerics/geometry3d/KdTree/KdNode.h>
+#include <numerics/geometry3d/KdTree/KdUtilities.h>
+#include <numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h>
+
+#include <set>
+
+namespace Kd
+{
+   template< typename T >
+   class CountLineIntersectionHandler : public LineIntersectionHandler<T> 
+   {
+   public:
+      bool intersectLine(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2, Node<T>& parent, Node<T>*& child1, Node<T>*& child2) const
+      {
+         if( parent.intersectLineBoundingBox(n1, n2)  == Intersection::INTERSECTION)
+         {
+            if( parent.isLeaf() ) 
+            {
+               std::vector<GbTriFaceMesh3D::TriFace>& triFaces = *parent.getTriFaces();
+               std::vector<GbTriFaceMesh3D::Vertex>& nodes = parent.getNodes();
+
+         for( std::size_t i=0; i<triFaces.size(); i++ )
+         {
+            GbTriFaceMesh3D::TriFace& triFace = triFaces[i];
+
+                  if( Kd::intersectLine(n1, n2, triFace, nodes) ) return true;
+               }
+               return false;
+               }
+            else
+               {
+               if( child1 )
+               {
+                  if (child1->intersectLine(n1, n2, *this)) return true;
+               }
+               if( child2 ) 
+               {
+                  if (child2->intersectLine(n1, n2, *this)) return true;
+               }
+            }
+         }
+         return false;
+      }
+      /* ======================================================================================= */
+   };
+}
+
+#endif //KDCOUNTLINEINTERSECTIONHANDLER_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h
index b95fc676ad04008b43b0ddf6db785887f941e7e0..e426723c1274466620051a4ce4528c9c7a0ca9bc 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h
@@ -1,164 +1,164 @@
-#ifndef KDCOUNTRAYINTERSECTIONHANDLER_H
-#define KDCOUNTRAYINTERSECTIONHANDLER_H
-
-#include <basics/utilities/UbTuple.h>
-#include <basics/utilities/UbKeys.h>
-
-#include <numerics/geometry3d/GbTriFaceMesh3D.h>
-
-#include <numerics/geometry3d/KdTree/KdNode.h>
-//#include <numerics/geometry3d/KdTree/KdUtilities.h>
-#include <numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h>
-
-#include <set>
-
-namespace Kd
-{
-   template< typename T >
-   class CountRayIntersectionHandler : public RayIntersectionHandler<T> 
-   {
-   public:
-      int intersectRay(const Ray<T>& ray, Node<T>& parent, Node<T>*& child1, Node<T>*& child2, std::set< UbKeys::Key3<int> >& mailbox) const
-      {
-         if( parent.intersectRayBoundingBox(ray)  == Intersection::INTERSECTION)
-         {
-            if( parent.isLeaf() ) 
-            {
-               return this->checkIntersectionWithTriFaces(ray, *parent.getTriFaces(), parent.getNodes(), mailbox);
-            } 
-            else
-            {
-               int sum = 0;
-               if( child1 )
-               {
-                  int erg = child1->intersectRay(ray, *this, mailbox);
-                  if(erg < 0)
-                  {
-                     return erg;
-                  }
-                  sum += erg;
-               }
-               if( child2 ) 
-               {
-                  int erg = child2->intersectRay(ray, *this, mailbox);
-                  if(erg < 0)
-                  {
-                     return erg;
-                  }
-                  sum += erg;
-               }
-               return sum;
-            }
-         } 
-         else 
-         {
-            return 0;
-         }
-      }
-      /* ======================================================================================= */
-
-   private:
-      int checkIntersectionWithTriFaces(const Ray<T>& ray, std::vector<GbTriFaceMesh3D::TriFace>& triFaces, std::vector<GbTriFaceMesh3D::Vertex>& nodes, std::set< UbKeys::Key3<int> >& mailbox) const
-      {
-         T e1x,e1y,e1z,e2x,e2y,e2z,px,py,pz,a,f,sx,sy,sz,u,qx,qy,qz,v,factor;
-
-         int counter = 0, iSec = 0;
-
-         for( std::size_t i=0; i<triFaces.size(); i++ )
-         {
-            GbTriFaceMesh3D::TriFace& triFace = triFaces[i];
-
-            if( mailbox.find( UbKeys::Key3<int>(triFace.getIndexVertex1(), triFace.getIndexVertex2(), triFace.getIndexVertex3() ) )==mailbox.end() ) 
-            {
-               mailbox.insert( UbKeys::Key3<int>(triFace.getIndexVertex1(), triFace.getIndexVertex2(), triFace.getIndexVertex3() ) ); //schon hier rein, ansonsten muss man es unten bei JEDEm continue und am ende des ifs machen
-
-               GbTriFaceMesh3D::Vertex& v1 = triFace.getNode(0, nodes);
-               GbTriFaceMesh3D::Vertex& v2 = triFace.getNode(1, nodes);
-               GbTriFaceMesh3D::Vertex& v3 = triFace.getNode(2, nodes);
-
-               //////////////////////////////////////////////////////////////////////////
-               //Raytracing - start(  Anm.: prüft NUR in Strahlrichtung
-               // Grundidee: Schnittpunkt in Baryzentrischen Koordinaten besimmten
-               // t(u,v,w) = w*v0 + u*v1 + v*v2 
-               // mit w = 1.0-u-v, da fuer alle Punkte (u,v,w) im Dreick gilt u+v+w = 1
-               // wenn u, v oder w == 0 -> Punkt liegt auf Kante
-               // wenn u, v oder w == 1 -> Punkt liegt auf Eckpunkt (-> die anderen Werte muessen 0 )
-               
-               //e1 = v1 - v0
-               e1x = v2.x-v1.x;
-               e1y = v2.y-v1.y;
-               e1z = v2.z-v1.z;
-
-               //e2 = v2 - v0
-               e2x = v3.x-v1.x;
-               e2y = v3.y-v1.y;
-               e2z = v3.z-v1.z;
-
-               //p = d x e2
-               px = ray.directionY*e2z - ray.directionZ*e2y;
-               py = ray.directionZ*e2x - ray.directionX*e2z;
-               pz = ray.directionX*e2y - ray.directionY*e2x;
-
-               //a = e1 dot p
-               a = e1x*px + e1y*py + e1z*pz;
-               //if( fabs(a)<1.E-10 ) continue;
-               if( fabs(a) < UbMath::Epsilon<T>::val() ) continue;
-               f = T(1.0/a);
-
-               //s = o - v0
-               sx = ray.originX - v1.x;
-               sy = ray.originY - v1.y;
-               sz = ray.originZ - v1.z;
-
-               //u = f * ( s dot p)
-               u = f * ( sx*px + sy*py + sz*pz );
-               
-               //u ist nur gueltig in [0;1] 
-               if( ( UbMath::less(   u, T(0.0) ) ) || ( UbMath::greater(u, T(1.0) ) ) ) 
-               {
-                  continue;
-               }
-
-               //q = s x e1
-               qx = sy*e1z - sz*e1y;
-               qy = sz*e1x - sx*e1z;
-               qz = sx*e1y - sy*e1x;
-
-               //v = f*(e2 dot q)
-               v = f * (ray.directionX*qx + ray.directionY*qy + ray.directionZ*qz);
-               
-               //v ist nur gueltig in [0;1] da aber v bereits gueltig ist -> u+v darf nicht > 1.0 sein ;-)
-               if(   ( UbMath::less(v, T(0.0) ) ) || ( UbMath::greater(u+v, T(1.0) ) ) ) 
-               {
-                  continue;
-               }
-
-               //t = f * (e2 dot q)
-               factor = f * (e2x*qx + e2y*qy + e2z*qz);
-               //Raytracing - end
-               //////////////////////////////////////////////////////////////////////////
-
-               if( UbMath::zero( factor ) ) 
-               {
-                  return Intersection::ON_BOUNDARY; //ray.Org liegt direkt auf einem dreieck --> boundary
-               }
-               if( factor < 0.0 )
-               {
-                  continue;  //Schnittpunkt liegt in entgegengesetzter Strahlrichtung
-               }
-
-               //edge tests
-               //wenn u, v oder w ==0 -> Punkt liegt auf Kante bzw. Eckpunkt
-               if( UbMath::zero(u)          )  return Intersection::INTERSECT_EDGE;
-               if( UbMath::zero(v)          )  return Intersection::INTERSECT_EDGE;
-               if( UbMath::zero(T(1.0)-u-v) )  return Intersection::INTERSECT_EDGE;
-
-               counter++;
-            }
-         }
-         return counter;
-      }
-   };
-}
-
-#endif //KDCOUNTRAYLINEINTERSECTIONHANDLER_H
+#ifndef KDCOUNTRAYINTERSECTIONHANDLER_H
+#define KDCOUNTRAYINTERSECTIONHANDLER_H
+
+#include <basics/utilities/UbTuple.h>
+#include <basics/utilities/UbKeys.h>
+
+#include <numerics/geometry3d/GbTriFaceMesh3D.h>
+
+#include <numerics/geometry3d/KdTree/KdNode.h>
+//#include <numerics/geometry3d/KdTree/KdUtilities.h>
+#include <numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h>
+
+#include <set>
+
+namespace Kd
+{
+   template< typename T >
+   class CountRayIntersectionHandler : public RayIntersectionHandler<T> 
+   {
+   public:
+      int intersectRay(const Ray<T>& ray, Node<T>& parent, Node<T>*& child1, Node<T>*& child2, std::set< UbKeys::Key3<int> >& mailbox) const
+      {
+         if( parent.intersectRayBoundingBox(ray)  == Intersection::INTERSECTION)
+         {
+            if( parent.isLeaf() ) 
+            {
+               return this->checkIntersectionWithTriFaces(ray, *parent.getTriFaces(), parent.getNodes(), mailbox);
+            } 
+            else
+            {
+               int sum = 0;
+               if( child1 )
+               {
+                  int erg = child1->intersectRay(ray, *this, mailbox);
+                  if(erg < 0)
+                  {
+                     return erg;
+                  }
+                  sum += erg;
+               }
+               if( child2 ) 
+               {
+                  int erg = child2->intersectRay(ray, *this, mailbox);
+                  if(erg < 0)
+                  {
+                     return erg;
+                  }
+                  sum += erg;
+               }
+               return sum;
+            }
+         } 
+         else 
+         {
+            return 0;
+         }
+      }
+      /* ======================================================================================= */
+
+   private:
+      int checkIntersectionWithTriFaces(const Ray<T>& ray, std::vector<GbTriFaceMesh3D::TriFace>& triFaces, std::vector<GbTriFaceMesh3D::Vertex>& nodes, std::set< UbKeys::Key3<int> >& mailbox) const
+      {
+         T e1x,e1y,e1z,e2x,e2y,e2z,px,py,pz,a,f,sx,sy,sz,u,qx,qy,qz,v,factor;
+
+         int counter = 0, iSec = 0;
+
+         for( std::size_t i=0; i<triFaces.size(); i++ )
+         {
+            GbTriFaceMesh3D::TriFace& triFace = triFaces[i];
+
+            if( mailbox.find( UbKeys::Key3<int>(triFace.getIndexVertex1(), triFace.getIndexVertex2(), triFace.getIndexVertex3() ) )==mailbox.end() ) 
+            {
+               mailbox.insert( UbKeys::Key3<int>(triFace.getIndexVertex1(), triFace.getIndexVertex2(), triFace.getIndexVertex3() ) ); //schon hier rein, ansonsten muss man es unten bei JEDEm continue und am ende des ifs machen
+
+               GbTriFaceMesh3D::Vertex& v1 = triFace.getNode(0, nodes);
+               GbTriFaceMesh3D::Vertex& v2 = triFace.getNode(1, nodes);
+               GbTriFaceMesh3D::Vertex& v3 = triFace.getNode(2, nodes);
+
+               //////////////////////////////////////////////////////////////////////////
+               //Raytracing - start(  Anm.: prüft NUR in Strahlrichtung
+               // Grundidee: Schnittpunkt in Baryzentrischen Koordinaten besimmten
+               // t(u,v,w) = w*v0 + u*v1 + v*v2 
+               // mit w = 1.0-u-v, da fuer alle Punkte (u,v,w) im Dreick gilt u+v+w = 1
+               // wenn u, v oder w == 0 -> Punkt liegt auf Kante
+               // wenn u, v oder w == 1 -> Punkt liegt auf Eckpunkt (-> die anderen Werte muessen 0 )
+               
+               //e1 = v1 - v0
+               e1x = v2.x-v1.x;
+               e1y = v2.y-v1.y;
+               e1z = v2.z-v1.z;
+
+               //e2 = v2 - v0
+               e2x = v3.x-v1.x;
+               e2y = v3.y-v1.y;
+               e2z = v3.z-v1.z;
+
+               //p = d x e2
+               px = ray.directionY*e2z - ray.directionZ*e2y;
+               py = ray.directionZ*e2x - ray.directionX*e2z;
+               pz = ray.directionX*e2y - ray.directionY*e2x;
+
+               //a = e1 dot p
+               a = e1x*px + e1y*py + e1z*pz;
+               //if( fabs(a)<1.E-10 ) continue;
+               if( fabs(a) < UbMath::Epsilon<T>::val() ) continue;
+               f = T(1.0/a);
+
+               //s = o - v0
+               sx = ray.originX - v1.x;
+               sy = ray.originY - v1.y;
+               sz = ray.originZ - v1.z;
+
+               //u = f * ( s dot p)
+               u = f * ( sx*px + sy*py + sz*pz );
+               
+               //u ist nur gueltig in [0;1] 
+               if( ( UbMath::less(   u, T(0.0) ) ) || ( UbMath::greater(u, T(1.0) ) ) ) 
+               {
+                  continue;
+               }
+
+               //q = s x e1
+               qx = sy*e1z - sz*e1y;
+               qy = sz*e1x - sx*e1z;
+               qz = sx*e1y - sy*e1x;
+
+               //v = f*(e2 dot q)
+               v = f * (ray.directionX*qx + ray.directionY*qy + ray.directionZ*qz);
+               
+               //v ist nur gueltig in [0;1] da aber v bereits gueltig ist -> u+v darf nicht > 1.0 sein ;-)
+               if(   ( UbMath::less(v, T(0.0) ) ) || ( UbMath::greater(u+v, T(1.0) ) ) ) 
+               {
+                  continue;
+               }
+
+               //t = f * (e2 dot q)
+               factor = f * (e2x*qx + e2y*qy + e2z*qz);
+               //Raytracing - end
+               //////////////////////////////////////////////////////////////////////////
+
+               if( UbMath::zero( factor ) ) 
+               {
+                  return Intersection::ON_BOUNDARY; //ray.Org liegt direkt auf einem dreieck --> boundary
+               }
+               if( factor < 0.0 )
+               {
+                  continue;  //Schnittpunkt liegt in entgegengesetzter Strahlrichtung
+               }
+
+               //edge tests
+               //wenn u, v oder w ==0 -> Punkt liegt auf Kante bzw. Eckpunkt
+               if( UbMath::zero(u)          )  return Intersection::INTERSECT_EDGE;
+               if( UbMath::zero(v)          )  return Intersection::INTERSECT_EDGE;
+               if( UbMath::zero(T(1.0)-u-v) )  return Intersection::INTERSECT_EDGE;
+
+               counter++;
+            }
+         }
+         return counter;
+      }
+   };
+}
+
+#endif //KDCOUNTRAYLINEINTERSECTIONHANDLER_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h
similarity index 100%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h
similarity index 100%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp
similarity index 100%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h
index 52e73ea714969df05098d7fed82f826357beeca5..aa2a739a3003350b78ed3fa6210f8fdc5c0d5204 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h
@@ -1,287 +1,287 @@
-#ifndef KDSAHSPLIT_H
-#define KDSAHSPLIT_H
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbMath.h>
-#include <basics/utilities/UbInfinity.h>
-#include <numerics/geometry3d/GbTriFaceMesh3D.h>
-
-#include <numerics/geometry3d/KdTree/KdNode.h>
-#include <numerics/geometry3d/KdTree/KdUtilities.h>
-#include <numerics/geometry3d/KdTree/KdSplitCandidateManager.h>
-#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h>
-
-#include <vector>
-#include <cmath>
-
-namespace Kd
-{
-   template< typename T >
-   class SAHSplit : public SplitAlgorithm<T> 
-   {
-   public:
-      /* ======================================================================================= */
-      SplitCandidate<T> findBestSplitCandidate(const int& level, const int& maxLevel, Node<T>& node ) const
-      {
-         if( !node.getTriFaces() )  throw UbException(UB_EXARGS, "triFace NULL pointer");
-
-         if(   node.getTriFaces()->size() <= 1 //max triangles in node
-            || level >= maxLevel     )
-         {
-            return SplitCandidate<T>();
-         }
-
-         SplitCandidate<T> bestSplitCandidate;
-         T minCN = Ub::inf;
-
-         for(int splitAxis = 0; splitAxis < 3; splitAxis++) 
-         {
-            SplitCandidateManager<T> sc;
-            findPossibleSplitCandidates(splitAxis, node, sc);
-
-            // incremental sweep to find best split position
-            for( std::size_t i = 0; i < sc.size(); i++)
-            {
-               if (i == 0) 
-               {
-                  sc[i].nl = sc.objects_starting_outside_left + sc.objects_fully_outside_node;
-                  sc[i].nr = node.getTriFaces()->size() - sc[0].np - sc[0].ending;
-               } 
-               else 
-               {
-                  sc[i].nl = sc[i - 1].nl + sc[i - 1].starting + sc[i - 1].np;
-                  sc[i].nr = sc[i - 1].nr - sc[i    ].ending   - sc[i    ].np;
-               }
-
-               this->calcSAH(sc[i], node);
-
-               if (sc[i].Cn < minCN)
-               {
-                  minCN              = sc[i].Cn;
-                  bestSplitCandidate = sc[i];
-               }
-            }
-         }
-
-         // automatic termination criterion (SAH)
-         if ( bestSplitCandidate.isValid && bestSplitCandidate.Cn >= node.getTriFaces()->size() * Ci) 
-         {
-            return SplitCandidate<T>();
-         }
-
-         return bestSplitCandidate;
-      }
-      /* ======================================================================================= */
-      void distributeTriFaces(const SplitCandidate<T>& candidate, std::vector<GbTriFaceMesh3D::TriFace>& triFacesForChild1, std::vector<GbTriFaceMesh3D::TriFace>& triFacesForChild2, Node<T>& node) const
-      {  
-         if( !node.getTriFaces() )  throw UbException(UB_EXARGS, "null pointer at triface list");
-
-         std::vector<GbTriFaceMesh3D::TriFace>& srcTriFaces = *node.getTriFaces();
-         std::vector<GbTriFaceMesh3D::Vertex>&  srcNodes    = node.getNodes();
-         std::vector<T> projection;
-
-         for(std::size_t i=0; i<srcTriFaces.size(); i++) 
-         {
-            GbTriFaceMesh3D::TriFace& triFace = srcTriFaces[i];
-            Kd::project2Axis(triFace, srcNodes, candidate.axis, projection);
-
-            T& min = projection[0];
-            T& max = projection[2];
-            // --------------------------------------------------- //
-            // case 1 : object inside plane
-            if( UbMath::equal(min, max) )
-            {
-               if( UbMath::equal(min, candidate.position) ) 
-               {
-                  if(candidate.np_left)
-                  {
-                     triFacesForChild1.push_back(triFace);
-                  } 
-                  else if(candidate.np_right) 
-                  {
-                     triFacesForChild2.push_back(triFace);
-                  }
-               } 
-               else if( UbMath::less(min, candidate.position) )
-               {
-                  triFacesForChild1.push_back(triFace);
-               } 
-               else //if( UbMath::greater(min, candidate.position) 
-               {
-                  triFacesForChild2.push_back(triFace);
-               }
-            } //
-            // --------------------------------------------------- //
-            // case 2 : object on left side of plane
-            else if( UbMath::lessEqual(max,candidate.position) )
-            {
-               triFacesForChild1.push_back(triFace);
-            } // --------------------------------------------------- //
-            // case 3 : object on right side of plane
-            else if ( UbMath::greaterEqual( min, candidate.position) ) 
-            {
-               triFacesForChild2.push_back(triFace);
-            }//
-            // --------------------------------------------------- //
-            // case 4 : object in both nodes
-            else 
-            {
-               triFacesForChild1.push_back(triFace);
-               triFacesForChild2.push_back(triFace);
-            }//
-            // --------------------------------------------------- //
-         }
-
-         node.deleteTriFaces();
-      }
-
-
-   private:
-      /* ======================================================================================= */
-      // cost function
-      inline T calcCosts(const int& nl, const int& nr, const T& SA_VL, const T& SA_VR, const T& SA_V) const
-      {
-         return Ct + Ci * (nl * SA_VL / SA_V + nr * SA_VR / SA_V);
-      }
-      /* ======================================================================================= */
-      void findPossibleSplitCandidates(const int& splitAxis, Node<T>& node, SplitCandidateManager<T>& splitCandidateManager) const
-      {
-         T p1_node = (splitAxis == Axis::X ? node.x[0] : splitAxis == Axis::Y ? node.y[0] : node.z[0]);
-         T p2_node = (splitAxis == Axis::X ? node.x[1] : splitAxis == Axis::Y ? node.y[1] : node.z[1]);
-
-         if( !node.getTriFaces() )  throw UbException(UB_EXARGS, "null pointer");
-
-         std::vector<GbTriFaceMesh3D::TriFace>& srcTriFaces = *node.getTriFaces();
-         std::vector<GbTriFaceMesh3D::Vertex >& srcNodes    = node.getNodes();
-         std::vector<T> projection;
-
-         for(std::size_t i=0; i<srcTriFaces.size(); i++) 
-         {
-            GbTriFaceMesh3D::TriFace& triFace = srcTriFaces[i];
-
-            // project object to axis
-            Kd::project2Axis(triFace,srcNodes,splitAxis, projection);
-            // left point
-            T& p1 = projection[0];
-            // right point
-            T& p2 = projection[2];
-
-            // --------------------------------------------------- //
-            // --------------------------------------------------- //
-            // case 1 : object is fully inside the current node
-            if(   UbMath::greaterEqual(p1, p1_node)   
-               && UbMath::lessEqual(p2, p2_node) )   
-            {
-               if( UbMath::equal(p1, p2) ) 
-               {
-                  // object is inside the plane
-                  splitCandidateManager.add(p1, splitAxis, 0, 0, 1);
-               } 
-               else 
-               {
-                  splitCandidateManager.add(p1, splitAxis, 1, 0, 0);
-                  splitCandidateManager.add(p2, splitAxis, 0, 1, 0);
-               }
-            } //
-            // --------------------------------------------------- //
-            // --------------------------------------------------- //
-            // case 2 : just the right point (p2) is inside the current node
-            else if(    UbMath::less(p1, p1_node) 
-                     && UbMath::lessEqual(p2,p2_node)
-                     && UbMath::greaterEqual(p2, p1_node)   )
-            {
-               splitCandidateManager.add(p2, splitAxis, 0, 1, 0);
-               splitCandidateManager.objects_starting_outside_left++;
-            } //
-            // --------------------------------------------------- //
-            // --------------------------------------------------- //
-            // case 3 : just the left point (p1) is inside the current node
-            else if(    UbMath::greaterEqual(p1, p1_node) 
-                     && UbMath::greater(p2, p2_node) 
-                     && UbMath::lessEqual(p1, p2_node)   ) 
-            {
-               splitCandidateManager.add(p1, splitAxis, 1, 0, 0);
-            } //
-            // --------------------------------------------------- //
-            // --------------------------------------------------- //
-            // case 4 : left and right point are outside the current node
-            else if(   UbMath::less(p1, p1_node)
-                    && UbMath::greater(p2, p2_node) )
-            {
-               splitCandidateManager.objects_fully_outside_node++;
-            } //
-            // --------------------------------------------------- //
-            // --------------------------------------------------- //
-         }
-
-         splitCandidateManager.createSortedArray();
-      }
-
-
-      /* ======================================================================================= */
-      // calculates the costs for a given splitCandidate based on the Surface Area Heuristic (SAH)
-      void calcSAH(SplitCandidate<T>& candidate, Node<T>& node) const 
-      {
-         T p1_node = (candidate.axis == Axis::X ? node.x[0] : candidate.axis == Axis::Y ? node.y[0] : node.z[0]);
-
-         // edges of (root) voxel
-         T dx = std::fabs(node.x[1] - node.x[0]);
-         T dy = std::fabs(node.y[1] - node.y[0]);
-         T dz = std::fabs(node.z[1] - node.z[0]);
-
-         // surface area (root) voxel
-         T SA_V = T((2.0 * dx * dy) + (2.0 * dx * dz) + (2.0 * dy * dz));
-
-         T delta = (candidate.axis == Axis::X ? dx : candidate.axis == Axis::Y ? dy : dz);
-         T deltaL = std::fabs(candidate.position - p1_node);
-         T deltaR = std::fabs(delta - deltaL);
-
-         // edges of sub voxel left
-         T dx_l = (candidate.axis == Axis::X ? deltaL : dx), dy_l = (candidate.axis == Axis::Y ? deltaL : dy), dz_l = (candidate.axis == Axis::Z ? deltaL : dz);
-
-         // surface area sub voxel left
-         T SA_VL = T( (2.0 * dx_l * dy_l) + (2.0 * dx_l * dz_l) + (2.0 * dy_l * dz_l) );
-
-         // edges of sub voxel right
-         T dx_r = (candidate.axis == Axis::X ? deltaR : dx), dy_r = (candidate.axis == Axis::Y ? deltaR : dy), dz_r = (candidate.axis == Axis::Z ? deltaR : dz);
-
-         // surface area sub voxel right
-         T SA_VR = T( (2.0 * dx_r * dy_r) + (2.0 * dx_r * dz_r) + (2.0 * dy_r * dz_r) );
-
-         if (candidate.np == 0) 
-         {
-            candidate.Cn = calcCosts(candidate.nl, candidate.nr, SA_VL, SA_VR, SA_V);
-            return;
-         }
-
-         // once putting np with nl, and once with nr - and select the one with lowest cost
-         // see: Wald, Havran: "On building fast kd-Trees for Ray Tracing, and doing that in O(N log N)", 2006
-         T CP_L = calcCosts(candidate.nl + candidate.np, candidate.nr               , SA_VL, SA_VR, SA_V);
-         T CP_R = calcCosts(candidate.nl               , candidate.nr + candidate.np, SA_VL, SA_VR, SA_V);
-         
-         if(CP_L < CP_R) 
-         {
-            candidate.Cn       = CP_L;
-            candidate.np_right = true;
-         } 
-         else 
-         {
-            candidate.Cn      = CP_R;
-            candidate.np_left = true;
-         }
-      }
-      /* ======================================================================================= */
-
-   protected:
-      static const T Ct;// = 3.0; traversal cost
-      static const T Ci;// = 4.0; ray-patch-intersection-cost
-   };
-
-   
-   template< typename T>
-   const T SAHSplit<T>::Ct = 3.0; //traversal cost
-   template< typename T>
-   const T SAHSplit<T>::Ci = 4.0; //ray-patch-intersection-cost
-}
-
-#endif //KDSAHSPLIT_H
+#ifndef KDSAHSPLIT_H
+#define KDSAHSPLIT_H
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbMath.h>
+#include <basics/utilities/UbInfinity.h>
+#include <numerics/geometry3d/GbTriFaceMesh3D.h>
+
+#include <numerics/geometry3d/KdTree/KdNode.h>
+#include <numerics/geometry3d/KdTree/KdUtilities.h>
+#include <numerics/geometry3d/KdTree/KdSplitCandidateManager.h>
+#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h>
+
+#include <vector>
+#include <cmath>
+
+namespace Kd
+{
+   template< typename T >
+   class SAHSplit : public SplitAlgorithm<T> 
+   {
+   public:
+      /* ======================================================================================= */
+      SplitCandidate<T> findBestSplitCandidate(const int& level, const int& maxLevel, Node<T>& node ) const
+      {
+         if( !node.getTriFaces() )  throw UbException(UB_EXARGS, "triFace NULL pointer");
+
+         if(   node.getTriFaces()->size() <= 1 //max triangles in node
+            || level >= maxLevel     )
+         {
+            return SplitCandidate<T>();
+         }
+
+         SplitCandidate<T> bestSplitCandidate;
+         T minCN = Ub::inf;
+
+         for(int splitAxis = 0; splitAxis < 3; splitAxis++) 
+         {
+            SplitCandidateManager<T> sc;
+            findPossibleSplitCandidates(splitAxis, node, sc);
+
+            // incremental sweep to find best split position
+            for( std::size_t i = 0; i < sc.size(); i++)
+            {
+               if (i == 0) 
+               {
+                  sc[i].nl = sc.objects_starting_outside_left + sc.objects_fully_outside_node;
+                  sc[i].nr = node.getTriFaces()->size() - sc[0].np - sc[0].ending;
+               } 
+               else 
+               {
+                  sc[i].nl = sc[i - 1].nl + sc[i - 1].starting + sc[i - 1].np;
+                  sc[i].nr = sc[i - 1].nr - sc[i    ].ending   - sc[i    ].np;
+               }
+
+               this->calcSAH(sc[i], node);
+
+               if (sc[i].Cn < minCN)
+               {
+                  minCN              = sc[i].Cn;
+                  bestSplitCandidate = sc[i];
+               }
+            }
+         }
+
+         // automatic termination criterion (SAH)
+         if ( bestSplitCandidate.isValid && bestSplitCandidate.Cn >= node.getTriFaces()->size() * Ci) 
+         {
+            return SplitCandidate<T>();
+         }
+
+         return bestSplitCandidate;
+      }
+      /* ======================================================================================= */
+      void distributeTriFaces(const SplitCandidate<T>& candidate, std::vector<GbTriFaceMesh3D::TriFace>& triFacesForChild1, std::vector<GbTriFaceMesh3D::TriFace>& triFacesForChild2, Node<T>& node) const
+      {  
+         if( !node.getTriFaces() )  throw UbException(UB_EXARGS, "null pointer at triface list");
+
+         std::vector<GbTriFaceMesh3D::TriFace>& srcTriFaces = *node.getTriFaces();
+         std::vector<GbTriFaceMesh3D::Vertex>&  srcNodes    = node.getNodes();
+         std::vector<T> projection;
+
+         for(std::size_t i=0; i<srcTriFaces.size(); i++) 
+         {
+            GbTriFaceMesh3D::TriFace& triFace = srcTriFaces[i];
+            Kd::project2Axis(triFace, srcNodes, candidate.axis, projection);
+
+            T& min = projection[0];
+            T& max = projection[2];
+            // --------------------------------------------------- //
+            // case 1 : object inside plane
+            if( UbMath::equal(min, max) )
+            {
+               if( UbMath::equal(min, candidate.position) ) 
+               {
+                  if(candidate.np_left)
+                  {
+                     triFacesForChild1.push_back(triFace);
+                  } 
+                  else if(candidate.np_right) 
+                  {
+                     triFacesForChild2.push_back(triFace);
+                  }
+               } 
+               else if( UbMath::less(min, candidate.position) )
+               {
+                  triFacesForChild1.push_back(triFace);
+               } 
+               else //if( UbMath::greater(min, candidate.position) 
+               {
+                  triFacesForChild2.push_back(triFace);
+               }
+            } //
+            // --------------------------------------------------- //
+            // case 2 : object on left side of plane
+            else if( UbMath::lessEqual(max,candidate.position) )
+            {
+               triFacesForChild1.push_back(triFace);
+            } // --------------------------------------------------- //
+            // case 3 : object on right side of plane
+            else if ( UbMath::greaterEqual( min, candidate.position) ) 
+            {
+               triFacesForChild2.push_back(triFace);
+            }//
+            // --------------------------------------------------- //
+            // case 4 : object in both nodes
+            else 
+            {
+               triFacesForChild1.push_back(triFace);
+               triFacesForChild2.push_back(triFace);
+            }//
+            // --------------------------------------------------- //
+         }
+
+         node.deleteTriFaces();
+      }
+
+
+   private:
+      /* ======================================================================================= */
+      // cost function
+      inline T calcCosts(const int& nl, const int& nr, const T& SA_VL, const T& SA_VR, const T& SA_V) const
+      {
+         return Ct + Ci * (nl * SA_VL / SA_V + nr * SA_VR / SA_V);
+      }
+      /* ======================================================================================= */
+      void findPossibleSplitCandidates(const int& splitAxis, Node<T>& node, SplitCandidateManager<T>& splitCandidateManager) const
+      {
+         T p1_node = (splitAxis == Axis::X ? node.x[0] : splitAxis == Axis::Y ? node.y[0] : node.z[0]);
+         T p2_node = (splitAxis == Axis::X ? node.x[1] : splitAxis == Axis::Y ? node.y[1] : node.z[1]);
+
+         if( !node.getTriFaces() )  throw UbException(UB_EXARGS, "null pointer");
+
+         std::vector<GbTriFaceMesh3D::TriFace>& srcTriFaces = *node.getTriFaces();
+         std::vector<GbTriFaceMesh3D::Vertex >& srcNodes    = node.getNodes();
+         std::vector<T> projection;
+
+         for(std::size_t i=0; i<srcTriFaces.size(); i++) 
+         {
+            GbTriFaceMesh3D::TriFace& triFace = srcTriFaces[i];
+
+            // project object to axis
+            Kd::project2Axis(triFace,srcNodes,splitAxis, projection);
+            // left point
+            T& p1 = projection[0];
+            // right point
+            T& p2 = projection[2];
+
+            // --------------------------------------------------- //
+            // --------------------------------------------------- //
+            // case 1 : object is fully inside the current node
+            if(   UbMath::greaterEqual(p1, p1_node)   
+               && UbMath::lessEqual(p2, p2_node) )   
+            {
+               if( UbMath::equal(p1, p2) ) 
+               {
+                  // object is inside the plane
+                  splitCandidateManager.add(p1, splitAxis, 0, 0, 1);
+               } 
+               else 
+               {
+                  splitCandidateManager.add(p1, splitAxis, 1, 0, 0);
+                  splitCandidateManager.add(p2, splitAxis, 0, 1, 0);
+               }
+            } //
+            // --------------------------------------------------- //
+            // --------------------------------------------------- //
+            // case 2 : just the right point (p2) is inside the current node
+            else if(    UbMath::less(p1, p1_node) 
+                     && UbMath::lessEqual(p2,p2_node)
+                     && UbMath::greaterEqual(p2, p1_node)   )
+            {
+               splitCandidateManager.add(p2, splitAxis, 0, 1, 0);
+               splitCandidateManager.objects_starting_outside_left++;
+            } //
+            // --------------------------------------------------- //
+            // --------------------------------------------------- //
+            // case 3 : just the left point (p1) is inside the current node
+            else if(    UbMath::greaterEqual(p1, p1_node) 
+                     && UbMath::greater(p2, p2_node) 
+                     && UbMath::lessEqual(p1, p2_node)   ) 
+            {
+               splitCandidateManager.add(p1, splitAxis, 1, 0, 0);
+            } //
+            // --------------------------------------------------- //
+            // --------------------------------------------------- //
+            // case 4 : left and right point are outside the current node
+            else if(   UbMath::less(p1, p1_node)
+                    && UbMath::greater(p2, p2_node) )
+            {
+               splitCandidateManager.objects_fully_outside_node++;
+            } //
+            // --------------------------------------------------- //
+            // --------------------------------------------------- //
+         }
+
+         splitCandidateManager.createSortedArray();
+      }
+
+
+      /* ======================================================================================= */
+      // calculates the costs for a given splitCandidate based on the Surface Area Heuristic (SAH)
+      void calcSAH(SplitCandidate<T>& candidate, Node<T>& node) const 
+      {
+         T p1_node = (candidate.axis == Axis::X ? node.x[0] : candidate.axis == Axis::Y ? node.y[0] : node.z[0]);
+
+         // edges of (root) voxel
+         T dx = std::fabs(node.x[1] - node.x[0]);
+         T dy = std::fabs(node.y[1] - node.y[0]);
+         T dz = std::fabs(node.z[1] - node.z[0]);
+
+         // surface area (root) voxel
+         T SA_V = T((2.0 * dx * dy) + (2.0 * dx * dz) + (2.0 * dy * dz));
+
+         T delta = (candidate.axis == Axis::X ? dx : candidate.axis == Axis::Y ? dy : dz);
+         T deltaL = std::fabs(candidate.position - p1_node);
+         T deltaR = std::fabs(delta - deltaL);
+
+         // edges of sub voxel left
+         T dx_l = (candidate.axis == Axis::X ? deltaL : dx), dy_l = (candidate.axis == Axis::Y ? deltaL : dy), dz_l = (candidate.axis == Axis::Z ? deltaL : dz);
+
+         // surface area sub voxel left
+         T SA_VL = T( (2.0 * dx_l * dy_l) + (2.0 * dx_l * dz_l) + (2.0 * dy_l * dz_l) );
+
+         // edges of sub voxel right
+         T dx_r = (candidate.axis == Axis::X ? deltaR : dx), dy_r = (candidate.axis == Axis::Y ? deltaR : dy), dz_r = (candidate.axis == Axis::Z ? deltaR : dz);
+
+         // surface area sub voxel right
+         T SA_VR = T( (2.0 * dx_r * dy_r) + (2.0 * dx_r * dz_r) + (2.0 * dy_r * dz_r) );
+
+         if (candidate.np == 0) 
+         {
+            candidate.Cn = calcCosts(candidate.nl, candidate.nr, SA_VL, SA_VR, SA_V);
+            return;
+         }
+
+         // once putting np with nl, and once with nr - and select the one with lowest cost
+         // see: Wald, Havran: "On building fast kd-Trees for Ray Tracing, and doing that in O(N log N)", 2006
+         T CP_L = calcCosts(candidate.nl + candidate.np, candidate.nr               , SA_VL, SA_VR, SA_V);
+         T CP_R = calcCosts(candidate.nl               , candidate.nr + candidate.np, SA_VL, SA_VR, SA_V);
+         
+         if(CP_L < CP_R) 
+         {
+            candidate.Cn       = CP_L;
+            candidate.np_right = true;
+         } 
+         else 
+         {
+            candidate.Cn      = CP_R;
+            candidate.np_left = true;
+         }
+      }
+      /* ======================================================================================= */
+
+   protected:
+      static const T Ct;// = 3.0; traversal cost
+      static const T Ci;// = 4.0; ray-patch-intersection-cost
+   };
+
+   
+   template< typename T>
+   const T SAHSplit<T>::Ct = 3.0; //traversal cost
+   template< typename T>
+   const T SAHSplit<T>::Ci = 4.0; //ray-patch-intersection-cost
+}
+
+#endif //KDSAHSPLIT_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h
similarity index 100%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h
diff --git a/source/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h b/source/VirtualFluidsBasic/numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h
similarity index 100%
rename from source/ThirdParty/Library/numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/CMakePackage.txt b/source/VirtualFluidsBasic/numerics/geometry3d/creator/CMakePackage.txt
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/CMakePackage.txt
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/CMakePackage.txt
index 7fc2bbf84209dc05bd7aa85886b2250007c2a107..57e527298452354c11014d9001adcc1b3215cd54 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/CMakePackage.txt
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/CMakePackage.txt
@@ -1,12 +1,12 @@
-GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
-COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
-
-#SET(SUBDIRPATH numerics/geometry3d/creator) 
-#SET(OPTION_LABEL BUILD_GEOMETRY3DCREATOR)
-#
-#SET(CURRENT_DIR ${SOURCE_ROOT}/${SUBDIRPATH})
-#
-#OPTION(${OPTION_LABEL} "${CURRENT_DIR}" ON)
-#IF(${OPTION_LABEL})
-#   COLLECT_PACKAGE_DATA( ${CURRENT_DIR} ${SUBDIRPATH} ALL_SOURCES)
-#ENDIF(${OPTION_LABEL})
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
+
+#SET(SUBDIRPATH numerics/geometry3d/creator) 
+#SET(OPTION_LABEL BUILD_GEOMETRY3DCREATOR)
+#
+#SET(CURRENT_DIR ${SOURCE_ROOT}/${SUBDIRPATH})
+#
+#OPTION(${OPTION_LABEL} "${CURRENT_DIR}" ON)
+#IF(${OPTION_LABEL})
+#   COLLECT_PACKAGE_DATA( ${CURRENT_DIR} ${SUBDIRPATH} ALL_SOURCES)
+#ENDIF(${OPTION_LABEL})
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbCuboid3DCreator.h b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbCuboid3DCreator.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbCuboid3DCreator.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbCuboid3DCreator.h
index 9b8478f8bdfaa680584e96e0f10b92a5b8726c3c..4f1414b7d6b7054d1096f296fbbcb7622e85ea56 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbCuboid3DCreator.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbCuboid3DCreator.h
@@ -1,77 +1,77 @@
-#ifndef GBCUBOID3DCREATOR_H
-#define GBCUBOID3DCREATOR_H
-
-#include <numerics/geometry3d/creator/GbObject3DCreator.h>
-#include <numerics/geometry3d/GbCuboid3D.h>     
-
-#ifdef CAB_QT 
-#include <numerics/geometry3d/presentation/QGbCuboid3DInstrument.h>
-#include <QtGui/QWidget>
-#include <QtGui/QDialog>
-#endif
-
-#ifdef CAB_VTK 
-#include <numerics/geometry3d/presentation/vtkGbCuboid3D.h>
-#endif
-
-class GbCuboid3DCreator : public GbObject3DCreator              
-{                                       
-public:
-   static GbCuboid3DCreator* getInstance()
-   {
-      static GbCuboid3DCreator instance;
-      return &instance;
-   }
-
-   GbCuboid3D* createGbObject3D() { return new GbCuboid3D(); }          
-
-   std::string getGbObject3DTypeID() { return "GbCuboid3D"; };
-   std::string toString()            { return "GbCuboid3DCreator"; }
-
-private:
-   GbCuboid3DCreator() : GbObject3DCreator() {}
-
-   GbCuboid3DCreator( const GbCuboid3DCreator& );                  //no copy allowed 
-   const GbCuboid3DCreator& operator=( const GbCuboid3DCreator& ); //no copy allowed
-
-#ifdef CAB_QT 
-public:
-   GbCuboid3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0)
-   {                                                              
-      GbCuboid3D* cuboid = this->createGbObject3D();
-      cuboid->getPoint2()->setX1(2.0);
-      cuboid->getPoint2()->setX2(2.0);
-      cuboid->getPoint2()->setX3(2.0);
-
-      QGbCuboid3DInstrument instrument(parent, flags);
-      instrument.setGbCuboid3D(cuboid);
-      if (instrument.exec()) { return cuboid; }
-      delete cuboid;
-
-      return NULL;
-   }
-
-   QDialog* getSpecificInstrument(QWidget* parent=0, Qt::WFlags flags=0) { return new QGbCuboid3DInstrument(parent, flags); }
-
-   void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0)
-   { 
-      GbCuboid3D* cuboid = dynamic_cast<GbCuboid3D*>(gbObj);
-      if(!cuboid) throw UbException(UB_EXARGS,"selected object to edit is no GbCuboid3D!");
-
-      QGbCuboid3DInstrument instrument(parent, flags);
-      instrument.setGbCuboid3D(cuboid);
-      instrument.exec();
-   }
-#endif
-#ifdef CAB_VTK
-public:
-   Presentator* createObjectPresentator(ObObject *object) { return new vtkGbCuboid3D(dynamic_cast<GbCuboid3D*>(object)); }
-#endif
-
-};
-
-#ifndef SWIG
-UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbCuboid3DCreator::getInstance()), CAB_GbCuboid3DCreator);
-#endif
-
-#endif   
+#ifndef GBCUBOID3DCREATOR_H
+#define GBCUBOID3DCREATOR_H
+
+#include <numerics/geometry3d/creator/GbObject3DCreator.h>
+#include <numerics/geometry3d/GbCuboid3D.h>     
+
+#ifdef CAB_QT 
+#include <numerics/geometry3d/presentation/QGbCuboid3DInstrument.h>
+#include <QtGui/QWidget>
+#include <QtGui/QDialog>
+#endif
+
+#ifdef CAB_VTK 
+#include <numerics/geometry3d/presentation/vtkGbCuboid3D.h>
+#endif
+
+class GbCuboid3DCreator : public GbObject3DCreator              
+{                                       
+public:
+   static GbCuboid3DCreator* getInstance()
+   {
+      static GbCuboid3DCreator instance;
+      return &instance;
+   }
+
+   GbCuboid3D* createGbObject3D() { return new GbCuboid3D(); }          
+
+   std::string getGbObject3DTypeID() { return "GbCuboid3D"; };
+   std::string toString()            { return "GbCuboid3DCreator"; }
+
+private:
+   GbCuboid3DCreator() : GbObject3DCreator() {}
+
+   GbCuboid3DCreator( const GbCuboid3DCreator& );                  //no copy allowed 
+   const GbCuboid3DCreator& operator=( const GbCuboid3DCreator& ); //no copy allowed
+
+#ifdef CAB_QT 
+public:
+   GbCuboid3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0)
+   {                                                              
+      GbCuboid3D* cuboid = this->createGbObject3D();
+      cuboid->getPoint2()->setX1(2.0);
+      cuboid->getPoint2()->setX2(2.0);
+      cuboid->getPoint2()->setX3(2.0);
+
+      QGbCuboid3DInstrument instrument(parent, flags);
+      instrument.setGbCuboid3D(cuboid);
+      if (instrument.exec()) { return cuboid; }
+      delete cuboid;
+
+      return NULL;
+   }
+
+   QDialog* getSpecificInstrument(QWidget* parent=0, Qt::WFlags flags=0) { return new QGbCuboid3DInstrument(parent, flags); }
+
+   void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0)
+   { 
+      GbCuboid3D* cuboid = dynamic_cast<GbCuboid3D*>(gbObj);
+      if(!cuboid) throw UbException(UB_EXARGS,"selected object to edit is no GbCuboid3D!");
+
+      QGbCuboid3DInstrument instrument(parent, flags);
+      instrument.setGbCuboid3D(cuboid);
+      instrument.exec();
+   }
+#endif
+#ifdef CAB_VTK
+public:
+   Presentator* createObjectPresentator(ObObject *object) { return new vtkGbCuboid3D(dynamic_cast<GbCuboid3D*>(object)); }
+#endif
+
+};
+
+#ifndef SWIG
+UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbCuboid3DCreator::getInstance()), CAB_GbCuboid3DCreator);
+#endif
+
+#endif   
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbCylinder3DCreator.h b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbCylinder3DCreator.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbCylinder3DCreator.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbCylinder3DCreator.h
index ca9614d7d50f5ba8f32f9a7cc134503a5d9cf49b..7769985da7919f4c79de61481b69ebd234d7d3e4 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbCylinder3DCreator.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbCylinder3DCreator.h
@@ -1,81 +1,81 @@
-#ifndef GBCYLINDER3DCREATOR_H
-#define GBCYLINDER3DCREATOR_H
-
-#include <numerics/geometry3d/creator/GbObject3DCreator.h>
-#include <numerics/geometry3d/GbCylinder3D.h>
-
-#ifdef CAB_QT 
-#include <numerics/geometry3d/presentation/QGbCylinder3DInstrument.h>
-#include <QtGui/QWidget>
-#include <QtGui/QDialog>
-#endif
-
-#ifdef CAB_VTK
-#include <numerics/geometry3d/presentation/vtkGbCylinder3D.h>
-#endif
-
-
-class GbCylinder3DCreator : public GbObject3DCreator              
-{                                       
-public:
-   static GbCylinder3DCreator* getInstance()
-   {
-      static GbCylinder3DCreator instance;
-      return &instance;
-   }
-
-   GbCylinder3D* createGbObject3D() { return new GbCylinder3D(); }
-   
-   std::string getGbObject3DTypeID(){ return "GbCylinder3D";        }
-   std::string toString()           { return "GbCylinder3DCreator"; }
-
-private:
-   GbCylinder3DCreator( const GbCylinder3DCreator& );                  //no copy allowed 
-   const GbCylinder3DCreator& operator=( const GbCylinder3DCreator& ); //no copy allowed
-GbCylinder3DCreator() : GbObject3DCreator() {}
-
-#ifdef CAB_QT
-public:
-
-   GbCylinder3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0)
-   {                                                              
-      GbCylinder3D* cylinder = this->createGbObject3D();
-      cylinder->setRadius(2.0);
-      cylinder->setPoint1(0.0, 0.0, 0.0);
-      cylinder->setPoint2(0.0, 5.0, 0.0);
-
-      QGbCylinder3DInstrument instrument(parent, flags);
-      instrument.setGbCylinder3D(cylinder);
-      if (instrument.exec()){ return cylinder; }
-      delete cylinder;
-
-      return NULL;
-   }
-
-   QDialog* getSpecificInstrument(QWidget* parent=0, Qt::WFlags flags=0)
-   { 
-      return new QGbCylinder3DInstrument(parent, flags);
-   }
-
-   void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0)
-   { 
-      GbCylinder3D* cylinder = dynamic_cast<GbCylinder3D*>(gbObj);
-      if(!cylinder) throw UbException(UB_EXARGS,"selected object to edit is no GbCylinder3D!");
-
-      QGbCylinder3DInstrument instrument(parent, flags);
-      instrument.setGbCylinder3D(cylinder);
-      instrument.exec();
-   }
-#endif
-#ifdef CAB_VTK
-public:
-   Presentator* createObjectPresentator(ObObject *object) { return new vtkGbCylinder3D(dynamic_cast<GbCylinder3D*>(object)); }
-#endif
-
-};
-
-#ifndef SWIG
-UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbCylinder3DCreator::getInstance()), CAB_GbCylinder3DCreator);
-#endif
-
-#endif   
+#ifndef GBCYLINDER3DCREATOR_H
+#define GBCYLINDER3DCREATOR_H
+
+#include <numerics/geometry3d/creator/GbObject3DCreator.h>
+#include <numerics/geometry3d/GbCylinder3D.h>
+
+#ifdef CAB_QT 
+#include <numerics/geometry3d/presentation/QGbCylinder3DInstrument.h>
+#include <QtGui/QWidget>
+#include <QtGui/QDialog>
+#endif
+
+#ifdef CAB_VTK
+#include <numerics/geometry3d/presentation/vtkGbCylinder3D.h>
+#endif
+
+
+class GbCylinder3DCreator : public GbObject3DCreator              
+{                                       
+public:
+   static GbCylinder3DCreator* getInstance()
+   {
+      static GbCylinder3DCreator instance;
+      return &instance;
+   }
+
+   GbCylinder3D* createGbObject3D() { return new GbCylinder3D(); }
+   
+   std::string getGbObject3DTypeID(){ return "GbCylinder3D";        }
+   std::string toString()           { return "GbCylinder3DCreator"; }
+
+private:
+   GbCylinder3DCreator( const GbCylinder3DCreator& );                  //no copy allowed 
+   const GbCylinder3DCreator& operator=( const GbCylinder3DCreator& ); //no copy allowed
+GbCylinder3DCreator() : GbObject3DCreator() {}
+
+#ifdef CAB_QT
+public:
+
+   GbCylinder3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0)
+   {                                                              
+      GbCylinder3D* cylinder = this->createGbObject3D();
+      cylinder->setRadius(2.0);
+      cylinder->setPoint1(0.0, 0.0, 0.0);
+      cylinder->setPoint2(0.0, 5.0, 0.0);
+
+      QGbCylinder3DInstrument instrument(parent, flags);
+      instrument.setGbCylinder3D(cylinder);
+      if (instrument.exec()){ return cylinder; }
+      delete cylinder;
+
+      return NULL;
+   }
+
+   QDialog* getSpecificInstrument(QWidget* parent=0, Qt::WFlags flags=0)
+   { 
+      return new QGbCylinder3DInstrument(parent, flags);
+   }
+
+   void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0)
+   { 
+      GbCylinder3D* cylinder = dynamic_cast<GbCylinder3D*>(gbObj);
+      if(!cylinder) throw UbException(UB_EXARGS,"selected object to edit is no GbCylinder3D!");
+
+      QGbCylinder3DInstrument instrument(parent, flags);
+      instrument.setGbCylinder3D(cylinder);
+      instrument.exec();
+   }
+#endif
+#ifdef CAB_VTK
+public:
+   Presentator* createObjectPresentator(ObObject *object) { return new vtkGbCylinder3D(dynamic_cast<GbCylinder3D*>(object)); }
+#endif
+
+};
+
+#ifndef SWIG
+UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbCylinder3DCreator::getInstance()), CAB_GbCylinder3DCreator);
+#endif
+
+#endif   
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbLine3DCreator.h b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbLine3DCreator.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbLine3DCreator.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbLine3DCreator.h
index 460613f8e3b65dbdad516a507501f7a035ccf13d..cb5bdb991e9ed7e65f982d860159948aceacabbd 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbLine3DCreator.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbLine3DCreator.h
@@ -1,31 +1,31 @@
-#ifndef GBLINE3DCREATOR_H
-#define GBLINE3DCREATOR_H
-
-#include <numerics/geometry3d/creator/GbObject3DCreator.h>
-#include <numerics/geometry3d/GbLine3D.h>
-
-class GbLine3DCreator : public GbObject3DCreator              
-{                                       
-public:
-   static GbLine3DCreator* getInstance()
-   {
-      static GbLine3DCreator instance;
-      return &instance;
-   }
-
-   GbLine3D* createGbObject3D() { return new GbLine3D(); }
-
-   std::string getGbObject3DTypeID(){ return "GbLine3D";        }
-   std::string toString()           { return "GbLine3DCreator"; }
-
-private:
-   GbLine3DCreator( const GbLine3DCreator& );                  //no copy allowed 
-   const GbLine3DCreator& operator=( const GbLine3DCreator& ); //no copy allowed
-   GbLine3DCreator() : GbObject3DCreator() {}
-};
-
-#ifndef SWIG
-UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbLine3DCreator::getInstance()), CAB_GbLine3DCreator);
-#endif
-
-#endif
+#ifndef GBLINE3DCREATOR_H
+#define GBLINE3DCREATOR_H
+
+#include <numerics/geometry3d/creator/GbObject3DCreator.h>
+#include <numerics/geometry3d/GbLine3D.h>
+
+class GbLine3DCreator : public GbObject3DCreator              
+{                                       
+public:
+   static GbLine3DCreator* getInstance()
+   {
+      static GbLine3DCreator instance;
+      return &instance;
+   }
+
+   GbLine3D* createGbObject3D() { return new GbLine3D(); }
+
+   std::string getGbObject3DTypeID(){ return "GbLine3D";        }
+   std::string toString()           { return "GbLine3DCreator"; }
+
+private:
+   GbLine3DCreator( const GbLine3DCreator& );                  //no copy allowed 
+   const GbLine3DCreator& operator=( const GbLine3DCreator& ); //no copy allowed
+   GbLine3DCreator() : GbObject3DCreator() {}
+};
+
+#ifndef SWIG
+UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbLine3DCreator::getInstance()), CAB_GbLine3DCreator);
+#endif
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DCreator.h b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbObject3DCreator.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DCreator.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbObject3DCreator.h
index d1a8fd785fcc325ab78252f2034663d49df3c25c..e2cc7b63882acec01c693e37423a452336079c1d 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DCreator.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbObject3DCreator.h
@@ -1,77 +1,77 @@
-#ifndef GBOBJECT3DCREATOR_H
-#define GBOBJECT3DCREATOR_H
-
-#include <string>
-
-#include <basics/objects/ObObjectCreator.h>
-#include <basics/utilities/UbAutoRun.hpp>
-
-#include <numerics/geometry3d/GbObject3D.h>
-
-#ifdef CAB_QT 
-#include <qdialog.h>
-#endif
-
-#ifdef CAB_VTK
-#include <userinterface/presentation/vtkPoElement3D.h>
-#endif
-
-#ifdef CAB_PARAVIEW 
-#include "vtkPVSource.h"
-#endif          
-
-class GbObject3DCreator : public ObObjectCreator                           
-{                                       
-protected:
-   GbObject3DCreator() {}
-private:
-   GbObject3DCreator( const GbObject3DCreator& );                  //no copy allowed !!!
-   const GbObject3DCreator& operator=( const GbObject3DCreator& ); //no copy allowed
-public:
-   virtual ~GbObject3DCreator(){}
-
-   virtual std::string getTypeID() { return getGbObject3DTypeID();}
-   virtual ObObject* createObObject()
-   {
-      return this->createGbObject3D();
-   }
-
-
-   virtual GbObject3D* createGbObject3D()=0;
-   virtual std::string getGbObject3DTypeID()=0;                       
-   virtual std::string toString() { return "GbObject3DCreator"; }     
-
-#ifdef CAB_QT 
-   virtual GbObject3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) { throw UbException(UB_EXARGS,"Not implemented..."); }
-   virtual void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0)  { throw UbException(UB_EXARGS,"Not implemented..."); }
-#endif
-   //die Teile von ObObjectCreator ...
-#ifdef CAB_QT 
-   void showSpecificInstrument(ObObject* object,QWidget* parent=0)
-   {
-      GbObject3D* geoObj = dynamic_cast<GbObject3D*>(object);
-      this->editGbObject3DwithQt(geoObj, parent);
-   }
-   virtual ObObject* createObObjectWithQt() { return this->createGbObject3DwithQt();}
-   virtual QObObjectSpecificInstrument* getSpecificInstrument() { throw UbException(UB_EXARGS,"not implemented"); }
-
-#endif
-#ifdef CAB_VTK 
-   virtual Presentator* createObjectPresentator(ObObject *object) { return NULL; }
-#endif
-
-
-#ifdef CAB_PARAVIEW 
-   virtual vtkPVSource* createPVSource(vtkPVWindow *Window) {  throw UbException(UB_EXARGS,"vtkPVSource* createPVSource"); }
-#endif
-
-
-};
-
-#include <numerics/geometry3d/creator/GbObject3DFactory.h>
-
-/*=========================================================================*/
-#endif
-
-
-
+#ifndef GBOBJECT3DCREATOR_H
+#define GBOBJECT3DCREATOR_H
+
+#include <string>
+
+#include <basics/objects/ObObjectCreator.h>
+#include <basics/utilities/UbAutoRun.hpp>
+
+#include <numerics/geometry3d/GbObject3D.h>
+
+#ifdef CAB_QT 
+#include <qdialog.h>
+#endif
+
+#ifdef CAB_VTK
+#include <userinterface/presentation/vtkPoElement3D.h>
+#endif
+
+#ifdef CAB_PARAVIEW 
+#include "vtkPVSource.h"
+#endif          
+
+class GbObject3DCreator : public ObObjectCreator                           
+{                                       
+protected:
+   GbObject3DCreator() {}
+private:
+   GbObject3DCreator( const GbObject3DCreator& );                  //no copy allowed !!!
+   const GbObject3DCreator& operator=( const GbObject3DCreator& ); //no copy allowed
+public:
+   virtual ~GbObject3DCreator(){}
+
+   virtual std::string getTypeID() { return getGbObject3DTypeID();}
+   virtual ObObject* createObObject()
+   {
+      return this->createGbObject3D();
+   }
+
+
+   virtual GbObject3D* createGbObject3D()=0;
+   virtual std::string getGbObject3DTypeID()=0;                       
+   virtual std::string toString() { return "GbObject3DCreator"; }     
+
+#ifdef CAB_QT 
+   virtual GbObject3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) { throw UbException(UB_EXARGS,"Not implemented..."); }
+   virtual void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0)  { throw UbException(UB_EXARGS,"Not implemented..."); }
+#endif
+   //die Teile von ObObjectCreator ...
+#ifdef CAB_QT 
+   void showSpecificInstrument(ObObject* object,QWidget* parent=0)
+   {
+      GbObject3D* geoObj = dynamic_cast<GbObject3D*>(object);
+      this->editGbObject3DwithQt(geoObj, parent);
+   }
+   virtual ObObject* createObObjectWithQt() { return this->createGbObject3DwithQt();}
+   virtual QObObjectSpecificInstrument* getSpecificInstrument() { throw UbException(UB_EXARGS,"not implemented"); }
+
+#endif
+#ifdef CAB_VTK 
+   virtual Presentator* createObjectPresentator(ObObject *object) { return NULL; }
+#endif
+
+
+#ifdef CAB_PARAVIEW 
+   virtual vtkPVSource* createPVSource(vtkPVWindow *Window) {  throw UbException(UB_EXARGS,"vtkPVSource* createPVSource"); }
+#endif
+
+
+};
+
+#include <numerics/geometry3d/creator/GbObject3DFactory.h>
+
+/*=========================================================================*/
+#endif
+
+
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DFactory.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbObject3DFactory.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DFactory.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbObject3DFactory.cpp
index eacc1cc086e46e0e3599dd1a318698d7d5fa2332..2b1f2412e2fd2eb02f6e99e2e89e2dc0559122f0 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DFactory.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbObject3DFactory.cpp
@@ -1,97 +1,97 @@
-#include <numerics/geometry3d/creator/GbObject3DFactory.h>
-#include <numerics/geometry3d/creator/GbObject3DCreator.h>
-//#include <numerics/geometry3d/creator/GbPoint3DCreator.h>
-// #include <numerics/geometry3d/creator/GbCuboid3DCreator.h>
-// #include <numerics/geometry3d/creator/GbSphere3DCreator.h>
-// #include <numerics/geometry3d/creator/GbCylinder3DCreator.h>
-// #include <numerics/geometry3d/creator/GbLine3DCreator.h>
-// #include <numerics/geometry3d/creator/GbPolygon3DCreator.h>
-// #include <numerics/geometry3d/creator/GbTriangle3DCreator.h>
-// #include <numerics/geometry3d/creator/GbTriangularMesh3DCreator.h>
-
-using namespace std;
-
-//GbObject3DFactory* GbObject3DFactory::instance = NULL;
-
-/*======================================================================*/
-GbObject3DFactory::GbObject3DFactory() 
-   : ObObjectFactory()
-{
-}
-/*======================================================================*/  
-GbObject3DFactory* GbObject3DFactory::getInstance()
-{
-   static GbObject3DFactory instance;
-   return &instance;
-}
-
-///*======================================================================*/
-//void GbObject3DFactory::addGbObject3DCreator(GbObject3DCreator* creator)
-//{
-//   //cout<<"Meth:"<<creator->toString()<<" Meth-ID:"<<creator->getGbObject3DTypeID()<<endl;
-//   creatorSet.insert(pair<string, GbObject3DCreator*>(creator->getGbObject3DTypeID(), creator));
-//}
-//
-//void GbObject3DFactory::deleteGbObject3DCreator(GbObject3DCreator* creator)
-//{
-//   throw UbException(UB_EXARGS,"GbObject3DFactory::deleteGbObject3DCreator not yet implemented");
-//   // this.creatorSet.delete(creator);
-//}
-
-/*======================================================================*/
-GbObject3D* GbObject3DFactory::createGbObject3D(UbFileInput *in) 
-{
-   string str = in->readString();
-   //cout<<"GbObject3DFactory::createGbObject3D:"<<str<<endl;
-
-   GbObject3D *gbObject3D = createEmptyGbObject3D(str);
-
-   if(!gbObject3D)
-      throw UbException(UB_EXARGS,"creator for type available");
-   
-   gbObject3D->read(in);
-
-   return gbObject3D;
-}
-/*======================================================================*/
-GbObject3D* GbObject3DFactory::createEmptyGbObject3D(string objectType)
-{
-   typedef std::map<string, ObObjectCreator*>::iterator CreatorIterator;
-   std::map<string, ObObjectCreator*>* creatorSet = this->getCreatorSet();
-   CreatorIterator creatorIterator = creatorSet->find(objectType);
-
-   if(creatorIterator == creatorSet->end()) 
-      throw UbException(UB_EXARGS,"factory has no creator for "+objectType);
-
-   GbObject3DCreator *creator = dynamic_cast<GbObject3DCreator*>(creatorIterator->second);
-
-   if(!creator) 
-      throw UbException(UB_EXARGS,"factory has no creator for "+objectType);
-
-   return creator->createGbObject3D();
-}
-/*======================================================================*/
-//GbObject3DCreator* GbObject3DFactory::getCreator(string objectType)
-//{
-//   CreatorIterator creatorIterator = creatorSet.find(objectType);
-//   if(creatorIterator == creatorSet.end()) throw UbException(UB_EXARGS,"factory has no creator for "+objectType);
-//   GbObject3DCreator *creator = creatorIterator->second;
-//   if(!creator) throw UbException(UB_EXARGS,"factory has no creator for "+objectType);
-//   return(creator);
-//}
-/*======================================================================*/
-string GbObject3DFactory::toString() 
-{
-   stringstream ss;
-   ss<<"GbObject2DFactory";
-   int a=1;
-   std::map<std::string, ObObjectCreator*>::iterator creatorIterator; 
-   std::map<std::string, ObObjectCreator*>* tmp = this->getCreatorSet();
-   for(creatorIterator=tmp->begin(); creatorIterator!=tmp->end(); creatorIterator++)
-   {
-      ss<<(a++)<<". ";
-      ss<<creatorIterator->second->getTypeID();
-      ss<<endl;
-   }
-   return(ss.str());
-}
+#include <numerics/geometry3d/creator/GbObject3DFactory.h>
+#include <numerics/geometry3d/creator/GbObject3DCreator.h>
+//#include <numerics/geometry3d/creator/GbPoint3DCreator.h>
+// #include <numerics/geometry3d/creator/GbCuboid3DCreator.h>
+// #include <numerics/geometry3d/creator/GbSphere3DCreator.h>
+// #include <numerics/geometry3d/creator/GbCylinder3DCreator.h>
+// #include <numerics/geometry3d/creator/GbLine3DCreator.h>
+// #include <numerics/geometry3d/creator/GbPolygon3DCreator.h>
+// #include <numerics/geometry3d/creator/GbTriangle3DCreator.h>
+// #include <numerics/geometry3d/creator/GbTriangularMesh3DCreator.h>
+
+using namespace std;
+
+//GbObject3DFactory* GbObject3DFactory::instance = NULL;
+
+/*======================================================================*/
+GbObject3DFactory::GbObject3DFactory() 
+   : ObObjectFactory()
+{
+}
+/*======================================================================*/  
+GbObject3DFactory* GbObject3DFactory::getInstance()
+{
+   static GbObject3DFactory instance;
+   return &instance;
+}
+
+///*======================================================================*/
+//void GbObject3DFactory::addGbObject3DCreator(GbObject3DCreator* creator)
+//{
+//   //cout<<"Meth:"<<creator->toString()<<" Meth-ID:"<<creator->getGbObject3DTypeID()<<endl;
+//   creatorSet.insert(pair<string, GbObject3DCreator*>(creator->getGbObject3DTypeID(), creator));
+//}
+//
+//void GbObject3DFactory::deleteGbObject3DCreator(GbObject3DCreator* creator)
+//{
+//   throw UbException(UB_EXARGS,"GbObject3DFactory::deleteGbObject3DCreator not yet implemented");
+//   // this.creatorSet.delete(creator);
+//}
+
+/*======================================================================*/
+GbObject3D* GbObject3DFactory::createGbObject3D(UbFileInput *in) 
+{
+   string str = in->readString();
+   //cout<<"GbObject3DFactory::createGbObject3D:"<<str<<endl;
+
+   GbObject3D *gbObject3D = createEmptyGbObject3D(str);
+
+   if(!gbObject3D)
+      throw UbException(UB_EXARGS,"creator for type available");
+   
+   gbObject3D->read(in);
+
+   return gbObject3D;
+}
+/*======================================================================*/
+GbObject3D* GbObject3DFactory::createEmptyGbObject3D(string objectType)
+{
+   typedef std::map<string, ObObjectCreator*>::iterator CreatorIterator;
+   std::map<string, ObObjectCreator*>* creatorSet = this->getCreatorSet();
+   CreatorIterator creatorIterator = creatorSet->find(objectType);
+
+   if(creatorIterator == creatorSet->end()) 
+      throw UbException(UB_EXARGS,"factory has no creator for "+objectType);
+
+   GbObject3DCreator *creator = dynamic_cast<GbObject3DCreator*>(creatorIterator->second);
+
+   if(!creator) 
+      throw UbException(UB_EXARGS,"factory has no creator for "+objectType);
+
+   return creator->createGbObject3D();
+}
+/*======================================================================*/
+//GbObject3DCreator* GbObject3DFactory::getCreator(string objectType)
+//{
+//   CreatorIterator creatorIterator = creatorSet.find(objectType);
+//   if(creatorIterator == creatorSet.end()) throw UbException(UB_EXARGS,"factory has no creator for "+objectType);
+//   GbObject3DCreator *creator = creatorIterator->second;
+//   if(!creator) throw UbException(UB_EXARGS,"factory has no creator for "+objectType);
+//   return(creator);
+//}
+/*======================================================================*/
+string GbObject3DFactory::toString() 
+{
+   stringstream ss;
+   ss<<"GbObject2DFactory";
+   int a=1;
+   std::map<std::string, ObObjectCreator*>::iterator creatorIterator; 
+   std::map<std::string, ObObjectCreator*>* tmp = this->getCreatorSet();
+   for(creatorIterator=tmp->begin(); creatorIterator!=tmp->end(); creatorIterator++)
+   {
+      ss<<(a++)<<". ";
+      ss<<creatorIterator->second->getTypeID();
+      ss<<endl;
+   }
+   return(ss.str());
+}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DFactory.h b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbObject3DFactory.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DFactory.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbObject3DFactory.h
index f01d1dd45f7c766a4703c3d22cf10747a394e53c..0231e34ad42493a70d5fc665864992c84789b5fb 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbObject3DFactory.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbObject3DFactory.h
@@ -1,43 +1,43 @@
-#ifndef GBOBJECT3DFACTORY_H
-#define GBOBJECT3DFACTORY_H
-
-#include <string>
-#include <sstream>
-#include <map>
-
-#include <basics/objects/ObObjectFactory.h>
-
-#include <basics/utilities/UbException.h>
-#include <basics/utilities/UbFileInput.h>
-
-class GbObject3D;
-class GbObject3DCreator;
-
-class GbObject3DFactory : public ObObjectFactory
-{
-private:
-   GbObject3DFactory();
-   GbObject3DFactory( const GbObject3DFactory& );                  //no copy allowed 
-   const GbObject3DFactory& operator=( const GbObject3DFactory& ); //no copy allowed
-public:
-   static GbObject3DFactory* getInstance();
-   
-   GbObject3D* createGbObject3D(UbFileInput* in);
-
-   //void addGbObject3DCreator(GbObject3DCreator* creator);
-   //void deleteGbObject3DCreator(GbObject3DCreator* creator);
-   //std::map<std::string, GbObject3DCreator*>* getCreatorSet() { return &creatorSet;   }
-
-   std::string toString();
-   GbObject3D* createEmptyGbObject3D(std::string objectType);
-   //GbObject3DCreator* getCreator(std::string objectTypeID);
-
-private:
-   
-   
-   //std::map<std::string, GbObject3DCreator*> creatorSet;
-   //typedef std::map<std::string, GbObject3DCreator*>::iterator CreatorIterator;
-};
-/*=========================================================================*/
-#endif
-
+#ifndef GBOBJECT3DFACTORY_H
+#define GBOBJECT3DFACTORY_H
+
+#include <string>
+#include <sstream>
+#include <map>
+
+#include <basics/objects/ObObjectFactory.h>
+
+#include <basics/utilities/UbException.h>
+#include <basics/utilities/UbFileInput.h>
+
+class GbObject3D;
+class GbObject3DCreator;
+
+class GbObject3DFactory : public ObObjectFactory
+{
+private:
+   GbObject3DFactory();
+   GbObject3DFactory( const GbObject3DFactory& );                  //no copy allowed 
+   const GbObject3DFactory& operator=( const GbObject3DFactory& ); //no copy allowed
+public:
+   static GbObject3DFactory* getInstance();
+   
+   GbObject3D* createGbObject3D(UbFileInput* in);
+
+   //void addGbObject3DCreator(GbObject3DCreator* creator);
+   //void deleteGbObject3DCreator(GbObject3DCreator* creator);
+   //std::map<std::string, GbObject3DCreator*>* getCreatorSet() { return &creatorSet;   }
+
+   std::string toString();
+   GbObject3D* createEmptyGbObject3D(std::string objectType);
+   //GbObject3DCreator* getCreator(std::string objectTypeID);
+
+private:
+   
+   
+   //std::map<std::string, GbObject3DCreator*> creatorSet;
+   //typedef std::map<std::string, GbObject3DCreator*>::iterator CreatorIterator;
+};
+/*=========================================================================*/
+#endif
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbPoint3DCreator.h b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbPoint3DCreator.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbPoint3DCreator.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbPoint3DCreator.h
index 40bb5835c3d9899cd63d18447c953eaa7a85d0b2..e861fe2cb265fce64053dc36434ad627eefcd746 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbPoint3DCreator.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbPoint3DCreator.h
@@ -1,31 +1,31 @@
-#ifndef GBPOINT3DCREATOR_H
-#define GBPOINT3DCREATOR_H
-
-#include <numerics/geometry3d/creator/GbObject3DCreator.h>
-#include <numerics/geometry3d/GbPoint3D.h>
-
-class GbPoint3DCreator : public GbObject3DCreator              
-{                                       
-public:
-   static GbPoint3DCreator* getInstance()
-   {
-      static GbPoint3DCreator instance;
-      return &instance;
-   }
-   
-   GbPoint3D* createGbObject3D() { return new GbPoint3D(); }
-   
-   std::string getGbObject3DTypeID() { return "GbPoint3D";        }
-   std::string toString()            { return "GbPoint3DCreator"; }
-
-private:
-   GbPoint3DCreator( const GbPoint3DCreator& );                  //no copy allowed 
-   const GbPoint3DCreator& operator=( const GbPoint3DCreator& ); //no copy allowed
-   GbPoint3DCreator() : GbObject3DCreator() {}
-};
-
-#ifndef SWIG
-UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbPoint3DCreator::getInstance()), CAB_GbPoint3DCreator);
-#endif
-
-#endif
+#ifndef GBPOINT3DCREATOR_H
+#define GBPOINT3DCREATOR_H
+
+#include <numerics/geometry3d/creator/GbObject3DCreator.h>
+#include <numerics/geometry3d/GbPoint3D.h>
+
+class GbPoint3DCreator : public GbObject3DCreator              
+{                                       
+public:
+   static GbPoint3DCreator* getInstance()
+   {
+      static GbPoint3DCreator instance;
+      return &instance;
+   }
+   
+   GbPoint3D* createGbObject3D() { return new GbPoint3D(); }
+   
+   std::string getGbObject3DTypeID() { return "GbPoint3D";        }
+   std::string toString()            { return "GbPoint3DCreator"; }
+
+private:
+   GbPoint3DCreator( const GbPoint3DCreator& );                  //no copy allowed 
+   const GbPoint3DCreator& operator=( const GbPoint3DCreator& ); //no copy allowed
+   GbPoint3DCreator() : GbObject3DCreator() {}
+};
+
+#ifndef SWIG
+UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbPoint3DCreator::getInstance()), CAB_GbPoint3DCreator);
+#endif
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbPolygon3DCreator.h b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbPolygon3DCreator.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbPolygon3DCreator.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbPolygon3DCreator.h
index 703397747d8caa917fd2af14b36059db9e79a9cc..72435ff0a00548e72ef071a56c23043778446ed2 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbPolygon3DCreator.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbPolygon3DCreator.h
@@ -1,32 +1,32 @@
-#ifndef GBPOLYGON3DCREATOR_H
-#define GBPOLYGON3DCREATOR_H
-
-#include <numerics/geometry3d/creator/GbObject3DCreator.h>
-#include <numerics/geometry3d/GbPoint3D.h>
-
-class GbPolygon3DCreator : public GbObject3DCreator              
-{                                       
-public:
-   static GbPolygon3DCreator* getInstance()
-   {
-      static GbPolygon3DCreator instance;
-      return &instance;
-   }
-
-   GbPolygon3D* createGbObject3D() { return new GbPolygon3D(); }
-
-   std::string getGbObject3DTypeID() { return "GbPolygon3D";        }
-   std::string toString()            { return "GbPolygon3DCreator"; }
-
-private:
-   GbPolygon3DCreator( const GbPolygon3DCreator& );                  //no copy allowed 
-   const GbPolygon3DCreator& operator=( const GbPolygon3DCreator& ); //no copy allowed
-
-   GbPolygon3DCreator() : GbObject3DCreator() {}
-};
-
-#ifndef SWIG
-UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbPolygon3DCreator::getInstance()), CAB_GbPolygon3DCreator);
-#endif
-
-#endif
+#ifndef GBPOLYGON3DCREATOR_H
+#define GBPOLYGON3DCREATOR_H
+
+#include <numerics/geometry3d/creator/GbObject3DCreator.h>
+#include <numerics/geometry3d/GbPoint3D.h>
+
+class GbPolygon3DCreator : public GbObject3DCreator              
+{                                       
+public:
+   static GbPolygon3DCreator* getInstance()
+   {
+      static GbPolygon3DCreator instance;
+      return &instance;
+   }
+
+   GbPolygon3D* createGbObject3D() { return new GbPolygon3D(); }
+
+   std::string getGbObject3DTypeID() { return "GbPolygon3D";        }
+   std::string toString()            { return "GbPolygon3DCreator"; }
+
+private:
+   GbPolygon3DCreator( const GbPolygon3DCreator& );                  //no copy allowed 
+   const GbPolygon3DCreator& operator=( const GbPolygon3DCreator& ); //no copy allowed
+
+   GbPolygon3DCreator() : GbObject3DCreator() {}
+};
+
+#ifndef SWIG
+UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbPolygon3DCreator::getInstance()), CAB_GbPolygon3DCreator);
+#endif
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp
index f0d818aa7263f0dbf5ddcdf33dc92fe067a23709..d5cc520a36972de405652a36c84975e506f50ab4 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp
@@ -1,66 +1,66 @@
-#include <numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h>
-#include <numerics/geometry3d/GbQuadFaceMesh3D.h>
-#include <basics/utilities/UbFileInputASCII.h>
-
-using namespace std;
-
-/***************************************************************************/
-GbObject3D* GbQuadFaceMesh3DCreator::createGbObject3D() 
-{ 
-   return new GbQuadFaceMesh3D(); 
-}
-/***************************************************************************/
-GbQuadFaceMesh3D* GbQuadFaceMesh3DCreator::createQuadMesh3D(int nodesX1, int nodesX2, float startX1, float startX2, double knotenabstandX1, double knotenabstandX2, float nullNiveau, string name)
-{
-   vector<GbQuadFaceMesh3D::Vertex> *vertices = new vector<GbQuadFaceMesh3D::Vertex>;
-   vector<GbQuadFaceMesh3D::QuadFace> *quads = new vector<GbQuadFaceMesh3D::QuadFace>;
-   for(int x1=0;x1<nodesX1;x1++)
-   {
-      for(int x2=0;x2<nodesX2;x2++)
-      {
-         vertices->push_back(GbQuadFaceMesh3D::Vertex((float)(x1*knotenabstandX1+startX1), (float)(x2*knotenabstandX2+startX2), nullNiveau));
-      }
-   }
-   for(int x1=0;x1<nodesX1-1;x1++)
-   {
-      for(int x2=0;x2<nodesX2-1;x2++)
-      {
-         int index = x1*nodesX2+x2;
-         quads->push_back(GbQuadFaceMesh3D::QuadFace(index, index+nodesX2, index+nodesX2+1, index+1));
-      }
-   }
-   
-   return (new GbQuadFaceMesh3D(name, vertices, quads));
-}
-
-/*============================================================*/
-
-#ifdef CAB_QT 
-
-GbQuadFaceMesh3D* GbQuadFaceMesh3DCreator::createGbObject3DwithQt()
-{
-   //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" );
-   //QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl");
-   //QFileDialog* fd = new QFileDialog( NULL );
-   //fd->setIconText(QString("Hallo"));
-   //fd->show();
-   //TODO: Open File Dialog einbauen.		
-   //UbFileInputASCII in( s.toAscii().data() );
-   //stringstream stream;
-   //stream <<"TriangularMesh3D ";//<<_objCount++;
-   //GbQuadFaceMesh3D *mesh = NULL;//GbQuadFaceMesh3DCreator::readMeshFromSTLFile(&in, stream.str() );
-   //return mesh;
-   return NULL;
-}
-//QDialog* getSpecificInstrument()  {  return 0;}
-void GbQuadFaceMesh3DCreator::editGbObject3DwithQt(GbObject3D* gbObj)
-{ 
-
-}
-#endif
-#ifdef CAB_VTK
-Presentator* GbQuadFaceMesh3DCreator::createObjectPresentator(ObObject *object) 
-{
-   return NULL;
-}
-#endif
+#include <numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h>
+#include <numerics/geometry3d/GbQuadFaceMesh3D.h>
+#include <basics/utilities/UbFileInputASCII.h>
+
+using namespace std;
+
+/***************************************************************************/
+GbObject3D* GbQuadFaceMesh3DCreator::createGbObject3D() 
+{ 
+   return new GbQuadFaceMesh3D(); 
+}
+/***************************************************************************/
+GbQuadFaceMesh3D* GbQuadFaceMesh3DCreator::createQuadMesh3D(int nodesX1, int nodesX2, float startX1, float startX2, double knotenabstandX1, double knotenabstandX2, float nullNiveau, string name)
+{
+   vector<GbQuadFaceMesh3D::Vertex> *vertices = new vector<GbQuadFaceMesh3D::Vertex>;
+   vector<GbQuadFaceMesh3D::QuadFace> *quads = new vector<GbQuadFaceMesh3D::QuadFace>;
+   for(int x1=0;x1<nodesX1;x1++)
+   {
+      for(int x2=0;x2<nodesX2;x2++)
+      {
+         vertices->push_back(GbQuadFaceMesh3D::Vertex((float)(x1*knotenabstandX1+startX1), (float)(x2*knotenabstandX2+startX2), nullNiveau));
+      }
+   }
+   for(int x1=0;x1<nodesX1-1;x1++)
+   {
+      for(int x2=0;x2<nodesX2-1;x2++)
+      {
+         int index = x1*nodesX2+x2;
+         quads->push_back(GbQuadFaceMesh3D::QuadFace(index, index+nodesX2, index+nodesX2+1, index+1));
+      }
+   }
+   
+   return (new GbQuadFaceMesh3D(name, vertices, quads));
+}
+
+/*============================================================*/
+
+#ifdef CAB_QT 
+
+GbQuadFaceMesh3D* GbQuadFaceMesh3DCreator::createGbObject3DwithQt()
+{
+   //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" );
+   //QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl");
+   //QFileDialog* fd = new QFileDialog( NULL );
+   //fd->setIconText(QString("Hallo"));
+   //fd->show();
+   //TODO: Open File Dialog einbauen.		
+   //UbFileInputASCII in( s.toAscii().data() );
+   //stringstream stream;
+   //stream <<"TriangularMesh3D ";//<<_objCount++;
+   //GbQuadFaceMesh3D *mesh = NULL;//GbQuadFaceMesh3DCreator::readMeshFromSTLFile(&in, stream.str() );
+   //return mesh;
+   return NULL;
+}
+//QDialog* getSpecificInstrument()  {  return 0;}
+void GbQuadFaceMesh3DCreator::editGbObject3DwithQt(GbObject3D* gbObj)
+{ 
+
+}
+#endif
+#ifdef CAB_VTK
+Presentator* GbQuadFaceMesh3DCreator::createObjectPresentator(ObObject *object) 
+{
+   return NULL;
+}
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h
index ac43dd4fe141e9b8b6c0150b8968d4ebf178377b..c2d779c63633f0442711644d68c38b2c13cacdd8 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h
@@ -1,52 +1,52 @@
-#ifndef GBQUADFACEMESH3DCREATOR_H
-#define GBQUADFACEMESH3DCREATOR_H
-
-#include <numerics/geometry3d/creator/GbObject3DCreator.h>
-
-class GbQuadFaceMesh3D;
-
-#ifdef CAB_QT 
-
-#endif
-
-#ifdef CAB_VTK
-//#include <numerics/geometry3d/presentation/vtkGbQuadangularMesh3D.h>
-#endif
-
-class GbQuadFaceMesh3DCreator : public GbObject3DCreator              
-{                                       
-public:
-   static GbQuadFaceMesh3DCreator* getInstance()
-   {
-      static GbQuadFaceMesh3DCreator instance;
-      return &instance;
-   }
-   static GbQuadFaceMesh3D *createQuadMesh3D(int nodesX1, int nodesX2, float startX1, float startX2, double knotenabstandX1, double knotenabstandX2, float nullNiveau, std::string name);
-
-   GbObject3D* createGbObject3D();
-   
-   std::string getGbObject3DTypeID() { return "GbQuadFaceMesh3D";        }
-   std::string toString()            { return "GbQuadFaceMesh3DCreator"; }
-
-#ifdef CAB_QT 
-
-   GbQuadFaceMesh3D* createGbObject3DwithQt();
-   //QDialog* getSpecificInstrument()  {  return 0;}
-   void editGbObject3DwithQt(GbObject3D* gbObj);
-#endif
-#ifdef CAB_VTK
-   Presentator* createObjectPresentator(ObObject *object);
-#endif
-
-
-private:
-   GbQuadFaceMesh3DCreator( const GbQuadFaceMesh3DCreator& );                  //no copy allowed 
-   const GbQuadFaceMesh3DCreator& operator=( const GbQuadFaceMesh3DCreator& ); //no copy allowed
-   GbQuadFaceMesh3DCreator() : GbObject3DCreator() {}
-};
-
-#ifndef SWIG
-UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbQuadFaceMesh3DCreator::getInstance()), CAB_GbQuadFaceMesh3DCreator);
-#endif
-
-#endif
+#ifndef GBQUADFACEMESH3DCREATOR_H
+#define GBQUADFACEMESH3DCREATOR_H
+
+#include <numerics/geometry3d/creator/GbObject3DCreator.h>
+
+class GbQuadFaceMesh3D;
+
+#ifdef CAB_QT 
+
+#endif
+
+#ifdef CAB_VTK
+//#include <numerics/geometry3d/presentation/vtkGbQuadangularMesh3D.h>
+#endif
+
+class GbQuadFaceMesh3DCreator : public GbObject3DCreator              
+{                                       
+public:
+   static GbQuadFaceMesh3DCreator* getInstance()
+   {
+      static GbQuadFaceMesh3DCreator instance;
+      return &instance;
+   }
+   static GbQuadFaceMesh3D *createQuadMesh3D(int nodesX1, int nodesX2, float startX1, float startX2, double knotenabstandX1, double knotenabstandX2, float nullNiveau, std::string name);
+
+   GbObject3D* createGbObject3D();
+   
+   std::string getGbObject3DTypeID() { return "GbQuadFaceMesh3D";        }
+   std::string toString()            { return "GbQuadFaceMesh3DCreator"; }
+
+#ifdef CAB_QT 
+
+   GbQuadFaceMesh3D* createGbObject3DwithQt();
+   //QDialog* getSpecificInstrument()  {  return 0;}
+   void editGbObject3DwithQt(GbObject3D* gbObj);
+#endif
+#ifdef CAB_VTK
+   Presentator* createObjectPresentator(ObObject *object);
+#endif
+
+
+private:
+   GbQuadFaceMesh3DCreator( const GbQuadFaceMesh3DCreator& );                  //no copy allowed 
+   const GbQuadFaceMesh3DCreator& operator=( const GbQuadFaceMesh3DCreator& ); //no copy allowed
+   GbQuadFaceMesh3DCreator() : GbObject3DCreator() {}
+};
+
+#ifndef SWIG
+UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbQuadFaceMesh3DCreator::getInstance()), CAB_GbQuadFaceMesh3DCreator);
+#endif
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbSphere3DCreator.h b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbSphere3DCreator.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbSphere3DCreator.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbSphere3DCreator.h
index 81e70daf041d2c71fb090a0c2b0034552891ee4f..30a9bfd81f17327b964af118e98817d54c3a3f62 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbSphere3DCreator.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbSphere3DCreator.h
@@ -1,126 +1,126 @@
-#ifndef GBSPHERE3DCREATOR_H
-#define GBSPHERE3DCREATOR_H
-
-#include <numerics/geometry3d/creator/GbObject3DCreator.h>
-#include <numerics/geometry3d/GbSphere3D.h>
-
-#ifdef CAB_QT 
-#include <numerics/geometry3d/presentation/QGbSphere3DInstrument.h>
-#include <QtGui/QWidget>
-#include <QtGui/QDialog>
-#endif
-
-#ifdef CAB_VTK
-#include <numerics/geometry3d/presentation/vtkGbSphere3D.h>
-#endif
-
-#ifdef CAB_PARAVIEW 
-#include "vtkSMSourceProxy.h"
-#include "vtkSMProperty.h"
-#include "vtkSMDoubleVectorProperty.h"
-#endif
-
-class GbSphere3DCreator : public GbObject3DCreator              
-{                                       
-public:
-   static GbSphere3DCreator* getInstance()
-   {
-      static GbSphere3DCreator instance;
-      return &instance;
-   }
-
-   GbSphere3D* createGbObject3D() { return new GbSphere3D(); }
-
-   std::string getGbObject3DTypeID() { return "GbSphere3D"; };
-   std::string toString()            { return "GbSphere3DCreator"; }
-
-private:
-   GbSphere3DCreator( const GbSphere3DCreator& );                  //no copy allowed 
-   const GbSphere3DCreator& operator=( const GbSphere3DCreator& ); //no copy allowed
-   GbSphere3DCreator() : GbObject3DCreator() {}
-
-#ifdef CAB_QT 
-public:
-
-   GbSphere3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0)
-   { 
-      GbSphere3D* sphere = this->createGbObject3D();
-      sphere->setRadius(3.0);
-      sphere->setCenterX1Coordinate(6.0);
-
-      QGbSphere3DInstrument instrument(parent, flags);
-      instrument.setGbSphere3D(sphere);
-      if (instrument.exec()) { return sphere; }
-      delete sphere;
-      return NULL;
-   }
-   QDialog* getSpecificInstrument(QWidget* parent=0, Qt::WFlags flags=0) { return new QGbSphere3DInstrument(parent, flags); }
-
-   void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0)
-   { 
-      GbSphere3D* sphere = dynamic_cast<GbSphere3D*>(gbObj);
-      if(!sphere) throw UbException(UB_EXARGS,"selected object to edit is no GbSphere3D");
-
-      QGbSphere3DInstrument instrument(parent, flags);
-      instrument.setGbSphere3D(sphere);
-      instrument.exec();
-   }
-#endif
-#ifdef CAB_VTK
-public:
-   Presentator* createObjectPresentator(ObObject *object) { return new vtkGbSphere3D(dynamic_cast<GbSphere3D*>(object)); }
-#endif
-  
-
-#ifdef CAB_PARAVIEW
-   vtkPVSource* createPVSource(vtkPVWindow *Window);
-#endif
-};
-
-#ifdef CAB_PARAVIEW                  
-vtkPVSource* GbSphere3DCreator::createPVSource(vtkPVWindow *Window)
-{
-   GbSphere3D *mysphere = this->createGbObject3D();
-   mysphere->setCenterX1Coordinate(2.0);
-   mysphere->setCenterX2Coordinate(1.0);
-   mysphere->setCenterX3Coordinate(3.0);
-   mysphere->setRadius(0.3);
-
-   vtkPVSource* pvs = Window->CreatePVSource("SphereSource");
-   pvs->CreateProperties();
-   if (pvs)
-   {
-      pvs->IsPermanentOn();
-      pvs->Accept(1, 1);
-      //pvs->SetTraceReferenceObject(this->GetWindow());
-      pvs->SetTraceReferenceObject(Window);
-   }
-   //vtkPVDisplayGUI *settingsGUI= pvs->GetPVOutput();
-
-   vtkSMSourceProxy* proxy = pvs->GetProxy();
-   vtkSMProperty *prop = proxy->GetProperty("Center");
-
-   vtkSMDoubleVectorProperty *doubleprop = vtkSMDoubleVectorProperty::SafeDownCast(proxy->GetProperty("Center"));
-   doubleprop->SetElement(0, mysphere->getX1Centroid());
-   doubleprop->SetElement(1, mysphere->getX2Centroid());
-   doubleprop->SetElement(2, mysphere->getX3Centroid());
-   pvs->SetLabel("Kugel");
-
-   doubleprop = vtkSMDoubleVectorProperty::SafeDownCast(proxy->GetProperty("Radius"));
-   doubleprop->SetElement(0, mysphere->getRadius());
-
-   pvs->GetPVWidget("Center")->ResetInternal();
-   pvs->GetPVWidget("Radius")->ResetInternal();
-
-   pvs->SetVisibility(TRUE);
-   pvs->AcceptCallback();
-   pvs->Update();
-   return pvs;
-}
-#endif
-
-#ifndef SWIG
-UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbSphere3DCreator::getInstance()), CAB_GbSphere3DCreator);
-#endif
-
-#endif
+#ifndef GBSPHERE3DCREATOR_H
+#define GBSPHERE3DCREATOR_H
+
+#include <numerics/geometry3d/creator/GbObject3DCreator.h>
+#include <numerics/geometry3d/GbSphere3D.h>
+
+#ifdef CAB_QT 
+#include <numerics/geometry3d/presentation/QGbSphere3DInstrument.h>
+#include <QtGui/QWidget>
+#include <QtGui/QDialog>
+#endif
+
+#ifdef CAB_VTK
+#include <numerics/geometry3d/presentation/vtkGbSphere3D.h>
+#endif
+
+#ifdef CAB_PARAVIEW 
+#include "vtkSMSourceProxy.h"
+#include "vtkSMProperty.h"
+#include "vtkSMDoubleVectorProperty.h"
+#endif
+
+class GbSphere3DCreator : public GbObject3DCreator              
+{                                       
+public:
+   static GbSphere3DCreator* getInstance()
+   {
+      static GbSphere3DCreator instance;
+      return &instance;
+   }
+
+   GbSphere3D* createGbObject3D() { return new GbSphere3D(); }
+
+   std::string getGbObject3DTypeID() { return "GbSphere3D"; };
+   std::string toString()            { return "GbSphere3DCreator"; }
+
+private:
+   GbSphere3DCreator( const GbSphere3DCreator& );                  //no copy allowed 
+   const GbSphere3DCreator& operator=( const GbSphere3DCreator& ); //no copy allowed
+   GbSphere3DCreator() : GbObject3DCreator() {}
+
+#ifdef CAB_QT 
+public:
+
+   GbSphere3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0)
+   { 
+      GbSphere3D* sphere = this->createGbObject3D();
+      sphere->setRadius(3.0);
+      sphere->setCenterX1Coordinate(6.0);
+
+      QGbSphere3DInstrument instrument(parent, flags);
+      instrument.setGbSphere3D(sphere);
+      if (instrument.exec()) { return sphere; }
+      delete sphere;
+      return NULL;
+   }
+   QDialog* getSpecificInstrument(QWidget* parent=0, Qt::WFlags flags=0) { return new QGbSphere3DInstrument(parent, flags); }
+
+   void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0)
+   { 
+      GbSphere3D* sphere = dynamic_cast<GbSphere3D*>(gbObj);
+      if(!sphere) throw UbException(UB_EXARGS,"selected object to edit is no GbSphere3D");
+
+      QGbSphere3DInstrument instrument(parent, flags);
+      instrument.setGbSphere3D(sphere);
+      instrument.exec();
+   }
+#endif
+#ifdef CAB_VTK
+public:
+   Presentator* createObjectPresentator(ObObject *object) { return new vtkGbSphere3D(dynamic_cast<GbSphere3D*>(object)); }
+#endif
+  
+
+#ifdef CAB_PARAVIEW
+   vtkPVSource* createPVSource(vtkPVWindow *Window);
+#endif
+};
+
+#ifdef CAB_PARAVIEW                  
+vtkPVSource* GbSphere3DCreator::createPVSource(vtkPVWindow *Window)
+{
+   GbSphere3D *mysphere = this->createGbObject3D();
+   mysphere->setCenterX1Coordinate(2.0);
+   mysphere->setCenterX2Coordinate(1.0);
+   mysphere->setCenterX3Coordinate(3.0);
+   mysphere->setRadius(0.3);
+
+   vtkPVSource* pvs = Window->CreatePVSource("SphereSource");
+   pvs->CreateProperties();
+   if (pvs)
+   {
+      pvs->IsPermanentOn();
+      pvs->Accept(1, 1);
+      //pvs->SetTraceReferenceObject(this->GetWindow());
+      pvs->SetTraceReferenceObject(Window);
+   }
+   //vtkPVDisplayGUI *settingsGUI= pvs->GetPVOutput();
+
+   vtkSMSourceProxy* proxy = pvs->GetProxy();
+   vtkSMProperty *prop = proxy->GetProperty("Center");
+
+   vtkSMDoubleVectorProperty *doubleprop = vtkSMDoubleVectorProperty::SafeDownCast(proxy->GetProperty("Center"));
+   doubleprop->SetElement(0, mysphere->getX1Centroid());
+   doubleprop->SetElement(1, mysphere->getX2Centroid());
+   doubleprop->SetElement(2, mysphere->getX3Centroid());
+   pvs->SetLabel("Kugel");
+
+   doubleprop = vtkSMDoubleVectorProperty::SafeDownCast(proxy->GetProperty("Radius"));
+   doubleprop->SetElement(0, mysphere->getRadius());
+
+   pvs->GetPVWidget("Center")->ResetInternal();
+   pvs->GetPVWidget("Radius")->ResetInternal();
+
+   pvs->SetVisibility(TRUE);
+   pvs->AcceptCallback();
+   pvs->Update();
+   return pvs;
+}
+#endif
+
+#ifndef SWIG
+UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbSphere3DCreator::getInstance()), CAB_GbSphere3DCreator);
+#endif
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp
index 64cf0f7f37e02f173739d862a240367a7b3bff2a..a39bf633a30e5cd697e02409ff8638213397af61 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp
@@ -1,431 +1,431 @@
-#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h>
-#include <basics/utilities/UbLogger.h>
-#include <basics/utilities/UbTiming.h>
-
-using namespace std;
-
-GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
-{
-   if(meshName.empty())
-   {
-      size_t pos=filename.rfind("/");
-      if(pos!=string::npos) meshName = filename.substr(pos+1);
-      else                  meshName = filename;
-   }
-
-   UbFileInputASCII stlfile(filename);
-   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
-   string ext=stlfile.getFileExtension();
-
-   //in "kleinbuchstaben" umwandeln
-   transform(ext.begin(), ext.end(), ext.begin(), (int(*)(int))tolower); //(int(*)(int)) ist irgendso ein fieser cast, weil tolower ne alte c-methode ist
-
-   //UBLOG(logINFO, "GbTriFaceMesh3DCreator::readMeshFromFile - read " <<filename );
-
-   if     ( !ext.compare("ply" ) ) return GbTriFaceMesh3DCreator::readMeshFromPLYFile(filename, meshName,splitAlg , removeRedundantNodes);
-   else if( !ext.compare("stl" ) ) return GbTriFaceMesh3DCreator::readMeshFromSTLFile(filename, meshName,splitAlg , removeRedundantNodes);
-   else if( !ext.compare("inp" ) ) return GbTriFaceMesh3DCreator::readMeshFromAVSFile(filename, meshName,splitAlg , removeRedundantNodes);
-   else if( !ext.compare("mesh") ) return GbTriFaceMesh3DCreator::readMeshFromMeshFile(filename, meshName,splitAlg , removeRedundantNodes);
-   //else if( !ext.compare("raw") ) return GbTriFaceMesh3DCreator::readMeshFromRAWFile(filename,splitAlg , meshName);
-   else throw UbException(UB_EXARGS,"fileformat "+ext);
-
-   return NULL;
-}
-/*======================================================================*/
-GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromMeshFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
-{
-   UbFileInputASCII meshfile(filename);
-   if(!meshfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
-   return GbTriFaceMesh3DCreator::readMeshFromMeshFile(&meshfile,meshName,splitAlg,removeRedundantNodes);
-}
-/*======================================================================*/
-GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromMeshFile(UbFileInput* in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
-{
-   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
-   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
-
-   while( !in->eof() )
-   {
-      std::string line = in->readStringLine();
-      if( line.find("Vertices") !=std::string::npos )
-         break;
-   }
-   int numVertices = in->readInteger();
-
-   UBLOG(logDEBUG1,"Number of vertices "<<numVertices);
-
-   nodes->resize(numVertices);
-   
-   float x, y, z;
-   for (int i=0; i<numVertices; i++)
-   {
-      x = in->readFloat();
-      y = in->readFloat();
-      z = in->readFloat();
-      in->readLine();
-      (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z);
-   }
-   UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done");
-
-   while( !in->eof() )
-   {
-      std::string line = in->readStringLine();
-      if( line.find("Triangles") !=std::string::npos )
-         break;
-   }
-   int numFaces = in->readInteger();
-   triangles->reserve(numFaces);
-   UBLOG(logDEBUG1,"Number of faces    "<<numFaces);
-
-   int j,k,l;
-   for(int i=0; i<numFaces; i++)
-   {
-      j = in->readInteger()-1;
-      k = in->readInteger()-1;
-      l = in->readInteger()-1;
-      in->readLine();
-
-      (*triangles).push_back(GbTriFaceMesh3D::TriFace(j,k,l));
-   }
-   UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done");
-
-   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes );
-
-   return mesh;
-}
-/*======================================================================*/
-GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromPLYFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
-{
-   UbFileInputASCII plyfile(filename);
-   if(!plyfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
-   return GbTriFaceMesh3DCreator::readMeshFromPLYFile(&plyfile,meshName,splitAlg,removeRedundantNodes);
-}
-/*======================================================================*/
-GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromPLYFile(UbFileInput* in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
-{
-   //cout<<"GbTriangularMesh3DFile.readMeshFromPLYFile !!! Dieses Format hat leider redundante Knoten ..."<<endl;
-   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
-   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
-   
-   float x, y, z;
-   string dummy;
-
-   int numVertices = in->readIntegerAfterString("element vertex");
-   int numFaces    = in->readIntegerAfterString("element face");
-   in->setPosAfterLineWithString("end_header");
-   
-   UBLOG(logDEBUG1,"Number of vertices "<<numVertices);
-   UBLOG(logDEBUG1,"Number of faces    "<<numFaces);
-   
-   nodes->resize(numVertices);
-   triangles->reserve(numFaces);
-
-   int onePercent = (int)UbMath::max(1,UbMath::integerRounding(numVertices*0.01));
-   for (int i=0; i<numVertices; i++)
-   {
-      if( i%onePercent==0 )
-         cout<<" - read vertices (#"<<numVertices<<") "<<UbMath::integerRounding(i/(double)numVertices*100.0)<<"% "<<"\r"<<flush;
-      x = in->readFloat();
-      y = in->readFloat();
-      z = in->readFloat();
-      in->readLine();
-      (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z);
-   }
-   UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done");
-
-   int p,j,k,l,n;
-   onePercent = (int)UbMath::max(1,UbMath::integerRounding(numFaces*0.01));
-   for(int i=0; i<numFaces; i++)
-   {
-      if( i%onePercent==0 ) cout<<" - read faces (#"<<numFaces<<") "<<UbMath::integerRounding(i/(double)numFaces*100.0)<<"% "<<"\r"<<flush;
-      
-      p = in->readInteger();
-      if(p==3)  //Dreieck, alles andere wird stumpf ingnoriert
-      {
-         j = in->readInteger();
-         k = in->readInteger();
-         l = in->readInteger();
-
-         if(   !UbMath::inClosedInterval(j,0,numVertices-1) 
-            || !UbMath::inClosedInterval(k,0,numVertices-1) 
-            || !UbMath::inClosedInterval(l,0,numVertices-1) ) 
-         {         
-            throw UbException(UB_EXARGS,"dreiecksindex ist groesser als max Knotenindex oder kleiner 0");
-         }
-         triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l));
-      }
-      else if(p==4)  //Viereck --> wird zu zwei Dreiecken!
-      {
-         j = in->readInteger();
-         k = in->readInteger();
-         l = in->readInteger();
-         n = in->readInteger();
-         numFaces++;
-         i++;
-
-         if(   !UbMath::inClosedInterval(j,0,numVertices-1) 
-            || !UbMath::inClosedInterval(k,0,numVertices-1) 
-            || !UbMath::inClosedInterval(l,0,numVertices-1) 
-            || !UbMath::inClosedInterval(n,0,numVertices-1) 
-            ) 
-         {         
-            throw UbException(UB_EXARGS,"vierecksindex ist groesser als max Knotenindex oder kleiner 0");
-         }
-         triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l));
-         triangles->push_back(GbTriFaceMesh3D::TriFace(l,n,j));
-      }
-
-      in->readLine();
-
-   }
-   UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done");
-
-   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes);
-   
-   return mesh;
-}
-/*======================================================================*/
-GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
-{
-   UbFileInputASCII stlfile(filename);
-   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
-   return GbTriFaceMesh3DCreator::readMeshFromSTLFile(&stlfile,meshName,splitAlg,removeRedundantNodes);
-}
-/*======================================================================*/
-GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
-{
-   UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ...");
-
-   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
-   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
-   string dummy;
-
-   double x, y, z;
-   int nr=0;
-
-   in->readLine();
-   while(dummy!="endsolid")
-   {
-      in->readLine();
-      in->readLine();
-      dummy = in->readString();
-      if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format");
-      x=in->readDouble();
-      y=in->readDouble();
-      z=in->readDouble();
-      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-      in->readLine();
-      in->readString();
-      x=in->readDouble();
-      y=in->readDouble();
-      z=in->readDouble();
-      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-      in->readLine();
-      in->readString();
-      x=in->readDouble();
-      y=in->readDouble();
-      z=in->readDouble();
-      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-      triangles->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2));
-      in->readLine();
-      in->readLine();
-      in->readLine();
-      dummy = in->readString();
-      nr+=3;
-      //std::cout<<"read mesh "<< nr <<" \n";
-   }
-
-   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes);
-   
-   return mesh;
-}
-//////////////////////////////////////////////////////////////////////////
-GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile2(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes,  bool isBinaryFormat)
-{
-   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
-   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
-   int nr=0;
-
-   if (!isBinaryFormat) {
-      ifstream in(filename.c_str());
-      if (!in.good()) 
-      {
-         delete nodes;
-         delete triangles;
-         UB_THROW(UbException(UB_EXARGS, "Can not open STL file: "+filename));
-      }
-      char title[80];
-      std::string s0, s1;
-      float n0, n1, n2, f0, f1, f2, f3, f4, f5, f6, f7, f8;
-      in.read(title, 80);
-      while (!in.eof()) {
-         in >> s0;                                // facet || endsolid
-         if (s0=="facet") {
-            in >> s1 >> n0 >> n1 >> n2;            // normal x y z
-            in >> s0 >> s1;                        // outer loop
-            in >> s0 >> f0 >> f1 >> f2;         // vertex x y z
-            in >> s0 >> f3 >> f4 >> f5;         // vertex x y z
-            in >> s0 >> f6 >> f7 >> f8;         // vertex x y z
-            in >> s0;                            // endloop
-            in >> s0;                            // endfacet
-            // Generate a new Triangle without Normal as 3 Vertices
-            nodes->push_back(GbTriFaceMesh3D::Vertex(f0, f1, f2));
-            nodes->push_back(GbTriFaceMesh3D::Vertex(f3, f4, f5));
-            nodes->push_back(GbTriFaceMesh3D::Vertex(f6, f7, f8));
-            triangles->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2));
-            nr+=3;
-         }
-         else if (s0=="endsolid") {
-            break;
-         }
-      }
-      in.close();
-   }
-   else {
-      FILE *f = fopen(filename.c_str(), "rb");
-      if (!f) 
-      {
-         delete nodes;
-         delete triangles;
-         UB_THROW(UbException(UB_EXARGS, "Can not open STL file: "+filename));
-      }
-      char title[80];
-      int nFaces;
-      fread(title, 80, 1, f);
-      fread((void*)&nFaces, 4, 1, f);
-      float v[12]; // normal=3, vertices=3*3 = 12
-      unsigned short uint16;
-      // Every Face is 50 Bytes: Normal(3*float), Vertices(9*float), 2 Bytes Spacer
-      for (size_t i=0; i<nFaces; ++i) {
-         for (size_t j=0; j<12; ++j) {
-            fread((void*)&v[j], sizeof(float), 1, f);
-         }
-         fread((void*)&uint16, sizeof(unsigned short), 1, f); // spacer between successive faces
-         nodes->push_back(GbTriFaceMesh3D::Vertex(v[3], v[4], v[5]));
-         nodes->push_back(GbTriFaceMesh3D::Vertex(v[6], v[7], v[8]));
-         nodes->push_back(GbTriFaceMesh3D::Vertex(v[9], v[10], v[11]));
-         triangles->push_back(GbTriFaceMesh3D::TriFace(nr, nr+1, nr+2));
-         nr+=3;
-      }
-      fclose(f);
-   }
-
-   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes);
-
-   return mesh;
-}
-
-/*======================================================================*/
-GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromAVSFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
-{
-   UbFileInputASCII stlfile(filename);
-   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
-   return GbTriFaceMesh3DCreator::readMeshFromAVSFile(&stlfile,meshName,splitAlg,removeRedundantNodes);
-}
-/*======================================================================*/
-GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromAVSFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg , bool removeRedundantNodes)
-{
-   UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromAVSFile !!! Dieses Format hat leider redundante Knoten ...");
-
-   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
-   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
-   string dummy;
-
-   in->readLine();
-   int numberNodes = in->readInteger();
-   int numberTris  = in->readInteger();
-   in->readLine();
-
-   double x,y,z;
-   for(int u=0;u<numberNodes;u++)
-   {
-      in->readInteger();
-      x=in->readDouble();
-      y=in->readDouble();
-      z=in->readDouble();
-      in->readLine();
-      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-   }
-   int id1,id2,id3;
-   for(int u=0;u<numberTris;u++)
-   {
-      in->readInteger();
-      in->readInteger();
-      in->readString();
-      id1 = in->readInteger();
-      id2 = in->readInteger();
-      id3 = in->readInteger();
-      triangles->push_back(GbTriFaceMesh3D::TriFace(id1-1,id2-1,id3-1));
-   }
-
-   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes);
-   
-   return mesh;
-}
-/*======================================================================*/
-GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
-{
-   UbFileInputASCII stlfile(filename);
-   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
-   return GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(&stlfile,meshName,splitAlg,removeRedundantNodes);
-}
-/*======================================================================*/
-GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
-{
-   UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromVTKASCIIFile !!! Dieses Format hat leider redundante Knoten ...");
-
-   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
-   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
-   string dummy;
-
-   in->readLine();
-   in->readLine();
-   in->readLine();
-   in->readLine();
-   
-   in->readString();
-   int numberNodes = in->readInteger();
-   in->readLine();
-
-   double x,y,z;
-   for(int u=0;u<numberNodes;u++)
-   {
-      x=in->readDouble();
-      y=in->readDouble();
-      z=in->readDouble();
-      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-      //cout<<u<<" - x,y,z:"<<x<<","<<y<<","<<z<<endl;
-      //x=in->readDouble();
-      //y=in->readDouble();
-      //z=in->readDouble();
-      //nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-      //x=in->readDouble();
-      //y=in->readDouble();
-      //z=in->readDouble();
-      //nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-      //in->readLine();
-   }
-   in->readLine();
-   in->readString();
-   int numberTris  = in->readInteger();
-   in->readLine();
-   UBLOG(logDEBUG1,"numberTris:"<<numberTris);
-
-   int id1,id2,id3;
-   for(int u=0;u<numberTris;u++)
-   {
-      in->readInteger();
-      id1 = in->readInteger();
-      id2 = in->readInteger();
-      id3 = in->readInteger();
-      triangles->push_back(GbTriFaceMesh3D::TriFace(id1,id2,id3));
-      //cout<<u<<" - id1,id2,id3:"<<id1<<","<<id2<<","<<id3<<endl;
-   }
-   UBLOG(logDEBUG1,"Tris gelesen");
-
-   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes);
-   UBLOG(logDEBUG1,"mesh erzeugt (with remove redundant nodes = "<< boolalpha <<removeRedundantNodes<<")");
-
-
-   return mesh;
-}
+#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h>
+#include <basics/utilities/UbLogger.h>
+#include <basics/utilities/UbTiming.h>
+
+using namespace std;
+
+GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
+{
+   if(meshName.empty())
+   {
+      size_t pos=filename.rfind("/");
+      if(pos!=string::npos) meshName = filename.substr(pos+1);
+      else                  meshName = filename;
+   }
+
+   UbFileInputASCII stlfile(filename);
+   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
+   string ext=stlfile.getFileExtension();
+
+   //in "kleinbuchstaben" umwandeln
+   transform(ext.begin(), ext.end(), ext.begin(), (int(*)(int))tolower); //(int(*)(int)) ist irgendso ein fieser cast, weil tolower ne alte c-methode ist
+
+   //UBLOG(logINFO, "GbTriFaceMesh3DCreator::readMeshFromFile - read " <<filename );
+
+   if     ( !ext.compare("ply" ) ) return GbTriFaceMesh3DCreator::readMeshFromPLYFile(filename, meshName,splitAlg , removeRedundantNodes);
+   else if( !ext.compare("stl" ) ) return GbTriFaceMesh3DCreator::readMeshFromSTLFile(filename, meshName,splitAlg , removeRedundantNodes);
+   else if( !ext.compare("inp" ) ) return GbTriFaceMesh3DCreator::readMeshFromAVSFile(filename, meshName,splitAlg , removeRedundantNodes);
+   else if( !ext.compare("mesh") ) return GbTriFaceMesh3DCreator::readMeshFromMeshFile(filename, meshName,splitAlg , removeRedundantNodes);
+   //else if( !ext.compare("raw") ) return GbTriFaceMesh3DCreator::readMeshFromRAWFile(filename,splitAlg , meshName);
+   else throw UbException(UB_EXARGS,"fileformat "+ext);
+
+   return NULL;
+}
+/*======================================================================*/
+GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromMeshFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
+{
+   UbFileInputASCII meshfile(filename);
+   if(!meshfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
+   return GbTriFaceMesh3DCreator::readMeshFromMeshFile(&meshfile,meshName,splitAlg,removeRedundantNodes);
+}
+/*======================================================================*/
+GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromMeshFile(UbFileInput* in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
+{
+   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
+   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
+
+   while( !in->eof() )
+   {
+      std::string line = in->readStringLine();
+      if( line.find("Vertices") !=std::string::npos )
+         break;
+   }
+   int numVertices = in->readInteger();
+
+   UBLOG(logDEBUG1,"Number of vertices "<<numVertices);
+
+   nodes->resize(numVertices);
+   
+   float x, y, z;
+   for (int i=0; i<numVertices; i++)
+   {
+      x = in->readFloat();
+      y = in->readFloat();
+      z = in->readFloat();
+      in->readLine();
+      (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z);
+   }
+   UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done");
+
+   while( !in->eof() )
+   {
+      std::string line = in->readStringLine();
+      if( line.find("Triangles") !=std::string::npos )
+         break;
+   }
+   int numFaces = in->readInteger();
+   triangles->reserve(numFaces);
+   UBLOG(logDEBUG1,"Number of faces    "<<numFaces);
+
+   int j,k,l;
+   for(int i=0; i<numFaces; i++)
+   {
+      j = in->readInteger()-1;
+      k = in->readInteger()-1;
+      l = in->readInteger()-1;
+      in->readLine();
+
+      (*triangles).push_back(GbTriFaceMesh3D::TriFace(j,k,l));
+   }
+   UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done");
+
+   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes );
+
+   return mesh;
+}
+/*======================================================================*/
+GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromPLYFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
+{
+   UbFileInputASCII plyfile(filename);
+   if(!plyfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
+   return GbTriFaceMesh3DCreator::readMeshFromPLYFile(&plyfile,meshName,splitAlg,removeRedundantNodes);
+}
+/*======================================================================*/
+GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromPLYFile(UbFileInput* in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
+{
+   //cout<<"GbTriangularMesh3DFile.readMeshFromPLYFile !!! Dieses Format hat leider redundante Knoten ..."<<endl;
+   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
+   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
+   
+   float x, y, z;
+   string dummy;
+
+   int numVertices = in->readIntegerAfterString("element vertex");
+   int numFaces    = in->readIntegerAfterString("element face");
+   in->setPosAfterLineWithString("end_header");
+   
+   UBLOG(logDEBUG1,"Number of vertices "<<numVertices);
+   UBLOG(logDEBUG1,"Number of faces    "<<numFaces);
+   
+   nodes->resize(numVertices);
+   triangles->reserve(numFaces);
+
+   int onePercent = (int)UbMath::max(1,UbMath::integerRounding(numVertices*0.01));
+   for (int i=0; i<numVertices; i++)
+   {
+      if( i%onePercent==0 )
+         cout<<" - read vertices (#"<<numVertices<<") "<<UbMath::integerRounding(i/(double)numVertices*100.0)<<"% "<<"\r"<<flush;
+      x = in->readFloat();
+      y = in->readFloat();
+      z = in->readFloat();
+      in->readLine();
+      (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z);
+   }
+   UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done");
+
+   int p,j,k,l,n;
+   onePercent = (int)UbMath::max(1,UbMath::integerRounding(numFaces*0.01));
+   for(int i=0; i<numFaces; i++)
+   {
+      if( i%onePercent==0 ) cout<<" - read faces (#"<<numFaces<<") "<<UbMath::integerRounding(i/(double)numFaces*100.0)<<"% "<<"\r"<<flush;
+      
+      p = in->readInteger();
+      if(p==3)  //Dreieck, alles andere wird stumpf ingnoriert
+      {
+         j = in->readInteger();
+         k = in->readInteger();
+         l = in->readInteger();
+
+         if(   !UbMath::inClosedInterval(j,0,numVertices-1) 
+            || !UbMath::inClosedInterval(k,0,numVertices-1) 
+            || !UbMath::inClosedInterval(l,0,numVertices-1) ) 
+         {         
+            throw UbException(UB_EXARGS,"dreiecksindex ist groesser als max Knotenindex oder kleiner 0");
+         }
+         triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l));
+      }
+      else if(p==4)  //Viereck --> wird zu zwei Dreiecken!
+      {
+         j = in->readInteger();
+         k = in->readInteger();
+         l = in->readInteger();
+         n = in->readInteger();
+         numFaces++;
+         i++;
+
+         if(   !UbMath::inClosedInterval(j,0,numVertices-1) 
+            || !UbMath::inClosedInterval(k,0,numVertices-1) 
+            || !UbMath::inClosedInterval(l,0,numVertices-1) 
+            || !UbMath::inClosedInterval(n,0,numVertices-1) 
+            ) 
+         {         
+            throw UbException(UB_EXARGS,"vierecksindex ist groesser als max Knotenindex oder kleiner 0");
+         }
+         triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l));
+         triangles->push_back(GbTriFaceMesh3D::TriFace(l,n,j));
+      }
+
+      in->readLine();
+
+   }
+   UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done");
+
+   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes);
+   
+   return mesh;
+}
+/*======================================================================*/
+GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
+{
+   UbFileInputASCII stlfile(filename);
+   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
+   return GbTriFaceMesh3DCreator::readMeshFromSTLFile(&stlfile,meshName,splitAlg,removeRedundantNodes);
+}
+/*======================================================================*/
+GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
+{
+   UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ...");
+
+   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
+   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
+   string dummy;
+
+   double x, y, z;
+   int nr=0;
+
+   in->readLine();
+   while(dummy!="endsolid")
+   {
+      in->readLine();
+      in->readLine();
+      dummy = in->readString();
+      if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format");
+      x=in->readDouble();
+      y=in->readDouble();
+      z=in->readDouble();
+      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+      in->readLine();
+      in->readString();
+      x=in->readDouble();
+      y=in->readDouble();
+      z=in->readDouble();
+      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+      in->readLine();
+      in->readString();
+      x=in->readDouble();
+      y=in->readDouble();
+      z=in->readDouble();
+      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+      triangles->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2));
+      in->readLine();
+      in->readLine();
+      in->readLine();
+      dummy = in->readString();
+      nr+=3;
+      //std::cout<<"read mesh "<< nr <<" \n";
+   }
+
+   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes);
+   
+   return mesh;
+}
+//////////////////////////////////////////////////////////////////////////
+GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile2(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes,  bool isBinaryFormat)
+{
+   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
+   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
+   int nr=0;
+
+   if (!isBinaryFormat) {
+      ifstream in(filename.c_str());
+      if (!in.good()) 
+      {
+         delete nodes;
+         delete triangles;
+         UB_THROW(UbException(UB_EXARGS, "Can not open STL file: "+filename));
+      }
+      char title[80];
+      std::string s0, s1;
+      float n0, n1, n2, f0, f1, f2, f3, f4, f5, f6, f7, f8;
+      in.read(title, 80);
+      while (!in.eof()) {
+         in >> s0;                                // facet || endsolid
+         if (s0=="facet") {
+            in >> s1 >> n0 >> n1 >> n2;            // normal x y z
+            in >> s0 >> s1;                        // outer loop
+            in >> s0 >> f0 >> f1 >> f2;         // vertex x y z
+            in >> s0 >> f3 >> f4 >> f5;         // vertex x y z
+            in >> s0 >> f6 >> f7 >> f8;         // vertex x y z
+            in >> s0;                            // endloop
+            in >> s0;                            // endfacet
+            // Generate a new Triangle without Normal as 3 Vertices
+            nodes->push_back(GbTriFaceMesh3D::Vertex(f0, f1, f2));
+            nodes->push_back(GbTriFaceMesh3D::Vertex(f3, f4, f5));
+            nodes->push_back(GbTriFaceMesh3D::Vertex(f6, f7, f8));
+            triangles->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2));
+            nr+=3;
+         }
+         else if (s0=="endsolid") {
+            break;
+         }
+      }
+      in.close();
+   }
+   else {
+      FILE *f = fopen(filename.c_str(), "rb");
+      if (!f) 
+      {
+         delete nodes;
+         delete triangles;
+         UB_THROW(UbException(UB_EXARGS, "Can not open STL file: "+filename));
+      }
+      char title[80];
+      int nFaces;
+      fread(title, 80, 1, f);
+      fread((void*)&nFaces, 4, 1, f);
+      float v[12]; // normal=3, vertices=3*3 = 12
+      unsigned short uint16;
+      // Every Face is 50 Bytes: Normal(3*float), Vertices(9*float), 2 Bytes Spacer
+      for (size_t i=0; i<nFaces; ++i) {
+         for (size_t j=0; j<12; ++j) {
+            fread((void*)&v[j], sizeof(float), 1, f);
+         }
+         fread((void*)&uint16, sizeof(unsigned short), 1, f); // spacer between successive faces
+         nodes->push_back(GbTriFaceMesh3D::Vertex(v[3], v[4], v[5]));
+         nodes->push_back(GbTriFaceMesh3D::Vertex(v[6], v[7], v[8]));
+         nodes->push_back(GbTriFaceMesh3D::Vertex(v[9], v[10], v[11]));
+         triangles->push_back(GbTriFaceMesh3D::TriFace(nr, nr+1, nr+2));
+         nr+=3;
+      }
+      fclose(f);
+   }
+
+   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes);
+
+   return mesh;
+}
+
+/*======================================================================*/
+GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromAVSFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
+{
+   UbFileInputASCII stlfile(filename);
+   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
+   return GbTriFaceMesh3DCreator::readMeshFromAVSFile(&stlfile,meshName,splitAlg,removeRedundantNodes);
+}
+/*======================================================================*/
+GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromAVSFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg , bool removeRedundantNodes)
+{
+   UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromAVSFile !!! Dieses Format hat leider redundante Knoten ...");
+
+   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
+   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
+   string dummy;
+
+   in->readLine();
+   int numberNodes = in->readInteger();
+   int numberTris  = in->readInteger();
+   in->readLine();
+
+   double x,y,z;
+   for(int u=0;u<numberNodes;u++)
+   {
+      in->readInteger();
+      x=in->readDouble();
+      y=in->readDouble();
+      z=in->readDouble();
+      in->readLine();
+      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+   }
+   int id1,id2,id3;
+   for(int u=0;u<numberTris;u++)
+   {
+      in->readInteger();
+      in->readInteger();
+      in->readString();
+      id1 = in->readInteger();
+      id2 = in->readInteger();
+      id3 = in->readInteger();
+      triangles->push_back(GbTriFaceMesh3D::TriFace(id1-1,id2-1,id3-1));
+   }
+
+   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes);
+   
+   return mesh;
+}
+/*======================================================================*/
+GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
+{
+   UbFileInputASCII stlfile(filename);
+   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
+   return GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(&stlfile,meshName,splitAlg,removeRedundantNodes);
+}
+/*======================================================================*/
+GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
+{
+   UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromVTKASCIIFile !!! Dieses Format hat leider redundante Knoten ...");
+
+   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
+   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
+   string dummy;
+
+   in->readLine();
+   in->readLine();
+   in->readLine();
+   in->readLine();
+   
+   in->readString();
+   int numberNodes = in->readInteger();
+   in->readLine();
+
+   double x,y,z;
+   for(int u=0;u<numberNodes;u++)
+   {
+      x=in->readDouble();
+      y=in->readDouble();
+      z=in->readDouble();
+      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+      //cout<<u<<" - x,y,z:"<<x<<","<<y<<","<<z<<endl;
+      //x=in->readDouble();
+      //y=in->readDouble();
+      //z=in->readDouble();
+      //nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+      //x=in->readDouble();
+      //y=in->readDouble();
+      //z=in->readDouble();
+      //nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+      //in->readLine();
+   }
+   in->readLine();
+   in->readString();
+   int numberTris  = in->readInteger();
+   in->readLine();
+   UBLOG(logDEBUG1,"numberTris:"<<numberTris);
+
+   int id1,id2,id3;
+   for(int u=0;u<numberTris;u++)
+   {
+      in->readInteger();
+      id1 = in->readInteger();
+      id2 = in->readInteger();
+      id3 = in->readInteger();
+      triangles->push_back(GbTriFaceMesh3D::TriFace(id1,id2,id3));
+      //cout<<u<<" - id1,id2,id3:"<<id1<<","<<id2<<","<<id3<<endl;
+   }
+   UBLOG(logDEBUG1,"Tris gelesen");
+
+   GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes);
+   UBLOG(logDEBUG1,"mesh erzeugt (with remove redundant nodes = "<< boolalpha <<removeRedundantNodes<<")");
+
+
+   return mesh;
+}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h
similarity index 98%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h
index 99c999a032e1e5645c7b8ab2d2b1834cbae66f83..38247cdbe76c5a5ec487674151f19a7e869e064f 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h
@@ -1,85 +1,85 @@
-#ifndef GBTRIFACEMESH3DCREATOR_H
-#define GBTRIFACEMESH3DCREATOR_H
-
-#include <numerics/geometry3d/creator/GbObject3DCreator.h>
-#include <numerics/geometry3d/GbTriFaceMesh3D.h>
-#include <basics/utilities/UbFileInputASCII.h>
-
-#ifdef CAB_QT 
-#include <qfiledialog.h>    
-#endif
-
-#ifdef CAB_VTK
-#include <numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h>
-#endif
-
-class GbTriFaceMesh3DCreator : public GbObject3DCreator              
-{                                       
-public:
-   static GbTriFaceMesh3DCreator* getInstance()
-   {
-      static GbTriFaceMesh3DCreator instance;
-      return &instance;
-   }
-   static GbTriFaceMesh3D* readMeshFromFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
-
-   static GbTriFaceMesh3D* readMeshFromMeshFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
-   static GbTriFaceMesh3D* readMeshFromMeshFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
-
-   static GbTriFaceMesh3D* readMeshFromPLYFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
-   static GbTriFaceMesh3D* readMeshFromPLYFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
-
-   static GbTriFaceMesh3D* readMeshFromSTLFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); 
-   static GbTriFaceMesh3D* readMeshFromSTLFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
-   static GbTriFaceMesh3D* readMeshFromSTLFile2(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true,  bool isBinaryFormat=true);
-
-   static GbTriFaceMesh3D* readMeshFromAVSFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); 
-   static GbTriFaceMesh3D* readMeshFromAVSFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
-
-   static GbTriFaceMesh3D* readMeshFromVTKASCIIFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); 
-   static GbTriFaceMesh3D* readMeshFromVTKASCIIFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
-
-   GbTriFaceMesh3D* createGbObject3D() { return new GbTriFaceMesh3D(); }
-   
-   std::string getGbObject3DTypeID(){ return "GbTriFaceMesh3D"; };
-   std::string toString()           { return "GbTriFaceMesh3DCreator"; }
-
-#ifdef CAB_QT 
-
-
-   GbTriFaceMesh3D* createGbObject3DwithQt()
-   {
-	   //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" );
-	   QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl");
-      //QFileDialog* fd = new QFileDialog( NULL );
-      //fd->setIconText(QString("Hallo"));
-      //fd->show();
-      //TODO: Open File Dialog einbauen.		
-      UbFileInputASCII in( s.toAscii().data() );
-      stringstream stream;
-      stream <<"TriangularMesh3D ";//<<_objCount++;
-      GbTriFaceMesh3D *mesh = NULL;//GbTriFaceMesh3DCreator::readMeshFromSTLFile(&in, stream.str() );
-      return mesh;
-   }
-   //QDialog* getSpecificInstrument()  {  return 0;}
-   void editGbObject3DwithQt(GbObject3D* gbObj)
-   { 
-   }
-#endif
-#ifdef CAB_VTK
-public:
-   Presentator* createObjectPresentator(ObObject *object) { return new vtkGbTriangularMesh3D((GbTriangularMesh3D*)object); }
-#endif
-
-
-private:
-   GbTriFaceMesh3DCreator( const GbTriFaceMesh3DCreator& );                  //no copy allowed 
-   const GbTriFaceMesh3DCreator& operator=( const GbTriFaceMesh3DCreator& ); //no copy allowed
-   GbTriFaceMesh3DCreator() : GbObject3DCreator() {}
-};
-
-#ifndef SWIG
-UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbTriFaceMesh3DCreator::getInstance()), CAB_GbTriFaceMesh3DCreator);
-#endif
-
-#endif
+#ifndef GBTRIFACEMESH3DCREATOR_H
+#define GBTRIFACEMESH3DCREATOR_H
+
+#include <numerics/geometry3d/creator/GbObject3DCreator.h>
+#include <numerics/geometry3d/GbTriFaceMesh3D.h>
+#include <basics/utilities/UbFileInputASCII.h>
+
+#ifdef CAB_QT 
+#include <qfiledialog.h>    
+#endif
+
+#ifdef CAB_VTK
+#include <numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h>
+#endif
+
+class GbTriFaceMesh3DCreator : public GbObject3DCreator              
+{                                       
+public:
+   static GbTriFaceMesh3DCreator* getInstance()
+   {
+      static GbTriFaceMesh3DCreator instance;
+      return &instance;
+   }
+   static GbTriFaceMesh3D* readMeshFromFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
+
+   static GbTriFaceMesh3D* readMeshFromMeshFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
+   static GbTriFaceMesh3D* readMeshFromMeshFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
+
+   static GbTriFaceMesh3D* readMeshFromPLYFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
+   static GbTriFaceMesh3D* readMeshFromPLYFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
+
+   static GbTriFaceMesh3D* readMeshFromSTLFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); 
+   static GbTriFaceMesh3D* readMeshFromSTLFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
+   static GbTriFaceMesh3D* readMeshFromSTLFile2(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true,  bool isBinaryFormat=true);
+
+   static GbTriFaceMesh3D* readMeshFromAVSFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); 
+   static GbTriFaceMesh3D* readMeshFromAVSFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
+
+   static GbTriFaceMesh3D* readMeshFromVTKASCIIFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); 
+   static GbTriFaceMesh3D* readMeshFromVTKASCIIFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
+
+   GbTriFaceMesh3D* createGbObject3D() { return new GbTriFaceMesh3D(); }
+   
+   std::string getGbObject3DTypeID(){ return "GbTriFaceMesh3D"; };
+   std::string toString()           { return "GbTriFaceMesh3DCreator"; }
+
+#ifdef CAB_QT 
+
+
+   GbTriFaceMesh3D* createGbObject3DwithQt()
+   {
+	   //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" );
+	   QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl");
+      //QFileDialog* fd = new QFileDialog( NULL );
+      //fd->setIconText(QString("Hallo"));
+      //fd->show();
+      //TODO: Open File Dialog einbauen.		
+      UbFileInputASCII in( s.toAscii().data() );
+      stringstream stream;
+      stream <<"TriangularMesh3D ";//<<_objCount++;
+      GbTriFaceMesh3D *mesh = NULL;//GbTriFaceMesh3DCreator::readMeshFromSTLFile(&in, stream.str() );
+      return mesh;
+   }
+   //QDialog* getSpecificInstrument()  {  return 0;}
+   void editGbObject3DwithQt(GbObject3D* gbObj)
+   { 
+   }
+#endif
+#ifdef CAB_VTK
+public:
+   Presentator* createObjectPresentator(ObObject *object) { return new vtkGbTriangularMesh3D((GbTriangularMesh3D*)object); }
+#endif
+
+
+private:
+   GbTriFaceMesh3DCreator( const GbTriFaceMesh3DCreator& );                  //no copy allowed 
+   const GbTriFaceMesh3DCreator& operator=( const GbTriFaceMesh3DCreator& ); //no copy allowed
+   GbTriFaceMesh3DCreator() : GbObject3DCreator() {}
+};
+
+#ifndef SWIG
+UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbTriFaceMesh3DCreator::getInstance()), CAB_GbTriFaceMesh3DCreator);
+#endif
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbTriangle3DCreator.h b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbTriangle3DCreator.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbTriangle3DCreator.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbTriangle3DCreator.h
index 4c075d6a022824fbd59bc15f844b48bc80221f10..54c1fd9a4a157ed62ddc75a99e8eb71c2304bf8c 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbTriangle3DCreator.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbTriangle3DCreator.h
@@ -1,31 +1,31 @@
-#ifndef GBTRIANGLE3DCREATOR_H
-#define GBTRIANGLE3DCREATOR_H
-
-#include <numerics/geometry3d/creator/GbObject3DCreator.h>
-#include <numerics/geometry3d/GbTriangle3D.h>
-
-class GbTriangle3DCreator : public GbObject3DCreator              
-{                                       
-public:
-   static GbTriangle3DCreator* getInstance()
-   {
-      static GbTriangle3DCreator instance;
-      return &instance;
-   }
-
-   GbTriangle3D* createGbObject3D() { return new GbTriangle3D(); }
-   
-   std::string getGbObject3DTypeID(){ return "GbTriangle3D";        }
-   std::string toString()           { return "GbTriangle3DCreator"; }
-
-private:
-   GbTriangle3DCreator( const GbTriangle3DCreator& ); //no copy allowed 
-   const GbTriangle3DCreator& operator=( const GbTriangle3DCreator& ); //no copy allowed
-   GbTriangle3DCreator() : GbObject3DCreator() {}
-};
-
-#ifndef SWIG
-UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbTriangle3DCreator::getInstance()), CAB_GbTriangle3DCreator);
-#endif
-
-#endif
+#ifndef GBTRIANGLE3DCREATOR_H
+#define GBTRIANGLE3DCREATOR_H
+
+#include <numerics/geometry3d/creator/GbObject3DCreator.h>
+#include <numerics/geometry3d/GbTriangle3D.h>
+
+class GbTriangle3DCreator : public GbObject3DCreator              
+{                                       
+public:
+   static GbTriangle3DCreator* getInstance()
+   {
+      static GbTriangle3DCreator instance;
+      return &instance;
+   }
+
+   GbTriangle3D* createGbObject3D() { return new GbTriangle3D(); }
+   
+   std::string getGbObject3DTypeID(){ return "GbTriangle3D";        }
+   std::string toString()           { return "GbTriangle3DCreator"; }
+
+private:
+   GbTriangle3DCreator( const GbTriangle3DCreator& ); //no copy allowed 
+   const GbTriangle3DCreator& operator=( const GbTriangle3DCreator& ); //no copy allowed
+   GbTriangle3DCreator() : GbObject3DCreator() {}
+};
+
+#ifndef SWIG
+UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbTriangle3DCreator::getInstance()), CAB_GbTriangle3DCreator);
+#endif
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbTriangularMesh3DCreator.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbTriangularMesh3DCreator.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbTriangularMesh3DCreator.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbTriangularMesh3DCreator.cpp
index bfb42296037a0b86bc374b083250e2889fa9e5ee..0b3f297cd65edeb16280d37130ef2faf61e7d46d 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbTriangularMesh3DCreator.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbTriangularMesh3DCreator.cpp
@@ -1,258 +1,258 @@
-#include <numerics/geometry3d/creator/GbTriangularMesh3DCreator.h>
-#include <algorithm>
-#include <basics/utilities/UbLogger.h>
-
-using namespace std;
-                                               
-GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromFile(string filename, string meshName)
-{
-   if(meshName.empty())
-   {
-      size_t pos=filename.rfind("/");
-      if(pos!=string::npos) meshName = filename.substr(pos+1);
-      else                  meshName = filename; 
-   }
-   
-   UbFileInputASCII stlfile(filename);
-   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
-   string ext=stlfile.getFileExtension();
-
-   //in "kleinbuchstaben" umwandeln
-   transform(ext.begin(), ext.end(), ext.begin(), (int(*)(int))tolower);
-
-   if     ( !ext.compare("ply") ) return GbTriangularMesh3DCreator::readMeshFromPLYFile(filename, meshName);
-   else if( !ext.compare("stl") ) return GbTriangularMesh3DCreator::readMeshFromSTLFile(filename, meshName);
-   else if( !ext.compare("gts") ) return GbTriangularMesh3DCreator::readMeshFromGTSFile(filename, meshName);
-   else if( !ext.compare("raw") ) return GbTriangularMesh3DCreator::readMeshFromRAWFile(filename, meshName);
-   else throw UbException(UB_EXARGS,"unrecognized fileformat "+ext);
-
-   return NULL;
-}
-/*======================================================================*/
-GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromSTLFile(string filename, string meshName) 
-{
-   UbFileInputASCII stlfile(filename);
-   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
-   return GbTriangularMesh3DCreator::readMeshFromSTLFile(&stlfile,meshName);
-}
-/*======================================================================*/
-GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromSTLFile(UbFileInput* in, string meshName) 
-{
-   UBLOG(logINFO,"GbTriangularMesh3DFile.readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ...");
-   vector<GbPoint3D*>     *nodes     = new vector<GbPoint3D*>;
-   vector<GbTriangle3D*>  *triangles = new vector<GbTriangle3D*>;
-   nodes->resize(0, NULL);
-   triangles->resize(0, NULL);
-   double x, y, z;
-   //int nr=0;
-   string dummy;
-   GbPoint3D     *node1    = NULL;                      
-   GbPoint3D     *node2    = NULL;
-   GbPoint3D     *node3    = NULL;
-   GbTriangle3D *triangle = NULL;
-   in->readLine();
-   while(dummy!="endsolid")
-   {		
-      in->readLine();	
-      in->readLine();	
-      dummy = in->readString(); if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format");
-      x=in->readDouble(); 
-      y=in->readDouble();           
-      z=in->readDouble(); 
-      node1 = new GbPoint3D(x,y,z); nodes->push_back(node1);
-      in->readLine();	
-      in->readString();	
-      x=in->readDouble();
-      y=in->readDouble(); 
-      z=in->readDouble();	
-      node2 = new GbPoint3D(x,y,z); nodes->push_back(node2);
-      in->readLine();	
-      in->readString();	
-      x=in->readDouble();
-      y=in->readDouble(); 
-      z=in->readDouble();	
-      node3 = new GbPoint3D(x,y,z); nodes->push_back(node3); 
-      triangle = new GbTriangle3D(node1, node2, node3); triangles->push_back(triangle);
-      in->readLine();
-      in->readLine();
-      in->readLine();
-      dummy = in->readString();		
-   }
-   return new GbTriangularMesh3D(meshName, nodes, triangles);
-}                                     
-/*======================================================================*/
-/**
-* Returns a triangular mesh created from the specified TICAD source ASCII stream (system.dat format).
-* @param in the input stream
-* @param meshName the name of the created mesh
-* @return a triangular mesh created from the specified TICAD source ASCII stream
-* @exception IOException if any error occurs in creating the triangular mesh
-*/
-GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromGTSFile(string inputfile, string meshName) 
-{
-   UbFileInputASCII gtlfile(inputfile);
-   if(!gtlfile) throw UbException(UB_EXARGS,"cannot open file "+inputfile);
-   return GbTriangularMesh3DCreator::readMeshFromGTSFile(&gtlfile,meshName);
-}
-/*======================================================================*/
-GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromGTSFile(UbFileInput *in, string meshName) 
-{
-   UBLOG(logINFO,"GbTriangularMesh3DFile.readMeshFromGTSFile !!! ");
-   vector<GbPoint3D*>     *nodes     = new vector<GbPoint3D*>;
-   vector<GbLine3D*>      *edges     = new vector<GbLine3D*>;
-   vector<GbTriangle3D*>  *triangles = new vector<GbTriangle3D*>;
-   nodes->resize(0, NULL);
-   edges->resize(0, NULL);
-   triangles->resize(0, NULL);
-   double x, y, z;
-   int point1, point2, point3;
-   //int nr = 0;
-   //in->readLine();
-   int nodesize     = in->readInteger();
-   int edgesize     = in->readInteger();
-   int trianglesize = in->readInteger();
-   UBLOG(logINFO,"node-/edge-/trianglesize: "<<nodesize<<" / "<<edgesize<<" / "<<trianglesize);
-
-   for(int i=0; i<nodesize;i++)
-   {		
-      in->readLine();	
-      x=in->readDouble(); 
-      y=in->readDouble();  
-      z=in->readDouble(); 
-      nodes->push_back(new GbPoint3D(x,y,z));
-   }
-   for(int i=0; i<edgesize;i++)
-   {		
-      in->readLine();	
-      point1=in->readInteger()-1; 
-      point2=in->readInteger()-1; 
-      edges->push_back(new GbLine3D((*nodes)[point1],(*nodes)[point2]));
-   }
-   for(int i=0; i<trianglesize;i++)
-   {		
-      in->readLine();	
-      point1=in->readInteger();                
-      point2=in->readInteger(); 
-      point3=in->readInteger(); 
-      //triangles->push_back(new GbTriangle3D((*nodes)[point1-1],(*nodes)[point2-1],(*nodes)[point3-1]));
-      triangles->push_back(new GbTriangle3D((GbPoint3D*)(*edges)[point1-1]->getPoint1(),(GbPoint3D*)(*edges)[point2-1]->getPoint1(),(GbPoint3D*)(*edges)[point3-1]->getPoint1()));
-   }
-   return(new GbTriangularMesh3D(meshName, nodes, edges, triangles));
-}                                  
-/*======================================================================*/
-/**
-* Returns a triangular mesh created from the specified TICAD source ASCII stream (system.dat format).
-* @param in the input stream
-* @param meshName the name of the created mesh
-* @return a triangular mesh created from the specified TICAD source ASCII stream
-* @exception IOException if any error occurs in creating the triangular mesh
-*/
-GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromPLYFile(string inputfile, string meshName) 
-{
-   UbFileInputASCII plyfile(inputfile);
-   if(!plyfile) throw UbException(UB_EXARGS,"cannot open file "+inputfile);
-   return GbTriangularMesh3DCreator::readMeshFromPLYFile(&plyfile,meshName);
-}
-/*======================================================================*/
-GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromPLYFile(UbFileInput *in, string meshName) 
-{
-   //cout<<"GbTriangularMesh3DFile.readMeshFromPLYFile !!! Dieses Format hat leider redundante Knoten ..."<<endl;
-   vector<GbPoint3D*>     *nodes     = new vector<GbPoint3D*>;
-   vector<GbTriangle3D*>  *triangles = new vector<GbTriangle3D*>;
-   nodes->resize(0, NULL);
-   triangles->resize(0, NULL);
-   double x, y, z;
-   int nr=0;
-   string dummy;
-   int numVertices, numFaces;
-   GbPoint3D     *node     = NULL;
-   GbPoint3D     *node1    = NULL;
-   GbPoint3D     *node2    = NULL;
-   GbPoint3D     *node3    = NULL;
-   GbTriangle3D *triangle = NULL;
-   in->readLine();
-   in->readLine();
-   in->readString(); in->readString(); numVertices = in->readInteger();
-   in->readLine();
-   in->readLine();
-   in->readLine();
-   in->readLine();
-   in->readLine();
-   in->readLine();
-   in->readLine();
-   in->readString(); in->readString(); numFaces = in->readInteger(); in->readLine();
-   in->readLine();
-   in->readLine();
-   UBLOG(logINFO,"Number of vertices "<<numVertices);
-   UBLOG(logINFO,"Number of faces    "<<numFaces);
-   for (int i=0; i<numVertices; i++)
-   {
-      x = in->readDouble();
-      y = in->readDouble();
-      z = in->readDouble();
-      //       cout<<x<<y<<z;
-      //       in->readString(); in->readString(); in->readString();
-      in->readLine();
-      node = new GbPoint3D(x,y,z); nodes->push_back(node); 
-   }
-   nr=0;
-
-   for (int i=0; i<numFaces; i++)
-   {
-      in->readString();
-      int j,k,l;
-      j = in->readInteger(); k = in->readInteger(); l = in->readInteger();
-      node1 = (*nodes)[j];
-      node2 = (*nodes)[k];
-      node3 = (*nodes)[l];
-      in->readLine();
-      nr++;
-      triangle = new GbTriangle3D(node1, node2, node3); triangles->push_back(triangle); 
-   }
-
-   return(new GbTriangularMesh3D(meshName, nodes, triangles));
-}
-/*======================================================================*/
-GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromRAWFile(string inputfile, string meshName) 
-{
-   UbFileInputASCII stlfile(inputfile);
-   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+inputfile);
-   return GbTriangularMesh3DCreator::readMeshFromRAWFile(&stlfile,meshName);
-}
-/*======================================================================*/
-GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromRAWFile(UbFileInput *in, string meshName) 
-{
-   UBLOG(logINFO,"GbTriangularMesh3DFile.readMeshFromGTSFile !!! ");
-   vector<GbPoint3D*>     *nodes     = new vector<GbPoint3D*>;
-   vector<GbLine3D*>      *edges     = new vector<GbLine3D*>;
-   vector<GbTriangle3D*>  *triangles = new vector<GbTriangle3D*>;
-   nodes->resize(0, NULL);
-   edges->resize(0, NULL);
-   triangles->resize(0, NULL);
-   double x, y, z;
-   int point1, point2, point3;
-   //int nr = 0;
-   //in->readLine();
-   int nodesize     = in->readInteger();
-   int trianglesize = in->readInteger();
-   int edgesize = 0;
-   UBLOG(logINFO,"node-/edge-/trianglesize "<<nodesize<<" / "<<edgesize<<" / "<<trianglesize);
-
-   for(int i=0; i<nodesize;i++)
-   {		
-      in->readLine();	
-      x=in->readDouble(); 
-      y=in->readDouble();  
-      z=in->readDouble(); 
-      nodes->push_back(new GbPoint3D(x,y,z));
-   }
-   for(int i=0; i<trianglesize;i++)
-   {		
-      in->readLine();	
-      point1=in->readInteger();                
-      point2=in->readInteger(); 
-      point3=in->readInteger(); 
-      triangles->push_back(new GbTriangle3D((*nodes)[point1],(*nodes)[point2],(*nodes)[point3]));
-   }
-   return(new GbTriangularMesh3D(meshName, nodes, edges, triangles));
-}                                  
+#include <numerics/geometry3d/creator/GbTriangularMesh3DCreator.h>
+#include <algorithm>
+#include <basics/utilities/UbLogger.h>
+
+using namespace std;
+                                               
+GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromFile(string filename, string meshName)
+{
+   if(meshName.empty())
+   {
+      size_t pos=filename.rfind("/");
+      if(pos!=string::npos) meshName = filename.substr(pos+1);
+      else                  meshName = filename; 
+   }
+   
+   UbFileInputASCII stlfile(filename);
+   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
+   string ext=stlfile.getFileExtension();
+
+   //in "kleinbuchstaben" umwandeln
+   transform(ext.begin(), ext.end(), ext.begin(), (int(*)(int))tolower);
+
+   if     ( !ext.compare("ply") ) return GbTriangularMesh3DCreator::readMeshFromPLYFile(filename, meshName);
+   else if( !ext.compare("stl") ) return GbTriangularMesh3DCreator::readMeshFromSTLFile(filename, meshName);
+   else if( !ext.compare("gts") ) return GbTriangularMesh3DCreator::readMeshFromGTSFile(filename, meshName);
+   else if( !ext.compare("raw") ) return GbTriangularMesh3DCreator::readMeshFromRAWFile(filename, meshName);
+   else throw UbException(UB_EXARGS,"unrecognized fileformat "+ext);
+
+   return NULL;
+}
+/*======================================================================*/
+GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromSTLFile(string filename, string meshName) 
+{
+   UbFileInputASCII stlfile(filename);
+   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
+   return GbTriangularMesh3DCreator::readMeshFromSTLFile(&stlfile,meshName);
+}
+/*======================================================================*/
+GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromSTLFile(UbFileInput* in, string meshName) 
+{
+   UBLOG(logINFO,"GbTriangularMesh3DFile.readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ...");
+   vector<GbPoint3D*>     *nodes     = new vector<GbPoint3D*>;
+   vector<GbTriangle3D*>  *triangles = new vector<GbTriangle3D*>;
+   nodes->resize(0, NULL);
+   triangles->resize(0, NULL);
+   double x, y, z;
+   //int nr=0;
+   string dummy;
+   GbPoint3D     *node1    = NULL;                      
+   GbPoint3D     *node2    = NULL;
+   GbPoint3D     *node3    = NULL;
+   GbTriangle3D *triangle = NULL;
+   in->readLine();
+   while(dummy!="endsolid")
+   {		
+      in->readLine();	
+      in->readLine();	
+      dummy = in->readString(); if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format");
+      x=in->readDouble(); 
+      y=in->readDouble();           
+      z=in->readDouble(); 
+      node1 = new GbPoint3D(x,y,z); nodes->push_back(node1);
+      in->readLine();	
+      in->readString();	
+      x=in->readDouble();
+      y=in->readDouble(); 
+      z=in->readDouble();	
+      node2 = new GbPoint3D(x,y,z); nodes->push_back(node2);
+      in->readLine();	
+      in->readString();	
+      x=in->readDouble();
+      y=in->readDouble(); 
+      z=in->readDouble();	
+      node3 = new GbPoint3D(x,y,z); nodes->push_back(node3); 
+      triangle = new GbTriangle3D(node1, node2, node3); triangles->push_back(triangle);
+      in->readLine();
+      in->readLine();
+      in->readLine();
+      dummy = in->readString();		
+   }
+   return new GbTriangularMesh3D(meshName, nodes, triangles);
+}                                     
+/*======================================================================*/
+/**
+* Returns a triangular mesh created from the specified TICAD source ASCII stream (system.dat format).
+* @param in the input stream
+* @param meshName the name of the created mesh
+* @return a triangular mesh created from the specified TICAD source ASCII stream
+* @exception IOException if any error occurs in creating the triangular mesh
+*/
+GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromGTSFile(string inputfile, string meshName) 
+{
+   UbFileInputASCII gtlfile(inputfile);
+   if(!gtlfile) throw UbException(UB_EXARGS,"cannot open file "+inputfile);
+   return GbTriangularMesh3DCreator::readMeshFromGTSFile(&gtlfile,meshName);
+}
+/*======================================================================*/
+GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromGTSFile(UbFileInput *in, string meshName) 
+{
+   UBLOG(logINFO,"GbTriangularMesh3DFile.readMeshFromGTSFile !!! ");
+   vector<GbPoint3D*>     *nodes     = new vector<GbPoint3D*>;
+   vector<GbLine3D*>      *edges     = new vector<GbLine3D*>;
+   vector<GbTriangle3D*>  *triangles = new vector<GbTriangle3D*>;
+   nodes->resize(0, NULL);
+   edges->resize(0, NULL);
+   triangles->resize(0, NULL);
+   double x, y, z;
+   int point1, point2, point3;
+   //int nr = 0;
+   //in->readLine();
+   int nodesize     = in->readInteger();
+   int edgesize     = in->readInteger();
+   int trianglesize = in->readInteger();
+   UBLOG(logINFO,"node-/edge-/trianglesize: "<<nodesize<<" / "<<edgesize<<" / "<<trianglesize);
+
+   for(int i=0; i<nodesize;i++)
+   {		
+      in->readLine();	
+      x=in->readDouble(); 
+      y=in->readDouble();  
+      z=in->readDouble(); 
+      nodes->push_back(new GbPoint3D(x,y,z));
+   }
+   for(int i=0; i<edgesize;i++)
+   {		
+      in->readLine();	
+      point1=in->readInteger()-1; 
+      point2=in->readInteger()-1; 
+      edges->push_back(new GbLine3D((*nodes)[point1],(*nodes)[point2]));
+   }
+   for(int i=0; i<trianglesize;i++)
+   {		
+      in->readLine();	
+      point1=in->readInteger();                
+      point2=in->readInteger(); 
+      point3=in->readInteger(); 
+      //triangles->push_back(new GbTriangle3D((*nodes)[point1-1],(*nodes)[point2-1],(*nodes)[point3-1]));
+      triangles->push_back(new GbTriangle3D((GbPoint3D*)(*edges)[point1-1]->getPoint1(),(GbPoint3D*)(*edges)[point2-1]->getPoint1(),(GbPoint3D*)(*edges)[point3-1]->getPoint1()));
+   }
+   return(new GbTriangularMesh3D(meshName, nodes, edges, triangles));
+}                                  
+/*======================================================================*/
+/**
+* Returns a triangular mesh created from the specified TICAD source ASCII stream (system.dat format).
+* @param in the input stream
+* @param meshName the name of the created mesh
+* @return a triangular mesh created from the specified TICAD source ASCII stream
+* @exception IOException if any error occurs in creating the triangular mesh
+*/
+GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromPLYFile(string inputfile, string meshName) 
+{
+   UbFileInputASCII plyfile(inputfile);
+   if(!plyfile) throw UbException(UB_EXARGS,"cannot open file "+inputfile);
+   return GbTriangularMesh3DCreator::readMeshFromPLYFile(&plyfile,meshName);
+}
+/*======================================================================*/
+GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromPLYFile(UbFileInput *in, string meshName) 
+{
+   //cout<<"GbTriangularMesh3DFile.readMeshFromPLYFile !!! Dieses Format hat leider redundante Knoten ..."<<endl;
+   vector<GbPoint3D*>     *nodes     = new vector<GbPoint3D*>;
+   vector<GbTriangle3D*>  *triangles = new vector<GbTriangle3D*>;
+   nodes->resize(0, NULL);
+   triangles->resize(0, NULL);
+   double x, y, z;
+   int nr=0;
+   string dummy;
+   int numVertices, numFaces;
+   GbPoint3D     *node     = NULL;
+   GbPoint3D     *node1    = NULL;
+   GbPoint3D     *node2    = NULL;
+   GbPoint3D     *node3    = NULL;
+   GbTriangle3D *triangle = NULL;
+   in->readLine();
+   in->readLine();
+   in->readString(); in->readString(); numVertices = in->readInteger();
+   in->readLine();
+   in->readLine();
+   in->readLine();
+   in->readLine();
+   in->readLine();
+   in->readLine();
+   in->readLine();
+   in->readString(); in->readString(); numFaces = in->readInteger(); in->readLine();
+   in->readLine();
+   in->readLine();
+   UBLOG(logINFO,"Number of vertices "<<numVertices);
+   UBLOG(logINFO,"Number of faces    "<<numFaces);
+   for (int i=0; i<numVertices; i++)
+   {
+      x = in->readDouble();
+      y = in->readDouble();
+      z = in->readDouble();
+      //       cout<<x<<y<<z;
+      //       in->readString(); in->readString(); in->readString();
+      in->readLine();
+      node = new GbPoint3D(x,y,z); nodes->push_back(node); 
+   }
+   nr=0;
+
+   for (int i=0; i<numFaces; i++)
+   {
+      in->readString();
+      int j,k,l;
+      j = in->readInteger(); k = in->readInteger(); l = in->readInteger();
+      node1 = (*nodes)[j];
+      node2 = (*nodes)[k];
+      node3 = (*nodes)[l];
+      in->readLine();
+      nr++;
+      triangle = new GbTriangle3D(node1, node2, node3); triangles->push_back(triangle); 
+   }
+
+   return(new GbTriangularMesh3D(meshName, nodes, triangles));
+}
+/*======================================================================*/
+GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromRAWFile(string inputfile, string meshName) 
+{
+   UbFileInputASCII stlfile(inputfile);
+   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+inputfile);
+   return GbTriangularMesh3DCreator::readMeshFromRAWFile(&stlfile,meshName);
+}
+/*======================================================================*/
+GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromRAWFile(UbFileInput *in, string meshName) 
+{
+   UBLOG(logINFO,"GbTriangularMesh3DFile.readMeshFromGTSFile !!! ");
+   vector<GbPoint3D*>     *nodes     = new vector<GbPoint3D*>;
+   vector<GbLine3D*>      *edges     = new vector<GbLine3D*>;
+   vector<GbTriangle3D*>  *triangles = new vector<GbTriangle3D*>;
+   nodes->resize(0, NULL);
+   edges->resize(0, NULL);
+   triangles->resize(0, NULL);
+   double x, y, z;
+   int point1, point2, point3;
+   //int nr = 0;
+   //in->readLine();
+   int nodesize     = in->readInteger();
+   int trianglesize = in->readInteger();
+   int edgesize = 0;
+   UBLOG(logINFO,"node-/edge-/trianglesize "<<nodesize<<" / "<<edgesize<<" / "<<trianglesize);
+
+   for(int i=0; i<nodesize;i++)
+   {		
+      in->readLine();	
+      x=in->readDouble(); 
+      y=in->readDouble();  
+      z=in->readDouble(); 
+      nodes->push_back(new GbPoint3D(x,y,z));
+   }
+   for(int i=0; i<trianglesize;i++)
+   {		
+      in->readLine();	
+      point1=in->readInteger();                
+      point2=in->readInteger(); 
+      point3=in->readInteger(); 
+      triangles->push_back(new GbTriangle3D((*nodes)[point1],(*nodes)[point2],(*nodes)[point3]));
+   }
+   return(new GbTriangularMesh3D(meshName, nodes, edges, triangles));
+}                                  
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbTriangularMesh3DCreator.h b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbTriangularMesh3DCreator.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbTriangularMesh3DCreator.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbTriangularMesh3DCreator.h
index d090115e321256764dae67df8afcad2e07df2a7e..d449f0849d034f28318f03b39bf74781d86c36f0 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbTriangularMesh3DCreator.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbTriangularMesh3DCreator.h
@@ -1,83 +1,83 @@
-#ifndef GBTRIANGULARMESH3DCREATOR_H
-#define GBTRIANGULARMESH3DCREATOR_H
-
-#include <numerics/geometry3d/creator/GbObject3DCreator.h>
-#include <numerics/geometry3d/GbTriangularMesh3D.h>
-#include <basics/utilities/UbFileInputASCII.h>
-
-#ifdef CAB_QT 
-#include <qfiledialog.h>    
-#endif
-
-#ifdef CAB_VTK
-#include <numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h>
-#endif
-
-class GbTriangularMesh3DCreator : public GbObject3DCreator              
-{                                       
-public:
-   static GbTriangularMesh3DCreator* getInstance()
-   {
-      static GbTriangularMesh3DCreator instance;
-      return &instance;
-   }
-   
-   static GbTriangularMesh3D* readMeshFromFile(std::string filename, std::string meshName="");
-
-   static GbTriangularMesh3D* readMeshFromSTLFile(std::string filename, std::string meshName);
-   static GbTriangularMesh3D* readMeshFromGTSFile(std::string filename, std::string meshName);     
-   static GbTriangularMesh3D* readMeshFromPLYFile(std::string filename, std::string meshName);
-   //static GbTriangularMesh3D* readMeshFromAVSFile(std::string filename, std::string meshName);
-   static GbTriangularMesh3D* readMeshFromRAWFile(std::string inputFile, std::string meshName);
-
-   static GbTriangularMesh3D* readMeshFromSTLFile(UbFileInput* infile, std::string meshName);
-   static GbTriangularMesh3D* readMeshFromGTSFile(UbFileInput* infile, std::string meshName);     
-   static GbTriangularMesh3D* readMeshFromPLYFile(UbFileInput* infile, std::string meshName);
-   //static GbTriangularMesh3D* readMeshFromAVSFile(UbFileInput* infile, std::string meshName);
-   static GbTriangularMesh3D* readMeshFromRAWFile(UbFileInput* infile, std::string meshName);
-	
-   
-	GbTriangularMesh3D* createGbObject3D() { return new GbTriangularMesh3D(); }
-   
-   std::string getGbObject3DTypeID(){ return "GbTriangularMesh3D"; };
-   std::string toString()           { return "GbTriangularMesh3DCreator"; }
-
-#ifdef CAB_QT 
-
-   GbTriangularMesh3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0)
-   {
-	   //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" );
-	   QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl");
-      //QFileDialog* fd = new QFileDialog( NULL );
-      //fd->setIconText(QString("Hallo"));
-      //fd->show();
-      //TODO: Open File Dialog einbauen.		
-      UbFileInputASCII in( s.toAscii().data() );
-      stringstream stream;
-      stream <<"TriangularMesh3D ";//<<_objCount++;
-      GbTriangularMesh3D *mesh = GbTriangularMesh3DCreator::readMeshFromSTLFile(&in, stream.str() );
-      mesh->deleteRedundantNodes();
-      return mesh;
-   }
-   //QDialog* getSpecificInstrument()  {  return 0;}
-   void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0)
-   { 
-   }
-#endif
-#ifdef CAB_VTK
-public:
-   Presentator* createObjectPresentator(ObObject *object) { return new vtkGbTriangularMesh3D((GbTriangularMesh3D*)object); }
-#endif
-
-
-private:
-   GbTriangularMesh3DCreator( const GbTriangularMesh3DCreator& );                  //no copy allowed 
-   const GbTriangularMesh3DCreator& operator=( const GbTriangularMesh3DCreator& ); //no copy allowed
-   GbTriangularMesh3DCreator() : GbObject3DCreator() {}
-};
-
-#ifndef SWIG
-UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbTriangularMesh3DCreator::getInstance()), CAB_GbTriangularMesh3DCreator);
-#endif
-
-#endif
+#ifndef GBTRIANGULARMESH3DCREATOR_H
+#define GBTRIANGULARMESH3DCREATOR_H
+
+#include <numerics/geometry3d/creator/GbObject3DCreator.h>
+#include <numerics/geometry3d/GbTriangularMesh3D.h>
+#include <basics/utilities/UbFileInputASCII.h>
+
+#ifdef CAB_QT 
+#include <qfiledialog.h>    
+#endif
+
+#ifdef CAB_VTK
+#include <numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h>
+#endif
+
+class GbTriangularMesh3DCreator : public GbObject3DCreator              
+{                                       
+public:
+   static GbTriangularMesh3DCreator* getInstance()
+   {
+      static GbTriangularMesh3DCreator instance;
+      return &instance;
+   }
+   
+   static GbTriangularMesh3D* readMeshFromFile(std::string filename, std::string meshName="");
+
+   static GbTriangularMesh3D* readMeshFromSTLFile(std::string filename, std::string meshName);
+   static GbTriangularMesh3D* readMeshFromGTSFile(std::string filename, std::string meshName);     
+   static GbTriangularMesh3D* readMeshFromPLYFile(std::string filename, std::string meshName);
+   //static GbTriangularMesh3D* readMeshFromAVSFile(std::string filename, std::string meshName);
+   static GbTriangularMesh3D* readMeshFromRAWFile(std::string inputFile, std::string meshName);
+
+   static GbTriangularMesh3D* readMeshFromSTLFile(UbFileInput* infile, std::string meshName);
+   static GbTriangularMesh3D* readMeshFromGTSFile(UbFileInput* infile, std::string meshName);     
+   static GbTriangularMesh3D* readMeshFromPLYFile(UbFileInput* infile, std::string meshName);
+   //static GbTriangularMesh3D* readMeshFromAVSFile(UbFileInput* infile, std::string meshName);
+   static GbTriangularMesh3D* readMeshFromRAWFile(UbFileInput* infile, std::string meshName);
+	
+   
+	GbTriangularMesh3D* createGbObject3D() { return new GbTriangularMesh3D(); }
+   
+   std::string getGbObject3DTypeID(){ return "GbTriangularMesh3D"; };
+   std::string toString()           { return "GbTriangularMesh3DCreator"; }
+
+#ifdef CAB_QT 
+
+   GbTriangularMesh3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0)
+   {
+	   //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" );
+	   QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl");
+      //QFileDialog* fd = new QFileDialog( NULL );
+      //fd->setIconText(QString("Hallo"));
+      //fd->show();
+      //TODO: Open File Dialog einbauen.		
+      UbFileInputASCII in( s.toAscii().data() );
+      stringstream stream;
+      stream <<"TriangularMesh3D ";//<<_objCount++;
+      GbTriangularMesh3D *mesh = GbTriangularMesh3DCreator::readMeshFromSTLFile(&in, stream.str() );
+      mesh->deleteRedundantNodes();
+      return mesh;
+   }
+   //QDialog* getSpecificInstrument()  {  return 0;}
+   void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0)
+   { 
+   }
+#endif
+#ifdef CAB_VTK
+public:
+   Presentator* createObjectPresentator(ObObject *object) { return new vtkGbTriangularMesh3D((GbTriangularMesh3D*)object); }
+#endif
+
+
+private:
+   GbTriangularMesh3DCreator( const GbTriangularMesh3DCreator& );                  //no copy allowed 
+   const GbTriangularMesh3DCreator& operator=( const GbTriangularMesh3DCreator& ); //no copy allowed
+   GbTriangularMesh3DCreator() : GbObject3DCreator() {}
+};
+
+#ifndef SWIG
+UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbTriangularMesh3DCreator::getInstance()), CAB_GbTriangularMesh3DCreator);
+#endif
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp
index 52b09e9aeca68ec4f46e49edff4301782a690456..182d8b30a0b4949fc604b143d8f4d0f1a1021e9e 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp
@@ -1,84 +1,84 @@
-#include <numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h>
-#include <numerics/geometry3d/GbVoxelMatrix3D.h>
-#include <basics/utilities/UbFileInputASCII.h>
-#include <basics/utilities/UbMath.h>
-#include <basics/utilities/UbLogger.h>
-
-using namespace std;
-
-/***************************************************************************/
-GbVoxelMatrix3D* GbVoxelMatrix3DCreator::createFromRawFloatFile(  string filename, int nodesX1, int nodesX2, int nodesX3, float threshold)
-{
-   UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start");
-   ifstream in(filename.c_str(), ios::binary);
-   if(!in) throw UbException(UB_EXARGS,"could not open file "+filename);
-   
-   in.seekg( 0, ios::end );     //Ende springen
-   fstream::off_type length = in.tellg(); //Position abfragen
-   in.seekg( 0, ios::beg );    //An den Anfang springen 
-   if( (nodesX1*nodesX2*nodesX3)*sizeof(float) != (long)length )
-   {
-      throw UbException(UB_EXARGS,"number of nodes doesn't match filesize");
-   }
-
-   UBLOG(logINFO,"  - create GbVoxelMatrix3D");
-   GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID, threshold);
-   
-   UBLOG(logINFO,"  - init values");
-   float val;
-   for(int x3=0; x3<nodesX3; x3++)
-      for(int x2=0; x2<nodesX2; x2++)
-         for(int x1=0; x1<nodesX1; x1++)
-         {
-            in.read((char*)&val,sizeof(float));
-            //if( !UbMath::equal(val, 0.0f) ) 
-            if( UbMath::greater(val, threshold) ) 
-            {
-               (*voxelGeo)(x1,x2,x3) = GbVoxelMatrix3D::SOLID;
-            }
-         }
-   
-   UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end");
-
-   return voxelGeo;
-}
-/***************************************************************************/
-GbVoxelMatrix3D* GbVoxelMatrix3DCreator::createFromVtiASCIIFloatFile(  string filename, int nodesX1, int nodesX2, int nodesX3, float threshold)
-{
-   UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromVtiASCIIFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start");
-   UbFileInputASCII in(filename);
-   //ifstream in(filename.c_str(), ios::binary);
-   if(!in) throw UbException(UB_EXARGS,"could not open file "+filename);
-   in.readLine();
-   in.readLine();
-   in.readLine();
-   in.readLine();
-   in.readLine();
-   //in.readLine(); !!!manchmal hat das vti file noch die xml version dabei ...
-
-   UBLOG(logINFO,"  - create GbVoxelMatrix3D");
-   GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID, threshold);
-
-   UBLOG(logINFO,"  - init values");
-   int val;
-   int u=0;
-   for(int x3=0; x3<nodesX3; x3++)
-      for(int x2=0; x2<nodesX2; x2++)
-         for(int x1=0; x1<nodesX1; x1++)
-         {
-            val = in.readInteger();
-            
-            //u++; if(u>125000) UBLOG(logINFO,"val:"<<u<<" "<<val);
-
-            //if( !UbMath::equal(val, 0.0f) ) 
-            if( UbMath::greater(val, threshold) ) 
-            {
-               (*voxelGeo)(x1,x2,x3) = GbVoxelMatrix3D::SOLID;
-            }
-         }
-
-         UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromVtiASCIIFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end");
-
-         return voxelGeo;
-}
-
+#include <numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h>
+#include <numerics/geometry3d/GbVoxelMatrix3D.h>
+#include <basics/utilities/UbFileInputASCII.h>
+#include <basics/utilities/UbMath.h>
+#include <basics/utilities/UbLogger.h>
+
+using namespace std;
+
+/***************************************************************************/
+GbVoxelMatrix3D* GbVoxelMatrix3DCreator::createFromRawFloatFile(  string filename, int nodesX1, int nodesX2, int nodesX3, float threshold)
+{
+   UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start");
+   ifstream in(filename.c_str(), ios::binary);
+   if(!in) throw UbException(UB_EXARGS,"could not open file "+filename);
+   
+   in.seekg( 0, ios::end );     //Ende springen
+   fstream::off_type length = in.tellg(); //Position abfragen
+   in.seekg( 0, ios::beg );    //An den Anfang springen 
+   if( (nodesX1*nodesX2*nodesX3)*sizeof(float) != (long)length )
+   {
+      throw UbException(UB_EXARGS,"number of nodes doesn't match filesize");
+   }
+
+   UBLOG(logINFO,"  - create GbVoxelMatrix3D");
+   GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID, threshold);
+   
+   UBLOG(logINFO,"  - init values");
+   float val;
+   for(int x3=0; x3<nodesX3; x3++)
+      for(int x2=0; x2<nodesX2; x2++)
+         for(int x1=0; x1<nodesX1; x1++)
+         {
+            in.read((char*)&val,sizeof(float));
+            //if( !UbMath::equal(val, 0.0f) ) 
+            if( UbMath::greater(val, threshold) ) 
+            {
+               (*voxelGeo)(x1,x2,x3) = GbVoxelMatrix3D::SOLID;
+            }
+         }
+   
+   UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end");
+
+   return voxelGeo;
+}
+/***************************************************************************/
+GbVoxelMatrix3D* GbVoxelMatrix3DCreator::createFromVtiASCIIFloatFile(  string filename, int nodesX1, int nodesX2, int nodesX3, float threshold)
+{
+   UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromVtiASCIIFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start");
+   UbFileInputASCII in(filename);
+   //ifstream in(filename.c_str(), ios::binary);
+   if(!in) throw UbException(UB_EXARGS,"could not open file "+filename);
+   in.readLine();
+   in.readLine();
+   in.readLine();
+   in.readLine();
+   in.readLine();
+   //in.readLine(); !!!manchmal hat das vti file noch die xml version dabei ...
+
+   UBLOG(logINFO,"  - create GbVoxelMatrix3D");
+   GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID, threshold);
+
+   UBLOG(logINFO,"  - init values");
+   int val;
+   int u=0;
+   for(int x3=0; x3<nodesX3; x3++)
+      for(int x2=0; x2<nodesX2; x2++)
+         for(int x1=0; x1<nodesX1; x1++)
+         {
+            val = in.readInteger();
+            
+            //u++; if(u>125000) UBLOG(logINFO,"val:"<<u<<" "<<val);
+
+            //if( !UbMath::equal(val, 0.0f) ) 
+            if( UbMath::greater(val, threshold) ) 
+            {
+               (*voxelGeo)(x1,x2,x3) = GbVoxelMatrix3D::SOLID;
+            }
+         }
+
+         UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromVtiASCIIFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end");
+
+         return voxelGeo;
+}
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h
index 33e77c6bc8c8a434629f947f28c36ded6e8d2d86..fd2cc0482dff533e2ca907f1322b8a872a9ac136 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h
@@ -1,81 +1,81 @@
-#ifndef GBVOXELMATRIX3DCREATOR_H
-#define GBVOXELMATRIX3DCREATOR_H
-
-#include <numerics/geometry3d/creator/GbObject3DCreator.h>
-#include <numerics/geometry3d/GbVoxelMatrix3D.h>     
-#include <iostream>
-#include <fstream>
-
-class GbVoxelMatrix3DCreator : public GbObject3DCreator              
-{               
-public:
-   enum DataType {t8bit, t16bit};
-public:
-   static GbVoxelMatrix3DCreator* getInstance()
-   {
-      static GbVoxelMatrix3DCreator instance;
-      return &instance;
-   }
-
-   GbVoxelMatrix3D* createGbObject3D() { return new GbVoxelMatrix3D(); }          
-   GbVoxelMatrix3D* createFromRawFloatFile(  std::string filename, int nodesX1, int nodesX2, int nodesX3, float threshold=0.0);
-   GbVoxelMatrix3D* createFromVtiASCIIFloatFile(  std::string filename, int nodesX1, int nodesX2, int nodesX3, float threshold=0.0);
-
-   std::string getGbObject3DTypeID() { return "GbVoxelMatrix3D"; };
-   std::string toString()            { return "GbVoxelMatrix3DCreator"; }
-
-private:
-   GbVoxelMatrix3DCreator() : GbObject3DCreator() {}
-
-   GbVoxelMatrix3DCreator( const GbVoxelMatrix3DCreator& );                  //no copy allowed 
-   const GbVoxelMatrix3DCreator& operator=( const GbVoxelMatrix3DCreator& ); //no copy allowed
-
-public:
-   template< typename T >
-   GbVoxelMatrix3D* createFromRawFile(std::string filename, int nodesX1, int nodesX2, int nodesX3, float threshold)
-   {
-      UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start");
-
-      std::ifstream in(filename.c_str(), std::ios::binary);
-      if(!in) throw UbException(UB_EXARGS,"could not open file "+filename);
-
-      in.seekg( 0, std::ios::end );     //Ende springen
-      std::fstream::off_type length = in.tellg(); //Position abfragen
-      in.seekg( 0, std::ios::beg );    //An den Anfang springen 
-      long m_size = (nodesX1*nodesX2*nodesX3)*sizeof(T);
-      if( m_size != (long)length )
-      {
-         throw UbException(UB_EXARGS,"number of nodes doesn't match filesize: " + UbSystem::toString(length));
-      }
-
-      UBLOG(logINFO,"  - create GbVoxelMatrix3D");
-      GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID, threshold);
-
-      UBLOG(logINFO,"  - init values");
-      T val;
-      for(int x3=0; x3<nodesX3; x3++)
-         for(int x2=0; x2<nodesX2; x2++)
-            for(int x1=0; x1<nodesX1; x1++)
-            {
-               in.read((char*)&val,sizeof(T));
-               //if( !UbMath::equal(val, 0.0f) ) 
-               //if( UbMath::greater(val, (T)threshold) ) 
-               if(val > (T)threshold)
-               {
-                  (*voxelGeo)(x1,x2,x3) = GbVoxelMatrix3D::SOLID;
-               }
-            }
-
-      UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end");
-
-      return voxelGeo;
-   }
-};
-
-
-
-#ifndef SWIG
-UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbVoxelMatrix3DCreator::getInstance()), CAB_GbVoxelMatrix3DCreator);
-#endif
-
-#endif  //GBVOXELMATRIX3DCREATOR_H 
+#ifndef GBVOXELMATRIX3DCREATOR_H
+#define GBVOXELMATRIX3DCREATOR_H
+
+#include <numerics/geometry3d/creator/GbObject3DCreator.h>
+#include <numerics/geometry3d/GbVoxelMatrix3D.h>     
+#include <iostream>
+#include <fstream>
+
+class GbVoxelMatrix3DCreator : public GbObject3DCreator              
+{               
+public:
+   enum DataType {t8bit, t16bit};
+public:
+   static GbVoxelMatrix3DCreator* getInstance()
+   {
+      static GbVoxelMatrix3DCreator instance;
+      return &instance;
+   }
+
+   GbVoxelMatrix3D* createGbObject3D() { return new GbVoxelMatrix3D(); }          
+   GbVoxelMatrix3D* createFromRawFloatFile(  std::string filename, int nodesX1, int nodesX2, int nodesX3, float threshold=0.0);
+   GbVoxelMatrix3D* createFromVtiASCIIFloatFile(  std::string filename, int nodesX1, int nodesX2, int nodesX3, float threshold=0.0);
+
+   std::string getGbObject3DTypeID() { return "GbVoxelMatrix3D"; };
+   std::string toString()            { return "GbVoxelMatrix3DCreator"; }
+
+private:
+   GbVoxelMatrix3DCreator() : GbObject3DCreator() {}
+
+   GbVoxelMatrix3DCreator( const GbVoxelMatrix3DCreator& );                  //no copy allowed 
+   const GbVoxelMatrix3DCreator& operator=( const GbVoxelMatrix3DCreator& ); //no copy allowed
+
+public:
+   template< typename T >
+   GbVoxelMatrix3D* createFromRawFile(std::string filename, int nodesX1, int nodesX2, int nodesX3, float threshold)
+   {
+      UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start");
+
+      std::ifstream in(filename.c_str(), std::ios::binary);
+      if(!in) throw UbException(UB_EXARGS,"could not open file "+filename);
+
+      in.seekg( 0, std::ios::end );     //Ende springen
+      std::fstream::off_type length = in.tellg(); //Position abfragen
+      in.seekg( 0, std::ios::beg );    //An den Anfang springen 
+      long m_size = (nodesX1*nodesX2*nodesX3)*sizeof(T);
+      if( m_size != (long)length )
+      {
+         throw UbException(UB_EXARGS,"number of nodes doesn't match filesize: " + UbSystem::toString(length));
+      }
+
+      UBLOG(logINFO,"  - create GbVoxelMatrix3D");
+      GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID, threshold);
+
+      UBLOG(logINFO,"  - init values");
+      T val;
+      for(int x3=0; x3<nodesX3; x3++)
+         for(int x2=0; x2<nodesX2; x2++)
+            for(int x1=0; x1<nodesX1; x1++)
+            {
+               in.read((char*)&val,sizeof(T));
+               //if( !UbMath::equal(val, 0.0f) ) 
+               //if( UbMath::greater(val, (T)threshold) ) 
+               if(val > (T)threshold)
+               {
+                  (*voxelGeo)(x1,x2,x3) = GbVoxelMatrix3D::SOLID;
+               }
+            }
+
+      UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end");
+
+      return voxelGeo;
+   }
+};
+
+
+
+#ifndef SWIG
+UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbVoxelMatrix3DCreator::getInstance()), CAB_GbVoxelMatrix3DCreator);
+#endif
+
+#endif  //GBVOXELMATRIX3DCREATOR_H 
diff --git a/source/ThirdParty/Library/numerics/geometry3d/examples/insideOutsideTests/CMakeLists.txt b/source/VirtualFluidsBasic/numerics/geometry3d/examples/insideOutsideTests/CMakeLists.txt
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/examples/insideOutsideTests/CMakeLists.txt
rename to source/VirtualFluidsBasic/numerics/geometry3d/examples/insideOutsideTests/CMakeLists.txt
index 153431958236b26fc67f1103d742ae8169364653..f4da9878985742367fc04307484b7961f321ac70 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/examples/insideOutsideTests/CMakeLists.txt
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/examples/insideOutsideTests/CMakeLists.txt
@@ -1,61 +1,61 @@
-cmake_minimum_required(VERSION 2.4)
-
-INCLUDE("../../../../CMakeCABMacros.txt")
-INCLUDE("../../../../CMakeSetCompilerFlags.txt")
-
-CHECK_FOR_VARIABLE(CAB_MACHINE "machine name, e.g. ALTIX, ARWEN")
-SET(CMAKE_CONFIG_FILE "${SOURCE_ROOT}/cmake_config_files/${CAB_MACHINE}.config.cmake")
-
-IF(CAB_MACHINE AND EXISTS ${CMAKE_CONFIG_FILE} )
-   
-   PROJECT(geo3dCellCutTests)
-
-   SET(EXECUTABLE_NAME geo3dCellCutTests)
-
-   #erst hier das config file einfügen, ansonsten werden manche settings durch (Project) überschrieben)  
-   INCLUDE(${CMAKE_CONFIG_FILE})  
-  
-   #################################################################
-   ###   PACKAGES						###
-   #################################################################
-   INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt)
-   INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt)
-   INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakePackage.txt)
-   INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakePackage.txt)
-   INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/fem/CMakePackage.txt)
-   
-   #################################################################
-   ###   OWN DEFINES 						###
-   #################################################################
-   FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h
-                            ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 
-
-
-   SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES})
-   SOURCE_GROUP(example FILES ${SPECIFIC_FILES})
-
-   SET_COMPILER_SPECIFIC_FLAGS(${CAB_COMPILER} BINARY)
-   
-   #################################################################
-   ###   ADDITIONAL_MAKE_CLEAN_FILES                             ###
-   #################################################################
-   SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${GENERATED_FILES}")
-
-   #################################################################
-   ###   EXCECUTABLE						###
-   #################################################################
-   ADD_EXECUTABLE(${EXECUTABLE_NAME} ${ALL_SOURCES} )
-
-   #################################################################
-   ###   ADDITIONAL LINK PROPERTIES    			        ###
-   #################################################################
-   IF(CAB_ADDITIONAL_LINK_FLAGS)
-     SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS ${CAB_ADDITIONAL_LINK_FLAGS})
-   ENDIF(CAB_ADDITIONAL_LINK_FLAGS)
-ELSE()
-    IF(CAB_MACHINE)
-      MESSAGE("CAB_MACHINE error - following file is missing: \n ${CMAKE_CONFIG_FILE}")
-    ELSE()
-      MESSAGE("check CAB_MACHINE!!!")
-    ENDIF()  
+cmake_minimum_required(VERSION 2.4)
+
+INCLUDE("../../../../CMakeCABMacros.txt")
+INCLUDE("../../../../CMakeSetCompilerFlags.txt")
+
+CHECK_FOR_VARIABLE(CAB_MACHINE "machine name, e.g. ALTIX, ARWEN")
+SET(CMAKE_CONFIG_FILE "${SOURCE_ROOT}/cmake_config_files/${CAB_MACHINE}.config.cmake")
+
+IF(CAB_MACHINE AND EXISTS ${CMAKE_CONFIG_FILE} )
+   
+   PROJECT(geo3dCellCutTests)
+
+   SET(EXECUTABLE_NAME geo3dCellCutTests)
+
+   #erst hier das config file einfügen, ansonsten werden manche settings durch (Project) überschrieben)  
+   INCLUDE(${CMAKE_CONFIG_FILE})  
+  
+   #################################################################
+   ###   PACKAGES						###
+   #################################################################
+   INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt)
+   INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt)
+   INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakePackage.txt)
+   INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakePackage.txt)
+   INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/fem/CMakePackage.txt)
+   
+   #################################################################
+   ###   OWN DEFINES 						###
+   #################################################################
+   FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h
+                            ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 
+
+
+   SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES})
+   SOURCE_GROUP(example FILES ${SPECIFIC_FILES})
+
+   SET_COMPILER_SPECIFIC_FLAGS(${CAB_COMPILER} BINARY)
+   
+   #################################################################
+   ###   ADDITIONAL_MAKE_CLEAN_FILES                             ###
+   #################################################################
+   SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${GENERATED_FILES}")
+
+   #################################################################
+   ###   EXCECUTABLE						###
+   #################################################################
+   ADD_EXECUTABLE(${EXECUTABLE_NAME} ${ALL_SOURCES} )
+
+   #################################################################
+   ###   ADDITIONAL LINK PROPERTIES    			        ###
+   #################################################################
+   IF(CAB_ADDITIONAL_LINK_FLAGS)
+     SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS ${CAB_ADDITIONAL_LINK_FLAGS})
+   ENDIF(CAB_ADDITIONAL_LINK_FLAGS)
+ELSE()
+    IF(CAB_MACHINE)
+      MESSAGE("CAB_MACHINE error - following file is missing: \n ${CMAKE_CONFIG_FILE}")
+    ELSE()
+      MESSAGE("check CAB_MACHINE!!!")
+    ENDIF()  
 ENDIF()
\ No newline at end of file
diff --git a/source/ThirdParty/Library/numerics/geometry3d/examples/insideOutsideTests/main.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/examples/insideOutsideTests/main.cpp
similarity index 98%
rename from source/ThirdParty/Library/numerics/geometry3d/examples/insideOutsideTests/main.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/examples/insideOutsideTests/main.cpp
index 911bc6965a1ee38a28b45d5e0e9f6874a2aa564d..f420be84a4ef3d5a28826fabf2256b713a411981 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/examples/insideOutsideTests/main.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/examples/insideOutsideTests/main.cpp
@@ -1,46 +1,46 @@
-#include <numerics/geometry3d/GbCuboid3D.h>
-#include <numerics/geometry3d/GbSphere3D.h>
-#include <numerics/geometry3d/GbCylinder3D.h>
-
-int main(int argc, char** argv)
-{
-     GbSphere3D test(10,10,10,8);
-     
-     bool cutSp1    /*false*/= test.isCellCuttingGbObject3D(9,9,9,11,11,11); //cell komplett IN sphere
-     bool cutSp2    /*true */= test.isCellCuttingGbObject3D(0,0,0,20,20,20); //cell umhuellt    sphere
-     bool cutSp3    /*true */= test.isCellCuttingGbObject3D(0,0,0,10,10,10); //cell cutted      sphere
-     bool cutSp4    /*false*/= test.isCellCuttingGbObject3D(100,100,100,101,101,101); //cell nix      sphere
-
-     
-     bool cutInsSp1 /*true */= test.isCellInsideOrCuttingGbObject3D(9,9,9,11,11,11);     //cell komplett IN sphere
-     bool cutInsSp2 /*true */= test.isCellInsideOrCuttingGbObject3D(0,0,0,20,20,20);     //cell umhuellt    sphere
-     bool cutInsSp3 /*true */= test.isCellInsideOrCuttingGbObject3D(0,0,0,10,10,10);     //cell cutted      sphere
-     bool cutInsSp4 /*false*/= test.isCellInsideOrCuttingGbObject3D(100,100,100,101,101,101); //cell nix      sphere
-                                                                    
-     GbCuboid3D test1(0,0,0,10,10,10);
-
-     bool cutCu1    /*false*/= test1.isCellCuttingGbObject3D(4,4,4,6,6,6);       //cell komplett IN cube
-     bool cutCu2    /*true */= test1.isCellCuttingGbObject3D(-1,-1,-1,11,11,11); //cell umhuellt    cube
-     bool cutCu3    /*true */= test1.isCellCuttingGbObject3D(5,5,5,15,15,15);   //cell cutted      cube
-     bool cutCu4    /*false*/= test1.isCellCuttingGbObject3D(12,12,12,15,15,15);   //cell nix      cube
-
-     bool cutInsCu1 /*true */= test1.isCellInsideOrCuttingGbObject3D(4,4,4,6,6,6);       //cell komplett IN cube
-     bool cutInsCu2 /*true */= test1.isCellInsideOrCuttingGbObject3D(-1,-1,-1,11,11,11); //cell umhuellt    cube
-     bool cutInsCu3 /*true */= test1.isCellInsideOrCuttingGbObject3D(5,5,5,15,15,15);   //cell cutted      cube
-     bool cutInsCu4 /*false*/= test1.isCellInsideOrCuttingGbObject3D(12,12,12,15,15,15);  //cell nix      cube
-
-     GbCylinder3D test2( 0,0,0, 20, 0, 0, 10);
-
-     bool cutCy1     /*false*/ = test2.isCellCuttingGbObject3D(1,-1,-1,4,1,1);       //cell komplett IN cyl
-     bool cutCy2     /*true */ = test2.isCellCuttingGbObject3D(10,0,0,15,12,11);     //cell umhuellt    cyl
-     bool cutCy3a    /*true */ = test2.isCellCuttingGbObject3D(5,5,5,15,15,15);      //cell cutted      cyl im kreisbreich
-     bool cutCy3b    /*true */ = test2.isCellCuttingGbObject3D(-5,-1,-1,5,1,1);      //cell cutted      cyl am stirn
-     bool cutCy4     /*false*/= test2.isCellCuttingGbObject3D(-10,-10,-10,-5,-5,-5);   //cell nix      cyl
-
-
-     bool cutInsCy1  /*true */= test2.isCellInsideOrCuttingGbObject3D(4,4,4,6,6,6);       //cell komplett IN cube
-     bool cutInsCy2  /*true */= test2.isCellInsideOrCuttingGbObject3D(10,0,0,15,12,11);   //cell umhuellt    cyl
-     bool cutInsCy3a /*true */= test2.isCellInsideOrCuttingGbObject3D(5,5,5,15,15,15);      //cell cutted      cyl im kreisbreich
-     bool cutInsCy3b /*true */= test2.isCellInsideOrCuttingGbObject3D(-5,-1,-1,5,1,1);   //cell cutted      cube
-     bool cutInsCy4  /*false*/= test2.isCellInsideOrCuttingGbObject3D(-10,-10,-10,-5,-5,-5);   //cell nix      cube
+#include <numerics/geometry3d/GbCuboid3D.h>
+#include <numerics/geometry3d/GbSphere3D.h>
+#include <numerics/geometry3d/GbCylinder3D.h>
+
+int main(int argc, char** argv)
+{
+     GbSphere3D test(10,10,10,8);
+     
+     bool cutSp1    /*false*/= test.isCellCuttingGbObject3D(9,9,9,11,11,11); //cell komplett IN sphere
+     bool cutSp2    /*true */= test.isCellCuttingGbObject3D(0,0,0,20,20,20); //cell umhuellt    sphere
+     bool cutSp3    /*true */= test.isCellCuttingGbObject3D(0,0,0,10,10,10); //cell cutted      sphere
+     bool cutSp4    /*false*/= test.isCellCuttingGbObject3D(100,100,100,101,101,101); //cell nix      sphere
+
+     
+     bool cutInsSp1 /*true */= test.isCellInsideOrCuttingGbObject3D(9,9,9,11,11,11);     //cell komplett IN sphere
+     bool cutInsSp2 /*true */= test.isCellInsideOrCuttingGbObject3D(0,0,0,20,20,20);     //cell umhuellt    sphere
+     bool cutInsSp3 /*true */= test.isCellInsideOrCuttingGbObject3D(0,0,0,10,10,10);     //cell cutted      sphere
+     bool cutInsSp4 /*false*/= test.isCellInsideOrCuttingGbObject3D(100,100,100,101,101,101); //cell nix      sphere
+                                                                    
+     GbCuboid3D test1(0,0,0,10,10,10);
+
+     bool cutCu1    /*false*/= test1.isCellCuttingGbObject3D(4,4,4,6,6,6);       //cell komplett IN cube
+     bool cutCu2    /*true */= test1.isCellCuttingGbObject3D(-1,-1,-1,11,11,11); //cell umhuellt    cube
+     bool cutCu3    /*true */= test1.isCellCuttingGbObject3D(5,5,5,15,15,15);   //cell cutted      cube
+     bool cutCu4    /*false*/= test1.isCellCuttingGbObject3D(12,12,12,15,15,15);   //cell nix      cube
+
+     bool cutInsCu1 /*true */= test1.isCellInsideOrCuttingGbObject3D(4,4,4,6,6,6);       //cell komplett IN cube
+     bool cutInsCu2 /*true */= test1.isCellInsideOrCuttingGbObject3D(-1,-1,-1,11,11,11); //cell umhuellt    cube
+     bool cutInsCu3 /*true */= test1.isCellInsideOrCuttingGbObject3D(5,5,5,15,15,15);   //cell cutted      cube
+     bool cutInsCu4 /*false*/= test1.isCellInsideOrCuttingGbObject3D(12,12,12,15,15,15);  //cell nix      cube
+
+     GbCylinder3D test2( 0,0,0, 20, 0, 0, 10);
+
+     bool cutCy1     /*false*/ = test2.isCellCuttingGbObject3D(1,-1,-1,4,1,1);       //cell komplett IN cyl
+     bool cutCy2     /*true */ = test2.isCellCuttingGbObject3D(10,0,0,15,12,11);     //cell umhuellt    cyl
+     bool cutCy3a    /*true */ = test2.isCellCuttingGbObject3D(5,5,5,15,15,15);      //cell cutted      cyl im kreisbreich
+     bool cutCy3b    /*true */ = test2.isCellCuttingGbObject3D(-5,-1,-1,5,1,1);      //cell cutted      cyl am stirn
+     bool cutCy4     /*false*/= test2.isCellCuttingGbObject3D(-10,-10,-10,-5,-5,-5);   //cell nix      cyl
+
+
+     bool cutInsCy1  /*true */= test2.isCellInsideOrCuttingGbObject3D(4,4,4,6,6,6);       //cell komplett IN cube
+     bool cutInsCy2  /*true */= test2.isCellInsideOrCuttingGbObject3D(10,0,0,15,12,11);   //cell umhuellt    cyl
+     bool cutInsCy3a /*true */= test2.isCellInsideOrCuttingGbObject3D(5,5,5,15,15,15);      //cell cutted      cyl im kreisbreich
+     bool cutInsCy3b /*true */= test2.isCellInsideOrCuttingGbObject3D(-5,-1,-1,5,1,1);   //cell cutted      cube
+     bool cutInsCy4  /*false*/= test2.isCellInsideOrCuttingGbObject3D(-10,-10,-10,-5,-5,-5);   //cell nix      cube
 }
\ No newline at end of file
diff --git a/source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/CMakeLists.txt b/source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/CMakeLists.txt
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/CMakeLists.txt
rename to source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/CMakeLists.txt
index 37e3f930aa4a3c9ca9ce5d96206c2269e67636ef..8046a72e2d3188e21adb33d8b46e7661d31aabea 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/CMakeLists.txt
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/CMakeLists.txt
@@ -1,140 +1,140 @@
-SET(SOURCE_ROOT $ENV{CAB_DIR} CACHE PATH "(e.g. d:/temp/source)" )
-STRING(REGEX REPLACE "\\\\" "/" SOURCE_ROOT ${SOURCE_ROOT}) # "\" --> "/"
-
-IF(EXISTS ${SOURCE_ROOT})
- IF(EXISTS ${SOURCE_ROOT}/basics)
-  
-  INCLUDE(${SOURCE_ROOT}/CMakeCABMacros.txt) 
- 
-  PROJECT (STL2INP)
-  SET(EXECUTABLE_NAME stl2inp)
-
-  #################################################################
-  ###   PACKAGES						###
-  #################################################################
- 
-  INCLUDE(${SOURCE_ROOT}/basics/objects/CMakeLists.txt)
-  INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakeLists.txt)
-  INCLUDE(${SOURCE_ROOT}/basics/relation/CMakeLists.txt)
-
- 
-  INCLUDE(${SOURCE_ROOT}/numerics/geometry2d/CMakeLists.txt)
-  INCLUDE(${SOURCE_ROOT}/numerics/geometry2d/creator/CMakeLists.txt)
- 
-  INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakeLists.txt)
-  INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakeLists.txt)
- 
-  INCLUDE(${SOURCE_ROOT}/octree/CMakeLists.txt)
-  INCLUDE(${SOURCE_ROOT}/octree/facette/CMakeLists.txt)
- 
-  INCLUDE(${SOURCE_ROOT}/quadtree/CMakeLists.txt)
-  INCLUDE(${SOURCE_ROOT}/quadtree/nodeadaptation/CMakeLists.txt)
-
- 
-  #################################################################
-  ###   OWN DEFINES                                             ###
-  #################################################################
- # ADD_DEFINITIONS( -DCAB_QT )
- # ADD_DEFINITIONS( -DCAB_QTONLY )
-  ADD_DEFINITIONS( -DMEMPOOL_A2PIIOCTNODEVD)
-  SET(SPECIFIC_FILES main.cpp stl2inp.h stl2inp.cpp QDefineUniformMesh.h QDefineUniformMesh.cpp)
-  SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES})
-  SOURCE_GROUP(z_specific FILES ${SPECIFIC_FILES})
-
-  IF(WIN32)
-    ADD_CXX_FLAGS("/wd4996")
-  ELSE(WIN32)
-    ADD_CXX_FLAGS("-O3 -mcpu=athlon-4 -fomit-frame-pointer -finline-functions -funroll-all-loops")
-  ENDIF(WIN32)
-
-  
-
-  #################################################################
-  ### QT SPECIFIC (only has effects if a QT source is included)	###
-  #################################################################
-  #QT specific 
-   SET(NEED_QT "YES")
-  INCLUDE(${SOURCE_ROOT}/CMakeQtMacros.txt)
-
-  IF(QT_FOUND)
-    INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} 
-			 ${QT_INCLUDE_PATH} 
-			 ${QT_QTCORE_INCLUDE_DIR}
-			 ${QT_QTGUI_INCLUDE_DIR}  
-                       )
-    LINK_LIBRARIES ( ${QT_QTCORE_LIBRARY} 
-                     ${QT_QTGUI_LIBRARY} 
-                    )
-    ADD_DEFINITIONS( ${QT_DEFINITIONS})
-   ELSE(QT_FOUND)
-    IF(${NEED_QT} MATCHES "YES") 
-      MESSAGE("Ups\nAt least one package needs Qt!\nPlease check Qt settings\n(e.g. librarys within Advanced Values)")
-    ENDIF(${NEED_QT} MATCHES "YES") 
-   
-    
-  ENDIF(QT_FOUND)
-
- IF(QT_FOUND)
-     SET(SUBDIRPATH numerics/geometry3d/examples/stl2inp) 
-     SET(CURRENT_DIR ${SOURCE_ROOT}/${SUBDIRPATH})
- 
-     ################################################################
-    ###         Qt4      UI FILES                                ###
-    ################################################################
-    FILE(GLOB UI_FILES ${CURRENT_DIR}/*.ui)           #collect ui files
-    QT4_WRAP_UI(${CURRENT_DIR} OUTFILES ${UI_FILES})  #wrap ui files
-    REMOVE(TEMP_FILES ${OUTFILES} )
-    SET(TEMP_FILES ${TEMP_FILES} ${OUTFILES} )
-    
-    #make subfolders for VS with new files
-    SOURCE_GROUP(${SUBDIRPATH} FILES ${OUTFILES})
-    
-    IF(WIN32)
-      SET(ALL_SOURCES ${ALL_SOURCES} ${UI_FILES})
-      SOURCE_GROUP(${SUBDIRPATH} FILES ${UI_FILES})
-    ENDIF(WIN32)
- 
-   ################################################################
-    ###       Qt4        HEADERS TO BE MOCED                     ###
-    ################################################################
-    MAKE_DIRECTORY(${CURRENT_DIR}${QTGEN_MOC})
-    SET(MOC_FILES ) #empty MOC_FILES
-    #SET(MOC_CLASSES  ${CURRENT_DIR}/stl2inp.h QDefineUniformMesh.ui )
-
-    QT4_WRAP_CPP(${CURRENT_DIR}${QTGEN_MOC} MOC_FILES ${MOC_CLASSES})
-    REMOVE(TEMP_FILES ${MOC_FILES})
-    SET(TEMP_FILES ${TEMP_FILES} ${MOC_FILES})
-    SOURCE_GROUP(${SUBDIRPATH}${QTGEN_MOC} FILES ${MOC_FILES})
-   
-    SET(ALL_SOURCES ${ALL_SOURCES} ${TEMP_FILES})
-   
-  ENDIF(QT_FOUND)
-
-
-  #################################################################
-  ###   ADDITIONAL_MAKE_CLEAN_FILES                             ###
-  #################################################################
-  SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${GENERATED_FILES}")
-  
-  #################################################################
-  ###   EXCECUTABLE						###
-  #################################################################
-    ADD_EXECUTABLE( ${EXECUTABLE_NAME} 
-                  ${ALL_SOURCES}
-                )
-
-
-  #################################################################
-  ###   ADDITIONAL LINK PROPERTIES    			        ###
-  #################################################################
-  IF(CAB_ADDITIONAL_LINK_FLAGS)
-    SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS ${CAB_ADDITIONAL_LINK_FLAGS})
-  ENDIF(CAB_ADDITIONAL_LINK_FLAGS)
-
- ELSE(EXISTS ${SOURCE_ROOT}/basics)
-   MESSAGE("Set Path to \"source\" directory at\nSOURCE_ROOT\nis not correct")
- ENDIF(EXISTS ${SOURCE_ROOT}/basics)
-ELSE(EXISTS ${SOURCE_ROOT})
- SET(SOURCE_ROOT "CAB_DIR NOT FOUND" CACHE PATH "(e.g. d:/temp/source)" FORCE)
- MESSAGE("Please Set Path to \"source\" directory at\nSOURCE_ROOT\n(e.g. D:/temp/source)")
-ENDIF(EXISTS ${SOURCE_ROOT})
+SET(SOURCE_ROOT $ENV{CAB_DIR} CACHE PATH "(e.g. d:/temp/source)" )
+STRING(REGEX REPLACE "\\\\" "/" SOURCE_ROOT ${SOURCE_ROOT}) # "\" --> "/"
+
+IF(EXISTS ${SOURCE_ROOT})
+ IF(EXISTS ${SOURCE_ROOT}/basics)
+  
+  INCLUDE(${SOURCE_ROOT}/CMakeCABMacros.txt) 
+ 
+  PROJECT (STL2INP)
+  SET(EXECUTABLE_NAME stl2inp)
+
+  #################################################################
+  ###   PACKAGES						###
+  #################################################################
+ 
+  INCLUDE(${SOURCE_ROOT}/basics/objects/CMakeLists.txt)
+  INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakeLists.txt)
+  INCLUDE(${SOURCE_ROOT}/basics/relation/CMakeLists.txt)
+
+ 
+  INCLUDE(${SOURCE_ROOT}/numerics/geometry2d/CMakeLists.txt)
+  INCLUDE(${SOURCE_ROOT}/numerics/geometry2d/creator/CMakeLists.txt)
+ 
+  INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakeLists.txt)
+  INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakeLists.txt)
+ 
+  INCLUDE(${SOURCE_ROOT}/octree/CMakeLists.txt)
+  INCLUDE(${SOURCE_ROOT}/octree/facette/CMakeLists.txt)
+ 
+  INCLUDE(${SOURCE_ROOT}/quadtree/CMakeLists.txt)
+  INCLUDE(${SOURCE_ROOT}/quadtree/nodeadaptation/CMakeLists.txt)
+
+ 
+  #################################################################
+  ###   OWN DEFINES                                             ###
+  #################################################################
+ # ADD_DEFINITIONS( -DCAB_QT )
+ # ADD_DEFINITIONS( -DCAB_QTONLY )
+  ADD_DEFINITIONS( -DMEMPOOL_A2PIIOCTNODEVD)
+  SET(SPECIFIC_FILES main.cpp stl2inp.h stl2inp.cpp QDefineUniformMesh.h QDefineUniformMesh.cpp)
+  SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES})
+  SOURCE_GROUP(z_specific FILES ${SPECIFIC_FILES})
+
+  IF(WIN32)
+    ADD_CXX_FLAGS("/wd4996")
+  ELSE(WIN32)
+    ADD_CXX_FLAGS("-O3 -mcpu=athlon-4 -fomit-frame-pointer -finline-functions -funroll-all-loops")
+  ENDIF(WIN32)
+
+  
+
+  #################################################################
+  ### QT SPECIFIC (only has effects if a QT source is included)	###
+  #################################################################
+  #QT specific 
+   SET(NEED_QT "YES")
+  INCLUDE(${SOURCE_ROOT}/CMakeQtMacros.txt)
+
+  IF(QT_FOUND)
+    INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} 
+			 ${QT_INCLUDE_PATH} 
+			 ${QT_QTCORE_INCLUDE_DIR}
+			 ${QT_QTGUI_INCLUDE_DIR}  
+                       )
+    LINK_LIBRARIES ( ${QT_QTCORE_LIBRARY} 
+                     ${QT_QTGUI_LIBRARY} 
+                    )
+    ADD_DEFINITIONS( ${QT_DEFINITIONS})
+   ELSE(QT_FOUND)
+    IF(${NEED_QT} MATCHES "YES") 
+      MESSAGE("Ups\nAt least one package needs Qt!\nPlease check Qt settings\n(e.g. librarys within Advanced Values)")
+    ENDIF(${NEED_QT} MATCHES "YES") 
+   
+    
+  ENDIF(QT_FOUND)
+
+ IF(QT_FOUND)
+     SET(SUBDIRPATH numerics/geometry3d/examples/stl2inp) 
+     SET(CURRENT_DIR ${SOURCE_ROOT}/${SUBDIRPATH})
+ 
+     ################################################################
+    ###         Qt4      UI FILES                                ###
+    ################################################################
+    FILE(GLOB UI_FILES ${CURRENT_DIR}/*.ui)           #collect ui files
+    QT4_WRAP_UI(${CURRENT_DIR} OUTFILES ${UI_FILES})  #wrap ui files
+    REMOVE(TEMP_FILES ${OUTFILES} )
+    SET(TEMP_FILES ${TEMP_FILES} ${OUTFILES} )
+    
+    #make subfolders for VS with new files
+    SOURCE_GROUP(${SUBDIRPATH} FILES ${OUTFILES})
+    
+    IF(WIN32)
+      SET(ALL_SOURCES ${ALL_SOURCES} ${UI_FILES})
+      SOURCE_GROUP(${SUBDIRPATH} FILES ${UI_FILES})
+    ENDIF(WIN32)
+ 
+   ################################################################
+    ###       Qt4        HEADERS TO BE MOCED                     ###
+    ################################################################
+    MAKE_DIRECTORY(${CURRENT_DIR}${QTGEN_MOC})
+    SET(MOC_FILES ) #empty MOC_FILES
+    #SET(MOC_CLASSES  ${CURRENT_DIR}/stl2inp.h QDefineUniformMesh.ui )
+
+    QT4_WRAP_CPP(${CURRENT_DIR}${QTGEN_MOC} MOC_FILES ${MOC_CLASSES})
+    REMOVE(TEMP_FILES ${MOC_FILES})
+    SET(TEMP_FILES ${TEMP_FILES} ${MOC_FILES})
+    SOURCE_GROUP(${SUBDIRPATH}${QTGEN_MOC} FILES ${MOC_FILES})
+   
+    SET(ALL_SOURCES ${ALL_SOURCES} ${TEMP_FILES})
+   
+  ENDIF(QT_FOUND)
+
+
+  #################################################################
+  ###   ADDITIONAL_MAKE_CLEAN_FILES                             ###
+  #################################################################
+  SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${GENERATED_FILES}")
+  
+  #################################################################
+  ###   EXCECUTABLE						###
+  #################################################################
+    ADD_EXECUTABLE( ${EXECUTABLE_NAME} 
+                  ${ALL_SOURCES}
+                )
+
+
+  #################################################################
+  ###   ADDITIONAL LINK PROPERTIES    			        ###
+  #################################################################
+  IF(CAB_ADDITIONAL_LINK_FLAGS)
+    SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS ${CAB_ADDITIONAL_LINK_FLAGS})
+  ENDIF(CAB_ADDITIONAL_LINK_FLAGS)
+
+ ELSE(EXISTS ${SOURCE_ROOT}/basics)
+   MESSAGE("Set Path to \"source\" directory at\nSOURCE_ROOT\nis not correct")
+ ENDIF(EXISTS ${SOURCE_ROOT}/basics)
+ELSE(EXISTS ${SOURCE_ROOT})
+ SET(SOURCE_ROOT "CAB_DIR NOT FOUND" CACHE PATH "(e.g. d:/temp/source)" FORCE)
+ MESSAGE("Please Set Path to \"source\" directory at\nSOURCE_ROOT\n(e.g. D:/temp/source)")
+ENDIF(EXISTS ${SOURCE_ROOT})
diff --git a/source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp
similarity index 94%
rename from source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp
index 278d021653712124e5f0bfb40eb5aaffd4291754..0676719cd8acd3bf5ccec29793bedd6e42405240 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp
@@ -1,17 +1,17 @@
-#include "./QDefineUniformMesh.h"
-#include <QtGui/QFileDialog>
-#include <QString>
-#include <QFile>
-#include <QMessageBox>
-#include <cstdio>
-
-
-QDefineUniformMesh::QDefineUniformMesh(QWidget *parent, Qt::WFlags flags)
-{
-	ui.setupUi(this);
-}
-
-QDefineUniformMesh::~QDefineUniformMesh()
-{
-
-}
+#include "./QDefineUniformMesh.h"
+#include <QtGui/QFileDialog>
+#include <QString>
+#include <QFile>
+#include <QMessageBox>
+#include <cstdio>
+
+
+QDefineUniformMesh::QDefineUniformMesh(QWidget *parent, Qt::WFlags flags)
+{
+	ui.setupUi(this);
+}
+
+QDefineUniformMesh::~QDefineUniformMesh()
+{
+
+}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.h b/source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.h
index f470a8edce55e67e93d17cd5de52e0bebef9a281..0648b9ae20f4d9452b0e7beb087607b0613beded 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.h
@@ -1,35 +1,35 @@
-#ifndef QDEFINEUNIFORMMESH_H
-#define QDEFINEUNIFORMMESH_H
-
-#include <QtGui/QDialog>
-#include "./QDefineUniformMeshUI.h"
-
-class QDefineUniformMesh : public QDialog
-{
-	Q_OBJECT
-
-public:
-	QDefineUniformMesh(QWidget *parent = 0, Qt::WFlags flags = 0);
-	~QDefineUniformMesh();
-
-	void	setStartLevel(int startLevel)	{ ui.spinBox_startLevel->setValue(startLevel); }
-	void	setStopLevel(int stopLevel)		{ ui.spinBox_stopLevel->setValue(stopLevel); }
-	void	setDelta(double delta)		{ ui.doubleSpinBox_delta->setValue(delta); }
-	void	setNX1(int nx1)				{ ui.spinBox_nx1->setValue(nx1); }
-	void	setNX2(int nx2)				{ ui.spinBox_nx2->setValue(nx2); }
-	void	setNX3(int nx3)				{ ui.spinBox_nx3->setValue(nx3); }
-
-	int		getStartLevel()	{ return ui.spinBox_startLevel->value(); }
-	int		getStopLevel()	{ return ui.spinBox_stopLevel->value(); }
-	double	getDelta()		{ return ui.doubleSpinBox_delta->value(); }
-	int		getNX1()		{ return ui.spinBox_nx1->value(); }
-	int		getNX2()		{ return ui.spinBox_nx2->value(); }
-	int		getNX3()		{ return ui.spinBox_nx3->value(); }
-
-private:
-	Ui::QDefineUniformMesh ui;
-
-//private slots:
-};
-
-#endif // QDEFINEUNIFORMMESH_H
+#ifndef QDEFINEUNIFORMMESH_H
+#define QDEFINEUNIFORMMESH_H
+
+#include <QtGui/QDialog>
+#include "./QDefineUniformMeshUI.h"
+
+class QDefineUniformMesh : public QDialog
+{
+	Q_OBJECT
+
+public:
+	QDefineUniformMesh(QWidget *parent = 0, Qt::WFlags flags = 0);
+	~QDefineUniformMesh();
+
+	void	setStartLevel(int startLevel)	{ ui.spinBox_startLevel->setValue(startLevel); }
+	void	setStopLevel(int stopLevel)		{ ui.spinBox_stopLevel->setValue(stopLevel); }
+	void	setDelta(double delta)		{ ui.doubleSpinBox_delta->setValue(delta); }
+	void	setNX1(int nx1)				{ ui.spinBox_nx1->setValue(nx1); }
+	void	setNX2(int nx2)				{ ui.spinBox_nx2->setValue(nx2); }
+	void	setNX3(int nx3)				{ ui.spinBox_nx3->setValue(nx3); }
+
+	int		getStartLevel()	{ return ui.spinBox_startLevel->value(); }
+	int		getStopLevel()	{ return ui.spinBox_stopLevel->value(); }
+	double	getDelta()		{ return ui.doubleSpinBox_delta->value(); }
+	int		getNX1()		{ return ui.spinBox_nx1->value(); }
+	int		getNX2()		{ return ui.spinBox_nx2->value(); }
+	int		getNX3()		{ return ui.spinBox_nx3->value(); }
+
+private:
+	Ui::QDefineUniformMesh ui;
+
+//private slots:
+};
+
+#endif // QDEFINEUNIFORMMESH_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.ui b/source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.ui
similarity index 100%
rename from source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.ui
rename to source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.ui
diff --git a/source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/main.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/main.cpp
similarity index 94%
rename from source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/main.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/main.cpp
index 17bf6a44174af3acbdd3d4d7a259235767b197ed..70f49c728e124f6692f30c79a9fdc05f3a6b84f6 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/main.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/main.cpp
@@ -1,15 +1,15 @@
-#include <iostream>
-#include <cstdlib>
-
-#include <QtGui/QApplication>
-#include "./stl2inp.h"
-
-int main(int argc, char *argv[])
-{
-    QApplication a(argc, argv);
-    STL2INP w;
-
-	w.show();
-    a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
-    return a.exec();
-}
+#include <iostream>
+#include <cstdlib>
+
+#include <QtGui/QApplication>
+#include "./stl2inp.h"
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    STL2INP w;
+
+	w.show();
+    a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
+    return a.exec();
+}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/stl2inp.cpp
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/stl2inp.cpp
index 6d5e95f17a269cd716170f9a0a66d0b64273269b..a476b0ced782a3936d8f11d4858970eb303fbf6f 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/stl2inp.cpp
@@ -1,261 +1,261 @@
-#include "stl2inp.h"
-#include <QtGui/QFileDialog>
-#include <QString>
-#include <QFile>
-#include <QMessageBox>
-#include <cstdio>
-
-#include "./QDefineUniformMesh.h"
-
-#include "./../../../../../source/basics/utilities/UbFileInputASCII.h"
-#include "./../../../../../source/basics/utilities/UbFileOutputASCII.h"
-#include "./../../../../../source/basics/utilities/UbFileOutputBinary.h"
-#include "./../../../../../source/numerics/geometry3d/GbTriangularMesh3D.h"
-#include "./../../../../../source/numerics/geometry3d/creator/GbTriangularMesh3DCreator.h"
-#include "./../../../../../source/numerics/geometry3D/CoordinateTransformation3D.h"
-#include "./../../../../../source/basics/utilities/UbTiming.h"
-#include "./../../../../../source/octree/facette/OctFacettenGrid2.h"
-
-STL2INP::STL2INP(QWidget *parent, Qt::WFlags flags)
-: QMainWindow(parent, flags)
-{
-	ui.setupUi(this);
-	startLevel	= 0;
-	stopLevel	= 3;
-	delta		= 10.00;
-	nx1			= 30;
-	nx2			= 15;
-	nx3			= 5;
-	
-}
-
-STL2INP::~STL2INP()
-{
-
-}
-
-void STL2INP::on_pBtn_Input_pressed()
-{
-	QString s = QFileDialog::getOpenFileName(
-		this,
-		"Choose a file",
-		"E:/",
-		"STL-Files (*.stl)");
-	if(s != ""){
-		ui.lineEdit_In->setText(s);
-		ui.statusBar->showMessage("Input-File: Filename defined", 3000);
-	}
-	else
-		ui.statusBar->showMessage("Input-File: No file found", 3000);
-
-}
-
-void STL2INP::on_lineEdit_In_returnPressed(){
-	QString s = ui.lineEdit_In->text();
-	if(s != ""){
-		if(!s.endsWith(".stl",Qt::CaseSensitivity(false)))
-		{
-			s.append(".stl");
-			ui.lineEdit_In->setText(s);
-		}
-		if(QFile::exists(s))
-			ui.statusBar->showMessage("Inputput-File: File found", 3000);
-		else
-			ui.statusBar->showMessage("Input-File: File does not exist", 3000);
-	}
-	else
-		ui.statusBar->showMessage("Input-File: no Filename", 3000);
-}
-
-void STL2INP::on_pBtn_Output_pressed(){
-	QString s = QFileDialog::getSaveFileName(
-		this,
-		"Choose a filename to save under",
-		"E:/",
-		"AVS-File (*.inp)");
-	if(s != ""){
-		ui.lineEdit_Out->setText(s);
-		ui.statusBar->showMessage("Output-File: Filename defined", 3000);
-	}
-	else
-		ui.statusBar->showMessage("Output-File: No file defined", 3000);
-}
-
-void STL2INP::on_lineEdit_Out_returnPressed(){
-	QString s = ui.lineEdit_Out->text();
-	if(s != ""){
-		if(!s.endsWith(".inp",Qt::CaseSensitivity(false)))
-		{
-			s.append(".inp");
-			ui.lineEdit_Out->setText(s);
-		}
-		if (QFile::exists(s))
-			if(QMessageBox::question(this,
-				tr("Overwrite File? -- Application Name"),
-				tr("A file called %1 already exists."
-				"Do you want to overwrite it?")
-				.arg(s),
-				tr("&Yes"), tr("&No"),
-				QString(), 0, 1))
-				ui.lineEdit_Out->setText("");
-			else
-				ui.statusBar->showMessage("Output-File: overwrite existing File", 3000);
-		else
-			ui.statusBar->showMessage("Output-File: Filename defined", 3000);
-	}
-	else
-		ui.statusBar->showMessage("Output-File: No file defined", 3000);
-}
-
-void STL2INP::on_pBtn_Output_2_pressed(){
-	QString s = QFileDialog::getSaveFileName(
-		this,
-		"Choose a filename to save under",
-		"E:/",
-		"Data-File (*.dat)");
-	if(s != ""){
-		ui.pBtn_EditMesh->setEnabled(true);
-		ui.lineEdit_Out_2->setText(s);
-		ui.statusBar->showMessage("Output-File: Filename defined", 3000);
-		on_pBtn_EditMesh_pressed();
-	}
-	else
-		ui.statusBar->showMessage("Output-File: No file defined", 3000);
-}
-
-void STL2INP::on_lineEdit_Out_2_returnPressed(){
-	QString s = ui.lineEdit_Out_2->text();
-	if(s != ""){
-		ui.pBtn_EditMesh->setEnabled(true);
-		if(!s.endsWith(".dat",Qt::CaseSensitivity(false)))
-		{
-			s.append(".dat");
-			ui.lineEdit_Out_2->setText(s);
-		}
-		if (QFile::exists(s))
-			if(QMessageBox::question(this,
-				tr("Overwrite File? -- Application Name"),
-				tr("A file called %1 already exists."
-				"Do you want to overwrite it?")
-				.arg(s),
-				tr("&Yes"), tr("&No"),
-				QString(), 0, 1)){
-					ui.lineEdit_Out_2->setText("");
-					ui.pBtn_EditMesh->setEnabled(false);
-			}
-			else{
-				ui.statusBar->showMessage("Output-File: overwrite existing File", 3000);
-				ui.pBtn_EditMesh->setEnabled(true);
-			}
-		else{
-			ui.statusBar->showMessage("Output-File: Filename defined", 3000);
-			on_pBtn_EditMesh_pressed();
-		}
-	}
-	else
-		ui.statusBar->showMessage("Output-File: No file defined", 3000);
-}
-
-void STL2INP::on_pBtn_Convert_pressed(){
-	if(ui.lineEdit_In->text() == "")
-		QMessageBox::warning(this,"ERROR", "No Input-File defined!",
-		QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
-	else if(ui.lineEdit_Out->text() == "" && ui.lineEdit_Out_2->text() == "")
-		QMessageBox::warning(this,"ERROR", "No Output-File defined!",
-		QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);  
-	else
-	{
-		UbFileInputASCII *fileInput = new UbFileInputASCII(std::string(ui.lineEdit_In->text().toAscii()));
-		GbTriangularMesh3D *mesh = GbTriangularMesh3DCreator::readMeshFromSTLFile(fileInput, "Cube");
-		ui.statusBar->showMessage("Input-File was read", 3000);
-		delete fileInput;
-		cout<<mesh->toString()<<endl;
-		if(ui.checkBox_writeAVS->isChecked()){
-			if(ui.checkBox_Binary->isChecked()){
-				UbFileOutputBinary *fileOutput_AVS = new UbFileOutputBinary(std::string(ui.lineEdit_Out->text().toAscii()));
-				mesh->writeAVSMesh(fileOutput_AVS);
-				delete fileOutput_AVS;
-			}
-			else{
-				UbFileOutputASCII *fileOutput_AVS = new UbFileOutputASCII(std::string(ui.lineEdit_Out->text().toAscii()));
-				mesh->writeAVSMesh(fileOutput_AVS);
-				delete fileOutput_AVS;
-			}
-			ui.statusBar->showMessage("wrote AVS-Output-File");
-		}
-		if(ui.checkBox_writeUM->isChecked()){
-			cout<<"MinX:"<<mesh->getX1Minimum()<<endl;
-			cout<<"MaxX:"<<mesh->getX1Maximum()<<endl;
-			cout<<"MinY:"<<mesh->getX2Minimum()<<endl;
-			cout<<"MaxY:"<<mesh->getX2Maximum()<<endl;
-			cout<<"MinZ:"<<mesh->getX3Minimum()<<endl;
-			cout<<"MaxZ:"<<mesh->getX3Maximum()<<endl;
-			ui.statusBar->showMessage("start Writing Uniform-Mesh-File");
-			double minX = 0.0;
-			double minY = 0.0;    
-			double minZ = 0.0;
-
-			CoordinateTransformation3D *trafo = new CoordinateTransformation3D(minX, minY, minZ, delta, delta, delta);
-
-			UbTiming time;
-			time.initTiming();
-			time.startTiming();
-
-			ui.statusBar->showMessage("start Building FacetteGrid", 3000);
-			OctFacettenGrid2 *facettegrid = new OctFacettenGrid2("FacettenGrid", nx1, nx2, nx3, startLevel, stopLevel, mesh, trafo);
-			ui.statusBar->showMessage("end Building FacetteGrid", 3000);
-
-			UbFileOutputASCII out("E:/DATA/test.inp");
-			facettegrid->writeCellsToAVS(&out);
-
-			time.endTiming();
-			cout<<"Dauer:"<<time.getDuration()<<endl;
-			cout<<"Number of cells:"<<facettegrid->getNumberOfCells()<<endl;
-			cout<<"after generation ..."<<endl<<endl;                                         
-			double mydouble=0.0;
-
-			time.initTiming(); 
-			time.startTiming();
-			ui.statusBar->showMessage("start writing", 3000);
-			UbFileOutputASCII *fileOutput_UM = new UbFileOutputASCII(std::string(ui.lineEdit_Out_2->text().toAscii()));
-			facettegrid->writeToUniformGridFile2(fileOutput_UM);
-			delete fileOutput_UM;
-			time.endTiming();
-			cout<<"Dauer:"<<time.getDuration()<<endl;
-			int number = (int)facettegrid->getCells()->size();
-			delete trafo;
-			delete mesh;
-			delete facettegrid;
-			cout<<"Ready!!!"<<endl;
-			ui.statusBar->showMessage("wrote Unstructured-Mesh Output-File", 3000);
-		}
-	}
-}
-
-void STL2INP::on_checkBox_stateChanged(int)
-{
-
-}
-
-void STL2INP::on_pBtn_EditMesh_pressed()
-{
-	QDefineUniformMesh *meshdef = new QDefineUniformMesh(this); 
-	meshdef->setStartLevel(startLevel);
-	meshdef->setStopLevel(stopLevel);
-	meshdef->setDelta(delta);
-	meshdef->setNX1(nx1);
-	meshdef->setNX2(nx2);
-	meshdef->setNX3(nx3);
-	meshdef->exec();
-
-	startLevel = meshdef->getStartLevel();
-	stopLevel = meshdef->getStopLevel();
-	//cout<<"Start-Level: "<<startLevel<<"  Stop-Level: "<<stopLevel<<endl;
-	delta = meshdef->getDelta();
-	//cout<<"Delta: "<<delta<<endl;
-	nx1 = meshdef->getNX1();
-	nx2 = meshdef->getNX2();
-	nx3 = meshdef->getNX3();
-	//cout<<"nx1: "<<nx1<<"  nx2: "<<nx2<<"  nx3: "<<nx3<<endl;
-	delete meshdef;
+#include "stl2inp.h"
+#include <QtGui/QFileDialog>
+#include <QString>
+#include <QFile>
+#include <QMessageBox>
+#include <cstdio>
+
+#include "./QDefineUniformMesh.h"
+
+#include "./../../../../../source/basics/utilities/UbFileInputASCII.h"
+#include "./../../../../../source/basics/utilities/UbFileOutputASCII.h"
+#include "./../../../../../source/basics/utilities/UbFileOutputBinary.h"
+#include "./../../../../../source/numerics/geometry3d/GbTriangularMesh3D.h"
+#include "./../../../../../source/numerics/geometry3d/creator/GbTriangularMesh3DCreator.h"
+#include "./../../../../../source/numerics/geometry3D/CoordinateTransformation3D.h"
+#include "./../../../../../source/basics/utilities/UbTiming.h"
+#include "./../../../../../source/octree/facette/OctFacettenGrid2.h"
+
+STL2INP::STL2INP(QWidget *parent, Qt::WFlags flags)
+: QMainWindow(parent, flags)
+{
+	ui.setupUi(this);
+	startLevel	= 0;
+	stopLevel	= 3;
+	delta		= 10.00;
+	nx1			= 30;
+	nx2			= 15;
+	nx3			= 5;
+	
+}
+
+STL2INP::~STL2INP()
+{
+
+}
+
+void STL2INP::on_pBtn_Input_pressed()
+{
+	QString s = QFileDialog::getOpenFileName(
+		this,
+		"Choose a file",
+		"E:/",
+		"STL-Files (*.stl)");
+	if(s != ""){
+		ui.lineEdit_In->setText(s);
+		ui.statusBar->showMessage("Input-File: Filename defined", 3000);
+	}
+	else
+		ui.statusBar->showMessage("Input-File: No file found", 3000);
+
+}
+
+void STL2INP::on_lineEdit_In_returnPressed(){
+	QString s = ui.lineEdit_In->text();
+	if(s != ""){
+		if(!s.endsWith(".stl",Qt::CaseSensitivity(false)))
+		{
+			s.append(".stl");
+			ui.lineEdit_In->setText(s);
+		}
+		if(QFile::exists(s))
+			ui.statusBar->showMessage("Inputput-File: File found", 3000);
+		else
+			ui.statusBar->showMessage("Input-File: File does not exist", 3000);
+	}
+	else
+		ui.statusBar->showMessage("Input-File: no Filename", 3000);
+}
+
+void STL2INP::on_pBtn_Output_pressed(){
+	QString s = QFileDialog::getSaveFileName(
+		this,
+		"Choose a filename to save under",
+		"E:/",
+		"AVS-File (*.inp)");
+	if(s != ""){
+		ui.lineEdit_Out->setText(s);
+		ui.statusBar->showMessage("Output-File: Filename defined", 3000);
+	}
+	else
+		ui.statusBar->showMessage("Output-File: No file defined", 3000);
+}
+
+void STL2INP::on_lineEdit_Out_returnPressed(){
+	QString s = ui.lineEdit_Out->text();
+	if(s != ""){
+		if(!s.endsWith(".inp",Qt::CaseSensitivity(false)))
+		{
+			s.append(".inp");
+			ui.lineEdit_Out->setText(s);
+		}
+		if (QFile::exists(s))
+			if(QMessageBox::question(this,
+				tr("Overwrite File? -- Application Name"),
+				tr("A file called %1 already exists."
+				"Do you want to overwrite it?")
+				.arg(s),
+				tr("&Yes"), tr("&No"),
+				QString(), 0, 1))
+				ui.lineEdit_Out->setText("");
+			else
+				ui.statusBar->showMessage("Output-File: overwrite existing File", 3000);
+		else
+			ui.statusBar->showMessage("Output-File: Filename defined", 3000);
+	}
+	else
+		ui.statusBar->showMessage("Output-File: No file defined", 3000);
+}
+
+void STL2INP::on_pBtn_Output_2_pressed(){
+	QString s = QFileDialog::getSaveFileName(
+		this,
+		"Choose a filename to save under",
+		"E:/",
+		"Data-File (*.dat)");
+	if(s != ""){
+		ui.pBtn_EditMesh->setEnabled(true);
+		ui.lineEdit_Out_2->setText(s);
+		ui.statusBar->showMessage("Output-File: Filename defined", 3000);
+		on_pBtn_EditMesh_pressed();
+	}
+	else
+		ui.statusBar->showMessage("Output-File: No file defined", 3000);
+}
+
+void STL2INP::on_lineEdit_Out_2_returnPressed(){
+	QString s = ui.lineEdit_Out_2->text();
+	if(s != ""){
+		ui.pBtn_EditMesh->setEnabled(true);
+		if(!s.endsWith(".dat",Qt::CaseSensitivity(false)))
+		{
+			s.append(".dat");
+			ui.lineEdit_Out_2->setText(s);
+		}
+		if (QFile::exists(s))
+			if(QMessageBox::question(this,
+				tr("Overwrite File? -- Application Name"),
+				tr("A file called %1 already exists."
+				"Do you want to overwrite it?")
+				.arg(s),
+				tr("&Yes"), tr("&No"),
+				QString(), 0, 1)){
+					ui.lineEdit_Out_2->setText("");
+					ui.pBtn_EditMesh->setEnabled(false);
+			}
+			else{
+				ui.statusBar->showMessage("Output-File: overwrite existing File", 3000);
+				ui.pBtn_EditMesh->setEnabled(true);
+			}
+		else{
+			ui.statusBar->showMessage("Output-File: Filename defined", 3000);
+			on_pBtn_EditMesh_pressed();
+		}
+	}
+	else
+		ui.statusBar->showMessage("Output-File: No file defined", 3000);
+}
+
+void STL2INP::on_pBtn_Convert_pressed(){
+	if(ui.lineEdit_In->text() == "")
+		QMessageBox::warning(this,"ERROR", "No Input-File defined!",
+		QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
+	else if(ui.lineEdit_Out->text() == "" && ui.lineEdit_Out_2->text() == "")
+		QMessageBox::warning(this,"ERROR", "No Output-File defined!",
+		QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);  
+	else
+	{
+		UbFileInputASCII *fileInput = new UbFileInputASCII(std::string(ui.lineEdit_In->text().toAscii()));
+		GbTriangularMesh3D *mesh = GbTriangularMesh3DCreator::readMeshFromSTLFile(fileInput, "Cube");
+		ui.statusBar->showMessage("Input-File was read", 3000);
+		delete fileInput;
+		cout<<mesh->toString()<<endl;
+		if(ui.checkBox_writeAVS->isChecked()){
+			if(ui.checkBox_Binary->isChecked()){
+				UbFileOutputBinary *fileOutput_AVS = new UbFileOutputBinary(std::string(ui.lineEdit_Out->text().toAscii()));
+				mesh->writeAVSMesh(fileOutput_AVS);
+				delete fileOutput_AVS;
+			}
+			else{
+				UbFileOutputASCII *fileOutput_AVS = new UbFileOutputASCII(std::string(ui.lineEdit_Out->text().toAscii()));
+				mesh->writeAVSMesh(fileOutput_AVS);
+				delete fileOutput_AVS;
+			}
+			ui.statusBar->showMessage("wrote AVS-Output-File");
+		}
+		if(ui.checkBox_writeUM->isChecked()){
+			cout<<"MinX:"<<mesh->getX1Minimum()<<endl;
+			cout<<"MaxX:"<<mesh->getX1Maximum()<<endl;
+			cout<<"MinY:"<<mesh->getX2Minimum()<<endl;
+			cout<<"MaxY:"<<mesh->getX2Maximum()<<endl;
+			cout<<"MinZ:"<<mesh->getX3Minimum()<<endl;
+			cout<<"MaxZ:"<<mesh->getX3Maximum()<<endl;
+			ui.statusBar->showMessage("start Writing Uniform-Mesh-File");
+			double minX = 0.0;
+			double minY = 0.0;    
+			double minZ = 0.0;
+
+			CoordinateTransformation3D *trafo = new CoordinateTransformation3D(minX, minY, minZ, delta, delta, delta);
+
+			UbTiming time;
+			time.initTiming();
+			time.startTiming();
+
+			ui.statusBar->showMessage("start Building FacetteGrid", 3000);
+			OctFacettenGrid2 *facettegrid = new OctFacettenGrid2("FacettenGrid", nx1, nx2, nx3, startLevel, stopLevel, mesh, trafo);
+			ui.statusBar->showMessage("end Building FacetteGrid", 3000);
+
+			UbFileOutputASCII out("E:/DATA/test.inp");
+			facettegrid->writeCellsToAVS(&out);
+
+			time.endTiming();
+			cout<<"Dauer:"<<time.getDuration()<<endl;
+			cout<<"Number of cells:"<<facettegrid->getNumberOfCells()<<endl;
+			cout<<"after generation ..."<<endl<<endl;                                         
+			double mydouble=0.0;
+
+			time.initTiming(); 
+			time.startTiming();
+			ui.statusBar->showMessage("start writing", 3000);
+			UbFileOutputASCII *fileOutput_UM = new UbFileOutputASCII(std::string(ui.lineEdit_Out_2->text().toAscii()));
+			facettegrid->writeToUniformGridFile2(fileOutput_UM);
+			delete fileOutput_UM;
+			time.endTiming();
+			cout<<"Dauer:"<<time.getDuration()<<endl;
+			int number = (int)facettegrid->getCells()->size();
+			delete trafo;
+			delete mesh;
+			delete facettegrid;
+			cout<<"Ready!!!"<<endl;
+			ui.statusBar->showMessage("wrote Unstructured-Mesh Output-File", 3000);
+		}
+	}
+}
+
+void STL2INP::on_checkBox_stateChanged(int)
+{
+
+}
+
+void STL2INP::on_pBtn_EditMesh_pressed()
+{
+	QDefineUniformMesh *meshdef = new QDefineUniformMesh(this); 
+	meshdef->setStartLevel(startLevel);
+	meshdef->setStopLevel(stopLevel);
+	meshdef->setDelta(delta);
+	meshdef->setNX1(nx1);
+	meshdef->setNX2(nx2);
+	meshdef->setNX3(nx3);
+	meshdef->exec();
+
+	startLevel = meshdef->getStartLevel();
+	stopLevel = meshdef->getStopLevel();
+	//cout<<"Start-Level: "<<startLevel<<"  Stop-Level: "<<stopLevel<<endl;
+	delta = meshdef->getDelta();
+	//cout<<"Delta: "<<delta<<endl;
+	nx1 = meshdef->getNX1();
+	nx2 = meshdef->getNX2();
+	nx3 = meshdef->getNX3();
+	//cout<<"nx1: "<<nx1<<"  nx2: "<<nx2<<"  nx3: "<<nx3<<endl;
+	delete meshdef;
 }
\ No newline at end of file
diff --git a/source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.h b/source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/stl2inp.h
similarity index 95%
rename from source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/stl2inp.h
index a48fd463a7bc7ebb9ad0a16b83c78368365d5630..353f2a2a72a2b9f6677029a4976da697cd141ef2 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/stl2inp.h
@@ -1,36 +1,36 @@
-#ifndef STL2INP_H
-#define STL2INP_H
-
-#include <QtGui/QMainWindow>
-#include <QtGui/QProgressBar>
-#include <QTimer>
-#include "stl2inpUI.h"
-
-class STL2INP : public QMainWindow
-{
-	Q_OBJECT
-
-public:
-	STL2INP(QWidget *parent = 0, Qt::WFlags flags = 0);
-	~STL2INP();
-	
-	int startLevel, stopLevel;
-	double delta;
-	int nx1, nx2, nx3;
-
-private:
-	Ui::STL2INPClass ui;
-
-	private slots:
-		void on_checkBox_stateChanged(int);
-		void on_pBtn_Input_pressed();
-		void on_pBtn_Output_pressed();
-		void on_pBtn_Output_2_pressed();
-		void on_pBtn_Convert_pressed();
-		void on_lineEdit_In_returnPressed();
-		void on_lineEdit_Out_returnPressed();
-		void on_lineEdit_Out_2_returnPressed();
-		void on_pBtn_EditMesh_pressed();
-};
-
-#endif // STL2INP_H
+#ifndef STL2INP_H
+#define STL2INP_H
+
+#include <QtGui/QMainWindow>
+#include <QtGui/QProgressBar>
+#include <QTimer>
+#include "stl2inpUI.h"
+
+class STL2INP : public QMainWindow
+{
+	Q_OBJECT
+
+public:
+	STL2INP(QWidget *parent = 0, Qt::WFlags flags = 0);
+	~STL2INP();
+	
+	int startLevel, stopLevel;
+	double delta;
+	int nx1, nx2, nx3;
+
+private:
+	Ui::STL2INPClass ui;
+
+	private slots:
+		void on_checkBox_stateChanged(int);
+		void on_pBtn_Input_pressed();
+		void on_pBtn_Output_pressed();
+		void on_pBtn_Output_2_pressed();
+		void on_pBtn_Convert_pressed();
+		void on_lineEdit_In_returnPressed();
+		void on_lineEdit_Out_returnPressed();
+		void on_lineEdit_Out_2_returnPressed();
+		void on_pBtn_EditMesh_pressed();
+};
+
+#endif // STL2INP_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.ui b/source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/stl2inp.ui
similarity index 100%
rename from source/ThirdParty/Library/numerics/geometry3d/examples/stl2inp/stl2inp.ui
rename to source/VirtualFluidsBasic/numerics/geometry3d/examples/stl2inp/stl2inp.ui
diff --git a/source/ThirdParty/Library/numerics/geometry3d/fem/CMakePackage.txt b/source/VirtualFluidsBasic/numerics/geometry3d/fem/CMakePackage.txt
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/fem/CMakePackage.txt
rename to source/VirtualFluidsBasic/numerics/geometry3d/fem/CMakePackage.txt
index fb2d6a4735aec73c8966db5d20f5b8ac29612b9e..e1eabdd71c235a7e5acbf03ab4c113140d0f1bf9 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/fem/CMakePackage.txt
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/fem/CMakePackage.txt
@@ -1,37 +1,37 @@
-SET(SUBDIRPATH numerics/geometry3d/fem) 
-SET(OPTION_LABEL BUILD_GEO3D_FEM)
-
-SET(CURRENT_DIR ${SOURCE_ROOT}/${SUBDIRPATH})
-
-OPTION(${OPTION_LABEL} "${CURRENT_DIR}" ON)
-IF(${OPTION_LABEL})
-  SET(TEMP_FILES "") 
-  FILE(GLOB HEADER_FILES ${CURRENT_DIR}/*.h  )
-  FILE(GLOB CPP_FILES    ${CURRENT_DIR}/*.cpp)
-  
-
-  SET(TEMPO_FILES ${HEADER_FILES} ${CPP_FILES})
-  IF(NOT ADHOC)
-    FILE(GLOB ADHOC_FILES ${CURRENT_DIR}/*Adhoc* )
-    REMOVE(TEMPO_FILES ${ADHOC_FILES} )
-  ENDIF(NOT ADHOC)
-
-  IF(NOT EIGENVALUE)
-    FILE(GLOB EIGENVALUE_FILES ${CURRENT_DIR}/*Eigen* )
-    REMOVE(TEMPO_FILES ${EIGENVALUE_FILES} )
-  ENDIF(NOT EIGENVALUE)
-
-IF(CAB_PACKAGE_DEFINTIONS)
-    SET_SOURCE_FILES_PROPERTIES(${CPP_FILES} PROPERTIES COMPILE_FLAGS ${CAB_PACKAGE_DEFINTIONS})
-ENDIF(CAB_PACKAGE_DEFINTIONS)
-
-  SET(ALL_SOURCES ${ALL_SOURCES} ${TEMPO_FILES})
-  
-  IF(${WITH_SUBFOLDERS_FOR_SG} MATCHES YES)  
-    STRING(REGEX REPLACE "/" "\\\\" SG_PATH ${SUBDIRPATH})
-    SOURCE_GROUP(${SG_PATH} FILES ${TEMPO_FILES})
-  ELSE(${WITH_SUBFOLDERS_FOR_SG} MATCHES YES)
-    SOURCE_GROUP(${SUBDIRPATH} FILES ${TEMPO_FILES})
-  ENDIF(${WITH_SUBFOLDERS_FOR_SG} MATCHES YES)
-
-ENDIF(${OPTION_LABEL})
+SET(SUBDIRPATH numerics/geometry3d/fem) 
+SET(OPTION_LABEL BUILD_GEO3D_FEM)
+
+SET(CURRENT_DIR ${SOURCE_ROOT}/${SUBDIRPATH})
+
+OPTION(${OPTION_LABEL} "${CURRENT_DIR}" ON)
+IF(${OPTION_LABEL})
+  SET(TEMP_FILES "") 
+  FILE(GLOB HEADER_FILES ${CURRENT_DIR}/*.h  )
+  FILE(GLOB CPP_FILES    ${CURRENT_DIR}/*.cpp)
+  
+
+  SET(TEMPO_FILES ${HEADER_FILES} ${CPP_FILES})
+  IF(NOT ADHOC)
+    FILE(GLOB ADHOC_FILES ${CURRENT_DIR}/*Adhoc* )
+    REMOVE(TEMPO_FILES ${ADHOC_FILES} )
+  ENDIF(NOT ADHOC)
+
+  IF(NOT EIGENVALUE)
+    FILE(GLOB EIGENVALUE_FILES ${CURRENT_DIR}/*Eigen* )
+    REMOVE(TEMPO_FILES ${EIGENVALUE_FILES} )
+  ENDIF(NOT EIGENVALUE)
+
+IF(CAB_PACKAGE_DEFINTIONS)
+    SET_SOURCE_FILES_PROPERTIES(${CPP_FILES} PROPERTIES COMPILE_FLAGS ${CAB_PACKAGE_DEFINTIONS})
+ENDIF(CAB_PACKAGE_DEFINTIONS)
+
+  SET(ALL_SOURCES ${ALL_SOURCES} ${TEMPO_FILES})
+  
+  IF(${WITH_SUBFOLDERS_FOR_SG} MATCHES YES)  
+    STRING(REGEX REPLACE "/" "\\\\" SG_PATH ${SUBDIRPATH})
+    SOURCE_GROUP(${SG_PATH} FILES ${TEMPO_FILES})
+  ELSE(${WITH_SUBFOLDERS_FOR_SG} MATCHES YES)
+    SOURCE_GROUP(${SUBDIRPATH} FILES ${TEMPO_FILES})
+  ENDIF(${WITH_SUBFOLDERS_FOR_SG} MATCHES YES)
+
+ENDIF(${OPTION_LABEL})
diff --git a/source/ThirdParty/Library/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp
similarity index 100%
rename from source/ThirdParty/Library/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp
diff --git a/source/ThirdParty/Library/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.h
index e0f3e339aa742b7669e18ad84c50a078771da7ab..99a0a983fc1783d8f4931b1411be9b75c97b9e72 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.h
@@ -1,62 +1,62 @@
-#ifndef FEADHOCTRIFACEMESH3D_H
-#define FEADHOCTRIFACEMESH3D_H
-
-#include <sstream>
-#include <iostream>
-#include <vector>
-using namespace std;
-
-//extern "C"
-//{
-   //#include "mshpi.h"
-    #include "fsi_interface.h"
-    #include "fsi_user_interface.h"
-//}
-
-#include "./FeTriFaceMesh3D.h"
-
-#ifdef CAB_RCF
-#include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-
-/*=========================================================================*/
-/* FeAdhocTriFaceMesh3D                                                    */
-/*                                                                         */
-/**
- * This Class provides the triangular meshes.
- * Note, that up to now no methods for checking consistency are included.
- * in this context this class describes facettes from an 3D-object !!!
-*/
-class FeAdhocTriFaceMesh3D : public FeTriFaceMesh3D
-{
-public:
-   FeAdhocTriFaceMesh3D();
-   FeAdhocTriFaceMesh3D(std::string name, Mesh *mesh);
-
-   Mesh*  getMesh() { return mesh; }
-
-   void writeAdhoCMeshForStefan(string filename);
-   std::vector< ::Vertex*>* getAdhocVertices() { return this->adhocVertices; }
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void serialize(Archive & ar, const unsigned int version)
-   {
-      serializeParent<FeTriFaceMesh3D>(ar, *this);
-   }
-#endif //CAB_RCF
-
-private:
-   Mesh* mesh;
-   std::vector< ::Vertex*>* adhocVertices;
-};
-
-#ifdef RCF_USE_SF_SERIALIZATION
-UB_AUTO_RUN_NAMED(   SF::registerType<FeAdhocTriFaceMesh3D  >("FeAdhocTriFaceMesh3D  ")    , SF_FeAdhocTriFaceMesh3D     );
-UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< FeTriFaceMesh3D, FeAdhocTriFaceMesh3D>() ), SF_FeAdhocTriFaceMesh3D_BD1 );
-UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbTriFaceMesh3D, FeAdhocTriFaceMesh3D>() ), SF_FeAdhocTriFaceMesh3D_BD2 );
-UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, FeAdhocTriFaceMesh3D>() ), SF_FeAdhocTriFaceMesh3D_BD3 );
-#endif //RCF_USE_SF_SERIALIZATION
-
-#endif //FEADHOCTRIFACEMESH3D_H
+#ifndef FEADHOCTRIFACEMESH3D_H
+#define FEADHOCTRIFACEMESH3D_H
+
+#include <sstream>
+#include <iostream>
+#include <vector>
+using namespace std;
+
+//extern "C"
+//{
+   //#include "mshpi.h"
+    #include "fsi_interface.h"
+    #include "fsi_user_interface.h"
+//}
+
+#include "./FeTriFaceMesh3D.h"
+
+#ifdef CAB_RCF
+#include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+
+/*=========================================================================*/
+/* FeAdhocTriFaceMesh3D                                                    */
+/*                                                                         */
+/**
+ * This Class provides the triangular meshes.
+ * Note, that up to now no methods for checking consistency are included.
+ * in this context this class describes facettes from an 3D-object !!!
+*/
+class FeAdhocTriFaceMesh3D : public FeTriFaceMesh3D
+{
+public:
+   FeAdhocTriFaceMesh3D();
+   FeAdhocTriFaceMesh3D(std::string name, Mesh *mesh);
+
+   Mesh*  getMesh() { return mesh; }
+
+   void writeAdhoCMeshForStefan(string filename);
+   std::vector< ::Vertex*>* getAdhocVertices() { return this->adhocVertices; }
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void serialize(Archive & ar, const unsigned int version)
+   {
+      serializeParent<FeTriFaceMesh3D>(ar, *this);
+   }
+#endif //CAB_RCF
+
+private:
+   Mesh* mesh;
+   std::vector< ::Vertex*>* adhocVertices;
+};
+
+#ifdef RCF_USE_SF_SERIALIZATION
+UB_AUTO_RUN_NAMED(   SF::registerType<FeAdhocTriFaceMesh3D  >("FeAdhocTriFaceMesh3D  ")    , SF_FeAdhocTriFaceMesh3D     );
+UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< FeTriFaceMesh3D, FeAdhocTriFaceMesh3D>() ), SF_FeAdhocTriFaceMesh3D_BD1 );
+UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbTriFaceMesh3D, FeAdhocTriFaceMesh3D>() ), SF_FeAdhocTriFaceMesh3D_BD2 );
+UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, FeAdhocTriFaceMesh3D>() ), SF_FeAdhocTriFaceMesh3D_BD3 );
+#endif //RCF_USE_SF_SERIALIZATION
+
+#endif //FEADHOCTRIFACEMESH3D_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/fem/FeHalfDisc3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FeHalfDisc3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/fem/FeHalfDisc3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/fem/FeHalfDisc3D.cpp
index 0b392588173b909338d025e7dc752f4decf95c66..b3751d20d04f2968c0d6cb97d25333c26d371463 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/fem/FeHalfDisc3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FeHalfDisc3D.cpp
@@ -1,622 +1,622 @@
-#include <numerics/geometry3d/fem/FeHalfDisc3D.h>    
-#include <numerics/geometry3d/GbSystem3D.h>
-#include <numerics/geometry3d/GbLine3D.h>
-#include <numerics/geometry3d/GbTriangle3D.h>
-#include <numerics/geometry3d/fem/FePoint3D.h>
-#include <basics/utilities/UbInfinity.h>
-
-using namespace std;
-
-/*=======================================================*/
-ObObjectCreator* FeHalfDisc3D::getCreator()
-{
-   return NULL;//FeHalfDisc3DCreator::getInstance(); 
-}
-// Konstruktor
-/*==========================================================*/
-FeHalfDisc3D::FeHalfDisc3D()
-{
-   GbPoint3D* p1 = new GbPoint3D();
-   GbPoint3D* p2 = new GbPoint3D();
-   mLine = new GbLine3D(p1,p2);
-   this->mLine->addObserver(this);
-   mRad = 0.0;
-   cylinderType = FeHalfDisc3D::NOTPARALLELTOAXIS;
-}                                                   
-/*=======================================================*/
-FeHalfDisc3D::FeHalfDisc3D(FeHalfDisc3D* cylinder)
-{
-   mRad         = cylinder->getRadius();
-   cylinderType = cylinder->cylinderType;
-   mLine        = cylinder->getLine()->clone();
-
-   this->mLine->addObserver(this);
-}                                                   
-/*==========================================================*/
-FeHalfDisc3D::FeHalfDisc3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& rad)
-{
-   mLine = new GbLine3D;
-   mLine->setPoints( new GbPoint3D(min(x1a,x1b), min(x2a,x2b), min(x3a,x3b))
-	                 ,new GbPoint3D(max(x1a,x1b), max(x2a,x2b), max(x3a,x3b)));
-   this->mLine->addObserver(this);
-   mRad = fabs(rad);
-
-   this->initCylinderType();
-   if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) 
-      throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}                                                            
-/*==========================================================*/
-FeHalfDisc3D::FeHalfDisc3D(GbPoint3D* p1, GbPoint3D* p2, const double& rad)
-{
-   mRad = rad;
-
-   mLine = new GbLine3D(p1,p2);
-   this->mLine->addObserver(this);
-   this->initCylinderType();
-   if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) 
-      throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}
-/*==========================================================*/
-FeHalfDisc3D::FeHalfDisc3D(GbLine3D* line, const double& rad)
-{
-   mRad = rad;
-
-   this->mLine = line;
-   this->mLine->addObserver(this);
-   this->initCylinderType();
-   if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) 
-      throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}
-/*==========================================================*/		
-// Destruktor
-FeHalfDisc3D::~FeHalfDisc3D()
-{
-   if(mLine) this->mLine->removeObserver(this);
-   mLine = NULL;
-}
-/*=======================================================*/
-void FeHalfDisc3D::initCylinderType()
-{
-   double x1a = mLine->getPoint1()->x1;    double x1b = mLine->getPoint2()->x1;
-   double x2a = mLine->getPoint1()->x2;    double x2b = mLine->getPoint2()->x2;
-   double x3a = mLine->getPoint1()->x3;    double x3b = mLine->getPoint2()->x3;
-   
-   if     (x1a!=x1b && x2a==x2b && x3a==x3b)  this->cylinderType = X1PARALLEL; 
-   else if(x2a!=x2b && x1a==x1b && x3a==x3b)  this->cylinderType = X2PARALLEL; 
-   else if(x3a!=x3b && x1a==x1b && x2a==x2b)  this->cylinderType = X3PARALLEL; 
-   else                                       this->cylinderType = NOTPARALLELTOAXIS;
-}
-/*=======================================================*/
-void FeHalfDisc3D::finalize() 
-{ 
-   if(this->mLine) 
-   {
-      mLine->finalize();
-      delete mLine; 
-      mLine=NULL;
-   } 
-}
-/*=======================================================*/
-double FeHalfDisc3D::getHeight()
-{
-   if(mLine) return mLine->getLength(); return 0.0; 
-}
-/*=======================================================*/
-GbPoint3D* FeHalfDisc3D::getPoint1()
-{
-   if(this->mLine) return this->mLine->getPoint1();
-   return NULL;
-}
-/*=======================================================*/
-GbPoint3D* FeHalfDisc3D::getPoint2()
-{
-   if(this->mLine) return this->mLine->getPoint2();
-   return NULL;
-}
-/*=======================================================*/
-void FeHalfDisc3D::setRadius(const double& radius) 
-{ 
-   this->mRad = std::fabs(radius); 
-   this->notifyObserversObjectChanged();
-}
-/*=======================================================*/
-void FeHalfDisc3D::setLine(GbLine3D* line) 
-{
-   if(this->mLine) this->mLine->removeObserver(this);
-   this->mLine = line;  
-   this->mLine->addObserver(this);
-   this->initCylinderType();
-
-   this->notifyObserversObjectChanged();
-}
-/*=======================================================*/
-void FeHalfDisc3D::setPoint1(const double& x1, const double& x2, const double& x3)
-{ 
-   if(!mLine->getPoint1()) throw UbException(UB_EXARGS,"line has no point1");
-   mLine->getPoint1()->setCoordinates(x1,x2,x3);
-   this->initCylinderType();
-
-   //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt...
-}
-/*=======================================================*/
-void FeHalfDisc3D::setPoint2(const double& x1, const double& x2, const double& x3)
-{ 
-   if(!mLine->getPoint2()) throw UbException(UB_EXARGS,"line has no point2");
-   mLine->getPoint2()->setCoordinates(x1,x2,x3);
-   this->initCylinderType();
-
-   //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt...
-}
-/*==========================================================*/		
-double FeHalfDisc3D::getX1Centroid()  
-{
-   return mLine->getX1Centroid();
-}
-/*==========================================================*/
-double FeHalfDisc3D::getX1Minimum()   
-{
-   if     (this->isParallelToX1Axis()) return mLine->getX1Minimum(); 
-   else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()-mRad; 
-   else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()-mRad; 
-   else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}
-/*==========================================================*/
-double FeHalfDisc3D::getX1Maximum()   
-{
-   if     (this->isParallelToX1Axis()) return mLine->getX1Maximum(); 
-   else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()+mRad; 
-   else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()+mRad; 
-   else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}
-/*==========================================================*/
-double FeHalfDisc3D::getX2Centroid()
-{
-   return mLine->getX2Centroid();
-}
-/*==========================================================*/
-double FeHalfDisc3D::getX2Minimum()   
-{
-   if     (this->isParallelToX1Axis()) return mLine->getX2Centroid()-mRad;
-   else if(this->isParallelToX2Axis()) return mLine->getX2Minimum();
-   else if(this->isParallelToX3Axis()) return mLine->getX2Centroid()-mRad; 
-   else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}	
-/*==========================================================*/
-double FeHalfDisc3D::getX2Maximum()   
-{
-   if     (this->isParallelToX1Axis())  return mLine->getX2Centroid()+mRad;
-   else if(this->isParallelToX2Axis())  return mLine->getX2Maximum();
-   else if(this->isParallelToX3Axis())  return mLine->getX2Centroid()+mRad; 
-   else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}
-/*==========================================================*/
-double FeHalfDisc3D::getX3Centroid()
-{
-   return mLine->getX3Centroid();
-}
-/*==========================================================*/
-double FeHalfDisc3D::getX3Minimum()   
-{	
-   if     (this->isParallelToX1Axis()) return mLine->getX3Centroid()-mRad;
-   else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()-mRad; 
-   else if(this->isParallelToX3Axis()) return mLine->getX3Minimum(); 
-   else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}	
-/*==========================================================*/
-double FeHalfDisc3D::getX3Maximum()   
-{
-   if     (this->isParallelToX1Axis()) return mLine->getX3Centroid()+mRad;
-   else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()+mRad; 
-   else if(this->isParallelToX3Axis()) return mLine->getX3Maximum(); 
-   else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}
-/*==========================================================*/
-bool FeHalfDisc3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
-{
-   throw UbException(UB_EXARGS,"sollte mal einer machen ... ");
-}
-/*==========================================================*/
-bool FeHalfDisc3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
-{
-   throw UbException(UB_EXARGS,"sollte mal einer machen ... ");
-}
-/*=======================================================*/
-bool FeHalfDisc3D::isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-{
-   throw UbException(UB_EXARGS,"sollte mal einer machen ... ");
-}
-
-/*==========================================================*/
-string FeHalfDisc3D::toString() 
-{
-	stringstream ss;
-	ss<<"FeHalfDisc3D[";
-	ss<<"line="<<this->mLine->toString();
-   ss<<", r="<<this->mRad;
-   ss<<"]";
-   return(ss.str());
-}
-/*==========================================================*/
-bool FeHalfDisc3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-{
-   throw UbException(UB_EXARGS,"sollte mal einer machen ... ");   
-}
-/*==========================================================*/
-bool FeHalfDisc3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-{
-   throw UbException(UB_EXARGS,"sollte mal einer machen ... ");
-}
-/*==========================================================*/
-GbLine3D* FeHalfDisc3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
-{
-   throw UbException(UB_EXARGS,"sollte mal einer machen ... ");
-}
-/*==========================================================*/
-vector<GbTriangle3D*> FeHalfDisc3D::getSurfaceTriangleSet()
-{
-   double x1ma,x1mb,x2m,x3m;
-   if( this->isParallelToX1Axis() ) 
-   {
-      x1ma = this->getX1Minimum();
-      x1mb = this->getX1Maximum();
-      x2m  = this->getX2Centroid();
-      x3m  = this->getX3Centroid();
-   }
-   else if( this->isParallelToX2Axis() ) 
-   {
-      x1ma = this->getX2Minimum();
-      x1mb = this->getX2Maximum();
-      x2m  = this->getX1Centroid();
-      x3m  = this->getX3Centroid();
-   }
-   else if( this->isParallelToX3Axis() ) 
-   {
-      x1ma = this->getX3Minimum();
-      x1mb = this->getX3Maximum();
-      x2m  = this->getX2Centroid();
-      x3m  = this->getX1Centroid();
-   }
-   else throw UbException(UB_EXARGS,"cylinder is not axis prallel");
-   
-   vector<GbTriangle3D*> triangles;    
-
-   int segmentsCircle  = 14;
-   double deltaPhi = UbMath::PI/(double)segmentsCircle;
-
-   double phiX1a,phiX1b;
-   double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d;
-   
-   double dXCylinder =  fabs((x1mb-x1ma)); ///(double)0.5;
-   int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder);
-   for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++)
-   {
-      x1a = x1d = x1ma+segCyl*dXCylinder;
-      x1b = x1c = x1a+dXCylinder;
-      
-      for(phiX1a=UbMath::PI-deltaPhi; phiX1a>-deltaPhi; phiX1a-=deltaPhi)
-      {
-         phiX1b = phiX1a+deltaPhi;
-         
-         x2a =  x2m+mRad*std::sin(phiX1a);
-         x3a =  x3m+mRad*std::cos(phiX1a);
-         x2b =  x2m+mRad*std::sin(phiX1b);
-         x3b =  x3m+mRad*std::cos(phiX1b);
-         
-         if( this->isParallelToX1Axis() ) 
-         { 
-            triangles.push_back(new GbTriangle3D(new FePoint3D(x1b,x2a,x3a),new FePoint3D(x1b,x2b,x3b),new FePoint3D(x1a,x2a,x3a)));
-            triangles.push_back(new GbTriangle3D(new FePoint3D(x1a,x2b,x3b),new FePoint3D(x1a,x2a,x3a),new FePoint3D(x1b,x2b,x3b))); 
-         }
-         else if( this->isParallelToX2Axis() ) 
-         { 
-            triangles.push_back(new GbTriangle3D(new FePoint3D(x2b,x1b,x3b),new FePoint3D(x2a,x1b,x3a),new FePoint3D(x2a,x1a,x3a)));
-            triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1a,x3a),new FePoint3D(x2b,x1a,x3b),new FePoint3D(x2b,x1b,x3b))); 
-         }
-         else if( this->isParallelToX3Axis() ) 
-         { 
-            triangles.push_back(new GbTriangle3D(new FePoint3D(x3b,x2b,x1b),new FePoint3D(x3a,x2a,x1b),new FePoint3D(x3a,x2a,x1a)));
-            triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1a),new FePoint3D(x3b,x2b,x1a),new FePoint3D(x3b,x2b,x1b))); 
-         }
-
-      }
-   }
-
-   x2a = x2m;
-   x3a = x3m;
-   x2d = x2m;
-   x3d = x3m+mRad;
-   x3b = x3m;
-   x3c = x3m-mRad;
-   
-   triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2a,x3a),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1ma,x2a,x3d)));
-   triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2a,x3d),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1mb,x2a,x3d)));
-   triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2a,x3b),new FePoint3D(x1ma,x2a,x3b),new FePoint3D(x1ma,x2a,x3c)));
-   triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2a,x3b),new FePoint3D(x1ma,x2a,x3c),new FePoint3D(x1mb,x2a,x3c)));
-  
-   for(phiX1a=UbMath::PI-deltaPhi; phiX1a>-deltaPhi; phiX1a-=deltaPhi)
-   {
-      phiX1b = phiX1a+deltaPhi;
-
-      x2a =  x2m;
-      x3a =  x3m;
-      x2b =  x2m;
-      x3b =  x3m;
-      x2c =  x2m+mRad*std::sin(phiX1b);
-      x3c =  x3m+mRad*std::cos(phiX1b);
-      x2d =  x2m+mRad*std::sin(phiX1a);
-      x3d =  x3m+mRad*std::cos(phiX1a);
-
-      if( this->isParallelToX1Axis() ) 
-      { 
-         triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2d,x3d),new FePoint3D(x1ma,x2c,x3c),new FePoint3D(x1ma,x2a,x3a)));
-         triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2d,x3d),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1mb,x2c,x3c)));
-      }
-      else if( this->isParallelToX2Axis() ) 
-      { 
-         triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1ma,x3a),new FePoint3D(x2b,x1ma,x3b),new FePoint3D(x2c,x1ma,x3c)));
-         triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1ma,x3c),new FePoint3D(x2d,x1ma,x3d),new FePoint3D(x2a,x1ma,x3a)));
-         triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1mb,x3c),new FePoint3D(x2b,x1mb,x3b),new FePoint3D(x2a,x1mb,x3a)));
-         triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1mb,x3a),new FePoint3D(x2d,x1mb,x3d),new FePoint3D(x2c,x1mb,x3c)));
-      }
-      else if( this->isParallelToX3Axis() ) 
-      { 
-         triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1ma),new FePoint3D(x3b,x2b,x1ma),new FePoint3D(x3c,x2c,x1ma)));
-         triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1ma),new FePoint3D(x3d,x2d,x1ma),new FePoint3D(x3a,x2a,x1ma)));
-         triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1mb),new FePoint3D(x3b,x2b,x1mb),new FePoint3D(x3a,x2a,x1mb)));
-         triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1mb),new FePoint3D(x3d,x2d,x1mb),new FePoint3D(x3c,x2c,x1mb)));
-      }
-   }
-
-   return triangles;
-}
-/*==========================================================*/
-void FeHalfDisc3D::objectChanged(UbObservable* changedObject)
-{
-   GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject);
-   if(!line || this->mLine!=line) return;
-
-   this->notifyObserversObjectChanged();
-}
-/*==========================================================*/
-void FeHalfDisc3D::objectWillBeDeleted(UbObservable* objectForDeletion)
-{
-   if(this->mLine)
-   {
-      UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine);
-      if(objectForDeletion == observedObj) { this->mLine = NULL; }
-   }
-}
-/*=======================================================*/
-void FeHalfDisc3D::scale(const double& sx1, const double& sx2, const double& sx3)
-{  
-   if( this->isParallelToX1Axis() )
-   {
-      if(!UbMath::equal(sx2,sx3)) throw UbException(UB_EXARGS,"|| to x1 -> different scaling sx2 and sx3 not possible");
-      this->mRad*=sx2;
-   }
-   else if( this->isParallelToX2Axis() )
-   {
-      if(!UbMath::equal(sx1,sx3)) throw UbException(UB_EXARGS,"|| to x2 -> different scaling sx1 and sx3 not possible");
-      this->mRad*=sx1;
-   }
-   else if( this->isParallelToX3Axis() )
-   {
-      if(!UbMath::equal(sx1,sx2)) throw UbException(UB_EXARGS,"|| to x3 -> different scaling sx1 and sx2 not possible");
-      this->mRad*=sx1;
-   }
-   else throw UbException(UB_EXARGS,"unknown direction");
-
-   this->mLine->scale(sx1,sx2,sx3);
-   //notify observer wird automatisch aufgerufen
-}
-/*==========================================================*/
-void FeHalfDisc3D::write(UbFileOutput* out) 
-{                                      
-   out->writeString(this->getCreator()->getTypeID());
-   mLine->write(out);
-   out->writeDouble(mRad);
-   out->writeInteger(cylinderType);
-}
-/*==========================================================*/
-void FeHalfDisc3D::read(UbFileInput* in) 
-{  
-   in->readString();                                    
-   mLine = new GbLine3D;
-   mLine->read(in);
-   mRad         = in->readDouble();
-   cylinderType = in->readInteger();
-}
-/*==========================================================*/
-double FeHalfDisc3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
-{
-   /*
-   Distance D of the intersection between a Ray((ox1,ox2,ox3),(dx1,dx2,dx3)) and a Plane P: ax+by+cz+d=0 
-   dc = a*dx1 + b*dx2 + c*dx3
-   dw = a*ox1 + b*ox2 + c*ox3 + d
-   D =   - dw / dc
-   */
-   double px1, px2, px3;
-   double d = Ub::inf; // Distance to Min or Max Plane of the Cylinder  
-                       // final distance should be less that d 
-   
-   if( this->isParallelToX1Axis() )
-   {
-      double minX1 = this->getX1Minimum();
-      double maxX1 = this->getX1Maximum();
-
-      if     (UbMath::equal(x1 ,minX1) && UbMath::negative(rx1))    return -1.0; 
-      else if(UbMath::equal(x1 ,maxX1) && UbMath::positive(rx1))    return -1.0; 
-
-      //falls die Linie nicht parallel zu den Seitenflächen ist
-      if( x1< minX1  ||  x1 > maxX1 ) //nur für punkte links und rechts des cylinders
-      {
-         px1 = (x1 < minX1 ? minX1 : maxX1);
-         //falls die Linie nicht parallel zu den Seitenflächen ist
-         if( !UbMath::zero(rx1) )
-         {
-            // Plane a= 0, b= 1, c=0 d= -1*px2
-            d   = -1.0*(x1 - px1) / rx1;
-            px2 = x2 + d*rx2;
-            px3 = x3 + d*rx3;
-
-            if(UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad))
-            {
-               if     (x1 < minX1 && rx1>0.0 ) d = Ub::inf;  //punkt liegt "links" vom cylinder und strahl hat evtl weiteren SP auf oberfläche 
-               else if(x1 > maxX1 && rx1<0.0 ) d = Ub::inf;
-               else return -1.0;
-            }
-            else return d;
-         }
-         else return -1.0;
-      }
-      else 
-      {
-         if     (UbMath::negative(rx1)) d = -1.0 * (x1 - minX1) / rx1;
-         else if(UbMath::positive(rx1)) d = -1.0 * (x1 - maxX1) / rx1;
-      }
-   }
-   else if( this->isParallelToX2Axis() )
-   { 
-      double minX2 = this->getX2Minimum();
-      double maxX2 = this->getX2Maximum();
-
-      if     (UbMath::equal(x2 ,minX2) && UbMath::negative(rx2))    return -1; 
-      else if(UbMath::equal(x2 ,maxX2) && UbMath::positive(rx2))    return -1; 
-
-      if( minX2 > x2  ||  x2 > maxX2 )
-      {
-         px2 = (x2 < minX2 ? minX2 : maxX2);
-         //falls die Linie nicht parallel zu den Seitenflächen ist
-         if( !UbMath::zero(rx2) )
-         {
-            // Plane a= 0, b= 1, c=0 d= -1*px2
-            d   = -1*(x2 - px2) / rx2;
-            px1 = x1 + d*rx1;
-            px3 = x3 + d*rx3;
-            
-            if (UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad))
-            {
-               if     (x2 < minX2 && rx2>0.0 ) d = Ub::inf;  //punkt liegt "links oberhalb" vom cylinder und strahl mit pos x1 hat evtl weiteren SP auf oberfläche 
-               else if(x2 > maxX2 && rx2<0.0 ) d = Ub::inf;
-               else return -1.0;
-            }
-            else return d;
-         }
-         else return -1.0;
-      }
-      else
-      {
-         if     (UbMath::negative(rx2)) d = -1.0 * (x2 - minX2) / rx2;
-         else if(UbMath::positive(rx2)) d = -1.0 * (x2 - maxX2) / rx2;
-      }
-   }
-   else if( this->isParallelToX3Axis() )
-   {
-      double minX3 = this->getX3Minimum();
-      double maxX3 = this->getX3Maximum();
-
-      if     (UbMath::equal(x3, minX3) && UbMath::negative(rx3)) return -1.0; 
-      else if(UbMath::equal(x3, maxX3) && UbMath::positive(rx3)) return -1.0; 
-
-      if(minX3 > x3  ||  x3 > maxX3 )
-      {
-         px3 = (x3 < minX3 ? minX3 : maxX3);
-         //falls die Linie nicht parallel zu den Seitenflächen ist
-         if (!UbMath::zero(rx3))
-         {
-            // Plane a= 0, b= 0, c=1 d= -1*px3
-            d   = -1.0*(x3 - px3) / rx3;
-            px2 = x2 + d*rx2;
-            px1 = x1 + d*rx1;
-            if( UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad) )
-            {
-               if     (x3 < minX3 && rx3>0.0 ) d = Ub::inf;  
-               else if(x3 > maxX3 && rx3<0.0 ) d = Ub::inf;
-               else return -1.0;
-            }
-            else return d;
-         }
-         else return -1.0;
-      }
-      else 
-      {
-         if     (UbMath::negative(rx3)) d = -1.0 * (x3 - minX3) / rx3;
-         else if(UbMath::positive(rx3)) d = -1.0 * (x3 - maxX3) / rx3;
-      }
-   }
-   else throw UbException(UB_EXARGS,"funzt nur bei achsen parallelem cylinder");
-   //////////////////////////////////////////////////////////////////////////
-   //Q berechnen für Infinity Cylinder
-   GbPoint3D* p1 = mLine->getPoint1();
-   GbPoint3D* p2 = mLine->getPoint2();
-   
-   double axisX1 = p2->x1 - p1->x1;  /* Axis of the cylinder   */
-   double axisX2 = p2->x2 - p1->x2;  /* mit p1 als base of cylinder */
-   double axisX3 = p2->x3 - p1->x3;       
-
-   //double dirlen = mLine->getLength(); 
-   //double abs, t, s;
-
-   double RCx1 = x1 - p1->x1;
-   double RCx2 = x2 - p1->x2; 
-   double RCx3 = x3 - p1->x3; 
-   
-   //n = ray x axis
-   double nx1 = rx2*axisX3 - rx3*axisX2;
-   double nx2 = rx3*axisX1 - rx1*axisX3;
-   double nx3 = rx1*axisX2 - rx2*axisX1;
-   double nLength = nx1*nx1 + nx2*nx2 + nx3*nx3;
-
-   double abs;
-   if( UbMath::zero( nLength ) )
-   {  /* ray parallel to cyl  */
-      //abs = RC dot axis
-      double abs = RCx1*axisX1 + RCx2*axisX2 + RCx3*axisX3;
-      double dx1 = RCx1 - abs*axisX1; 
-      double dx2 = RCx2 - abs*axisX2;
-      double dx3 = RCx3 - abs*axisX3;
-      //abs   = sqrt(dx1*dx1 + dx2*dx2 + dx3*dx3);
-      if( UbMath::greater( dx1*dx1 + dx2*dx2 + dx3*dx3 , mRad*mRad) ) 
-         return -1.0;
-   }
-
-   //normalize "n"
-   nLength = std::sqrt(nLength);
-   double invnLength = 1.0/nLength;
-   nx1*=invnLength;
-   nx2*=invnLength;
-   nx3*=invnLength;
-
-   //shortest distance  = fabs( RC dot n )
-   abs = fabs( RCx1*nx1 + RCx2*nx2 + RCx3*nx3 );     
-   
-   if( UbMath::lessEqual(abs, mRad) )
-   {                    /* if ray hits cylinder */
-      //Ox1 = RC x axis
-      double Ox1 = RCx2*axisX3 - RCx3*axisX2;
-      double Ox2 = RCx3*axisX1 - RCx1*axisX3;
-      double Ox3 = RCx1*axisX2 - RCx2*axisX1;
-      //t = - O dot n / nLength;
-      double t = - (Ox1*nx1 + Ox2*nx2 + Ox3*nx3) / nLength;
-      
-      //O = n x axis;
-      Ox1 = nx2*axisX3 - nx3*axisX2;
-      Ox2 = nx3*axisX1 - nx1*axisX3;
-      Ox3 = nx1*axisX2 - nx2*axisX1;
-
-      //normalize O
-      invnLength = 1.0/sqrt(Ox1*Ox1 + Ox2*Ox2 + Ox3*Ox3);
-      Ox1*=invnLength;
-      Ox2*=invnLength;
-      Ox3*=invnLength;
-
-      double s = fabs( sqrt(mRad*mRad - abs*abs) / (rx1*Ox1 + rx2*Ox2 + rx3*Ox3) );
-      
-      if( UbMath::greater(t-s,d) ) return -1.0;
-      
-      return  t - s;
-   }
-   
-   return -1.0;
-}
-/*==========================================================*/
+#include <numerics/geometry3d/fem/FeHalfDisc3D.h>    
+#include <numerics/geometry3d/GbSystem3D.h>
+#include <numerics/geometry3d/GbLine3D.h>
+#include <numerics/geometry3d/GbTriangle3D.h>
+#include <numerics/geometry3d/fem/FePoint3D.h>
+#include <basics/utilities/UbInfinity.h>
+
+using namespace std;
+
+/*=======================================================*/
+ObObjectCreator* FeHalfDisc3D::getCreator()
+{
+   return NULL;//FeHalfDisc3DCreator::getInstance(); 
+}
+// Konstruktor
+/*==========================================================*/
+FeHalfDisc3D::FeHalfDisc3D()
+{
+   GbPoint3D* p1 = new GbPoint3D();
+   GbPoint3D* p2 = new GbPoint3D();
+   mLine = new GbLine3D(p1,p2);
+   this->mLine->addObserver(this);
+   mRad = 0.0;
+   cylinderType = FeHalfDisc3D::NOTPARALLELTOAXIS;
+}                                                   
+/*=======================================================*/
+FeHalfDisc3D::FeHalfDisc3D(FeHalfDisc3D* cylinder)
+{
+   mRad         = cylinder->getRadius();
+   cylinderType = cylinder->cylinderType;
+   mLine        = cylinder->getLine()->clone();
+
+   this->mLine->addObserver(this);
+}                                                   
+/*==========================================================*/
+FeHalfDisc3D::FeHalfDisc3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& rad)
+{
+   mLine = new GbLine3D;
+   mLine->setPoints( new GbPoint3D(min(x1a,x1b), min(x2a,x2b), min(x3a,x3b))
+	                 ,new GbPoint3D(max(x1a,x1b), max(x2a,x2b), max(x3a,x3b)));
+   this->mLine->addObserver(this);
+   mRad = fabs(rad);
+
+   this->initCylinderType();
+   if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) 
+      throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}                                                            
+/*==========================================================*/
+FeHalfDisc3D::FeHalfDisc3D(GbPoint3D* p1, GbPoint3D* p2, const double& rad)
+{
+   mRad = rad;
+
+   mLine = new GbLine3D(p1,p2);
+   this->mLine->addObserver(this);
+   this->initCylinderType();
+   if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) 
+      throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}
+/*==========================================================*/
+FeHalfDisc3D::FeHalfDisc3D(GbLine3D* line, const double& rad)
+{
+   mRad = rad;
+
+   this->mLine = line;
+   this->mLine->addObserver(this);
+   this->initCylinderType();
+   if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) 
+      throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}
+/*==========================================================*/		
+// Destruktor
+FeHalfDisc3D::~FeHalfDisc3D()
+{
+   if(mLine) this->mLine->removeObserver(this);
+   mLine = NULL;
+}
+/*=======================================================*/
+void FeHalfDisc3D::initCylinderType()
+{
+   double x1a = mLine->getPoint1()->x1;    double x1b = mLine->getPoint2()->x1;
+   double x2a = mLine->getPoint1()->x2;    double x2b = mLine->getPoint2()->x2;
+   double x3a = mLine->getPoint1()->x3;    double x3b = mLine->getPoint2()->x3;
+   
+   if     (x1a!=x1b && x2a==x2b && x3a==x3b)  this->cylinderType = X1PARALLEL; 
+   else if(x2a!=x2b && x1a==x1b && x3a==x3b)  this->cylinderType = X2PARALLEL; 
+   else if(x3a!=x3b && x1a==x1b && x2a==x2b)  this->cylinderType = X3PARALLEL; 
+   else                                       this->cylinderType = NOTPARALLELTOAXIS;
+}
+/*=======================================================*/
+void FeHalfDisc3D::finalize() 
+{ 
+   if(this->mLine) 
+   {
+      mLine->finalize();
+      delete mLine; 
+      mLine=NULL;
+   } 
+}
+/*=======================================================*/
+double FeHalfDisc3D::getHeight()
+{
+   if(mLine) return mLine->getLength(); return 0.0; 
+}
+/*=======================================================*/
+GbPoint3D* FeHalfDisc3D::getPoint1()
+{
+   if(this->mLine) return this->mLine->getPoint1();
+   return NULL;
+}
+/*=======================================================*/
+GbPoint3D* FeHalfDisc3D::getPoint2()
+{
+   if(this->mLine) return this->mLine->getPoint2();
+   return NULL;
+}
+/*=======================================================*/
+void FeHalfDisc3D::setRadius(const double& radius) 
+{ 
+   this->mRad = std::fabs(radius); 
+   this->notifyObserversObjectChanged();
+}
+/*=======================================================*/
+void FeHalfDisc3D::setLine(GbLine3D* line) 
+{
+   if(this->mLine) this->mLine->removeObserver(this);
+   this->mLine = line;  
+   this->mLine->addObserver(this);
+   this->initCylinderType();
+
+   this->notifyObserversObjectChanged();
+}
+/*=======================================================*/
+void FeHalfDisc3D::setPoint1(const double& x1, const double& x2, const double& x3)
+{ 
+   if(!mLine->getPoint1()) throw UbException(UB_EXARGS,"line has no point1");
+   mLine->getPoint1()->setCoordinates(x1,x2,x3);
+   this->initCylinderType();
+
+   //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt...
+}
+/*=======================================================*/
+void FeHalfDisc3D::setPoint2(const double& x1, const double& x2, const double& x3)
+{ 
+   if(!mLine->getPoint2()) throw UbException(UB_EXARGS,"line has no point2");
+   mLine->getPoint2()->setCoordinates(x1,x2,x3);
+   this->initCylinderType();
+
+   //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt...
+}
+/*==========================================================*/		
+double FeHalfDisc3D::getX1Centroid()  
+{
+   return mLine->getX1Centroid();
+}
+/*==========================================================*/
+double FeHalfDisc3D::getX1Minimum()   
+{
+   if     (this->isParallelToX1Axis()) return mLine->getX1Minimum(); 
+   else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()-mRad; 
+   else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()-mRad; 
+   else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}
+/*==========================================================*/
+double FeHalfDisc3D::getX1Maximum()   
+{
+   if     (this->isParallelToX1Axis()) return mLine->getX1Maximum(); 
+   else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()+mRad; 
+   else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()+mRad; 
+   else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}
+/*==========================================================*/
+double FeHalfDisc3D::getX2Centroid()
+{
+   return mLine->getX2Centroid();
+}
+/*==========================================================*/
+double FeHalfDisc3D::getX2Minimum()   
+{
+   if     (this->isParallelToX1Axis()) return mLine->getX2Centroid()-mRad;
+   else if(this->isParallelToX2Axis()) return mLine->getX2Minimum();
+   else if(this->isParallelToX3Axis()) return mLine->getX2Centroid()-mRad; 
+   else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}	
+/*==========================================================*/
+double FeHalfDisc3D::getX2Maximum()   
+{
+   if     (this->isParallelToX1Axis())  return mLine->getX2Centroid()+mRad;
+   else if(this->isParallelToX2Axis())  return mLine->getX2Maximum();
+   else if(this->isParallelToX3Axis())  return mLine->getX2Centroid()+mRad; 
+   else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}
+/*==========================================================*/
+double FeHalfDisc3D::getX3Centroid()
+{
+   return mLine->getX3Centroid();
+}
+/*==========================================================*/
+double FeHalfDisc3D::getX3Minimum()   
+{	
+   if     (this->isParallelToX1Axis()) return mLine->getX3Centroid()-mRad;
+   else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()-mRad; 
+   else if(this->isParallelToX3Axis()) return mLine->getX3Minimum(); 
+   else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}	
+/*==========================================================*/
+double FeHalfDisc3D::getX3Maximum()   
+{
+   if     (this->isParallelToX1Axis()) return mLine->getX3Centroid()+mRad;
+   else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()+mRad; 
+   else if(this->isParallelToX3Axis()) return mLine->getX3Maximum(); 
+   else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}
+/*==========================================================*/
+bool FeHalfDisc3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
+{
+   throw UbException(UB_EXARGS,"sollte mal einer machen ... ");
+}
+/*==========================================================*/
+bool FeHalfDisc3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
+{
+   throw UbException(UB_EXARGS,"sollte mal einer machen ... ");
+}
+/*=======================================================*/
+bool FeHalfDisc3D::isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+{
+   throw UbException(UB_EXARGS,"sollte mal einer machen ... ");
+}
+
+/*==========================================================*/
+string FeHalfDisc3D::toString() 
+{
+	stringstream ss;
+	ss<<"FeHalfDisc3D[";
+	ss<<"line="<<this->mLine->toString();
+   ss<<", r="<<this->mRad;
+   ss<<"]";
+   return(ss.str());
+}
+/*==========================================================*/
+bool FeHalfDisc3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+{
+   throw UbException(UB_EXARGS,"sollte mal einer machen ... ");   
+}
+/*==========================================================*/
+bool FeHalfDisc3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+{
+   throw UbException(UB_EXARGS,"sollte mal einer machen ... ");
+}
+/*==========================================================*/
+GbLine3D* FeHalfDisc3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
+{
+   throw UbException(UB_EXARGS,"sollte mal einer machen ... ");
+}
+/*==========================================================*/
+vector<GbTriangle3D*> FeHalfDisc3D::getSurfaceTriangleSet()
+{
+   double x1ma,x1mb,x2m,x3m;
+   if( this->isParallelToX1Axis() ) 
+   {
+      x1ma = this->getX1Minimum();
+      x1mb = this->getX1Maximum();
+      x2m  = this->getX2Centroid();
+      x3m  = this->getX3Centroid();
+   }
+   else if( this->isParallelToX2Axis() ) 
+   {
+      x1ma = this->getX2Minimum();
+      x1mb = this->getX2Maximum();
+      x2m  = this->getX1Centroid();
+      x3m  = this->getX3Centroid();
+   }
+   else if( this->isParallelToX3Axis() ) 
+   {
+      x1ma = this->getX3Minimum();
+      x1mb = this->getX3Maximum();
+      x2m  = this->getX2Centroid();
+      x3m  = this->getX1Centroid();
+   }
+   else throw UbException(UB_EXARGS,"cylinder is not axis prallel");
+   
+   vector<GbTriangle3D*> triangles;    
+
+   int segmentsCircle  = 14;
+   double deltaPhi = UbMath::PI/(double)segmentsCircle;
+
+   double phiX1a,phiX1b;
+   double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d;
+   
+   double dXCylinder =  fabs((x1mb-x1ma)); ///(double)0.5;
+   int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder);
+   for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++)
+   {
+      x1a = x1d = x1ma+segCyl*dXCylinder;
+      x1b = x1c = x1a+dXCylinder;
+      
+      for(phiX1a=UbMath::PI-deltaPhi; phiX1a>-deltaPhi; phiX1a-=deltaPhi)
+      {
+         phiX1b = phiX1a+deltaPhi;
+         
+         x2a =  x2m+mRad*std::sin(phiX1a);
+         x3a =  x3m+mRad*std::cos(phiX1a);
+         x2b =  x2m+mRad*std::sin(phiX1b);
+         x3b =  x3m+mRad*std::cos(phiX1b);
+         
+         if( this->isParallelToX1Axis() ) 
+         { 
+            triangles.push_back(new GbTriangle3D(new FePoint3D(x1b,x2a,x3a),new FePoint3D(x1b,x2b,x3b),new FePoint3D(x1a,x2a,x3a)));
+            triangles.push_back(new GbTriangle3D(new FePoint3D(x1a,x2b,x3b),new FePoint3D(x1a,x2a,x3a),new FePoint3D(x1b,x2b,x3b))); 
+         }
+         else if( this->isParallelToX2Axis() ) 
+         { 
+            triangles.push_back(new GbTriangle3D(new FePoint3D(x2b,x1b,x3b),new FePoint3D(x2a,x1b,x3a),new FePoint3D(x2a,x1a,x3a)));
+            triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1a,x3a),new FePoint3D(x2b,x1a,x3b),new FePoint3D(x2b,x1b,x3b))); 
+         }
+         else if( this->isParallelToX3Axis() ) 
+         { 
+            triangles.push_back(new GbTriangle3D(new FePoint3D(x3b,x2b,x1b),new FePoint3D(x3a,x2a,x1b),new FePoint3D(x3a,x2a,x1a)));
+            triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1a),new FePoint3D(x3b,x2b,x1a),new FePoint3D(x3b,x2b,x1b))); 
+         }
+
+      }
+   }
+
+   x2a = x2m;
+   x3a = x3m;
+   x2d = x2m;
+   x3d = x3m+mRad;
+   x3b = x3m;
+   x3c = x3m-mRad;
+   
+   triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2a,x3a),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1ma,x2a,x3d)));
+   triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2a,x3d),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1mb,x2a,x3d)));
+   triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2a,x3b),new FePoint3D(x1ma,x2a,x3b),new FePoint3D(x1ma,x2a,x3c)));
+   triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2a,x3b),new FePoint3D(x1ma,x2a,x3c),new FePoint3D(x1mb,x2a,x3c)));
+  
+   for(phiX1a=UbMath::PI-deltaPhi; phiX1a>-deltaPhi; phiX1a-=deltaPhi)
+   {
+      phiX1b = phiX1a+deltaPhi;
+
+      x2a =  x2m;
+      x3a =  x3m;
+      x2b =  x2m;
+      x3b =  x3m;
+      x2c =  x2m+mRad*std::sin(phiX1b);
+      x3c =  x3m+mRad*std::cos(phiX1b);
+      x2d =  x2m+mRad*std::sin(phiX1a);
+      x3d =  x3m+mRad*std::cos(phiX1a);
+
+      if( this->isParallelToX1Axis() ) 
+      { 
+         triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2d,x3d),new FePoint3D(x1ma,x2c,x3c),new FePoint3D(x1ma,x2a,x3a)));
+         triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2d,x3d),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1mb,x2c,x3c)));
+      }
+      else if( this->isParallelToX2Axis() ) 
+      { 
+         triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1ma,x3a),new FePoint3D(x2b,x1ma,x3b),new FePoint3D(x2c,x1ma,x3c)));
+         triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1ma,x3c),new FePoint3D(x2d,x1ma,x3d),new FePoint3D(x2a,x1ma,x3a)));
+         triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1mb,x3c),new FePoint3D(x2b,x1mb,x3b),new FePoint3D(x2a,x1mb,x3a)));
+         triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1mb,x3a),new FePoint3D(x2d,x1mb,x3d),new FePoint3D(x2c,x1mb,x3c)));
+      }
+      else if( this->isParallelToX3Axis() ) 
+      { 
+         triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1ma),new FePoint3D(x3b,x2b,x1ma),new FePoint3D(x3c,x2c,x1ma)));
+         triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1ma),new FePoint3D(x3d,x2d,x1ma),new FePoint3D(x3a,x2a,x1ma)));
+         triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1mb),new FePoint3D(x3b,x2b,x1mb),new FePoint3D(x3a,x2a,x1mb)));
+         triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1mb),new FePoint3D(x3d,x2d,x1mb),new FePoint3D(x3c,x2c,x1mb)));
+      }
+   }
+
+   return triangles;
+}
+/*==========================================================*/
+void FeHalfDisc3D::objectChanged(UbObservable* changedObject)
+{
+   GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject);
+   if(!line || this->mLine!=line) return;
+
+   this->notifyObserversObjectChanged();
+}
+/*==========================================================*/
+void FeHalfDisc3D::objectWillBeDeleted(UbObservable* objectForDeletion)
+{
+   if(this->mLine)
+   {
+      UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine);
+      if(objectForDeletion == observedObj) { this->mLine = NULL; }
+   }
+}
+/*=======================================================*/
+void FeHalfDisc3D::scale(const double& sx1, const double& sx2, const double& sx3)
+{  
+   if( this->isParallelToX1Axis() )
+   {
+      if(!UbMath::equal(sx2,sx3)) throw UbException(UB_EXARGS,"|| to x1 -> different scaling sx2 and sx3 not possible");
+      this->mRad*=sx2;
+   }
+   else if( this->isParallelToX2Axis() )
+   {
+      if(!UbMath::equal(sx1,sx3)) throw UbException(UB_EXARGS,"|| to x2 -> different scaling sx1 and sx3 not possible");
+      this->mRad*=sx1;
+   }
+   else if( this->isParallelToX3Axis() )
+   {
+      if(!UbMath::equal(sx1,sx2)) throw UbException(UB_EXARGS,"|| to x3 -> different scaling sx1 and sx2 not possible");
+      this->mRad*=sx1;
+   }
+   else throw UbException(UB_EXARGS,"unknown direction");
+
+   this->mLine->scale(sx1,sx2,sx3);
+   //notify observer wird automatisch aufgerufen
+}
+/*==========================================================*/
+void FeHalfDisc3D::write(UbFileOutput* out) 
+{                                      
+   out->writeString(this->getCreator()->getTypeID());
+   mLine->write(out);
+   out->writeDouble(mRad);
+   out->writeInteger(cylinderType);
+}
+/*==========================================================*/
+void FeHalfDisc3D::read(UbFileInput* in) 
+{  
+   in->readString();                                    
+   mLine = new GbLine3D;
+   mLine->read(in);
+   mRad         = in->readDouble();
+   cylinderType = in->readInteger();
+}
+/*==========================================================*/
+double FeHalfDisc3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
+{
+   /*
+   Distance D of the intersection between a Ray((ox1,ox2,ox3),(dx1,dx2,dx3)) and a Plane P: ax+by+cz+d=0 
+   dc = a*dx1 + b*dx2 + c*dx3
+   dw = a*ox1 + b*ox2 + c*ox3 + d
+   D =   - dw / dc
+   */
+   double px1, px2, px3;
+   double d = Ub::inf; // Distance to Min or Max Plane of the Cylinder  
+                       // final distance should be less that d 
+   
+   if( this->isParallelToX1Axis() )
+   {
+      double minX1 = this->getX1Minimum();
+      double maxX1 = this->getX1Maximum();
+
+      if     (UbMath::equal(x1 ,minX1) && UbMath::negative(rx1))    return -1.0; 
+      else if(UbMath::equal(x1 ,maxX1) && UbMath::positive(rx1))    return -1.0; 
+
+      //falls die Linie nicht parallel zu den Seitenflächen ist
+      if( x1< minX1  ||  x1 > maxX1 ) //nur für punkte links und rechts des cylinders
+      {
+         px1 = (x1 < minX1 ? minX1 : maxX1);
+         //falls die Linie nicht parallel zu den Seitenflächen ist
+         if( !UbMath::zero(rx1) )
+         {
+            // Plane a= 0, b= 1, c=0 d= -1*px2
+            d   = -1.0*(x1 - px1) / rx1;
+            px2 = x2 + d*rx2;
+            px3 = x3 + d*rx3;
+
+            if(UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad))
+            {
+               if     (x1 < minX1 && rx1>0.0 ) d = Ub::inf;  //punkt liegt "links" vom cylinder und strahl hat evtl weiteren SP auf oberfläche 
+               else if(x1 > maxX1 && rx1<0.0 ) d = Ub::inf;
+               else return -1.0;
+            }
+            else return d;
+         }
+         else return -1.0;
+      }
+      else 
+      {
+         if     (UbMath::negative(rx1)) d = -1.0 * (x1 - minX1) / rx1;
+         else if(UbMath::positive(rx1)) d = -1.0 * (x1 - maxX1) / rx1;
+      }
+   }
+   else if( this->isParallelToX2Axis() )
+   { 
+      double minX2 = this->getX2Minimum();
+      double maxX2 = this->getX2Maximum();
+
+      if     (UbMath::equal(x2 ,minX2) && UbMath::negative(rx2))    return -1; 
+      else if(UbMath::equal(x2 ,maxX2) && UbMath::positive(rx2))    return -1; 
+
+      if( minX2 > x2  ||  x2 > maxX2 )
+      {
+         px2 = (x2 < minX2 ? minX2 : maxX2);
+         //falls die Linie nicht parallel zu den Seitenflächen ist
+         if( !UbMath::zero(rx2) )
+         {
+            // Plane a= 0, b= 1, c=0 d= -1*px2
+            d   = -1*(x2 - px2) / rx2;
+            px1 = x1 + d*rx1;
+            px3 = x3 + d*rx3;
+            
+            if (UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad))
+            {
+               if     (x2 < minX2 && rx2>0.0 ) d = Ub::inf;  //punkt liegt "links oberhalb" vom cylinder und strahl mit pos x1 hat evtl weiteren SP auf oberfläche 
+               else if(x2 > maxX2 && rx2<0.0 ) d = Ub::inf;
+               else return -1.0;
+            }
+            else return d;
+         }
+         else return -1.0;
+      }
+      else
+      {
+         if     (UbMath::negative(rx2)) d = -1.0 * (x2 - minX2) / rx2;
+         else if(UbMath::positive(rx2)) d = -1.0 * (x2 - maxX2) / rx2;
+      }
+   }
+   else if( this->isParallelToX3Axis() )
+   {
+      double minX3 = this->getX3Minimum();
+      double maxX3 = this->getX3Maximum();
+
+      if     (UbMath::equal(x3, minX3) && UbMath::negative(rx3)) return -1.0; 
+      else if(UbMath::equal(x3, maxX3) && UbMath::positive(rx3)) return -1.0; 
+
+      if(minX3 > x3  ||  x3 > maxX3 )
+      {
+         px3 = (x3 < minX3 ? minX3 : maxX3);
+         //falls die Linie nicht parallel zu den Seitenflächen ist
+         if (!UbMath::zero(rx3))
+         {
+            // Plane a= 0, b= 0, c=1 d= -1*px3
+            d   = -1.0*(x3 - px3) / rx3;
+            px2 = x2 + d*rx2;
+            px1 = x1 + d*rx1;
+            if( UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad) )
+            {
+               if     (x3 < minX3 && rx3>0.0 ) d = Ub::inf;  
+               else if(x3 > maxX3 && rx3<0.0 ) d = Ub::inf;
+               else return -1.0;
+            }
+            else return d;
+         }
+         else return -1.0;
+      }
+      else 
+      {
+         if     (UbMath::negative(rx3)) d = -1.0 * (x3 - minX3) / rx3;
+         else if(UbMath::positive(rx3)) d = -1.0 * (x3 - maxX3) / rx3;
+      }
+   }
+   else throw UbException(UB_EXARGS,"funzt nur bei achsen parallelem cylinder");
+   //////////////////////////////////////////////////////////////////////////
+   //Q berechnen für Infinity Cylinder
+   GbPoint3D* p1 = mLine->getPoint1();
+   GbPoint3D* p2 = mLine->getPoint2();
+   
+   double axisX1 = p2->x1 - p1->x1;  /* Axis of the cylinder   */
+   double axisX2 = p2->x2 - p1->x2;  /* mit p1 als base of cylinder */
+   double axisX3 = p2->x3 - p1->x3;       
+
+   //double dirlen = mLine->getLength(); 
+   //double abs, t, s;
+
+   double RCx1 = x1 - p1->x1;
+   double RCx2 = x2 - p1->x2; 
+   double RCx3 = x3 - p1->x3; 
+   
+   //n = ray x axis
+   double nx1 = rx2*axisX3 - rx3*axisX2;
+   double nx2 = rx3*axisX1 - rx1*axisX3;
+   double nx3 = rx1*axisX2 - rx2*axisX1;
+   double nLength = nx1*nx1 + nx2*nx2 + nx3*nx3;
+
+   double abs;
+   if( UbMath::zero( nLength ) )
+   {  /* ray parallel to cyl  */
+      //abs = RC dot axis
+      double abs = RCx1*axisX1 + RCx2*axisX2 + RCx3*axisX3;
+      double dx1 = RCx1 - abs*axisX1; 
+      double dx2 = RCx2 - abs*axisX2;
+      double dx3 = RCx3 - abs*axisX3;
+      //abs   = sqrt(dx1*dx1 + dx2*dx2 + dx3*dx3);
+      if( UbMath::greater( dx1*dx1 + dx2*dx2 + dx3*dx3 , mRad*mRad) ) 
+         return -1.0;
+   }
+
+   //normalize "n"
+   nLength = std::sqrt(nLength);
+   double invnLength = 1.0/nLength;
+   nx1*=invnLength;
+   nx2*=invnLength;
+   nx3*=invnLength;
+
+   //shortest distance  = fabs( RC dot n )
+   abs = fabs( RCx1*nx1 + RCx2*nx2 + RCx3*nx3 );     
+   
+   if( UbMath::lessEqual(abs, mRad) )
+   {                    /* if ray hits cylinder */
+      //Ox1 = RC x axis
+      double Ox1 = RCx2*axisX3 - RCx3*axisX2;
+      double Ox2 = RCx3*axisX1 - RCx1*axisX3;
+      double Ox3 = RCx1*axisX2 - RCx2*axisX1;
+      //t = - O dot n / nLength;
+      double t = - (Ox1*nx1 + Ox2*nx2 + Ox3*nx3) / nLength;
+      
+      //O = n x axis;
+      Ox1 = nx2*axisX3 - nx3*axisX2;
+      Ox2 = nx3*axisX1 - nx1*axisX3;
+      Ox3 = nx1*axisX2 - nx2*axisX1;
+
+      //normalize O
+      invnLength = 1.0/sqrt(Ox1*Ox1 + Ox2*Ox2 + Ox3*Ox3);
+      Ox1*=invnLength;
+      Ox2*=invnLength;
+      Ox3*=invnLength;
+
+      double s = fabs( sqrt(mRad*mRad - abs*abs) / (rx1*Ox1 + rx2*Ox2 + rx3*Ox3) );
+      
+      if( UbMath::greater(t-s,d) ) return -1.0;
+      
+      return  t - s;
+   }
+   
+   return -1.0;
+}
+/*==========================================================*/
diff --git a/source/ThirdParty/Library/numerics/geometry3d/fem/FeHalfDisc3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FeHalfDisc3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/fem/FeHalfDisc3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/fem/FeHalfDisc3D.h
index 1f7ad43f816a073b8b39eaf0f2a4f8923b3647da..4855dac3fad7928ef16cd9662a85202b8a11772c 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/fem/FeHalfDisc3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FeHalfDisc3D.h
@@ -1,104 +1,104 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef FEHALFDISC3D_H
-#define FEHALFDISC3D_H
-
-#include <vector>
-#include <cmath>
-
-#include <numerics/geometry3d/GbObject3D.h>
-#include <basics/utilities/UbObserver.h>
-
-class GbPoint3D;
-class GbLine3D;
-class GbTriangle3D;
-
-class GbObject3DCreator;
-
-class FeHalfDisc3D : public GbObject3D , public UbObserver 
-{
-public:
-   FeHalfDisc3D();
-	FeHalfDisc3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& radius);
-	FeHalfDisc3D(GbPoint3D* p1, GbPoint3D* p2, const double& radius);
-	FeHalfDisc3D(GbLine3D* line, const double& rad);
-	FeHalfDisc3D(FeHalfDisc3D* cylinder);
-	~FeHalfDisc3D();    
-
-	FeHalfDisc3D* clone() { return new FeHalfDisc3D(this); }
-	void finalize();
-
-	double     getRadius() { return this->mRad; };
-	GbLine3D*  getLine() {return mLine;}
-	GbPoint3D* getPoint1();
-	GbPoint3D* getPoint2();
-
-	void setRadius(const double& radius);
-	void setLine(GbLine3D* line);
-	void setPoint1(const double& x1, const double& x2, const double& x3);
-	void setPoint2(const double& x1, const double& x2, const double& x3);
-
-	bool isParallelToX1Axis() { return((this->cylinderType & X1PARALLEL        )    ==  X1PARALLEL        );}
-	bool isParallelToX2Axis() { return((this->cylinderType & X2PARALLEL        )    ==  X2PARALLEL        );}
-	bool isParallelToX3Axis() { return((this->cylinderType & X3PARALLEL        )    ==  X3PARALLEL        );}
-	bool isNotParallelToAxis(){ return((this->cylinderType & NOTPARALLELTOAXIS )    ==  NOTPARALLELTOAXIS );}
-
-	double getHeight(); 
-
-	void scale(const double& sx1, const double& sx2, const double& sx3);
-
-	double getX1Centroid();
-	double getX1Minimum() ;
-	double getX1Maximum() ;
-	double getX2Centroid();
-	double getX2Minimum() ;
-	double getX2Maximum() ;
-	double getX3Centroid();
-	double getX3Minimum() ;
-	double getX3Maximum() ;
-
-	bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); 
-	bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); 
-   bool isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-
-	GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2);
-   
-   bool hasRaytracing() { return true; }
-   /*|r| must be 1! einheitsvector!!*/
-   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
-
-	std::vector<GbTriangle3D*> getSurfaceTriangleSet();
-   
-	std::string toString();
-	ObObjectCreator* getCreator();
-	void write(UbFileOutput* out);
-	void read(UbFileInput* in);
-
-	//virtuelle Methoden von UbObserver
-	void objectChanged(UbObservable* changedObject);
-	void objectWillBeDeleted(UbObservable* objectForDeletion);
-
-   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
-
-protected:
-	void initCylinderType();
-
-   GbLine3D* mLine;
-	double    mRad;
-
-	int cylinderType;
-
-	//void berechneQuerschnittsWerte();
-   static const int NOTPARALLELTOAXIS  = (1<<0); //1
-   static const int X1PARALLEL         = (1<<1); //2
-   static const int X2PARALLEL         = (1<<2); //4
-   static const int X3PARALLEL         = (1<<3); //8
-};
-
-#endif   
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef FEHALFDISC3D_H
+#define FEHALFDISC3D_H
+
+#include <vector>
+#include <cmath>
+
+#include <numerics/geometry3d/GbObject3D.h>
+#include <basics/utilities/UbObserver.h>
+
+class GbPoint3D;
+class GbLine3D;
+class GbTriangle3D;
+
+class GbObject3DCreator;
+
+class FeHalfDisc3D : public GbObject3D , public UbObserver 
+{
+public:
+   FeHalfDisc3D();
+	FeHalfDisc3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& radius);
+	FeHalfDisc3D(GbPoint3D* p1, GbPoint3D* p2, const double& radius);
+	FeHalfDisc3D(GbLine3D* line, const double& rad);
+	FeHalfDisc3D(FeHalfDisc3D* cylinder);
+	~FeHalfDisc3D();    
+
+	FeHalfDisc3D* clone() { return new FeHalfDisc3D(this); }
+	void finalize();
+
+	double     getRadius() { return this->mRad; };
+	GbLine3D*  getLine() {return mLine;}
+	GbPoint3D* getPoint1();
+	GbPoint3D* getPoint2();
+
+	void setRadius(const double& radius);
+	void setLine(GbLine3D* line);
+	void setPoint1(const double& x1, const double& x2, const double& x3);
+	void setPoint2(const double& x1, const double& x2, const double& x3);
+
+	bool isParallelToX1Axis() { return((this->cylinderType & X1PARALLEL        )    ==  X1PARALLEL        );}
+	bool isParallelToX2Axis() { return((this->cylinderType & X2PARALLEL        )    ==  X2PARALLEL        );}
+	bool isParallelToX3Axis() { return((this->cylinderType & X3PARALLEL        )    ==  X3PARALLEL        );}
+	bool isNotParallelToAxis(){ return((this->cylinderType & NOTPARALLELTOAXIS )    ==  NOTPARALLELTOAXIS );}
+
+	double getHeight(); 
+
+	void scale(const double& sx1, const double& sx2, const double& sx3);
+
+	double getX1Centroid();
+	double getX1Minimum() ;
+	double getX1Maximum() ;
+	double getX2Centroid();
+	double getX2Minimum() ;
+	double getX2Maximum() ;
+	double getX3Centroid();
+	double getX3Minimum() ;
+	double getX3Maximum() ;
+
+	bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); 
+	bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); 
+   bool isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+
+	GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2);
+   
+   bool hasRaytracing() { return true; }
+   /*|r| must be 1! einheitsvector!!*/
+   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
+
+	std::vector<GbTriangle3D*> getSurfaceTriangleSet();
+   
+	std::string toString();
+	ObObjectCreator* getCreator();
+	void write(UbFileOutput* out);
+	void read(UbFileInput* in);
+
+	//virtuelle Methoden von UbObserver
+	void objectChanged(UbObservable* changedObject);
+	void objectWillBeDeleted(UbObservable* objectForDeletion);
+
+   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
+
+protected:
+	void initCylinderType();
+
+   GbLine3D* mLine;
+	double    mRad;
+
+	int cylinderType;
+
+	//void berechneQuerschnittsWerte();
+   static const int NOTPARALLELTOAXIS  = (1<<0); //1
+   static const int X1PARALLEL         = (1<<1); //2
+   static const int X2PARALLEL         = (1<<2); //4
+   static const int X3PARALLEL         = (1<<3); //8
+};
+
+#endif   
diff --git a/source/ThirdParty/Library/numerics/geometry3d/fem/FePlateTriangularMesh3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FePlateTriangularMesh3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/fem/FePlateTriangularMesh3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/fem/FePlateTriangularMesh3D.cpp
index 82f053daa4c38de22c79466530e184858e91083f..8654792cba9d79c95bf745af9642a9c9143e5aed 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/fem/FePlateTriangularMesh3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FePlateTriangularMesh3D.cpp
@@ -1,223 +1,223 @@
-#include <numerics/geometry3d/fem/FePlateTriangularMesh3D.h>
-
-using namespace std;
-                         
-FePlateTriangularMesh3D::FePlateTriangularMesh3D() : GbTriangularMesh3D()
-{
-}
-
-FePlateTriangularMesh3D::FePlateTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbTriangle3D*> *triangles) : GbTriangularMesh3D(name, nodes, triangles)
-{
-}
-
-/*=============================================================================================*/
-
-FePlateTriangularMesh3D::FePlateTriangularMesh3D(string name, vector<GbTriangle3D*> *triangles) : GbTriangularMesh3D(name, triangles)
-{
-}
-
-/*=============================================================================================*/
-FePlateTriangularMesh3D::FePlateTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbLine3D*> *edges, vector<GbTriangle3D*> *triangles) : GbTriangularMesh3D(name, nodes, edges, triangles)
-{
-}
-/*=============================================================================================*/
-FePlateTriangularMesh3D::~FePlateTriangularMesh3D()
-{
-
-}
-/*======================================================================*/
-
-/*======================================================================*/
-bool FePlateTriangularMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3)
-{
-	//cout<<"GbTriangularMesh3D::isPointInGbObject3D"<<endl;
-	//Sebastian
-	//double xmin=this->getX1Minimum();	double xmax=this->getX1Maximum();
- //  double ymin=this->getX2Minimum();	double ymax=this->getX2Maximum();
- //  double zmin=this->getX3Minimum();	double zmax=this->getX3Maximum();
- //  double dX = (xmax-xmin)/100.;
- //  double dY = (ymax-ymin)/100.;
- //  double dZ = (zmax-zmin)/100.;
- //  GbCuboid3D boundingCube(xmin-dX, ymin-dY, zmin-dZ, xmax+dX, ymax+dY, zmax+dZ);
-	//
-	//if(this->isPointInObject3DHalfSpace(x1,x2,x3))
-	//{
-	//	return true;
-	//}
-	//if(!boundingCube.isPointInGbObject3D(x1, x2, x3))
-	//{
-	//	return false;
-	//}
-
-	//return false;
-	//Marco
-	int inside = 0;
-   int nx1 = this->getNodesX1Dir()-1;
-   int nx2 = this->getNodesX2Dir()-1;
-   int maxTriangels = 2*nx1*nx2;
-
-   //Überprüft, ob der Punkt innerhalb des Netzes liegt
-	double xmin=this->getX1Minimum();	double xmax=this->getX1Maximum();
-	double ymin=this->getX2Minimum();	double ymax=this->getX2Maximum();
-	double zmin=this->getX3Minimum();	double zmax=this->getX3Maximum();
-	if(	x1<=xmax && x1>=xmin
-		&& x2<=ymax && x2>=ymin
-		&& x3<=zmax && x3>=zmin)
-	{
-      //Achtung Sonderfall
-      //Es wird nur gegen die obere Lage Dreiecke getestet, da die untere Lage um den Abstand 'height' verschoben ist!
-      //Die Seiten müssen somit auch nicht berücksichtigt werden
-      for(int i=0; i<int(maxTriangels);i++)     
-		{
-			if(	(triangles->at(i))->enclosesPoint2D(x1, x2)
-				&&	x3<triangles->at(i)->getX3Centroid()
-				&& x3>triangles->at(i)->getX3Centroid() - this->height  )
-			{
-					inside++;
-			}
-		}
-	}
-
-	if(inside!=0)
-	{
-		return true;
-	}
-	else return false;
-}
-/*======================================================================*/
-FePlateTriangularMesh3D* FePlateTriangularMesh3D::createMeshByElements(int ElementsX1, int ElementsX2, double nulllevel, double deltaX1, double deltaX2, double height)
-{
-   FePlateTriangularMesh3D* triMesh = FePlateTriangularMesh3D::createMeshByNodes(ElementsX1+1, ElementsX2+1, nulllevel, deltaX1, deltaX2, height);
-   return triMesh;
-}
-/*======================================================================*/
-FePlateTriangularMesh3D* FePlateTriangularMesh3D::createMeshByNodes(int nodesX1, int nodesX2, double nulllevel, double deltaX1, double deltaX2, double height)
-{
-   cout<<"erstelle GbTriangularMesh3D -> ";
-   vector<GbTriangle3D*>  *triangles = new vector<GbTriangle3D*>;
-   vector<GbPoint3D*> *points = new vector<GbPoint3D*>;
-   double h1=nulllevel+0.5*height;
-   double h2=nulllevel-0.5*height;
-   GbPoint3D* point1;
-   GbPoint3D* point2;
-   GbPoint3D* point3;
-   GbPoint3D* point4;
-   //Erstelle Knoten
-   //oben
-   for(int i=0; i<nodesX1; i++)
-   {
-      for(int j=0; j<nodesX2; j++)
-      {
-         GbPoint3D* point = new GbPoint3D(i*deltaX1,j*deltaX2,h1);
-         points->push_back(point);
-      }
-   }
-   //unten
-   for(int i=0; i<nodesX1; i++)
-   {
-      for(int j=0; j<nodesX2; j++)
-      {
-         GbPoint3D* point = new GbPoint3D(i*deltaX1,j*deltaX2,h2);
-         points->push_back(point);
-      }
-   }
-   int size=int(points->size());
-   //Erstelle Dreiecke
-   //oben
-   for(int i=0; i<(size/2)-nodesX2; i+=nodesX2)
-   {
-      for(int j=0; j<nodesX2-1; j++)
-      {
-         point1 = points->at(i+j);
-         point2 = points->at(i+j+1);
-         point3 = points->at(i+j+nodesX2);
-         point4 = points->at(i+j+nodesX2+1);
-         GbTriangle3D* tri1 = new GbTriangle3D(point1,point3,point4);
-         GbTriangle3D* tri2 = new GbTriangle3D(point1,point4,point2);
-         triangles->push_back(tri1);
-         triangles->push_back(tri2);
-      }
-   }
-   //unten
-   for(int i=(size/2); i<size-nodesX2; i+=nodesX2)
-   {
-      for(int j=0; j<nodesX2-1; j++)
-      {
-         point1 = points->at(i+j);
-         point2 = points->at(i+j+1);
-         point3 = points->at(i+j+nodesX2);
-         point4 = points->at(i+j+nodesX2+1);
-         GbTriangle3D* tri1 = new GbTriangle3D(point4,point3,point1);
-         GbTriangle3D* tri2 = new GbTriangle3D(point2,point4,point1);
-         triangles->push_back(tri1);
-         triangles->push_back(tri2);
-      }
-   }
-   //Rand
-   //Nord
-   for(int i=0;i<nodesX1-1;i++)
-   {	
-      int a = i*nodesX2+nodesX2-1;
-      int b = (i+1)*nodesX2+nodesX2-1;
-      point1 = points->at(a);
-      point2 = points->at(b);
-      point3 = points->at(a+size/2);
-      point4 = points->at(b+size/2);
-      GbTriangle3D* tri1 = new GbTriangle3D(point1,point2,point3);
-      GbTriangle3D* tri2 = new GbTriangle3D(point2,point4,point3);
-      triangles->push_back(tri1);
-      triangles->push_back(tri2);
-   }
-   //Süd
-   for(int i=0;i<nodesX1-1;i++)
-   {	
-      int a = i*nodesX2;
-      int b = (i+1)*nodesX2;
-      point1 = points->at(a);
-      point2 = points->at(b);
-      point3 = points->at(a+size/2);
-      point4 = points->at(b+size/2);
-      GbTriangle3D* tri1 = new GbTriangle3D(point3,point2,point1);
-      GbTriangle3D* tri2 = new GbTriangle3D(point3,point4,point2);
-      triangles->push_back(tri1);
-      triangles->push_back(tri2);
-   }
-   //Ost
-   for(int j=0;j<nodesX2-1;j++)
-   {	
-      int a = j;
-      int b = j+1;
-      point1 = points->at(a);
-      point2 = points->at(b);
-      point3 = points->at(a+size/2);
-      point4 = points->at(b+size/2);
-      GbTriangle3D* tri1 = new GbTriangle3D(point1,point2,point3);
-      GbTriangle3D* tri2 = new GbTriangle3D(point4,point3,point2);
-      triangles->push_back(tri1);
-      triangles->push_back(tri2);
-   }
-   //West
-   for(int j=0;j<nodesX2-1;j++)
-   {	
-      int a = j+(nodesX1-1)*nodesX2;
-      int b = j+(nodesX1-1)*nodesX2+1;
-      point1 = points->at(a);
-      point2 = points->at(b);
-      point3 = points->at(a+size/2);
-      point4 = points->at(b+size/2);
-      GbTriangle3D* tri1 = new GbTriangle3D(point3,point2,point1);
-      GbTriangle3D* tri2 = new GbTriangle3D(point2,point3,point4);
-      triangles->push_back(tri1);
-      triangles->push_back(tri2);
-   }
-   string name = "TriMesh";
-   FePlateTriangularMesh3D* triMesh = new FePlateTriangularMesh3D(name,points,triangles);
-   triMesh->setNullLevel((float)nulllevel);
-   triMesh->setHeight(height);
-   triMesh->setNodesX1Dir(nodesX1);
-   triMesh->setNodesX2Dir(nodesX2);
-   cout<<"done"<<endl;
-   return triMesh;
-}
-
-
+#include <numerics/geometry3d/fem/FePlateTriangularMesh3D.h>
+
+using namespace std;
+                         
+FePlateTriangularMesh3D::FePlateTriangularMesh3D() : GbTriangularMesh3D()
+{
+}
+
+FePlateTriangularMesh3D::FePlateTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbTriangle3D*> *triangles) : GbTriangularMesh3D(name, nodes, triangles)
+{
+}
+
+/*=============================================================================================*/
+
+FePlateTriangularMesh3D::FePlateTriangularMesh3D(string name, vector<GbTriangle3D*> *triangles) : GbTriangularMesh3D(name, triangles)
+{
+}
+
+/*=============================================================================================*/
+FePlateTriangularMesh3D::FePlateTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbLine3D*> *edges, vector<GbTriangle3D*> *triangles) : GbTriangularMesh3D(name, nodes, edges, triangles)
+{
+}
+/*=============================================================================================*/
+FePlateTriangularMesh3D::~FePlateTriangularMesh3D()
+{
+
+}
+/*======================================================================*/
+
+/*======================================================================*/
+bool FePlateTriangularMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3)
+{
+	//cout<<"GbTriangularMesh3D::isPointInGbObject3D"<<endl;
+	//Sebastian
+	//double xmin=this->getX1Minimum();	double xmax=this->getX1Maximum();
+ //  double ymin=this->getX2Minimum();	double ymax=this->getX2Maximum();
+ //  double zmin=this->getX3Minimum();	double zmax=this->getX3Maximum();
+ //  double dX = (xmax-xmin)/100.;
+ //  double dY = (ymax-ymin)/100.;
+ //  double dZ = (zmax-zmin)/100.;
+ //  GbCuboid3D boundingCube(xmin-dX, ymin-dY, zmin-dZ, xmax+dX, ymax+dY, zmax+dZ);
+	//
+	//if(this->isPointInObject3DHalfSpace(x1,x2,x3))
+	//{
+	//	return true;
+	//}
+	//if(!boundingCube.isPointInGbObject3D(x1, x2, x3))
+	//{
+	//	return false;
+	//}
+
+	//return false;
+	//Marco
+	int inside = 0;
+   int nx1 = this->getNodesX1Dir()-1;
+   int nx2 = this->getNodesX2Dir()-1;
+   int maxTriangels = 2*nx1*nx2;
+
+   //Überprüft, ob der Punkt innerhalb des Netzes liegt
+	double xmin=this->getX1Minimum();	double xmax=this->getX1Maximum();
+	double ymin=this->getX2Minimum();	double ymax=this->getX2Maximum();
+	double zmin=this->getX3Minimum();	double zmax=this->getX3Maximum();
+	if(	x1<=xmax && x1>=xmin
+		&& x2<=ymax && x2>=ymin
+		&& x3<=zmax && x3>=zmin)
+	{
+      //Achtung Sonderfall
+      //Es wird nur gegen die obere Lage Dreiecke getestet, da die untere Lage um den Abstand 'height' verschoben ist!
+      //Die Seiten müssen somit auch nicht berücksichtigt werden
+      for(int i=0; i<int(maxTriangels);i++)     
+		{
+			if(	(triangles->at(i))->enclosesPoint2D(x1, x2)
+				&&	x3<triangles->at(i)->getX3Centroid()
+				&& x3>triangles->at(i)->getX3Centroid() - this->height  )
+			{
+					inside++;
+			}
+		}
+	}
+
+	if(inside!=0)
+	{
+		return true;
+	}
+	else return false;
+}
+/*======================================================================*/
+FePlateTriangularMesh3D* FePlateTriangularMesh3D::createMeshByElements(int ElementsX1, int ElementsX2, double nulllevel, double deltaX1, double deltaX2, double height)
+{
+   FePlateTriangularMesh3D* triMesh = FePlateTriangularMesh3D::createMeshByNodes(ElementsX1+1, ElementsX2+1, nulllevel, deltaX1, deltaX2, height);
+   return triMesh;
+}
+/*======================================================================*/
+FePlateTriangularMesh3D* FePlateTriangularMesh3D::createMeshByNodes(int nodesX1, int nodesX2, double nulllevel, double deltaX1, double deltaX2, double height)
+{
+   cout<<"erstelle GbTriangularMesh3D -> ";
+   vector<GbTriangle3D*>  *triangles = new vector<GbTriangle3D*>;
+   vector<GbPoint3D*> *points = new vector<GbPoint3D*>;
+   double h1=nulllevel+0.5*height;
+   double h2=nulllevel-0.5*height;
+   GbPoint3D* point1;
+   GbPoint3D* point2;
+   GbPoint3D* point3;
+   GbPoint3D* point4;
+   //Erstelle Knoten
+   //oben
+   for(int i=0; i<nodesX1; i++)
+   {
+      for(int j=0; j<nodesX2; j++)
+      {
+         GbPoint3D* point = new GbPoint3D(i*deltaX1,j*deltaX2,h1);
+         points->push_back(point);
+      }
+   }
+   //unten
+   for(int i=0; i<nodesX1; i++)
+   {
+      for(int j=0; j<nodesX2; j++)
+      {
+         GbPoint3D* point = new GbPoint3D(i*deltaX1,j*deltaX2,h2);
+         points->push_back(point);
+      }
+   }
+   int size=int(points->size());
+   //Erstelle Dreiecke
+   //oben
+   for(int i=0; i<(size/2)-nodesX2; i+=nodesX2)
+   {
+      for(int j=0; j<nodesX2-1; j++)
+      {
+         point1 = points->at(i+j);
+         point2 = points->at(i+j+1);
+         point3 = points->at(i+j+nodesX2);
+         point4 = points->at(i+j+nodesX2+1);
+         GbTriangle3D* tri1 = new GbTriangle3D(point1,point3,point4);
+         GbTriangle3D* tri2 = new GbTriangle3D(point1,point4,point2);
+         triangles->push_back(tri1);
+         triangles->push_back(tri2);
+      }
+   }
+   //unten
+   for(int i=(size/2); i<size-nodesX2; i+=nodesX2)
+   {
+      for(int j=0; j<nodesX2-1; j++)
+      {
+         point1 = points->at(i+j);
+         point2 = points->at(i+j+1);
+         point3 = points->at(i+j+nodesX2);
+         point4 = points->at(i+j+nodesX2+1);
+         GbTriangle3D* tri1 = new GbTriangle3D(point4,point3,point1);
+         GbTriangle3D* tri2 = new GbTriangle3D(point2,point4,point1);
+         triangles->push_back(tri1);
+         triangles->push_back(tri2);
+      }
+   }
+   //Rand
+   //Nord
+   for(int i=0;i<nodesX1-1;i++)
+   {	
+      int a = i*nodesX2+nodesX2-1;
+      int b = (i+1)*nodesX2+nodesX2-1;
+      point1 = points->at(a);
+      point2 = points->at(b);
+      point3 = points->at(a+size/2);
+      point4 = points->at(b+size/2);
+      GbTriangle3D* tri1 = new GbTriangle3D(point1,point2,point3);
+      GbTriangle3D* tri2 = new GbTriangle3D(point2,point4,point3);
+      triangles->push_back(tri1);
+      triangles->push_back(tri2);
+   }
+   //Süd
+   for(int i=0;i<nodesX1-1;i++)
+   {	
+      int a = i*nodesX2;
+      int b = (i+1)*nodesX2;
+      point1 = points->at(a);
+      point2 = points->at(b);
+      point3 = points->at(a+size/2);
+      point4 = points->at(b+size/2);
+      GbTriangle3D* tri1 = new GbTriangle3D(point3,point2,point1);
+      GbTriangle3D* tri2 = new GbTriangle3D(point3,point4,point2);
+      triangles->push_back(tri1);
+      triangles->push_back(tri2);
+   }
+   //Ost
+   for(int j=0;j<nodesX2-1;j++)
+   {	
+      int a = j;
+      int b = j+1;
+      point1 = points->at(a);
+      point2 = points->at(b);
+      point3 = points->at(a+size/2);
+      point4 = points->at(b+size/2);
+      GbTriangle3D* tri1 = new GbTriangle3D(point1,point2,point3);
+      GbTriangle3D* tri2 = new GbTriangle3D(point4,point3,point2);
+      triangles->push_back(tri1);
+      triangles->push_back(tri2);
+   }
+   //West
+   for(int j=0;j<nodesX2-1;j++)
+   {	
+      int a = j+(nodesX1-1)*nodesX2;
+      int b = j+(nodesX1-1)*nodesX2+1;
+      point1 = points->at(a);
+      point2 = points->at(b);
+      point3 = points->at(a+size/2);
+      point4 = points->at(b+size/2);
+      GbTriangle3D* tri1 = new GbTriangle3D(point3,point2,point1);
+      GbTriangle3D* tri2 = new GbTriangle3D(point2,point3,point4);
+      triangles->push_back(tri1);
+      triangles->push_back(tri2);
+   }
+   string name = "TriMesh";
+   FePlateTriangularMesh3D* triMesh = new FePlateTriangularMesh3D(name,points,triangles);
+   triMesh->setNullLevel((float)nulllevel);
+   triMesh->setHeight(height);
+   triMesh->setNodesX1Dir(nodesX1);
+   triMesh->setNodesX2Dir(nodesX2);
+   cout<<"done"<<endl;
+   return triMesh;
+}
+
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/fem/FePlateTriangularMesh3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FePlateTriangularMesh3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/fem/FePlateTriangularMesh3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/fem/FePlateTriangularMesh3D.h
index a938503a2fff98c4d2b034b61f5f46e853adad89..19fc2a07cbe9322cfc92a748b11b6d7c43d5d22e 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/fem/FePlateTriangularMesh3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FePlateTriangularMesh3D.h
@@ -1,50 +1,50 @@
-#ifndef FEPLATETRIANGULARMESH_H
-#define FEPLATETRIANGULARMESH_H
-
-#include <sstream>
-#include <iostream>
-
-#include <numerics/geometry3d/GbTriangularMesh3D.h>
-
-
-/*=========================================================================*/
-/* GbTriangularMesh3D                                                      */
-/*                                                                         */
-/**
- * This Class provides the triangular meshes.
- * Note, that up to now no methods for checking consistency are included.
- * in this context this class describes facettes from an 3D-object !!!
-*/
-class FePlateTriangularMesh3D : public GbTriangularMesh3D 
-{                             
-public:
-   FePlateTriangularMesh3D();
-   FePlateTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbTriangle3D*> *triangles);
-   FePlateTriangularMesh3D(std::string name, std::vector<GbTriangle3D*> *triangles);
-   FePlateTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbLine3D*> *edges, std::vector<GbTriangle3D*> *triangles);
-	virtual ~FePlateTriangularMesh3D();   
-
-   static FePlateTriangularMesh3D* createMeshByNodes(int nodesX1, int nodesX2, double nulllevel, double deltaX1, double deltaX2, double height);
-   static FePlateTriangularMesh3D* createMeshByElements(int ElementsX1, int ElementsX2, double nulllevel, double deltaX1, double deltaX2, double height);
-
-
-	float	 getNullLevel()						{	return this->nulllevel;	}
-	void	 setNullLevel(float nulllevel)	{	this->nulllevel = nulllevel;	}
-   double getHeight()							{	return this->height;	}
-   void	 setHeight(double height)			{	this->height = height;	}
-   int    getNodesX1Dir()						{	return this->nodesX1Dir;	}
-   void	 setNodesX1Dir(int nodesX1Dir)   {	this->nodesX1Dir = nodesX1Dir;	}
-   int    getNodesX2Dir()						{	return this->nodesX2Dir;	}
-   void	 setNodesX2Dir(int nodesX2Dir)   {	this->nodesX2Dir = nodesX2Dir;	}
-
-	bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3);
-   
-   /*======================================================================*/
-private:
-	float			nulllevel;
-	double		height;
-   int         nodesX1Dir;
-   int         nodesX2Dir;
-};
-/*=========================================================================*/
-#endif
+#ifndef FEPLATETRIANGULARMESH_H
+#define FEPLATETRIANGULARMESH_H
+
+#include <sstream>
+#include <iostream>
+
+#include <numerics/geometry3d/GbTriangularMesh3D.h>
+
+
+/*=========================================================================*/
+/* GbTriangularMesh3D                                                      */
+/*                                                                         */
+/**
+ * This Class provides the triangular meshes.
+ * Note, that up to now no methods for checking consistency are included.
+ * in this context this class describes facettes from an 3D-object !!!
+*/
+class FePlateTriangularMesh3D : public GbTriangularMesh3D 
+{                             
+public:
+   FePlateTriangularMesh3D();
+   FePlateTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbTriangle3D*> *triangles);
+   FePlateTriangularMesh3D(std::string name, std::vector<GbTriangle3D*> *triangles);
+   FePlateTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbLine3D*> *edges, std::vector<GbTriangle3D*> *triangles);
+	virtual ~FePlateTriangularMesh3D();   
+
+   static FePlateTriangularMesh3D* createMeshByNodes(int nodesX1, int nodesX2, double nulllevel, double deltaX1, double deltaX2, double height);
+   static FePlateTriangularMesh3D* createMeshByElements(int ElementsX1, int ElementsX2, double nulllevel, double deltaX1, double deltaX2, double height);
+
+
+	float	 getNullLevel()						{	return this->nulllevel;	}
+	void	 setNullLevel(float nulllevel)	{	this->nulllevel = nulllevel;	}
+   double getHeight()							{	return this->height;	}
+   void	 setHeight(double height)			{	this->height = height;	}
+   int    getNodesX1Dir()						{	return this->nodesX1Dir;	}
+   void	 setNodesX1Dir(int nodesX1Dir)   {	this->nodesX1Dir = nodesX1Dir;	}
+   int    getNodesX2Dir()						{	return this->nodesX2Dir;	}
+   void	 setNodesX2Dir(int nodesX2Dir)   {	this->nodesX2Dir = nodesX2Dir;	}
+
+	bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3);
+   
+   /*======================================================================*/
+private:
+	float			nulllevel;
+	double		height;
+   int         nodesX1Dir;
+   int         nodesX2Dir;
+};
+/*=========================================================================*/
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/fem/FePoint3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FePoint3D.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/fem/FePoint3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/fem/FePoint3D.h
index c26ac282c0c6f054c2ec214f47e64b40044a3eb0..8e0eb8a7a08e33f4b8f3c629ffd59ce326bb7798 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/fem/FePoint3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FePoint3D.h
@@ -1,148 +1,148 @@
-#ifndef FEPOINT3D_H
-#define FEPOINT3D_H
-
-#include <sstream>
-#include <numerics/geometry3d/GbPoint3D.h>
-
-
-/*=========================================================================*/
-/* GbPoint3D                                                               */
-/*                                                                         */
-/**
- * This Class provides basic 3D point objects.
- * <BR><BR><HR>
- * @author <A HREF="mailto:geller@bauinf.tu-cottbus.de">S. Geller</A>
- * @version 1.0 - 10.02.07
- * 
-	*/
-class FePoint3D : public GbPoint3D 
-{
-private:
-
-	double Fx;
-	double Fy;
-	double Fz;
-    //double oldFx;
-    //double oldFy;
-    double sumFx;
-    double sumFy;
-    double sumFz;
-	double velocityX;
-	double velocityY;
-	double velocityZ;
-    //double accelerationX;
-    //double accelerationY;
-   UbTupleDouble6 stresses; 
-
-   double area;
-public:
-	FePoint3D():GbPoint3D()
-   {
-      this->init();
-	}
-	FePoint3D(double x, double y, double z):GbPoint3D(x,y,z)
-	{
-      this->init();
-	}
-   FePoint3D(GbPoint3D *point):GbPoint3D(point)
-   {
-      this->init();
-   }
-
-	FePoint3D(FePoint3D *point):GbPoint3D(point)
-	{
-      this->Fx = point->Fx;
-      this->Fy = point->Fy;
-      this->Fz = point->Fz;
-      throw UbException(__FILE__,__LINE__,"spaeter fertig machen...");
-   }
-
-	virtual ~FePoint3D()
-	{
-	}
-
-   void init()
-   {
-      this->Fx = 0.0;
-      this->Fy = 0.0;
-      this->Fz = 0.0;
-      //this->oldFx = 0.0;
-      //this->oldFy = 0.0;
-      this->sumFx = 0.0;
-      this->sumFy = 0.0;
-      this->sumFz = 0.0;
-      val<1>(stresses) = 0.0;
-      val<2>(stresses) = 0.0;
-      val<3>(stresses) = 0.0;
-      val<4>(stresses) = 0.0;
-      val<5>(stresses) = 0.0;
-      val<6>(stresses) = 0.0;
-      this->area = 0.0;
-      this->velocityX = 0.0;
-      this->velocityY = 0.0;
-      this->velocityZ = 0.0;
-   }
-	/*======================================================================*/
-   FePoint3D* clone()   
-   { 
-      return(new FePoint3D(this)); 
-   }
-
-	double getVelocityX()   { return(this->velocityX); }
-	double getVelocityY()   { return(this->velocityY); }
-	double getVelocityZ()   { return(this->velocityZ); }
-	void setVelocityX(double x)   { this->velocityX = x; }
-	void setVelocityY(double y)   { this->velocityY = y; }
-	void setVelocityZ(double z)   { this->velocityZ = z; }
-
-   double getFX()   { return(this->Fx); }
-	double getFY()   { return(this->Fy); }
-	double getFZ()   { return(this->Fz); }
-	void setFX(double FX)   { this->Fx = FX; }
-	void setFY(double FY)   { this->Fy = FY; }
-	void setFZ(double FZ)   { this->Fz = FZ; }
-	void addFX(double FX)   { this->Fx += FX; }
-	void addFY(double FY)   { this->Fy += FY; }
-	void addFZ(double FZ)   { this->Fz += FZ; }
-
-   double getSumFX()   { return(this->sumFx); }
-   double getSumFY()   { return(this->sumFy); }
-   double getSumFZ()   { return(this->sumFz); }
-   void setSumFX(double FX)   { this->sumFx = FX; }
-   void setSumFY(double FY)   { this->sumFy = FY; }
-   void setSumFZ(double FZ)   { this->sumFz = FZ; }
-   void addSumFX(double FX)   { this->sumFx += FX; }
-   void addSumFY(double FY)   { this->sumFy += FY; }
-   void addSumFZ(double FZ)   { this->sumFz += FZ; }
-
-   UbTupleDouble6& getStresses() { return this->stresses; }
-//   void setS11(double S11) { this->S11 = S11; }
-//   void setS12(double S12) { this->S12 = S12; }
-//   void setS22(double S22) { this->S22 = S22; }
-   double getArea() { return this->area; }
-   void setArea(double area) { this->area = area; }
-   void addArea(double area) { this->area += area; }
-
-   /**
-    * Returns a string representation of this 3D fe-point.
-    * @return a string representation of this 3D fe-point
-    */
-   std::string toString()
-   {
-      std::stringstream ss; 
-      ss<<"FePoint3D[";
-		ss<<"x1="<<this->x1;
-		ss<<", x2="<<this->x2;		
-		ss<<", x3="<<this->x3;		
-		ss<<", Fx="<<this->Fx;
-		ss<<", Fy="<<this->Fy;
-		ss<<", Fz="<<this->Fz<<"]";
-		return((ss.str()).c_str());
-   }
-   /*======================================================================*/
-};
-/*=========================================================================*/
-#endif
-
-
-
+#ifndef FEPOINT3D_H
+#define FEPOINT3D_H
+
+#include <sstream>
+#include <numerics/geometry3d/GbPoint3D.h>
+
+
+/*=========================================================================*/
+/* GbPoint3D                                                               */
+/*                                                                         */
+/**
+ * This Class provides basic 3D point objects.
+ * <BR><BR><HR>
+ * @author <A HREF="mailto:geller@bauinf.tu-cottbus.de">S. Geller</A>
+ * @version 1.0 - 10.02.07
+ * 
+	*/
+class FePoint3D : public GbPoint3D 
+{
+private:
+
+	double Fx;
+	double Fy;
+	double Fz;
+    //double oldFx;
+    //double oldFy;
+    double sumFx;
+    double sumFy;
+    double sumFz;
+	double velocityX;
+	double velocityY;
+	double velocityZ;
+    //double accelerationX;
+    //double accelerationY;
+   UbTupleDouble6 stresses; 
+
+   double area;
+public:
+	FePoint3D():GbPoint3D()
+   {
+      this->init();
+	}
+	FePoint3D(double x, double y, double z):GbPoint3D(x,y,z)
+	{
+      this->init();
+	}
+   FePoint3D(GbPoint3D *point):GbPoint3D(point)
+   {
+      this->init();
+   }
+
+	FePoint3D(FePoint3D *point):GbPoint3D(point)
+	{
+      this->Fx = point->Fx;
+      this->Fy = point->Fy;
+      this->Fz = point->Fz;
+      throw UbException(__FILE__,__LINE__,"spaeter fertig machen...");
+   }
+
+	virtual ~FePoint3D()
+	{
+	}
+
+   void init()
+   {
+      this->Fx = 0.0;
+      this->Fy = 0.0;
+      this->Fz = 0.0;
+      //this->oldFx = 0.0;
+      //this->oldFy = 0.0;
+      this->sumFx = 0.0;
+      this->sumFy = 0.0;
+      this->sumFz = 0.0;
+      val<1>(stresses) = 0.0;
+      val<2>(stresses) = 0.0;
+      val<3>(stresses) = 0.0;
+      val<4>(stresses) = 0.0;
+      val<5>(stresses) = 0.0;
+      val<6>(stresses) = 0.0;
+      this->area = 0.0;
+      this->velocityX = 0.0;
+      this->velocityY = 0.0;
+      this->velocityZ = 0.0;
+   }
+	/*======================================================================*/
+   FePoint3D* clone()   
+   { 
+      return(new FePoint3D(this)); 
+   }
+
+	double getVelocityX()   { return(this->velocityX); }
+	double getVelocityY()   { return(this->velocityY); }
+	double getVelocityZ()   { return(this->velocityZ); }
+	void setVelocityX(double x)   { this->velocityX = x; }
+	void setVelocityY(double y)   { this->velocityY = y; }
+	void setVelocityZ(double z)   { this->velocityZ = z; }
+
+   double getFX()   { return(this->Fx); }
+	double getFY()   { return(this->Fy); }
+	double getFZ()   { return(this->Fz); }
+	void setFX(double FX)   { this->Fx = FX; }
+	void setFY(double FY)   { this->Fy = FY; }
+	void setFZ(double FZ)   { this->Fz = FZ; }
+	void addFX(double FX)   { this->Fx += FX; }
+	void addFY(double FY)   { this->Fy += FY; }
+	void addFZ(double FZ)   { this->Fz += FZ; }
+
+   double getSumFX()   { return(this->sumFx); }
+   double getSumFY()   { return(this->sumFy); }
+   double getSumFZ()   { return(this->sumFz); }
+   void setSumFX(double FX)   { this->sumFx = FX; }
+   void setSumFY(double FY)   { this->sumFy = FY; }
+   void setSumFZ(double FZ)   { this->sumFz = FZ; }
+   void addSumFX(double FX)   { this->sumFx += FX; }
+   void addSumFY(double FY)   { this->sumFy += FY; }
+   void addSumFZ(double FZ)   { this->sumFz += FZ; }
+
+   UbTupleDouble6& getStresses() { return this->stresses; }
+//   void setS11(double S11) { this->S11 = S11; }
+//   void setS12(double S12) { this->S12 = S12; }
+//   void setS22(double S22) { this->S22 = S22; }
+   double getArea() { return this->area; }
+   void setArea(double area) { this->area = area; }
+   void addArea(double area) { this->area += area; }
+
+   /**
+    * Returns a string representation of this 3D fe-point.
+    * @return a string representation of this 3D fe-point
+    */
+   std::string toString()
+   {
+      std::stringstream ss; 
+      ss<<"FePoint3D[";
+		ss<<"x1="<<this->x1;
+		ss<<", x2="<<this->x2;		
+		ss<<", x3="<<this->x3;		
+		ss<<", Fx="<<this->Fx;
+		ss<<", Fy="<<this->Fy;
+		ss<<", Fz="<<this->Fz<<"]";
+		return((ss.str()).c_str());
+   }
+   /*======================================================================*/
+};
+/*=========================================================================*/
+#endif
+
+
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/fem/FeRing3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FeRing3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/fem/FeRing3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/fem/FeRing3D.cpp
index 8b30959432d1003324ba4070aaba3679b926f346..320e4d2b169f0f66c09551c8e4761df734469b08 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/fem/FeRing3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FeRing3D.cpp
@@ -1,468 +1,468 @@
-#include <numerics/geometry3d/fem/FeRing3D.h>    
-#include <numerics/geometry3d/GbSystem3D.h>
-#include <numerics/geometry3d/fem/FePoint3D.h>                    
-#include <numerics/geometry3d/GbLine3D.h>
-#include <numerics/geometry3d/GbTriangle3D.h>
-
-using namespace std;
-
-/*=======================================================*/
-ObObjectCreator* FeRing3D::getCreator()
-{
-   return NULL; //FeRing3DCreator::getInstance(); 
-}
-// Konstruktor
-/*==========================================================*/
-FeRing3D::FeRing3D()
-{
-   GbPoint3D* p1 = new GbPoint3D();
-   GbPoint3D* p2 = new GbPoint3D();
-   mLine = new GbLine3D(p1,p2);
-   this->mLine->addObserver(this);
-   inRadius = 0.0;
-   outRadius = 0.0;
-   ringType = FeRing3D::NOTPARALLELTOAXIS;
-}                                                   
-/*=======================================================*/
-FeRing3D::FeRing3D(FeRing3D* ring)
-{
-   inRadius     = ring->getInRadius();
-   outRadius    = ring->getOutRadius();
-   ringType     = ring->ringType;
-   mLine        = ring->getLine()->clone();
-
-   this->mLine->addObserver(this);
-}                                                   
-/*==========================================================*/
-FeRing3D::FeRing3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& inradius, const double& outradius)
-{
-   mLine = new GbLine3D;
-   mLine->setPoints( new GbPoint3D(min(x1a,x1b), min(x2a,x2b), min(x3a,x3b))
-	                 ,new GbPoint3D(max(x1a,x1b), max(x2a,x2b), max(x3a,x3b)));
-   this->mLine->addObserver(this);
-   this->inRadius = inradius;
-   this->outRadius = outradius;
-
-   this->initRingType();
-   if((this->ringType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) 
-      throw UbException("FeRing3D::FeRing3D - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}                                                            
-/*==========================================================*/
-FeRing3D::FeRing3D(GbPoint3D* p1, GbPoint3D* p2, const double& inradius, const double& outradius)
-{
-   this->inRadius = inradius;
-   this->outRadius = outradius;
-
-   mLine = new GbLine3D(p1,p2);
-   this->mLine->addObserver(this);
-   this->initRingType();
-   if((this->ringType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) 
-      throw UbException("FeRing3D::FeRing3D - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}
-/*==========================================================*/
-FeRing3D::FeRing3D(GbLine3D* line, const double& inradius, const double& outradius)
-{
-   this->inRadius = inradius;
-   this->outRadius = outradius;
-
-   this->mLine = line;
-   this->mLine->addObserver(this);
-   this->initRingType();
-   if((this->ringType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) 
-      throw UbException("FeRing3D::FeRing3D - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}
-/*==========================================================*/		
-// Destruktor
-FeRing3D::~FeRing3D()
-{
-   if(mLine) this->mLine->removeObserver(this);
-   mLine = NULL;
-}
-/*=======================================================*/
-void FeRing3D::initRingType()
-{
-   double x1a = mLine->getPoint1()->x1;    double x1b = mLine->getPoint2()->x1;
-   double x2a = mLine->getPoint1()->x2;    double x2b = mLine->getPoint2()->x2;
-   double x3a = mLine->getPoint1()->x3;    double x3b = mLine->getPoint2()->x3;
-   
-   if     (x1a!=x1b && x2a==x2b && x3a==x3b)  this->ringType = X1PARALLEL; 
-   else if(x2a!=x2b && x1a==x1b && x3a==x3b)  this->ringType = X2PARALLEL; 
-   else if(x3a!=x3b && x1a==x1b && x2a==x2b)  this->ringType = X3PARALLEL; 
-   else                                       this->ringType = NOTPARALLELTOAXIS;
-}
-/*=======================================================*/
-void FeRing3D::finalize() 
-{ 
-   if(this->mLine) 
-   {
-      mLine->finalize();
-      delete mLine; 
-      mLine=NULL;
-   } 
-}
-/*=======================================================*/
-double FeRing3D::getHeight()
-{
-   if(mLine) return mLine->getLength(); return 0.0; 
-}
-/*=======================================================*/
-GbPoint3D* FeRing3D::getPoint1()
-{
-   if(this->mLine) return this->mLine->getPoint1();
-   return NULL;
-}
-/*=======================================================*/
-GbPoint3D* FeRing3D::getPoint2()
-{
-   if(this->mLine) return this->mLine->getPoint2();
-   return NULL;
-}
-/*=======================================================*/
-void FeRing3D::setInRadius(const double& radius) 
-{ 
-   this->inRadius = std::fabs(radius); 
-   this->notifyObserversObjectChanged();
-}
-/*=======================================================*/
-void FeRing3D::setOutRadius(const double& radius) 
-{ 
-   this->outRadius = std::fabs(radius); 
-   this->notifyObserversObjectChanged();
-}
-/*=======================================================*/
-void FeRing3D::setLine(GbLine3D* line) 
-{
-   if(this->mLine) this->mLine->removeObserver(this);
-   this->mLine = line;  
-   this->mLine->addObserver(this);
-   this->initRingType();
-
-   this->notifyObserversObjectChanged();
-}
-/*=======================================================*/
-void FeRing3D::setPoint1(const double& x1, const double& x2, const double& x3)
-{ 
-   if(!mLine->getPoint1()) throw UbException("FeRing3D::setPoint1() - line has no point1");
-   mLine->getPoint1()->setCoordinates(x1,x2,x3);
-   this->initRingType();
-
-   //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt...
-}
-/*=======================================================*/
-void FeRing3D::setPoint2(const double& x1, const double& x2, const double& x3)
-{ 
-   if(!mLine->getPoint2()) throw UbException("FeRing3D::setPoint1() - line has no point2");
-   mLine->getPoint2()->setCoordinates(x1,x2,x3);
-   this->initRingType();
-
-   //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt...
-}
-/*==========================================================*/		
-double FeRing3D::getX1Centroid()  
-{
-   return mLine->getX1Centroid();
-}
-/*==========================================================*/
-double FeRing3D::getX1Minimum()   
-{
-   if     (this->isParallelToX1Axis()) return mLine->getX1Minimum(); 
-   else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()-outRadius; 
-   else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()-outRadius; 
-   else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Minimum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}
-/*==========================================================*/
-double FeRing3D::getX1Maximum()   
-{
-   if     (this->isParallelToX1Axis()) return mLine->getX1Maximum(); 
-   else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()+outRadius; 
-   else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()+outRadius; 
-   else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Maximum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}
-/*==========================================================*/
-double FeRing3D::getX2Centroid()
-{
-   return mLine->getX2Centroid();
-}
-/*==========================================================*/
-double FeRing3D::getX2Minimum()   
-{
-   if     (this->isParallelToX1Axis()) return mLine->getX2Centroid()-outRadius;
-   else if(this->isParallelToX2Axis()) return mLine->getX2Minimum();
-   else if(this->isParallelToX3Axis()) return mLine->getX2Centroid()-outRadius; 
-   else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Minimum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}	
-/*==========================================================*/
-double FeRing3D::getX2Maximum()   
-{
-   if     (this->isParallelToX1Axis())  return mLine->getX2Centroid()+outRadius;
-   else if(this->isParallelToX2Axis())  return mLine->getX2Maximum();
-   else if(this->isParallelToX3Axis())  return mLine->getX2Centroid()+outRadius; 
-   else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Maximum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}
-/*==========================================================*/
-double FeRing3D::getX3Centroid()
-{
-   return mLine->getX3Centroid();
-}
-/*==========================================================*/
-double FeRing3D::getX3Minimum()   
-{	
-   if     (this->isParallelToX1Axis()) return mLine->getX3Centroid()-outRadius;
-   else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()-outRadius; 
-   else if(this->isParallelToX3Axis()) return mLine->getX3Minimum(); 
-   else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Minimum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}	
-/*==========================================================*/
-double FeRing3D::getX3Maximum()   
-{
-   if     (this->isParallelToX1Axis()) return mLine->getX3Centroid()+outRadius;
-   else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()+outRadius; 
-   else if(this->isParallelToX3Axis()) return mLine->getX3Maximum(); 
-   else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Maximum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
-}
-/*==========================================================*/
-bool FeRing3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
-{
-   throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented");
-
-}
-/*==========================================================*/
-bool FeRing3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
-{
-   throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented");
-}
-/*=======================================================*/
-bool FeRing3D::isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-{
-   throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented");
-}
-
-/*==========================================================*/
-string FeRing3D::toString() 
-{
-	stringstream ss;
-	ss<<"FeRing3D[";
-	ss<<"line="<<this->mLine->toString();
-   ss<<", inRadius="<<this->inRadius;
-   ss<<", outRadius="<<this->outRadius;
-   ss<<"]";
-   return(ss.str());
-}
-/*==========================================================*/
-bool FeRing3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-{
-   throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented");
-}
-/*==========================================================*/
-bool FeRing3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
-{
-   throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented");
-}
-/*==========================================================*/
-GbLine3D* FeRing3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
-{
-   throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented");
-}
-/*==========================================================*/
-vector<GbTriangle3D*> FeRing3D::getSurfaceTriangleSet()
-{
-   double x1ma,x1mb,x2m,x3m;
-   if( this->isParallelToX1Axis() ) 
-   {
-      x1ma = this->getX1Minimum();
-      x1mb = this->getX1Maximum();
-      x2m  = this->getX2Centroid();
-      x3m  = this->getX3Centroid();
-   }
-   else if( this->isParallelToX2Axis() ) 
-   {
-      x1ma = this->getX2Minimum();
-      x1mb = this->getX2Maximum();
-      x2m  = this->getX1Centroid();
-      x3m  = this->getX3Centroid();
-   }
-   else if( this->isParallelToX3Axis() ) 
-   {
-      x1ma = this->getX3Minimum();
-      x1mb = this->getX3Maximum();
-      x2m  = this->getX2Centroid();
-      x3m  = this->getX1Centroid();
-   }
-   else throw UbException(__FILE__, __LINE__, "FeRing3D::getSurfaceTriangleSet() - ring not axis prallel");
-   
-   vector<GbTriangle3D*> triangles;    
-
-   int segmentsCircle  = 14;
-   double deltaPhi = UbMath::PI/(double)segmentsCircle;
-
-   double phiX1a,phiX1b;
-   double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d;
-   double x2aa,x3aa,x2bb,x3bb;
-   
-   double dXCylinder =  fabs((x1mb-x1ma)); // /(double)segmentsCircle;
-   int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder);
-   for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++)
-   {
-      x1a = x1d = x1ma+segCyl*dXCylinder;
-      x1b = x1c = x1a+dXCylinder;
-      
-      for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi)
-      {
-         phiX1b = phiX1a+deltaPhi;
-         
-         x2a =  x2m+this->outRadius*std::sin(phiX1a);
-         x3a =  x3m+this->outRadius*std::cos(phiX1a);
-         x2b =  x2m+this->outRadius*std::sin(phiX1b);
-         x3b =  x3m+this->outRadius*std::cos(phiX1b);
-
-         x2aa =  x2m+this->inRadius*std::sin(phiX1a);
-         x3aa =  x3m+this->inRadius*std::cos(phiX1a);
-         x2bb =  x2m+this->inRadius*std::sin(phiX1b);
-         x3bb =  x3m+this->inRadius*std::cos(phiX1b);
-         
-         if( this->isParallelToX1Axis() ) 
-         { 
-            triangles.push_back(new GbTriangle3D(new FePoint3D(x1b,x2a,x3a),new FePoint3D(x1b,x2b,x3b),new FePoint3D(x1a,x2a,x3a)));
-            triangles.push_back(new GbTriangle3D(new FePoint3D(x1a,x2b,x3b),new FePoint3D(x1a,x2a,x3a),new FePoint3D(x1b,x2b,x3b))); 
-            triangles.push_back(new GbTriangle3D(new FePoint3D(x1b,x2bb,x3bb),new FePoint3D(x1b,x2aa,x3aa),new FePoint3D(x1a,x2aa,x3aa)));
-            triangles.push_back(new GbTriangle3D(new FePoint3D(x1a,x2aa,x3aa),new FePoint3D(x1a,x2bb,x3bb),new FePoint3D(x1b,x2bb,x3bb))); 
-         }
-         else if( this->isParallelToX2Axis() ) 
-         { 
-            throw UbException(__FILE__,__LINE__," sollte man mal machen");
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2b,x1b,x3b),new FePoint3D(x2a,x1b,x3a),new FePoint3D(x2a,x1a,x3a)));
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1a,x3a),new FePoint3D(x2b,x1a,x3b),new FePoint3D(x2b,x1b,x3b))); 
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2bb,x1b,x3bb),new FePoint3D(x2aa,x1b,x3aa),new FePoint3D(x2aa,x1a,x3aa)));
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2aa,x1a,x3aa),new FePoint3D(x2bb,x1a,x3bb),new FePoint3D(x2bb,x1b,x3bb))); 
-         }
-         else if( this->isParallelToX3Axis() ) 
-         { 
-            throw UbException(__FILE__,__LINE__," sollte man mal machen");
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3b,x2b,x1b),new FePoint3D(x3a,x2a,x1b),new FePoint3D(x3a,x2a,x1a)));
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1a),new FePoint3D(x3b,x2b,x1a),new FePoint3D(x3b,x2b,x1b))); 
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3bb,x2bb,x1b),new FePoint3D(x3aa,x2aa,x1b),new FePoint3D(x3aa,x2aa,x1a)));
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3aa,x2aa,x1a),new FePoint3D(x3bb,x2bb,x1a),new FePoint3D(x3bb,x2bb,x1b))); 
-         }
-
-      }
-   }
-   
-   //int segmentsSide = (int)(this->outRadius/dXCylinder);
-
-   double radius0, radius1;
-   //for(int segCyl = 10; segCyl<segmentsSide; segCyl++)
-   //{
-      radius0 = inRadius;//segCyl*dXCylinder;
-      radius1 = outRadius;//radius0+dXCylinder;
-      //if(segCyl==segmentsSide-1) radius1=outRadius;
-
-      for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi)
-      {
-         phiX1b = phiX1a+deltaPhi;
-
-         x2a =  x2m+radius0*std::sin(phiX1a);
-         x3a =  x3m+radius0*std::cos(phiX1a);
-         x2b =  x2m+radius0*std::sin(phiX1b);
-         x3b =  x3m+radius0*std::cos(phiX1b);
-         x2c =  x2m+radius1*std::sin(phiX1b);
-         x3c =  x3m+radius1*std::cos(phiX1b);
-         x2d =  x2m+radius1*std::sin(phiX1a);
-         x3d =  x3m+radius1*std::cos(phiX1a);
-
-         if( this->isParallelToX1Axis() ) 
-         { 
-            triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2b,x3b),new FePoint3D(x1ma,x2a,x3a),new FePoint3D(x1ma,x2c,x3c)));
-            triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2d,x3d),new FePoint3D(x1ma,x2c,x3c),new FePoint3D(x1ma,x2a,x3a)));
-            triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2b,x3b),new FePoint3D(x1mb,x2c,x3c),new FePoint3D(x1mb,x2a,x3a)));
-            triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2d,x3d),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1mb,x2c,x3c)));
-         }                                                                   
-         else if( this->isParallelToX2Axis() ) 
-         { 
-            throw UbException(__FILE__,__LINE__," sollte man mal machen");
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1ma,x3a),new FePoint3D(x2b,x1ma,x3b),new FePoint3D(x2c,x1ma,x3c)));
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1ma,x3c),new FePoint3D(x2d,x1ma,x3d),new FePoint3D(x2a,x1ma,x3a)));
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1mb,x3c),new FePoint3D(x2b,x1mb,x3b),new FePoint3D(x2a,x1mb,x3a)));
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1mb,x3a),new FePoint3D(x2d,x1mb,x3d),new FePoint3D(x2c,x1mb,x3c)));
-         }
-         else if( this->isParallelToX3Axis() ) 
-         { 
-            throw UbException(__FILE__,__LINE__," sollte man mal machen");
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1ma),new FePoint3D(x3b,x2b,x1ma),new FePoint3D(x3c,x2c,x1ma)));
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1ma),new FePoint3D(x3d,x2d,x1ma),new FePoint3D(x3a,x2a,x1ma)));
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1mb),new FePoint3D(x3b,x2b,x1mb),new FePoint3D(x3a,x2a,x1mb)));
-            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1mb),new FePoint3D(x3d,x2d,x1mb),new FePoint3D(x3c,x2c,x1mb)));
-         }
-      }
-  // }
-
-   return triangles;
-}
-/*==========================================================*/
-void FeRing3D::objectChanged(UbObservable* changedObject)
-{
-   GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject);
-   if(!line || this->mLine!=line) return;
-
-   this->notifyObserversObjectChanged();
-}
-/*==========================================================*/
-void FeRing3D::objectWillBeDeleted(UbObservable* objectForDeletion)
-{
-   if(this->mLine)
-   {
-      UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine);
-      if(objectForDeletion == observedObj) { this->mLine = NULL; }
-   }
-}
-/*=======================================================*/
-void FeRing3D::scale(const double& sx1, const double& sx2, const double& sx3)
-{  
-   if( this->isParallelToX1Axis() )
-   {
-      if(!UbMath::equal(sx2,sx3)) throw UbException("FeRing3D::scale - || to x1 -> different scaling sx2 and sx3 not possible");
-      this->inRadius*=sx2;
-      this->outRadius*=sx2;
-   }
-   else if( this->isParallelToX2Axis() )
-   {
-      if(!UbMath::equal(sx1,sx3)) throw UbException("FeRing3D::scale - || to x2 -> different scaling sx1 and sx3 not possible");
-      this->inRadius*=sx1;
-      this->outRadius*=sx1;
-   }
-   else if( this->isParallelToX3Axis() )
-   {
-      if(!UbMath::equal(sx1,sx2)) throw UbException("FeRing3D::scale - || to x3 -> different scaling sx1 and sx2 not possible");
-      this->inRadius*=sx1;
-      this->outRadius*=sx1;
-   }
-   else throw UbException("FeRing3D::scale - unknown direction");
-
-   this->mLine->scale(sx1,sx2,sx3);
-   //notify observer wird automatisch aufgerufen
-}
-/*==========================================================*/
-void FeRing3D::write(UbFileOutput* out) 
-{                                      
-   out->writeString(this->getCreator()->getTypeID());
-   mLine->write(out);
-   out->writeDouble(inRadius);
-   out->writeDouble(outRadius);
-   out->writeInteger(ringType);
-}
-/*==========================================================*/
-void FeRing3D::read(UbFileInput* in) 
-{  
-   in->readString();                                    
-   mLine = new GbLine3D;
-   mLine->read(in);
-   inRadius  = in->readDouble();
-   outRadius = in->readDouble();
-   ringType  = in->readInteger();
-}
-/*==========================================================*/
-double FeRing3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
-{
-   throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented");
-}
-/*==========================================================*/
-
+#include <numerics/geometry3d/fem/FeRing3D.h>    
+#include <numerics/geometry3d/GbSystem3D.h>
+#include <numerics/geometry3d/fem/FePoint3D.h>                    
+#include <numerics/geometry3d/GbLine3D.h>
+#include <numerics/geometry3d/GbTriangle3D.h>
+
+using namespace std;
+
+/*=======================================================*/
+ObObjectCreator* FeRing3D::getCreator()
+{
+   return NULL; //FeRing3DCreator::getInstance(); 
+}
+// Konstruktor
+/*==========================================================*/
+FeRing3D::FeRing3D()
+{
+   GbPoint3D* p1 = new GbPoint3D();
+   GbPoint3D* p2 = new GbPoint3D();
+   mLine = new GbLine3D(p1,p2);
+   this->mLine->addObserver(this);
+   inRadius = 0.0;
+   outRadius = 0.0;
+   ringType = FeRing3D::NOTPARALLELTOAXIS;
+}                                                   
+/*=======================================================*/
+FeRing3D::FeRing3D(FeRing3D* ring)
+{
+   inRadius     = ring->getInRadius();
+   outRadius    = ring->getOutRadius();
+   ringType     = ring->ringType;
+   mLine        = ring->getLine()->clone();
+
+   this->mLine->addObserver(this);
+}                                                   
+/*==========================================================*/
+FeRing3D::FeRing3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& inradius, const double& outradius)
+{
+   mLine = new GbLine3D;
+   mLine->setPoints( new GbPoint3D(min(x1a,x1b), min(x2a,x2b), min(x3a,x3b))
+	                 ,new GbPoint3D(max(x1a,x1b), max(x2a,x2b), max(x3a,x3b)));
+   this->mLine->addObserver(this);
+   this->inRadius = inradius;
+   this->outRadius = outradius;
+
+   this->initRingType();
+   if((this->ringType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) 
+      throw UbException("FeRing3D::FeRing3D - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}                                                            
+/*==========================================================*/
+FeRing3D::FeRing3D(GbPoint3D* p1, GbPoint3D* p2, const double& inradius, const double& outradius)
+{
+   this->inRadius = inradius;
+   this->outRadius = outradius;
+
+   mLine = new GbLine3D(p1,p2);
+   this->mLine->addObserver(this);
+   this->initRingType();
+   if((this->ringType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) 
+      throw UbException("FeRing3D::FeRing3D - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}
+/*==========================================================*/
+FeRing3D::FeRing3D(GbLine3D* line, const double& inradius, const double& outradius)
+{
+   this->inRadius = inradius;
+   this->outRadius = outradius;
+
+   this->mLine = line;
+   this->mLine->addObserver(this);
+   this->initRingType();
+   if((this->ringType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) 
+      throw UbException("FeRing3D::FeRing3D - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}
+/*==========================================================*/		
+// Destruktor
+FeRing3D::~FeRing3D()
+{
+   if(mLine) this->mLine->removeObserver(this);
+   mLine = NULL;
+}
+/*=======================================================*/
+void FeRing3D::initRingType()
+{
+   double x1a = mLine->getPoint1()->x1;    double x1b = mLine->getPoint2()->x1;
+   double x2a = mLine->getPoint1()->x2;    double x2b = mLine->getPoint2()->x2;
+   double x3a = mLine->getPoint1()->x3;    double x3b = mLine->getPoint2()->x3;
+   
+   if     (x1a!=x1b && x2a==x2b && x3a==x3b)  this->ringType = X1PARALLEL; 
+   else if(x2a!=x2b && x1a==x1b && x3a==x3b)  this->ringType = X2PARALLEL; 
+   else if(x3a!=x3b && x1a==x1b && x2a==x2b)  this->ringType = X3PARALLEL; 
+   else                                       this->ringType = NOTPARALLELTOAXIS;
+}
+/*=======================================================*/
+void FeRing3D::finalize() 
+{ 
+   if(this->mLine) 
+   {
+      mLine->finalize();
+      delete mLine; 
+      mLine=NULL;
+   } 
+}
+/*=======================================================*/
+double FeRing3D::getHeight()
+{
+   if(mLine) return mLine->getLength(); return 0.0; 
+}
+/*=======================================================*/
+GbPoint3D* FeRing3D::getPoint1()
+{
+   if(this->mLine) return this->mLine->getPoint1();
+   return NULL;
+}
+/*=======================================================*/
+GbPoint3D* FeRing3D::getPoint2()
+{
+   if(this->mLine) return this->mLine->getPoint2();
+   return NULL;
+}
+/*=======================================================*/
+void FeRing3D::setInRadius(const double& radius) 
+{ 
+   this->inRadius = std::fabs(radius); 
+   this->notifyObserversObjectChanged();
+}
+/*=======================================================*/
+void FeRing3D::setOutRadius(const double& radius) 
+{ 
+   this->outRadius = std::fabs(radius); 
+   this->notifyObserversObjectChanged();
+}
+/*=======================================================*/
+void FeRing3D::setLine(GbLine3D* line) 
+{
+   if(this->mLine) this->mLine->removeObserver(this);
+   this->mLine = line;  
+   this->mLine->addObserver(this);
+   this->initRingType();
+
+   this->notifyObserversObjectChanged();
+}
+/*=======================================================*/
+void FeRing3D::setPoint1(const double& x1, const double& x2, const double& x3)
+{ 
+   if(!mLine->getPoint1()) throw UbException("FeRing3D::setPoint1() - line has no point1");
+   mLine->getPoint1()->setCoordinates(x1,x2,x3);
+   this->initRingType();
+
+   //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt...
+}
+/*=======================================================*/
+void FeRing3D::setPoint2(const double& x1, const double& x2, const double& x3)
+{ 
+   if(!mLine->getPoint2()) throw UbException("FeRing3D::setPoint1() - line has no point2");
+   mLine->getPoint2()->setCoordinates(x1,x2,x3);
+   this->initRingType();
+
+   //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt...
+}
+/*==========================================================*/		
+double FeRing3D::getX1Centroid()  
+{
+   return mLine->getX1Centroid();
+}
+/*==========================================================*/
+double FeRing3D::getX1Minimum()   
+{
+   if     (this->isParallelToX1Axis()) return mLine->getX1Minimum(); 
+   else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()-outRadius; 
+   else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()-outRadius; 
+   else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Minimum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}
+/*==========================================================*/
+double FeRing3D::getX1Maximum()   
+{
+   if     (this->isParallelToX1Axis()) return mLine->getX1Maximum(); 
+   else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()+outRadius; 
+   else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()+outRadius; 
+   else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Maximum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}
+/*==========================================================*/
+double FeRing3D::getX2Centroid()
+{
+   return mLine->getX2Centroid();
+}
+/*==========================================================*/
+double FeRing3D::getX2Minimum()   
+{
+   if     (this->isParallelToX1Axis()) return mLine->getX2Centroid()-outRadius;
+   else if(this->isParallelToX2Axis()) return mLine->getX2Minimum();
+   else if(this->isParallelToX3Axis()) return mLine->getX2Centroid()-outRadius; 
+   else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Minimum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}	
+/*==========================================================*/
+double FeRing3D::getX2Maximum()   
+{
+   if     (this->isParallelToX1Axis())  return mLine->getX2Centroid()+outRadius;
+   else if(this->isParallelToX2Axis())  return mLine->getX2Maximum();
+   else if(this->isParallelToX3Axis())  return mLine->getX2Centroid()+outRadius; 
+   else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Maximum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}
+/*==========================================================*/
+double FeRing3D::getX3Centroid()
+{
+   return mLine->getX3Centroid();
+}
+/*==========================================================*/
+double FeRing3D::getX3Minimum()   
+{	
+   if     (this->isParallelToX1Axis()) return mLine->getX3Centroid()-outRadius;
+   else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()-outRadius; 
+   else if(this->isParallelToX3Axis()) return mLine->getX3Minimum(); 
+   else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Minimum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}	
+/*==========================================================*/
+double FeRing3D::getX3Maximum()   
+{
+   if     (this->isParallelToX1Axis()) return mLine->getX3Centroid()+outRadius;
+   else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()+outRadius; 
+   else if(this->isParallelToX3Axis()) return mLine->getX3Maximum(); 
+   else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Maximum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned");
+}
+/*==========================================================*/
+bool FeRing3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p)
+{
+   throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented");
+
+}
+/*==========================================================*/
+bool FeRing3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary)
+{
+   throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented");
+}
+/*=======================================================*/
+bool FeRing3D::isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+{
+   throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented");
+}
+
+/*==========================================================*/
+string FeRing3D::toString() 
+{
+	stringstream ss;
+	ss<<"FeRing3D[";
+	ss<<"line="<<this->mLine->toString();
+   ss<<", inRadius="<<this->inRadius;
+   ss<<", outRadius="<<this->outRadius;
+   ss<<"]";
+   return(ss.str());
+}
+/*==========================================================*/
+bool FeRing3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+{
+   throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented");
+}
+/*==========================================================*/
+bool FeRing3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b)
+{
+   throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented");
+}
+/*==========================================================*/
+GbLine3D* FeRing3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2)
+{
+   throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented");
+}
+/*==========================================================*/
+vector<GbTriangle3D*> FeRing3D::getSurfaceTriangleSet()
+{
+   double x1ma,x1mb,x2m,x3m;
+   if( this->isParallelToX1Axis() ) 
+   {
+      x1ma = this->getX1Minimum();
+      x1mb = this->getX1Maximum();
+      x2m  = this->getX2Centroid();
+      x3m  = this->getX3Centroid();
+   }
+   else if( this->isParallelToX2Axis() ) 
+   {
+      x1ma = this->getX2Minimum();
+      x1mb = this->getX2Maximum();
+      x2m  = this->getX1Centroid();
+      x3m  = this->getX3Centroid();
+   }
+   else if( this->isParallelToX3Axis() ) 
+   {
+      x1ma = this->getX3Minimum();
+      x1mb = this->getX3Maximum();
+      x2m  = this->getX2Centroid();
+      x3m  = this->getX1Centroid();
+   }
+   else throw UbException(__FILE__, __LINE__, "FeRing3D::getSurfaceTriangleSet() - ring not axis prallel");
+   
+   vector<GbTriangle3D*> triangles;    
+
+   int segmentsCircle  = 14;
+   double deltaPhi = UbMath::PI/(double)segmentsCircle;
+
+   double phiX1a,phiX1b;
+   double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d;
+   double x2aa,x3aa,x2bb,x3bb;
+   
+   double dXCylinder =  fabs((x1mb-x1ma)); // /(double)segmentsCircle;
+   int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder);
+   for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++)
+   {
+      x1a = x1d = x1ma+segCyl*dXCylinder;
+      x1b = x1c = x1a+dXCylinder;
+      
+      for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi)
+      {
+         phiX1b = phiX1a+deltaPhi;
+         
+         x2a =  x2m+this->outRadius*std::sin(phiX1a);
+         x3a =  x3m+this->outRadius*std::cos(phiX1a);
+         x2b =  x2m+this->outRadius*std::sin(phiX1b);
+         x3b =  x3m+this->outRadius*std::cos(phiX1b);
+
+         x2aa =  x2m+this->inRadius*std::sin(phiX1a);
+         x3aa =  x3m+this->inRadius*std::cos(phiX1a);
+         x2bb =  x2m+this->inRadius*std::sin(phiX1b);
+         x3bb =  x3m+this->inRadius*std::cos(phiX1b);
+         
+         if( this->isParallelToX1Axis() ) 
+         { 
+            triangles.push_back(new GbTriangle3D(new FePoint3D(x1b,x2a,x3a),new FePoint3D(x1b,x2b,x3b),new FePoint3D(x1a,x2a,x3a)));
+            triangles.push_back(new GbTriangle3D(new FePoint3D(x1a,x2b,x3b),new FePoint3D(x1a,x2a,x3a),new FePoint3D(x1b,x2b,x3b))); 
+            triangles.push_back(new GbTriangle3D(new FePoint3D(x1b,x2bb,x3bb),new FePoint3D(x1b,x2aa,x3aa),new FePoint3D(x1a,x2aa,x3aa)));
+            triangles.push_back(new GbTriangle3D(new FePoint3D(x1a,x2aa,x3aa),new FePoint3D(x1a,x2bb,x3bb),new FePoint3D(x1b,x2bb,x3bb))); 
+         }
+         else if( this->isParallelToX2Axis() ) 
+         { 
+            throw UbException(__FILE__,__LINE__," sollte man mal machen");
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2b,x1b,x3b),new FePoint3D(x2a,x1b,x3a),new FePoint3D(x2a,x1a,x3a)));
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1a,x3a),new FePoint3D(x2b,x1a,x3b),new FePoint3D(x2b,x1b,x3b))); 
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2bb,x1b,x3bb),new FePoint3D(x2aa,x1b,x3aa),new FePoint3D(x2aa,x1a,x3aa)));
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2aa,x1a,x3aa),new FePoint3D(x2bb,x1a,x3bb),new FePoint3D(x2bb,x1b,x3bb))); 
+         }
+         else if( this->isParallelToX3Axis() ) 
+         { 
+            throw UbException(__FILE__,__LINE__," sollte man mal machen");
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3b,x2b,x1b),new FePoint3D(x3a,x2a,x1b),new FePoint3D(x3a,x2a,x1a)));
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1a),new FePoint3D(x3b,x2b,x1a),new FePoint3D(x3b,x2b,x1b))); 
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3bb,x2bb,x1b),new FePoint3D(x3aa,x2aa,x1b),new FePoint3D(x3aa,x2aa,x1a)));
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3aa,x2aa,x1a),new FePoint3D(x3bb,x2bb,x1a),new FePoint3D(x3bb,x2bb,x1b))); 
+         }
+
+      }
+   }
+   
+   //int segmentsSide = (int)(this->outRadius/dXCylinder);
+
+   double radius0, radius1;
+   //for(int segCyl = 10; segCyl<segmentsSide; segCyl++)
+   //{
+      radius0 = inRadius;//segCyl*dXCylinder;
+      radius1 = outRadius;//radius0+dXCylinder;
+      //if(segCyl==segmentsSide-1) radius1=outRadius;
+
+      for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi)
+      {
+         phiX1b = phiX1a+deltaPhi;
+
+         x2a =  x2m+radius0*std::sin(phiX1a);
+         x3a =  x3m+radius0*std::cos(phiX1a);
+         x2b =  x2m+radius0*std::sin(phiX1b);
+         x3b =  x3m+radius0*std::cos(phiX1b);
+         x2c =  x2m+radius1*std::sin(phiX1b);
+         x3c =  x3m+radius1*std::cos(phiX1b);
+         x2d =  x2m+radius1*std::sin(phiX1a);
+         x3d =  x3m+radius1*std::cos(phiX1a);
+
+         if( this->isParallelToX1Axis() ) 
+         { 
+            triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2b,x3b),new FePoint3D(x1ma,x2a,x3a),new FePoint3D(x1ma,x2c,x3c)));
+            triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2d,x3d),new FePoint3D(x1ma,x2c,x3c),new FePoint3D(x1ma,x2a,x3a)));
+            triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2b,x3b),new FePoint3D(x1mb,x2c,x3c),new FePoint3D(x1mb,x2a,x3a)));
+            triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2d,x3d),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1mb,x2c,x3c)));
+         }                                                                   
+         else if( this->isParallelToX2Axis() ) 
+         { 
+            throw UbException(__FILE__,__LINE__," sollte man mal machen");
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1ma,x3a),new FePoint3D(x2b,x1ma,x3b),new FePoint3D(x2c,x1ma,x3c)));
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1ma,x3c),new FePoint3D(x2d,x1ma,x3d),new FePoint3D(x2a,x1ma,x3a)));
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1mb,x3c),new FePoint3D(x2b,x1mb,x3b),new FePoint3D(x2a,x1mb,x3a)));
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1mb,x3a),new FePoint3D(x2d,x1mb,x3d),new FePoint3D(x2c,x1mb,x3c)));
+         }
+         else if( this->isParallelToX3Axis() ) 
+         { 
+            throw UbException(__FILE__,__LINE__," sollte man mal machen");
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1ma),new FePoint3D(x3b,x2b,x1ma),new FePoint3D(x3c,x2c,x1ma)));
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1ma),new FePoint3D(x3d,x2d,x1ma),new FePoint3D(x3a,x2a,x1ma)));
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1mb),new FePoint3D(x3b,x2b,x1mb),new FePoint3D(x3a,x2a,x1mb)));
+            //triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1mb),new FePoint3D(x3d,x2d,x1mb),new FePoint3D(x3c,x2c,x1mb)));
+         }
+      }
+  // }
+
+   return triangles;
+}
+/*==========================================================*/
+void FeRing3D::objectChanged(UbObservable* changedObject)
+{
+   GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject);
+   if(!line || this->mLine!=line) return;
+
+   this->notifyObserversObjectChanged();
+}
+/*==========================================================*/
+void FeRing3D::objectWillBeDeleted(UbObservable* objectForDeletion)
+{
+   if(this->mLine)
+   {
+      UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine);
+      if(objectForDeletion == observedObj) { this->mLine = NULL; }
+   }
+}
+/*=======================================================*/
+void FeRing3D::scale(const double& sx1, const double& sx2, const double& sx3)
+{  
+   if( this->isParallelToX1Axis() )
+   {
+      if(!UbMath::equal(sx2,sx3)) throw UbException("FeRing3D::scale - || to x1 -> different scaling sx2 and sx3 not possible");
+      this->inRadius*=sx2;
+      this->outRadius*=sx2;
+   }
+   else if( this->isParallelToX2Axis() )
+   {
+      if(!UbMath::equal(sx1,sx3)) throw UbException("FeRing3D::scale - || to x2 -> different scaling sx1 and sx3 not possible");
+      this->inRadius*=sx1;
+      this->outRadius*=sx1;
+   }
+   else if( this->isParallelToX3Axis() )
+   {
+      if(!UbMath::equal(sx1,sx2)) throw UbException("FeRing3D::scale - || to x3 -> different scaling sx1 and sx2 not possible");
+      this->inRadius*=sx1;
+      this->outRadius*=sx1;
+   }
+   else throw UbException("FeRing3D::scale - unknown direction");
+
+   this->mLine->scale(sx1,sx2,sx3);
+   //notify observer wird automatisch aufgerufen
+}
+/*==========================================================*/
+void FeRing3D::write(UbFileOutput* out) 
+{                                      
+   out->writeString(this->getCreator()->getTypeID());
+   mLine->write(out);
+   out->writeDouble(inRadius);
+   out->writeDouble(outRadius);
+   out->writeInteger(ringType);
+}
+/*==========================================================*/
+void FeRing3D::read(UbFileInput* in) 
+{  
+   in->readString();                                    
+   mLine = new GbLine3D;
+   mLine->read(in);
+   inRadius  = in->readDouble();
+   outRadius = in->readDouble();
+   ringType  = in->readInteger();
+}
+/*==========================================================*/
+double FeRing3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3)
+{
+   throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented");
+}
+/*==========================================================*/
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/fem/FeRing3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FeRing3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/fem/FeRing3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/fem/FeRing3D.h
index e2d45f5339ff7028d03be9b97ad6cd45fc026a32..65e9a7ba4dedb63f4b4b6f0c75b5b3348827bfef 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/fem/FeRing3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FeRing3D.h
@@ -1,107 +1,107 @@
-//  _    ___      __              __________      _     __
-// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
-// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
-// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
-// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
-//
-#ifndef FERING3D_H
-#define FERING3D_H
-
-#include <vector>
-#include <cmath>
-
-#include <numerics/geometry3d/GbObject3D.h>
-#include <basics/utilities/UbObserver.h>
-
-class GbPoint3D;
-class GbLine3D;
-class GbTriangle3D;
-
-class GbObject3DCreator;
-
-class FeRing3D : public GbObject3D , public UbObserver 
-{
-public:
-   FeRing3D();
-	FeRing3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& inradius, const double& outradius);
-	FeRing3D(GbPoint3D* p1, GbPoint3D* p2, const double& inradius, const double& outradius);
-	FeRing3D(GbLine3D* line, const double& inradius, const double& outradius);
-	FeRing3D(FeRing3D* ring);
-	~FeRing3D();    
-
-	FeRing3D* clone() { return new FeRing3D(this); }
-	void finalize();
-
-	double     getInRadius() { return this->inRadius; };
-   double     getOutRadius() { return this->outRadius; };
-	GbLine3D*  getLine() {return mLine;}
-	GbPoint3D* getPoint1();
-	GbPoint3D* getPoint2();
-
-	void setInRadius(const double& radius);
-   void setOutRadius(const double& radius);
-	void setLine(GbLine3D* line);
-	void setPoint1(const double& x1, const double& x2, const double& x3);
-	void setPoint2(const double& x1, const double& x2, const double& x3);
-
-	bool isParallelToX1Axis() { return((this->ringType & X1PARALLEL        )    ==  X1PARALLEL        );}
-	bool isParallelToX2Axis() { return((this->ringType & X2PARALLEL        )    ==  X2PARALLEL        );}
-	bool isParallelToX3Axis() { return((this->ringType & X3PARALLEL        )    ==  X3PARALLEL        );}
-	bool isNotParallelToAxis(){ return((this->ringType & NOTPARALLELTOAXIS )    ==  NOTPARALLELTOAXIS );}
-
-	double getHeight(); 
-
-	void scale(const double& sx1, const double& sx2, const double& sx3);
-
-	double getX1Centroid();
-	double getX1Minimum() ;
-	double getX1Maximum() ;
-	double getX2Centroid();
-	double getX2Minimum() ;
-	double getX2Maximum() ;
-	double getX3Centroid();
-	double getX3Minimum() ;
-	double getX3Maximum() ;
-
-	bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); 
-	bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); 
-   bool isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-   bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
-
-	GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2);
-   
-   bool hasRaytracing() { return true; }
-   /*|r| must be 1! einheitsvector!!*/
-   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
-
-	std::vector<GbTriangle3D*> getSurfaceTriangleSet();
-   
-	std::string toString();
-	ObObjectCreator* getCreator();
-	void write(UbFileOutput* out);
-	void read(UbFileInput* in);
-
-	//virtuelle Methoden von UbObserver
-	void objectChanged(UbObservable* changedObject);
-	void objectWillBeDeleted(UbObservable* objectForDeletion);
-
-   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
-
-protected:
-	void initRingType();
-
-   GbLine3D* mLine;
-	double    inRadius;
-   double    outRadius;
-
-	int ringType;
-
-	//void berechneQuerschnittsWerte();
-   static const int NOTPARALLELTOAXIS  = (1<<0); //1
-   static const int X1PARALLEL         = (1<<1); //2
-   static const int X2PARALLEL         = (1<<2); //4
-   static const int X3PARALLEL         = (1<<3); //8
-};
-
-#endif   
+//  _    ___      __              __________      _     __
+// | |  / (_)____/ /___  ______ _/ / ____/ /_  __(_)___/ /____
+// | | / / / ___/ __/ / / / __ `/ / /_  / / / / / / __  / ___/
+// | |/ / / /  / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__  )
+// |___/_/_/   \__/\__,_/\__,_/_/_/   /_/\__,_/_/\__,_/____/
+//
+#ifndef FERING3D_H
+#define FERING3D_H
+
+#include <vector>
+#include <cmath>
+
+#include <numerics/geometry3d/GbObject3D.h>
+#include <basics/utilities/UbObserver.h>
+
+class GbPoint3D;
+class GbLine3D;
+class GbTriangle3D;
+
+class GbObject3DCreator;
+
+class FeRing3D : public GbObject3D , public UbObserver 
+{
+public:
+   FeRing3D();
+	FeRing3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& inradius, const double& outradius);
+	FeRing3D(GbPoint3D* p1, GbPoint3D* p2, const double& inradius, const double& outradius);
+	FeRing3D(GbLine3D* line, const double& inradius, const double& outradius);
+	FeRing3D(FeRing3D* ring);
+	~FeRing3D();    
+
+	FeRing3D* clone() { return new FeRing3D(this); }
+	void finalize();
+
+	double     getInRadius() { return this->inRadius; };
+   double     getOutRadius() { return this->outRadius; };
+	GbLine3D*  getLine() {return mLine;}
+	GbPoint3D* getPoint1();
+	GbPoint3D* getPoint2();
+
+	void setInRadius(const double& radius);
+   void setOutRadius(const double& radius);
+	void setLine(GbLine3D* line);
+	void setPoint1(const double& x1, const double& x2, const double& x3);
+	void setPoint2(const double& x1, const double& x2, const double& x3);
+
+	bool isParallelToX1Axis() { return((this->ringType & X1PARALLEL        )    ==  X1PARALLEL        );}
+	bool isParallelToX2Axis() { return((this->ringType & X2PARALLEL        )    ==  X2PARALLEL        );}
+	bool isParallelToX3Axis() { return((this->ringType & X3PARALLEL        )    ==  X3PARALLEL        );}
+	bool isNotParallelToAxis(){ return((this->ringType & NOTPARALLELTOAXIS )    ==  NOTPARALLELTOAXIS );}
+
+	double getHeight(); 
+
+	void scale(const double& sx1, const double& sx2, const double& sx3);
+
+	double getX1Centroid();
+	double getX1Minimum() ;
+	double getX1Maximum() ;
+	double getX2Centroid();
+	double getX2Minimum() ;
+	double getX2Maximum() ;
+	double getX3Centroid();
+	double getX3Minimum() ;
+	double getX3Maximum() ;
+
+	bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); 
+	bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); 
+   bool isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+   bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b);
+
+	GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2);
+   
+   bool hasRaytracing() { return true; }
+   /*|r| must be 1! einheitsvector!!*/
+   double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3);
+
+	std::vector<GbTriangle3D*> getSurfaceTriangleSet();
+   
+	std::string toString();
+	ObObjectCreator* getCreator();
+	void write(UbFileOutput* out);
+	void read(UbFileInput* in);
+
+	//virtuelle Methoden von UbObserver
+	void objectChanged(UbObservable* changedObject);
+	void objectWillBeDeleted(UbObservable* objectForDeletion);
+
+   using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier  isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere
+
+protected:
+	void initRingType();
+
+   GbLine3D* mLine;
+	double    inRadius;
+   double    outRadius;
+
+	int ringType;
+
+	//void berechneQuerschnittsWerte();
+   static const int NOTPARALLELTOAXIS  = (1<<0); //1
+   static const int X1PARALLEL         = (1<<1); //2
+   static const int X2PARALLEL         = (1<<2); //4
+   static const int X3PARALLEL         = (1<<3); //8
+};
+
+#endif   
diff --git a/source/ThirdParty/Library/numerics/geometry3d/fem/FeTriFaceMesh3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FeTriFaceMesh3D.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/fem/FeTriFaceMesh3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/fem/FeTriFaceMesh3D.cpp
index f5b0a7835f0459609c15b7fa6bba7713dc800c16..68838ccead2c3560f45af10fe87182e28384514b 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/fem/FeTriFaceMesh3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FeTriFaceMesh3D.cpp
@@ -1,256 +1,256 @@
-#include <numerics/geometry3d/fem/FeTriFaceMesh3D.h>
-
-#include <numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h>
-#include <numerics/geometry3d/GbTriangle3D.h>
-
-#include <basics/writer/WbWriterVtkXmlBinary.h>
-#include <basics/writer/WbWriterVtkXmlASCII.h>
-
-using namespace std;
-
-FeTriFaceMesh3D::FeTriFaceMesh3D():GbTriFaceMesh3D()
-{
-   this->attributes = new vector<VertexAttributes>;
-//   this->createVertexTriFaceMap();
-}
-/*====================================================*/
-FeTriFaceMesh3D::FeTriFaceMesh3D(std::string name, std::vector<Vertex>* nodes, std::vector<TriFace>* triangles):GbTriFaceMesh3D(name,nodes,triangles)
-{
-   this->attributes = new vector<VertexAttributes>;
-   this->attributes->resize(nodes->size());
-//   this->createVertexTriFaceMap();
-}
-/*======================================================================*/
-ObObjectCreator* FeTriFaceMesh3D::getCreator()
-{
-   return FeTriFaceMesh3DCreator::getInstance();
-}
-/*====================================================*/
-void FeTriFaceMesh3D::resizeAttributes()
-{
-   this->attributes->resize(nodes->size());
-}
-/*====================================================*/
-//void FeTriFaceMesh3D::createVertexTriFaceMap()
-//{
-//   vertexTriFaceMap.clear();
-//   vector<TriFace>& tris = *this->triangles;
-//   vector<Vertex>&  pts  = *this->nodes;
-//
-//   for(size_t t=0; t<tris.size(); t++)
-//   {
-//      TriFace& tri = tris[t];
-//      Vertex& vert1 = pts[tri.v1];
-//      Vertex& vert2 = pts[tri.v2];
-//      Vertex& vert3 = pts[tri.v3];
-//      vertexTriFaceMap.setVertexTriFaceRelation(&vert1,&tri);
-//      vertexTriFaceMap.setVertexTriFaceRelation(&vert2,&tri);
-//      vertexTriFaceMap.setVertexTriFaceRelation(&vert3,&tri);
-//   }
-//}
-/*====================================================*/
-FeTriFaceMesh3D* FeTriFaceMesh3D::createMeshByTriangles(std::string name, std::vector<GbTriangle3D*> *triangles)
-{
-   vector<GbTriFaceMesh3D::Vertex>    *nodes = new vector<GbTriFaceMesh3D::Vertex>;
-   vector<GbTriFaceMesh3D::TriFace>   *tris  = new vector<GbTriFaceMesh3D::TriFace>;
-   int nr=0;
-   for(int u=0;u<(int)triangles->size();u++)
-   {
-      if(UbMath::zero((*triangles)[u]->getArea())) continue;
-
-      GbPoint3D* p1 = (*triangles)[u]->getPoint1();
-      GbPoint3D* p2 = (*triangles)[u]->getPoint2();
-      GbPoint3D* p3 = (*triangles)[u]->getPoint3();
-      nodes->push_back(GbTriFaceMesh3D::Vertex((float)p1->getX1Coordinate(),(float)p1->getX2Coordinate(),(float)p1->getX3Coordinate()));
-      nodes->push_back(GbTriFaceMesh3D::Vertex((float)p2->getX1Coordinate(),(float)p2->getX2Coordinate(),(float)p2->getX3Coordinate()));
-      nodes->push_back(GbTriFaceMesh3D::Vertex((float)p3->getX1Coordinate(),(float)p3->getX2Coordinate(),(float)p3->getX3Coordinate()));
-      tris->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2));
-      nr+=3;
-   }
-   FeTriFaceMesh3D* triMesh = new FeTriFaceMesh3D(name, nodes, tris);
-   triMesh->deleteRedundantNodes();
-   triMesh->resizeAttributes();
-   return triMesh;
-}
-
-/*======================================================================*/
-UbTuple<string,string> FeTriFaceMesh3D::writeMesh(string filename, WbWriter* writer, bool writeNormals, std::vector< std::string >* datanames, std::vector< std::vector < double > >* nodedata)
-{
-   if(datanames || nodedata)
-   {
-      UBLOG(logWARNING,"FeTriFaceMesh3D::writeMesh - no support for extra datanames || nodedata");
-   }
-
-   UBLOG2(logDEBUG1,std::cout,"FeTriFaceMesh3D::writeMesh - start");
-
-   UbTuple<string,string> filenames;
-
-   if( dynamic_cast<WbWriterVtkXmlBinary*>(writer) || dynamic_cast<WbWriterVtkXmlASCII*>(writer))
-   {
-      vector< UbTupleFloat3 > triNodes( nodes->size() );
-      vector< UbTupleInt3   > tris( triangles->size() );
-
-      for(size_t i=0; i<nodes->size(); i++)
-         triNodes[i] = makeUbTuple( (*nodes)[i].x, (*nodes)[i].y, (*nodes)[i].z );
-
-      for(size_t i=0; i<triangles->size(); i++)
-         tris[i] = makeUbTuple( (*triangles)[i].v1, (*triangles)[i].v2, (*triangles)[i].v3 ) ;
-
-      vector<string> localDataNames;
-      localDataNames.push_back("Fx"      );		
-      localDataNames.push_back("Fy"      );		
-      localDataNames.push_back("Fz"      );		
-      localDataNames.push_back("sumFx"   );		
-      localDataNames.push_back("sumFy"   );		
-      localDataNames.push_back("sumFz"   );		
-      localDataNames.push_back("vx"      );		
-      localDataNames.push_back("vy"      );		
-      localDataNames.push_back("vz"      );		
-      localDataNames.push_back("S1"      );		
-      localDataNames.push_back("S2"      );		
-      localDataNames.push_back("S3"      );		
-      localDataNames.push_back("S4"      );		
-      localDataNames.push_back("S5"      );		
-      localDataNames.push_back("S6"      );		
-      localDataNames.push_back("Pressure");		
-
-      std::vector< std::vector < double > > localNodedata( localDataNames.size(), std::vector<double>( nodes->size() ) );
-      for(size_t n=0; n<nodes->size(); n++)
-      {
-         FeTriFaceMesh3D::VertexAttributes& attribut = (*this->attributes)[n];
-
-         localNodedata[ 0][n] = attribut.getFX();
-         localNodedata[ 1][n] = attribut.getFY();
-         localNodedata[ 2][n] = attribut.getFZ();
-         localNodedata[ 3][n] = attribut.getSumFX();
-         localNodedata[ 4][n] = attribut.getSumFY();
-         localNodedata[ 5][n] = attribut.getSumFZ();
-         localNodedata[ 6][n] = attribut.getVelocityX();
-         localNodedata[ 7][n] = attribut.getVelocityY();
-         localNodedata[ 8][n] = attribut.getVelocityZ();
-         localNodedata[ 9][n] = val<1>(attribut.getStresses());
-         localNodedata[10][n] = val<2>(attribut.getStresses());
-         localNodedata[11][n] = val<3>(attribut.getStresses());
-         localNodedata[12][n] = val<4>(attribut.getStresses());
-         localNodedata[13][n] = val<5>(attribut.getStresses());
-         localNodedata[14][n] = val<6>(attribut.getStresses());
-         localNodedata[15][n] = attribut.getPressure();
-      }
-      val<1>(filenames) = writer->writeTrianglesWithNodeData(filename,triNodes,tris,localDataNames,localNodedata);
-   }
-   else
-   {
-      string avsfilename = filename+writer->getFileExtension();
-      val<1>(filenames)=avsfilename;
-
-      ofstream out(avsfilename.c_str(),ios::out);
-      if(!out)
-      { 
-         out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
-         string path = UbSystem::getPathFromString(filename);
-         if(path.size()>0){UbSystem::makeDirectory(path);out.open(filename.c_str(),ios::out);}
-         if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden");
-      }
-
-      //cout<<"AvsASCII - writeLines to "<<avsfilename<<" ...";
-
-      int nofNodes = (int)nodes->size(); 
-      int nofTrian = (int)triangles->size(); 
-      int dataSize = 16;
-
-      out<<"# UCD-File created by WbWriterAvsASCII\n";
-      out<<nofNodes<<" "<<nofTrian<<" "<<dataSize<<" 0 0 "<<endl;
-
-      for(int i=0; i<nofNodes; i++)
-         out<<i+1<<" "<< (*nodes)[i].x<<" "<< (*nodes)[i].y<<" "<< (*nodes)[i].z<<" \n";
-
-      for(int i=0; i<nofTrian; i++)
-         out<<i+1<<" 2 tri "<<(*triangles)[i].v1+1<<" "<<(*triangles)[i].v2+1<<" "<<(*triangles)[i].v3+1<<" "<<endl;
-
-      out<<dataSize;	
-      for(int i=0;i<dataSize;i++) out<<" "<<1;
-      out<<endl;
-
-      out<<"Fx, no_unit"<<endl;		
-      out<<"Fy, no_unit"<<endl;		
-      out<<"Fz, no_unit"<<endl;		
-      out<<"sumFx, no_unit"<<endl;		
-      out<<"sumFy, no_unit"<<endl;		
-      out<<"sumFz, no_unit"<<endl;		
-      out<<"vx, no_unit"<<endl;		
-      out<<"vy, no_unit"<<endl;		
-      out<<"vz, no_unit"<<endl;		
-      out<<"S1, no_unit"<<endl;		
-      out<<"S2, no_unit"<<endl;		
-      out<<"S3, no_unit"<<endl;		
-      out<<"S4, no_unit"<<endl;		
-      out<<"S5, no_unit"<<endl;		
-      out<<"S6, no_unit"<<endl;		
-      out<<"Pressure, no_unit"<<endl;		
-
-      for(int n=0; n<nofNodes; n++)
-      {
-         FeTriFaceMesh3D::VertexAttributes& attribut = (*this->attributes)[n];
-
-         double Fx = attribut.getFX();
-         double Fy = attribut.getFY();
-         double Fz = attribut.getFZ();
-         double sumFx = attribut.getSumFX();
-         double sumFy = attribut.getSumFY();
-         double sumFz = attribut.getSumFZ();
-         double vx = attribut.getVelocityX();
-         double vy = attribut.getVelocityY();
-         double vz = attribut.getVelocityZ();
-         double p = attribut.getPressure();
-         UbTupleDouble6& stresses = attribut.getStresses();
-         out<<n+1<<" "<<Fx<<" "<<Fy<<" "<<Fz;
-         out<<" "<<sumFx<<" "<<sumFy<<" "<<sumFz;
-         out<<" "<<vx<<" "<<vy<<" "<<vz;
-         out<<" "<<val<1>(stresses)<<" "<<val<2>(stresses)<<" "<<val<3>(stresses);
-         out<<" "<<val<4>(stresses)<<" "<<val<5>(stresses)<<" "<<val<6>(stresses);
-         out<<" "<<p<<endl;
-      }
-      out.close();
-   }
-
-   if(writeNormals)
-   {
-      vector<UbTupleFloat3 > lineNodes(triangles->size()*2);
-      vector<UbTupleInt2 >   lines(triangles->size());
-      for(size_t i=0; i<triangles->size(); i++)
-      {
-         TriFace& triangle = (*triangles)[i];
-         lineNodes[i*2  ] = makeUbTuple( triangle.getX1Centroid(*nodes)
-                                        ,triangle.getX2Centroid(*nodes)
-                                        ,triangle.getX3Centroid(*nodes));
-         lineNodes[i*2+1] = makeUbTuple( (float)(triangle.getX1Centroid(*nodes)+triangle.nx)
-                                        ,(float)(triangle.getX2Centroid(*nodes)+triangle.ny)
-                                        ,(float)(triangle.getX3Centroid(*nodes)+triangle.nz));
-
-         lines[i] = makeUbTuple((int)i*2,(int)i*2+1);
-      }
-      val<2>(filenames) = writer->writeLines(filename+"_normals",lineNodes,lines);
-   }
-
-
-   if(writeNormals)
-   {
-      vector<UbTupleFloat3 > lineNodes(nodes->size()*2);
-      vector<UbTupleInt2 >   lines(nodes->size());
-      for(size_t i=0; i<nodes->size(); i++)
-      {
-   	    FeTriFaceMesh3D::VertexAttributes& attribut = (*this->attributes)[i];
-         lineNodes[i*2  ] = makeUbTuple((*nodes)[i].x, (*nodes)[i].y, (*nodes)[i].z );
-         lineNodes[i*2+1] = makeUbTuple((*nodes)[i].x+(float)attribut.getNormalX()
-                                       ,(*nodes)[i].y+(float)attribut.getNormalY()
-                                       ,(*nodes)[i].z+(float)attribut.getNormalZ());
-
-         lines[i] = makeUbTuple((int)i*2,(int)i*2+1);
-      }
-      writer->writeLines(filename+"_PointNormals",lineNodes,lines);
-   }
-
-   UBLOG2(logDEBUG1,std::cout,"FeTriFaceMesh3D::writeMesh - end");
-
-   return filenames;
-}
+#include <numerics/geometry3d/fem/FeTriFaceMesh3D.h>
+
+#include <numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h>
+#include <numerics/geometry3d/GbTriangle3D.h>
+
+#include <basics/writer/WbWriterVtkXmlBinary.h>
+#include <basics/writer/WbWriterVtkXmlASCII.h>
+
+using namespace std;
+
+FeTriFaceMesh3D::FeTriFaceMesh3D():GbTriFaceMesh3D()
+{
+   this->attributes = new vector<VertexAttributes>;
+//   this->createVertexTriFaceMap();
+}
+/*====================================================*/
+FeTriFaceMesh3D::FeTriFaceMesh3D(std::string name, std::vector<Vertex>* nodes, std::vector<TriFace>* triangles):GbTriFaceMesh3D(name,nodes,triangles)
+{
+   this->attributes = new vector<VertexAttributes>;
+   this->attributes->resize(nodes->size());
+//   this->createVertexTriFaceMap();
+}
+/*======================================================================*/
+ObObjectCreator* FeTriFaceMesh3D::getCreator()
+{
+   return FeTriFaceMesh3DCreator::getInstance();
+}
+/*====================================================*/
+void FeTriFaceMesh3D::resizeAttributes()
+{
+   this->attributes->resize(nodes->size());
+}
+/*====================================================*/
+//void FeTriFaceMesh3D::createVertexTriFaceMap()
+//{
+//   vertexTriFaceMap.clear();
+//   vector<TriFace>& tris = *this->triangles;
+//   vector<Vertex>&  pts  = *this->nodes;
+//
+//   for(size_t t=0; t<tris.size(); t++)
+//   {
+//      TriFace& tri = tris[t];
+//      Vertex& vert1 = pts[tri.v1];
+//      Vertex& vert2 = pts[tri.v2];
+//      Vertex& vert3 = pts[tri.v3];
+//      vertexTriFaceMap.setVertexTriFaceRelation(&vert1,&tri);
+//      vertexTriFaceMap.setVertexTriFaceRelation(&vert2,&tri);
+//      vertexTriFaceMap.setVertexTriFaceRelation(&vert3,&tri);
+//   }
+//}
+/*====================================================*/
+FeTriFaceMesh3D* FeTriFaceMesh3D::createMeshByTriangles(std::string name, std::vector<GbTriangle3D*> *triangles)
+{
+   vector<GbTriFaceMesh3D::Vertex>    *nodes = new vector<GbTriFaceMesh3D::Vertex>;
+   vector<GbTriFaceMesh3D::TriFace>   *tris  = new vector<GbTriFaceMesh3D::TriFace>;
+   int nr=0;
+   for(int u=0;u<(int)triangles->size();u++)
+   {
+      if(UbMath::zero((*triangles)[u]->getArea())) continue;
+
+      GbPoint3D* p1 = (*triangles)[u]->getPoint1();
+      GbPoint3D* p2 = (*triangles)[u]->getPoint2();
+      GbPoint3D* p3 = (*triangles)[u]->getPoint3();
+      nodes->push_back(GbTriFaceMesh3D::Vertex((float)p1->getX1Coordinate(),(float)p1->getX2Coordinate(),(float)p1->getX3Coordinate()));
+      nodes->push_back(GbTriFaceMesh3D::Vertex((float)p2->getX1Coordinate(),(float)p2->getX2Coordinate(),(float)p2->getX3Coordinate()));
+      nodes->push_back(GbTriFaceMesh3D::Vertex((float)p3->getX1Coordinate(),(float)p3->getX2Coordinate(),(float)p3->getX3Coordinate()));
+      tris->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2));
+      nr+=3;
+   }
+   FeTriFaceMesh3D* triMesh = new FeTriFaceMesh3D(name, nodes, tris);
+   triMesh->deleteRedundantNodes();
+   triMesh->resizeAttributes();
+   return triMesh;
+}
+
+/*======================================================================*/
+UbTuple<string,string> FeTriFaceMesh3D::writeMesh(string filename, WbWriter* writer, bool writeNormals, std::vector< std::string >* datanames, std::vector< std::vector < double > >* nodedata)
+{
+   if(datanames || nodedata)
+   {
+      UBLOG(logWARNING,"FeTriFaceMesh3D::writeMesh - no support for extra datanames || nodedata");
+   }
+
+   UBLOG2(logDEBUG1,std::cout,"FeTriFaceMesh3D::writeMesh - start");
+
+   UbTuple<string,string> filenames;
+
+   if( dynamic_cast<WbWriterVtkXmlBinary*>(writer) || dynamic_cast<WbWriterVtkXmlASCII*>(writer))
+   {
+      vector< UbTupleFloat3 > triNodes( nodes->size() );
+      vector< UbTupleInt3   > tris( triangles->size() );
+
+      for(size_t i=0; i<nodes->size(); i++)
+         triNodes[i] = makeUbTuple( (*nodes)[i].x, (*nodes)[i].y, (*nodes)[i].z );
+
+      for(size_t i=0; i<triangles->size(); i++)
+         tris[i] = makeUbTuple( (*triangles)[i].v1, (*triangles)[i].v2, (*triangles)[i].v3 ) ;
+
+      vector<string> localDataNames;
+      localDataNames.push_back("Fx"      );		
+      localDataNames.push_back("Fy"      );		
+      localDataNames.push_back("Fz"      );		
+      localDataNames.push_back("sumFx"   );		
+      localDataNames.push_back("sumFy"   );		
+      localDataNames.push_back("sumFz"   );		
+      localDataNames.push_back("vx"      );		
+      localDataNames.push_back("vy"      );		
+      localDataNames.push_back("vz"      );		
+      localDataNames.push_back("S1"      );		
+      localDataNames.push_back("S2"      );		
+      localDataNames.push_back("S3"      );		
+      localDataNames.push_back("S4"      );		
+      localDataNames.push_back("S5"      );		
+      localDataNames.push_back("S6"      );		
+      localDataNames.push_back("Pressure");		
+
+      std::vector< std::vector < double > > localNodedata( localDataNames.size(), std::vector<double>( nodes->size() ) );
+      for(size_t n=0; n<nodes->size(); n++)
+      {
+         FeTriFaceMesh3D::VertexAttributes& attribut = (*this->attributes)[n];
+
+         localNodedata[ 0][n] = attribut.getFX();
+         localNodedata[ 1][n] = attribut.getFY();
+         localNodedata[ 2][n] = attribut.getFZ();
+         localNodedata[ 3][n] = attribut.getSumFX();
+         localNodedata[ 4][n] = attribut.getSumFY();
+         localNodedata[ 5][n] = attribut.getSumFZ();
+         localNodedata[ 6][n] = attribut.getVelocityX();
+         localNodedata[ 7][n] = attribut.getVelocityY();
+         localNodedata[ 8][n] = attribut.getVelocityZ();
+         localNodedata[ 9][n] = val<1>(attribut.getStresses());
+         localNodedata[10][n] = val<2>(attribut.getStresses());
+         localNodedata[11][n] = val<3>(attribut.getStresses());
+         localNodedata[12][n] = val<4>(attribut.getStresses());
+         localNodedata[13][n] = val<5>(attribut.getStresses());
+         localNodedata[14][n] = val<6>(attribut.getStresses());
+         localNodedata[15][n] = attribut.getPressure();
+      }
+      val<1>(filenames) = writer->writeTrianglesWithNodeData(filename,triNodes,tris,localDataNames,localNodedata);
+   }
+   else
+   {
+      string avsfilename = filename+writer->getFileExtension();
+      val<1>(filenames)=avsfilename;
+
+      ofstream out(avsfilename.c_str(),ios::out);
+      if(!out)
+      { 
+         out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!!
+         string path = UbSystem::getPathFromString(filename);
+         if(path.size()>0){UbSystem::makeDirectory(path);out.open(filename.c_str(),ios::out);}
+         if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden");
+      }
+
+      //cout<<"AvsASCII - writeLines to "<<avsfilename<<" ...";
+
+      int nofNodes = (int)nodes->size(); 
+      int nofTrian = (int)triangles->size(); 
+      int dataSize = 16;
+
+      out<<"# UCD-File created by WbWriterAvsASCII\n";
+      out<<nofNodes<<" "<<nofTrian<<" "<<dataSize<<" 0 0 "<<endl;
+
+      for(int i=0; i<nofNodes; i++)
+         out<<i+1<<" "<< (*nodes)[i].x<<" "<< (*nodes)[i].y<<" "<< (*nodes)[i].z<<" \n";
+
+      for(int i=0; i<nofTrian; i++)
+         out<<i+1<<" 2 tri "<<(*triangles)[i].v1+1<<" "<<(*triangles)[i].v2+1<<" "<<(*triangles)[i].v3+1<<" "<<endl;
+
+      out<<dataSize;	
+      for(int i=0;i<dataSize;i++) out<<" "<<1;
+      out<<endl;
+
+      out<<"Fx, no_unit"<<endl;		
+      out<<"Fy, no_unit"<<endl;		
+      out<<"Fz, no_unit"<<endl;		
+      out<<"sumFx, no_unit"<<endl;		
+      out<<"sumFy, no_unit"<<endl;		
+      out<<"sumFz, no_unit"<<endl;		
+      out<<"vx, no_unit"<<endl;		
+      out<<"vy, no_unit"<<endl;		
+      out<<"vz, no_unit"<<endl;		
+      out<<"S1, no_unit"<<endl;		
+      out<<"S2, no_unit"<<endl;		
+      out<<"S3, no_unit"<<endl;		
+      out<<"S4, no_unit"<<endl;		
+      out<<"S5, no_unit"<<endl;		
+      out<<"S6, no_unit"<<endl;		
+      out<<"Pressure, no_unit"<<endl;		
+
+      for(int n=0; n<nofNodes; n++)
+      {
+         FeTriFaceMesh3D::VertexAttributes& attribut = (*this->attributes)[n];
+
+         double Fx = attribut.getFX();
+         double Fy = attribut.getFY();
+         double Fz = attribut.getFZ();
+         double sumFx = attribut.getSumFX();
+         double sumFy = attribut.getSumFY();
+         double sumFz = attribut.getSumFZ();
+         double vx = attribut.getVelocityX();
+         double vy = attribut.getVelocityY();
+         double vz = attribut.getVelocityZ();
+         double p = attribut.getPressure();
+         UbTupleDouble6& stresses = attribut.getStresses();
+         out<<n+1<<" "<<Fx<<" "<<Fy<<" "<<Fz;
+         out<<" "<<sumFx<<" "<<sumFy<<" "<<sumFz;
+         out<<" "<<vx<<" "<<vy<<" "<<vz;
+         out<<" "<<val<1>(stresses)<<" "<<val<2>(stresses)<<" "<<val<3>(stresses);
+         out<<" "<<val<4>(stresses)<<" "<<val<5>(stresses)<<" "<<val<6>(stresses);
+         out<<" "<<p<<endl;
+      }
+      out.close();
+   }
+
+   if(writeNormals)
+   {
+      vector<UbTupleFloat3 > lineNodes(triangles->size()*2);
+      vector<UbTupleInt2 >   lines(triangles->size());
+      for(size_t i=0; i<triangles->size(); i++)
+      {
+         TriFace& triangle = (*triangles)[i];
+         lineNodes[i*2  ] = makeUbTuple( triangle.getX1Centroid(*nodes)
+                                        ,triangle.getX2Centroid(*nodes)
+                                        ,triangle.getX3Centroid(*nodes));
+         lineNodes[i*2+1] = makeUbTuple( (float)(triangle.getX1Centroid(*nodes)+triangle.nx)
+                                        ,(float)(triangle.getX2Centroid(*nodes)+triangle.ny)
+                                        ,(float)(triangle.getX3Centroid(*nodes)+triangle.nz));
+
+         lines[i] = makeUbTuple((int)i*2,(int)i*2+1);
+      }
+      val<2>(filenames) = writer->writeLines(filename+"_normals",lineNodes,lines);
+   }
+
+
+   if(writeNormals)
+   {
+      vector<UbTupleFloat3 > lineNodes(nodes->size()*2);
+      vector<UbTupleInt2 >   lines(nodes->size());
+      for(size_t i=0; i<nodes->size(); i++)
+      {
+   	    FeTriFaceMesh3D::VertexAttributes& attribut = (*this->attributes)[i];
+         lineNodes[i*2  ] = makeUbTuple((*nodes)[i].x, (*nodes)[i].y, (*nodes)[i].z );
+         lineNodes[i*2+1] = makeUbTuple((*nodes)[i].x+(float)attribut.getNormalX()
+                                       ,(*nodes)[i].y+(float)attribut.getNormalY()
+                                       ,(*nodes)[i].z+(float)attribut.getNormalZ());
+
+         lines[i] = makeUbTuple((int)i*2,(int)i*2+1);
+      }
+      writer->writeLines(filename+"_PointNormals",lineNodes,lines);
+   }
+
+   UBLOG2(logDEBUG1,std::cout,"FeTriFaceMesh3D::writeMesh - end");
+
+   return filenames;
+}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/fem/FeTriFaceMesh3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FeTriFaceMesh3D.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/fem/FeTriFaceMesh3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/fem/FeTriFaceMesh3D.h
index ae05f674aaae03d1407b1ebe980f1a3455eebd00..924941867af336b5fcfa69e0ce2e7f0afc4df546 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/fem/FeTriFaceMesh3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/fem/FeTriFaceMesh3D.h
@@ -1,204 +1,204 @@
-#ifndef FETRIFACEMESH3D_H
-#define FETRIFACEMESH3D_H
-
-#include <sstream>
-#include <iostream>
-#include <vector>
-#include <map>
-
-#include "./../GbTriFaceMesh3D.h"
-
-#ifdef CAB_RCF
-#include <3rdParty/rcf/RcfSerializationIncludes.h>
-#endif //CAB_RCF
-
-/*=========================================================================*/
-/* FeTriFaceMesh3D                                                                  */
-/*                                                                         */
-/**
- * This Class provides the triangular meshes.
- * Note, that up to now no methods for checking consistency are included.
- * in this context this class describes facettes from an 3D-object !!!
-*/
-class FeTriFaceMesh3D : public GbTriFaceMesh3D
-{                             
-public:
-   class VertexAttributes
-   {
-   private:
-      double Fx;
-      double Fy;
-      double Fz;
-      double sumFx;
-      double sumFy;
-      double sumFz;
-      double velocityX;
-      double velocityY;
-      double velocityZ;
-      double normalX;
-      double normalY;
-      double normalZ;
-      UbTupleDouble6 stresses; 
-      double area;
-      double p; //pressure
-   public:
-      VertexAttributes()
-      {
-         this->init();
-      }
-      ~VertexAttributes() {}
-
-#ifdef CAB_RCF
-      template<class Archive>
-      void SF_SERIALIZE(Archive & ar)
-      {
-         ar & Fx; ar & Fy; ar & Fz;
-         ar & velocityX; ar & velocityY; ar & velocityZ;
-      }
-#endif //CAB_RCF
-
-      void init()
-      {
-         this->Fx         = 0.0;
-         this->Fy         = 0.0;
-         this->Fz         = 0.0;
-         this->sumFx      = 0.0;
-         this->sumFy      = 0.0;
-         this->sumFz      = 0.0;
-         val<1>(stresses) = 0.0;
-         val<2>(stresses) = 0.0;
-         val<3>(stresses) = 0.0;
-         val<4>(stresses) = 0.0;
-         val<5>(stresses) = 0.0;
-         val<6>(stresses) = 0.0;
-         this->area       = 0.0;
-         this->p = 0.0;
-         this->velocityX  = 0.0;
-         this->velocityY  = 0.0;
-         this->velocityZ  = 0.0;
-         this->normalX  = 0.0;
-         this->normalY  = 0.0;
-         this->normalZ  = 0.0;
-      }
-      double getVelocityX()         { return this->velocityX; }
-      double getVelocityY()         { return this->velocityY; }
-      double getVelocityZ()         { return this->velocityZ; }
-      void   setVelocityX(double x) { this->velocityX = x;    }
-      void   setVelocityY(double y) { this->velocityY = y;    }
-      void   setVelocityZ(double z) { this->velocityZ = z;    }
-
-      double getNormalX()         { return this->normalX; }
-      double getNormalY()         { return this->normalY; }
-      double getNormalZ()         { return this->normalZ; }
-      void   setNormalX(double x) { this->normalX = x;    }
-      void   setNormalY(double y) { this->normalY = y;    }
-      void   setNormalZ(double z) { this->normalZ = z;    }
-
-      double getFX()          { return this->Fx; }
-      double getFY()          { return this->Fy; }
-      double getFZ()          { return this->Fz; }
-      void   setFX(double FX) { this->Fx = FX;   }
-      void   setFY(double FY) { this->Fy = FY;   }
-      void   setFZ(double FZ) { this->Fz = FZ;   }
-      void   addFX(double FX) { this->Fx += FX;  }
-      void   addFY(double FY) { this->Fy += FY;  }
-      void   addFZ(double FZ) { this->Fz += FZ;  }
-
-      double getSumFX()          { return this->sumFx; }
-      double getSumFY()          { return this->sumFy; }
-      double getSumFZ()          { return this->sumFz; }
-      void   setSumFX(double FX) { this->sumFx = FX;   }
-      void   setSumFY(double FY) { this->sumFy = FY;   }
-      void   setSumFZ(double FZ) { this->sumFz = FZ;   }
-      void   addSumFX(double FX) { this->sumFx += FX;  }
-      void   addSumFY(double FY) { this->sumFy += FY;  }
-      void   addSumFZ(double FZ) { this->sumFz += FZ;  }
-
-      UbTupleDouble6& getStresses() { return this->stresses; }
-      
-      double getArea()            { return this->area;  }
-      void   setArea(double area) { this->area  = area; }
-      void   addArea(double area) { this->area += area; }
-
-      double getPressure()         { return this->p;  }
-      void   setPressure(double p) { this->p = p; }
-
-   };
-/*=========================================================================*/
-/*=========================================================================*/
-/*=========================================================================*/
-   //class VertexTriFaceMap : public std::multimap<Vertex*, TriFace*>
-   //{
-   //public:
-   //   VertexTriFaceMap()  {}
-   //   /*=========================================================================*/
-   //   void setVertexTriFaceRelation(Vertex* v, TriFace* tri)
-   //   {
-   //      this->insert(std::pair<Vertex*,TriFace*>(v,tri));
-   //   }
-   //   /*=========================================================================*/
-   //   int getNumberOfTriFaces(Vertex* v)
-   //   {  
-   //      return((int)this->count(v));
-   //   }
-   //   /*=========================================================================*/
-   //   std::vector<TriFace*> getTriFacesForVertex(Vertex* v)
-   //   {
-   //      std::vector<TriFace*> trivector;
-   //      unsigned number = (unsigned)this->count(v);
-   //      std::multimap<Vertex*,TriFace*>::iterator mapIterator = this->find(v);
-   //      for(unsigned u =0; u<number; u++) 
-   //      {
-   //         trivector.push_back(mapIterator->second);
-   //         mapIterator ++;
-   //      }
-   //      return trivector;
-   //   }
-   //   //void deleteNeighbors(QtInteractor* interactor);
-   //   ///*=========================================================================*/
-   //};
-/*=========================================================================*/
-/*=========================================================================*/
-/*=========================================================================*/
-public:
-   //#ifndef SWIG
-   //VertexTriFaceMap vertexTriFaceMap;
-   //#endif
-
-   FeTriFaceMesh3D();
-   FeTriFaceMesh3D(std::string name, std::vector<Vertex>* nodes, std::vector<TriFace>* triangles);
-
-   std::vector<VertexAttributes>* getAttributes() { return this->attributes; }
-   void resizeAttributes();
-   //void createVertexTriFaceMap();
-
-   UbTuple<std::string,std::string> writeMesh(std::string filename, WbWriter* writer, bool writeNormals=false, std::vector< std::string >* datanames=NULL, std::vector< std::vector < double > >* nodedata=NULL);
-
-   static FeTriFaceMesh3D* createMeshByTriangles(std::string name, std::vector<GbTriangle3D*>* triangles);
-
-   virtual ObObjectCreator* getCreator();
-
-#ifdef CAB_RCF
-   template<class Archive>
-   void SF_SERIALIZE(Archive & ar)
-   {
-      SF_SERIALIZE_PARENT<GbTriFaceMesh3D>(ar, *this);
-      ar & attributes;
-      //if( ArchiveTools::isReading(ar) ) this->createVertexTriFaceMap();
-   }
-#endif //CAB_RCF
-
-
-protected:
-   std::vector<VertexAttributes>* attributes;
-   
-};
-
-#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
-   UB_AUTO_RUN_NAMED(   SF::registerType<FeTriFaceMesh3D  >("FeTriFaceMesh3D  ")     , SF_FeTriFaceMesh3D     );
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbTriFaceMesh3D, FeTriFaceMesh3D >() ), SF_FeTriFaceMesh3D_BD1 );
-   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, FeTriFaceMesh3D >() ), SF_FeTriFaceMesh3D_BD2 );
-#endif //RCF_USE_SF_SERIALIZATION
-
-
-#endif //FETRIFACEMESH3D_H
+#ifndef FETRIFACEMESH3D_H
+#define FETRIFACEMESH3D_H
+
+#include <sstream>
+#include <iostream>
+#include <vector>
+#include <map>
+
+#include "./../GbTriFaceMesh3D.h"
+
+#ifdef CAB_RCF
+#include <3rdParty/rcf/RcfSerializationIncludes.h>
+#endif //CAB_RCF
+
+/*=========================================================================*/
+/* FeTriFaceMesh3D                                                                  */
+/*                                                                         */
+/**
+ * This Class provides the triangular meshes.
+ * Note, that up to now no methods for checking consistency are included.
+ * in this context this class describes facettes from an 3D-object !!!
+*/
+class FeTriFaceMesh3D : public GbTriFaceMesh3D
+{                             
+public:
+   class VertexAttributes
+   {
+   private:
+      double Fx;
+      double Fy;
+      double Fz;
+      double sumFx;
+      double sumFy;
+      double sumFz;
+      double velocityX;
+      double velocityY;
+      double velocityZ;
+      double normalX;
+      double normalY;
+      double normalZ;
+      UbTupleDouble6 stresses; 
+      double area;
+      double p; //pressure
+   public:
+      VertexAttributes()
+      {
+         this->init();
+      }
+      ~VertexAttributes() {}
+
+#ifdef CAB_RCF
+      template<class Archive>
+      void SF_SERIALIZE(Archive & ar)
+      {
+         ar & Fx; ar & Fy; ar & Fz;
+         ar & velocityX; ar & velocityY; ar & velocityZ;
+      }
+#endif //CAB_RCF
+
+      void init()
+      {
+         this->Fx         = 0.0;
+         this->Fy         = 0.0;
+         this->Fz         = 0.0;
+         this->sumFx      = 0.0;
+         this->sumFy      = 0.0;
+         this->sumFz      = 0.0;
+         val<1>(stresses) = 0.0;
+         val<2>(stresses) = 0.0;
+         val<3>(stresses) = 0.0;
+         val<4>(stresses) = 0.0;
+         val<5>(stresses) = 0.0;
+         val<6>(stresses) = 0.0;
+         this->area       = 0.0;
+         this->p = 0.0;
+         this->velocityX  = 0.0;
+         this->velocityY  = 0.0;
+         this->velocityZ  = 0.0;
+         this->normalX  = 0.0;
+         this->normalY  = 0.0;
+         this->normalZ  = 0.0;
+      }
+      double getVelocityX()         { return this->velocityX; }
+      double getVelocityY()         { return this->velocityY; }
+      double getVelocityZ()         { return this->velocityZ; }
+      void   setVelocityX(double x) { this->velocityX = x;    }
+      void   setVelocityY(double y) { this->velocityY = y;    }
+      void   setVelocityZ(double z) { this->velocityZ = z;    }
+
+      double getNormalX()         { return this->normalX; }
+      double getNormalY()         { return this->normalY; }
+      double getNormalZ()         { return this->normalZ; }
+      void   setNormalX(double x) { this->normalX = x;    }
+      void   setNormalY(double y) { this->normalY = y;    }
+      void   setNormalZ(double z) { this->normalZ = z;    }
+
+      double getFX()          { return this->Fx; }
+      double getFY()          { return this->Fy; }
+      double getFZ()          { return this->Fz; }
+      void   setFX(double FX) { this->Fx = FX;   }
+      void   setFY(double FY) { this->Fy = FY;   }
+      void   setFZ(double FZ) { this->Fz = FZ;   }
+      void   addFX(double FX) { this->Fx += FX;  }
+      void   addFY(double FY) { this->Fy += FY;  }
+      void   addFZ(double FZ) { this->Fz += FZ;  }
+
+      double getSumFX()          { return this->sumFx; }
+      double getSumFY()          { return this->sumFy; }
+      double getSumFZ()          { return this->sumFz; }
+      void   setSumFX(double FX) { this->sumFx = FX;   }
+      void   setSumFY(double FY) { this->sumFy = FY;   }
+      void   setSumFZ(double FZ) { this->sumFz = FZ;   }
+      void   addSumFX(double FX) { this->sumFx += FX;  }
+      void   addSumFY(double FY) { this->sumFy += FY;  }
+      void   addSumFZ(double FZ) { this->sumFz += FZ;  }
+
+      UbTupleDouble6& getStresses() { return this->stresses; }
+      
+      double getArea()            { return this->area;  }
+      void   setArea(double area) { this->area  = area; }
+      void   addArea(double area) { this->area += area; }
+
+      double getPressure()         { return this->p;  }
+      void   setPressure(double p) { this->p = p; }
+
+   };
+/*=========================================================================*/
+/*=========================================================================*/
+/*=========================================================================*/
+   //class VertexTriFaceMap : public std::multimap<Vertex*, TriFace*>
+   //{
+   //public:
+   //   VertexTriFaceMap()  {}
+   //   /*=========================================================================*/
+   //   void setVertexTriFaceRelation(Vertex* v, TriFace* tri)
+   //   {
+   //      this->insert(std::pair<Vertex*,TriFace*>(v,tri));
+   //   }
+   //   /*=========================================================================*/
+   //   int getNumberOfTriFaces(Vertex* v)
+   //   {  
+   //      return((int)this->count(v));
+   //   }
+   //   /*=========================================================================*/
+   //   std::vector<TriFace*> getTriFacesForVertex(Vertex* v)
+   //   {
+   //      std::vector<TriFace*> trivector;
+   //      unsigned number = (unsigned)this->count(v);
+   //      std::multimap<Vertex*,TriFace*>::iterator mapIterator = this->find(v);
+   //      for(unsigned u =0; u<number; u++) 
+   //      {
+   //         trivector.push_back(mapIterator->second);
+   //         mapIterator ++;
+   //      }
+   //      return trivector;
+   //   }
+   //   //void deleteNeighbors(QtInteractor* interactor);
+   //   ///*=========================================================================*/
+   //};
+/*=========================================================================*/
+/*=========================================================================*/
+/*=========================================================================*/
+public:
+   //#ifndef SWIG
+   //VertexTriFaceMap vertexTriFaceMap;
+   //#endif
+
+   FeTriFaceMesh3D();
+   FeTriFaceMesh3D(std::string name, std::vector<Vertex>* nodes, std::vector<TriFace>* triangles);
+
+   std::vector<VertexAttributes>* getAttributes() { return this->attributes; }
+   void resizeAttributes();
+   //void createVertexTriFaceMap();
+
+   UbTuple<std::string,std::string> writeMesh(std::string filename, WbWriter* writer, bool writeNormals=false, std::vector< std::string >* datanames=NULL, std::vector< std::vector < double > >* nodedata=NULL);
+
+   static FeTriFaceMesh3D* createMeshByTriangles(std::string name, std::vector<GbTriangle3D*>* triangles);
+
+   virtual ObObjectCreator* getCreator();
+
+#ifdef CAB_RCF
+   template<class Archive>
+   void SF_SERIALIZE(Archive & ar)
+   {
+      SF_SERIALIZE_PARENT<GbTriFaceMesh3D>(ar, *this);
+      ar & attributes;
+      //if( ArchiveTools::isReading(ar) ) this->createVertexTriFaceMap();
+   }
+#endif //CAB_RCF
+
+
+protected:
+   std::vector<VertexAttributes>* attributes;
+   
+};
+
+#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG)
+   UB_AUTO_RUN_NAMED(   SF::registerType<FeTriFaceMesh3D  >("FeTriFaceMesh3D  ")     , SF_FeTriFaceMesh3D     );
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbTriFaceMesh3D, FeTriFaceMesh3D >() ), SF_FeTriFaceMesh3D_BD1 );
+   UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, FeTriFaceMesh3D >() ), SF_FeTriFaceMesh3D_BD2 );
+#endif //RCF_USE_SF_SERIALIZATION
+
+
+#endif //FETRIFACEMESH3D_H
diff --git a/source/ThirdParty/Library/numerics/geometry3d/fem/creator/CMakePackage.txt b/source/VirtualFluidsBasic/numerics/geometry3d/fem/creator/CMakePackage.txt
similarity index 99%
rename from source/ThirdParty/Library/numerics/geometry3d/fem/creator/CMakePackage.txt
rename to source/VirtualFluidsBasic/numerics/geometry3d/fem/creator/CMakePackage.txt
index de1dc5a88225180b8e40c6cf46f4a6fbb102778f..e3e3f9a387b022a62ecc0d63c3ef0210313e906d 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/fem/creator/CMakePackage.txt
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/fem/creator/CMakePackage.txt
@@ -1,2 +1,2 @@
-GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
 COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
\ No newline at end of file
diff --git a/source/ThirdParty/Library/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp
index 4e47547ad966b0de03f5590c45995cca7e983eaf..58a6171c1bbc33013211255cc883e58c29b72fa7 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp
@@ -1,417 +1,417 @@
-#include <numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h>
-#include <basics/utilities/UbLogger.h>
-#include <basics/utilities/UbTiming.h>
-
-using namespace std;
-
-FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromFile(string filename, string meshName, bool removeRedundantNodes)
-{
-   if(meshName.empty())
-   {
-      size_t pos=filename.rfind("/");
-      if(pos!=string::npos) meshName = filename.substr(pos+1);
-      else                  meshName = filename;
-   }
-
-   UbFileInputASCII stlfile(filename);
-   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
-   string ext=stlfile.getFileExtension();
-
-   //in "kleinbuchstaben" umwandeln
-   transform(ext.begin(), ext.end(), ext.begin(), (int(*)(int))tolower); //(int(*)(int)) ist irgendso ein fieser cast, weil tolower ne alte c-methode ist
-
-   if     ( !ext.compare("ply") ) return FeTriFaceMesh3DCreator::readMeshFromPLYFile(filename, meshName, removeRedundantNodes);
-   else if( !ext.compare("stl") ) return FeTriFaceMesh3DCreator::readMeshFromSTLFile(filename, meshName, removeRedundantNodes);
-   else if( !ext.compare("inp") ) return FeTriFaceMesh3DCreator::readMeshFromAVSFile(filename, meshName, removeRedundantNodes);
-   //else if( !ext.compare("gts") ) return FeTriFaceMesh3DCreator::readMeshFromGTSFile(filename, meshName);
-   //else if( !ext.compare("raw") ) return FeTriFaceMesh3DCreator::readMeshFromRAWFile(filename, meshName);
-   else throw UbException(UB_EXARGS,"fileformat "+ext);
-
-   return NULL;
-}
-/*======================================================================*/
-FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromPLYFile(string filename, string meshName, bool removeRedundantNodes)
-{
-   UbFileInputASCII plyfile(filename);
-   if(!plyfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
-   return FeTriFaceMesh3DCreator::readMeshFromPLYFile(&plyfile,meshName);
-}
-/*======================================================================*/
-FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromPLYFile(UbFileInput* in, string meshName, bool removeRedundantNodes)
-{
-   //cout<<"GbTriangularMesh3DFile.readMeshFromPLYFile !!! Dieses Format hat leider redundante Knoten ..."<<endl;
-   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
-   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
-
-   float x, y, z;
-   string dummy;
-
-   int numVertices = in->readIntegerAfterString("element vertex");
-   int numFaces    = in->readIntegerAfterString("element face");
-   in->setPosAfterLineWithString("end_header");
-
-   UBLOG(logDEBUG1,"Number of vertices "<<numVertices);
-   UBLOG(logDEBUG1,"Number of faces    "<<numFaces);
-
-   nodes->resize(numVertices);
-   triangles->reserve(numFaces);
-
-   int onePercent = (int)UbMath::max(1,UbMath::integerRounding(numVertices*0.01));
-   for (int i=0; i<numVertices; i++)
-   {
-      if( i%onePercent==0 )
-         cout<<" - read vertices (#"<<numVertices<<") "<<UbMath::integerRounding(i/(double)numVertices*100.0)<<"% "<<"\r"<<flush;
-      x = in->readFloat();
-      y = in->readFloat();
-      z = in->readFloat();
-      in->readLine();
-      (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z);
-   }
-   UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done");
-
-   int p,j,k,l,n;
-   onePercent = (int)UbMath::max(1,UbMath::integerRounding(numFaces*0.01));
-   for(int i=0; i<numFaces; i++)
-   {
-      if( i%onePercent==0 ) cout<<" - read faces (#"<<numFaces<<") "<<UbMath::integerRounding(i/(double)numFaces*100.0)<<"% "<<"\r"<<flush;
-
-      p = in->readInteger();
-      if(p==3)  //Dreieck, alles andere wird stumpf ingnoriert
-      {
-         j = in->readInteger();
-         k = in->readInteger();
-         l = in->readInteger();
-
-         if(   !UbMath::inClosedInterval(j,0,numVertices-1) 
-            || !UbMath::inClosedInterval(k,0,numVertices-1) 
-            || !UbMath::inClosedInterval(l,0,numVertices-1) ) 
-         {         
-            throw UbException(UB_EXARGS,"dreiecksindex ist groesser als max Knotenindex oder kleiner 0");
-         }
-         triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l));
-      }
-      else if(p==4)  //Viereck --> wird zu zwei Dreiecken!
-      {
-         j = in->readInteger();
-         k = in->readInteger();
-         l = in->readInteger();
-         n = in->readInteger();
-         numFaces++;
-         i++;
-
-         if(   !UbMath::inClosedInterval(j,0,numVertices-1) 
-            || !UbMath::inClosedInterval(k,0,numVertices-1) 
-            || !UbMath::inClosedInterval(l,0,numVertices-1) 
-            || !UbMath::inClosedInterval(n,0,numVertices-1) 
-            ) 
-         {         
-            throw UbException(UB_EXARGS,"vierecksindex ist groesser als max Knotenindex oder kleiner 0");
-         }
-         triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l));
-         triangles->push_back(GbTriFaceMesh3D::TriFace(l,n,j));
-      }
-
-      in->readLine();
-
-   }
-   UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done");
-
-   FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles);
-   
-   if(removeRedundantNodes) mesh->deleteRedundantNodes();
-
-   mesh->resizeAttributes();
-   //mesh->createVertexTriFaceMap();
-   mesh->calculateValues();
-
-
-   return mesh;
-}
-/*======================================================================*/
-FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromSTLFile(string filename, string meshName, bool removeRedundantNodes)
-{
-   UbFileInputASCII stlfile(filename);
-   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
-   return FeTriFaceMesh3DCreator::readMeshFromSTLFile(&stlfile,meshName,removeRedundantNodes);
-}
-/*======================================================================*/
-FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromSTLFile(UbFileInput *in, string meshName, bool removeRedundantNodes)
-{
-   UBLOG(logINFO,"FeTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ...");
-
-   vector<FeTriFaceMesh3D::Vertex>    *nodes     = new vector<FeTriFaceMesh3D::Vertex>;
-   vector<FeTriFaceMesh3D::TriFace>   *triangles = new vector<FeTriFaceMesh3D::TriFace>;
-   string dummy;
-
-   double x, y, z;
-   int nr=0;
-
-   in->readLine();
-   while(dummy!="endsolid")
-   {
-      in->readLine();
-      in->readLine();
-      dummy = in->readString();
-      if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format");
-      x=in->readDouble();
-      y=in->readDouble();
-      z=in->readDouble();
-      nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-      in->readLine();
-      in->readString();
-      x=in->readDouble();
-      y=in->readDouble();
-      z=in->readDouble();
-      nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-      in->readLine();
-      in->readString();
-      x=in->readDouble();
-      y=in->readDouble();
-      z=in->readDouble();
-      nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-      triangles->push_back(FeTriFaceMesh3D::TriFace(nr,nr+1,nr+2));
-      in->readLine();
-      in->readLine();
-      in->readLine();
-      dummy = in->readString();
-      nr+=3;
-   }
-
-
-   FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles);
-   
-   if(removeRedundantNodes) mesh->deleteRedundantNodes();
-
-   mesh->resizeAttributes();
-//   mesh->createVertexTriFaceMap();
-   mesh->calculateValues();
-
-   
-   return mesh;
-}
-// /*======================================================================*/
-// FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromMeshFile(string filename, string meshName, bool removeRedundantNodes)
-// {
-//    public static void read(String file, ArrayList<Node3d> nodeList, ArrayList<TrianglePatch> patches) throws FileReaderException {
-// 
-//       UBLOG(logINFO,"FeTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ...");
-// 
-//    vector<FeTriFaceMesh3D::Vertex>    *nodes     = new vector<FeTriFaceMesh3D::Vertex>;
-//    vector<FeTriFaceMesh3D::TriFace>   *triangles = new vector<FeTriFaceMesh3D::TriFace>;
-//    string dummy;
-// 
-//    double x, y, z;
-//    int nr=0;
-// 
-//    in->readLine();
-//    while(dummy!="endsolid")
-//    {
-//       in->readLine();
-//       in->readLine();
-//       dummy = in->readString();
-//       if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format");
-//       x=in->readDouble();
-//       y=in->readDouble();
-//       z=in->readDouble();
-//       nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-//       in->readLine();
-//       in->readString();
-//       x=in->readDouble();
-//       y=in->readDouble();
-//       z=in->readDouble();
-//       nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-//       in->readLine();
-//       in->readString();
-//       x=in->readDouble();
-//       y=in->readDouble();
-//       z=in->readDouble();
-//       nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-//       triangles->push_back(FeTriFaceMesh3D::TriFace(nr,nr+1,nr+2));
-//       in->readLine();
-//       in->readLine();
-//       in->readLine();
-//       dummy = in->readString();
-//       nr+=3;
-//    }
-// 
-// 
-//    FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles);
-// 
-//    if(removeRedundantNodes) mesh->deleteRedundantNodes();
-// 
-//    return mesh;
-// 
-// 
-//    try {
-// 
-//       FileInput input = new FileInput(file);
-// 
-//       int line = 0;
-//       while(true)
-//       { 
-//          if(line>1000) break;            
-//          if(input.readLine().contains("Vertices")) 
-//             break;              
-//          line++;
-//       }
-// 
-//       int num_of_points = input.readInt();
-// 
-//       for (int i = 0; i < num_of_points; i++) {               
-//          float x = (float) input.readDouble();
-//          float y = (float) input.readDouble();
-//          float z = (float) input.readDouble();
-//          int nr = input.readInt();
-//          nodeList.add(new Node3d(x, y, z));
-//       }
-// 
-//       input.skipLine();
-//       input.skipLine();
-//       int num_of_triangles = input.readInt();
-// 
-//       for (int i = 0; i < num_of_triangles; i++) {
-// 
-//          int a = input.readInt();
-//          int b = input.readInt();
-//          int c = input.readInt();
-//          int nr = input.readInt();
-// 
-//          Node3d P1 = nodeList.get(a - 1);
-//          Node3d P2 = nodeList.get(b - 1);
-//          Node3d P3 = nodeList.get(c - 1);
-// 
-//          patches.add(new TrianglePatch(P1, P2, P3));
-//       }
-// 
-//       // END reading mesh file
-//    }
-// 
-//    -- 
-// 
-//       Dipl.-Ing. Sebastian Bindick
-// 
-//       Institute for Computational Modeling in Civil Engineering (iRMB) Technische Universität Braunschweig Pockelsstr. 3 (9th Floor) D-38106, Braunschweig, Germany
-// 
-//       phone +49 531/391-7598
-//       fax   +49 531/391-7599
-//       email    bindick@irmb.tu-bs.de
-//       web  www.irmb.tu-bs.de
-// 
-// 
-/*======================================================================*/
-FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromAVSFile(string filename, string meshName, bool removeRedundantNodes)
-{
-   UbFileInputASCII stlfile(filename);
-   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
-   return FeTriFaceMesh3DCreator::readMeshFromAVSFile(&stlfile,meshName,removeRedundantNodes);
-}
-/*======================================================================*/
-FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromAVSFile(UbFileInput *in, string meshName, bool removeRedundantNodes)
-{
-   UBLOG(logINFO,"FeTriFaceMesh3DCreator.readMeshFromAVSFile !!! Dieses Format hat leider redundante Knoten ...");
-
-   vector<FeTriFaceMesh3D::Vertex>    *nodes     = new vector<FeTriFaceMesh3D::Vertex>;
-   vector<FeTriFaceMesh3D::TriFace>   *triangles = new vector<FeTriFaceMesh3D::TriFace>;
-   string dummy;
-
-   in->readLine();
-   int numberNodes = in->readInteger();
-   int numberTris  = in->readInteger();
-   in->readLine();
-
-   double x,y,z;
-   for(int u=0;u<numberNodes;u++)
-   {
-      in->readInteger();
-      x=in->readDouble();
-      y=in->readDouble();
-      z=in->readDouble();
-      in->readLine();
-      nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-   }
-   int id1,id2,id3;
-   for(int u=0;u<numberTris;u++)
-   {
-      in->readInteger();
-      in->readInteger();
-      in->readString();
-      id1 = in->readInteger();
-      id2 = in->readInteger();
-      id3 = in->readInteger();
-      triangles->push_back(FeTriFaceMesh3D::TriFace(id1-1,id2-1,id3-1));
-   }
-
-   FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles);
-   
-   if(removeRedundantNodes) mesh->deleteRedundantNodes();
-
-   mesh->resizeAttributes();
-//   mesh->createVertexTriFaceMap();
-   mesh->calculateValues();
-
-
-   return mesh;
-}
-/*======================================================================*/
-FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
-{
-   UbFileInputASCII stlfile(filename);
-   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
-   return FeTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(&stlfile,meshName,splitAlg,removeRedundantNodes);
-}
-/*======================================================================*/
-FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
-{
-   UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromVTKASCIIFile !!! Dieses Format hat leider redundante Knoten ...");
-
-   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
-   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
-   string dummy;
-
-   in->readLine();
-   in->readLine();
-   in->readLine();
-   in->readLine();
-
-   in->readString();
-   int numberNodes = in->readInteger();
-   in->readLine();
-
-   double x,y,z;
-   for(int u=0;u<numberNodes;u++)
-   {
-      x=in->readDouble();
-      y=in->readDouble();
-      z=in->readDouble();
-      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
-   }
-   in->readLine();
-   in->readString();
-   int numberTris  = in->readInteger();
-   in->readLine();
-   UBLOG(logDEBUG1,"numberTris:"<<numberTris);
-
-   int id1,id2,id3;
-   for(int u=0;u<numberTris;u++)
-   {
-      in->readInteger();
-      id1 = in->readInteger();
-      id2 = in->readInteger();
-      id3 = in->readInteger();
-      triangles->push_back(GbTriFaceMesh3D::TriFace(id1,id2,id3));
-      //cout<<u<<" - id1,id2,id3:"<<id1<<","<<id2<<","<<id3<<endl;
-   }
-   UBLOG(logDEBUG1,"Tris gelesen");
-
-   FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles);
-
-   if(removeRedundantNodes) mesh->deleteRedundantNodes();
-   
-   mesh->resizeAttributes();
-//   mesh->createVertexTriFaceMap();
-   mesh->calculateValues();
-
-   UBLOG(logDEBUG1,"mesh erzeugt (with remove redundant nodes = "<< boolalpha <<removeRedundantNodes<<")");
-
-   return mesh;
-}
+#include <numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h>
+#include <basics/utilities/UbLogger.h>
+#include <basics/utilities/UbTiming.h>
+
+using namespace std;
+
+FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromFile(string filename, string meshName, bool removeRedundantNodes)
+{
+   if(meshName.empty())
+   {
+      size_t pos=filename.rfind("/");
+      if(pos!=string::npos) meshName = filename.substr(pos+1);
+      else                  meshName = filename;
+   }
+
+   UbFileInputASCII stlfile(filename);
+   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
+   string ext=stlfile.getFileExtension();
+
+   //in "kleinbuchstaben" umwandeln
+   transform(ext.begin(), ext.end(), ext.begin(), (int(*)(int))tolower); //(int(*)(int)) ist irgendso ein fieser cast, weil tolower ne alte c-methode ist
+
+   if     ( !ext.compare("ply") ) return FeTriFaceMesh3DCreator::readMeshFromPLYFile(filename, meshName, removeRedundantNodes);
+   else if( !ext.compare("stl") ) return FeTriFaceMesh3DCreator::readMeshFromSTLFile(filename, meshName, removeRedundantNodes);
+   else if( !ext.compare("inp") ) return FeTriFaceMesh3DCreator::readMeshFromAVSFile(filename, meshName, removeRedundantNodes);
+   //else if( !ext.compare("gts") ) return FeTriFaceMesh3DCreator::readMeshFromGTSFile(filename, meshName);
+   //else if( !ext.compare("raw") ) return FeTriFaceMesh3DCreator::readMeshFromRAWFile(filename, meshName);
+   else throw UbException(UB_EXARGS,"fileformat "+ext);
+
+   return NULL;
+}
+/*======================================================================*/
+FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromPLYFile(string filename, string meshName, bool removeRedundantNodes)
+{
+   UbFileInputASCII plyfile(filename);
+   if(!plyfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
+   return FeTriFaceMesh3DCreator::readMeshFromPLYFile(&plyfile,meshName);
+}
+/*======================================================================*/
+FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromPLYFile(UbFileInput* in, string meshName, bool removeRedundantNodes)
+{
+   //cout<<"GbTriangularMesh3DFile.readMeshFromPLYFile !!! Dieses Format hat leider redundante Knoten ..."<<endl;
+   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
+   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
+
+   float x, y, z;
+   string dummy;
+
+   int numVertices = in->readIntegerAfterString("element vertex");
+   int numFaces    = in->readIntegerAfterString("element face");
+   in->setPosAfterLineWithString("end_header");
+
+   UBLOG(logDEBUG1,"Number of vertices "<<numVertices);
+   UBLOG(logDEBUG1,"Number of faces    "<<numFaces);
+
+   nodes->resize(numVertices);
+   triangles->reserve(numFaces);
+
+   int onePercent = (int)UbMath::max(1,UbMath::integerRounding(numVertices*0.01));
+   for (int i=0; i<numVertices; i++)
+   {
+      if( i%onePercent==0 )
+         cout<<" - read vertices (#"<<numVertices<<") "<<UbMath::integerRounding(i/(double)numVertices*100.0)<<"% "<<"\r"<<flush;
+      x = in->readFloat();
+      y = in->readFloat();
+      z = in->readFloat();
+      in->readLine();
+      (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z);
+   }
+   UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done");
+
+   int p,j,k,l,n;
+   onePercent = (int)UbMath::max(1,UbMath::integerRounding(numFaces*0.01));
+   for(int i=0; i<numFaces; i++)
+   {
+      if( i%onePercent==0 ) cout<<" - read faces (#"<<numFaces<<") "<<UbMath::integerRounding(i/(double)numFaces*100.0)<<"% "<<"\r"<<flush;
+
+      p = in->readInteger();
+      if(p==3)  //Dreieck, alles andere wird stumpf ingnoriert
+      {
+         j = in->readInteger();
+         k = in->readInteger();
+         l = in->readInteger();
+
+         if(   !UbMath::inClosedInterval(j,0,numVertices-1) 
+            || !UbMath::inClosedInterval(k,0,numVertices-1) 
+            || !UbMath::inClosedInterval(l,0,numVertices-1) ) 
+         {         
+            throw UbException(UB_EXARGS,"dreiecksindex ist groesser als max Knotenindex oder kleiner 0");
+         }
+         triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l));
+      }
+      else if(p==4)  //Viereck --> wird zu zwei Dreiecken!
+      {
+         j = in->readInteger();
+         k = in->readInteger();
+         l = in->readInteger();
+         n = in->readInteger();
+         numFaces++;
+         i++;
+
+         if(   !UbMath::inClosedInterval(j,0,numVertices-1) 
+            || !UbMath::inClosedInterval(k,0,numVertices-1) 
+            || !UbMath::inClosedInterval(l,0,numVertices-1) 
+            || !UbMath::inClosedInterval(n,0,numVertices-1) 
+            ) 
+         {         
+            throw UbException(UB_EXARGS,"vierecksindex ist groesser als max Knotenindex oder kleiner 0");
+         }
+         triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l));
+         triangles->push_back(GbTriFaceMesh3D::TriFace(l,n,j));
+      }
+
+      in->readLine();
+
+   }
+   UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done");
+
+   FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles);
+   
+   if(removeRedundantNodes) mesh->deleteRedundantNodes();
+
+   mesh->resizeAttributes();
+   //mesh->createVertexTriFaceMap();
+   mesh->calculateValues();
+
+
+   return mesh;
+}
+/*======================================================================*/
+FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromSTLFile(string filename, string meshName, bool removeRedundantNodes)
+{
+   UbFileInputASCII stlfile(filename);
+   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
+   return FeTriFaceMesh3DCreator::readMeshFromSTLFile(&stlfile,meshName,removeRedundantNodes);
+}
+/*======================================================================*/
+FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromSTLFile(UbFileInput *in, string meshName, bool removeRedundantNodes)
+{
+   UBLOG(logINFO,"FeTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ...");
+
+   vector<FeTriFaceMesh3D::Vertex>    *nodes     = new vector<FeTriFaceMesh3D::Vertex>;
+   vector<FeTriFaceMesh3D::TriFace>   *triangles = new vector<FeTriFaceMesh3D::TriFace>;
+   string dummy;
+
+   double x, y, z;
+   int nr=0;
+
+   in->readLine();
+   while(dummy!="endsolid")
+   {
+      in->readLine();
+      in->readLine();
+      dummy = in->readString();
+      if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format");
+      x=in->readDouble();
+      y=in->readDouble();
+      z=in->readDouble();
+      nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+      in->readLine();
+      in->readString();
+      x=in->readDouble();
+      y=in->readDouble();
+      z=in->readDouble();
+      nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+      in->readLine();
+      in->readString();
+      x=in->readDouble();
+      y=in->readDouble();
+      z=in->readDouble();
+      nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+      triangles->push_back(FeTriFaceMesh3D::TriFace(nr,nr+1,nr+2));
+      in->readLine();
+      in->readLine();
+      in->readLine();
+      dummy = in->readString();
+      nr+=3;
+   }
+
+
+   FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles);
+   
+   if(removeRedundantNodes) mesh->deleteRedundantNodes();
+
+   mesh->resizeAttributes();
+//   mesh->createVertexTriFaceMap();
+   mesh->calculateValues();
+
+   
+   return mesh;
+}
+// /*======================================================================*/
+// FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromMeshFile(string filename, string meshName, bool removeRedundantNodes)
+// {
+//    public static void read(String file, ArrayList<Node3d> nodeList, ArrayList<TrianglePatch> patches) throws FileReaderException {
+// 
+//       UBLOG(logINFO,"FeTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ...");
+// 
+//    vector<FeTriFaceMesh3D::Vertex>    *nodes     = new vector<FeTriFaceMesh3D::Vertex>;
+//    vector<FeTriFaceMesh3D::TriFace>   *triangles = new vector<FeTriFaceMesh3D::TriFace>;
+//    string dummy;
+// 
+//    double x, y, z;
+//    int nr=0;
+// 
+//    in->readLine();
+//    while(dummy!="endsolid")
+//    {
+//       in->readLine();
+//       in->readLine();
+//       dummy = in->readString();
+//       if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format");
+//       x=in->readDouble();
+//       y=in->readDouble();
+//       z=in->readDouble();
+//       nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+//       in->readLine();
+//       in->readString();
+//       x=in->readDouble();
+//       y=in->readDouble();
+//       z=in->readDouble();
+//       nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+//       in->readLine();
+//       in->readString();
+//       x=in->readDouble();
+//       y=in->readDouble();
+//       z=in->readDouble();
+//       nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+//       triangles->push_back(FeTriFaceMesh3D::TriFace(nr,nr+1,nr+2));
+//       in->readLine();
+//       in->readLine();
+//       in->readLine();
+//       dummy = in->readString();
+//       nr+=3;
+//    }
+// 
+// 
+//    FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles);
+// 
+//    if(removeRedundantNodes) mesh->deleteRedundantNodes();
+// 
+//    return mesh;
+// 
+// 
+//    try {
+// 
+//       FileInput input = new FileInput(file);
+// 
+//       int line = 0;
+//       while(true)
+//       { 
+//          if(line>1000) break;            
+//          if(input.readLine().contains("Vertices")) 
+//             break;              
+//          line++;
+//       }
+// 
+//       int num_of_points = input.readInt();
+// 
+//       for (int i = 0; i < num_of_points; i++) {               
+//          float x = (float) input.readDouble();
+//          float y = (float) input.readDouble();
+//          float z = (float) input.readDouble();
+//          int nr = input.readInt();
+//          nodeList.add(new Node3d(x, y, z));
+//       }
+// 
+//       input.skipLine();
+//       input.skipLine();
+//       int num_of_triangles = input.readInt();
+// 
+//       for (int i = 0; i < num_of_triangles; i++) {
+// 
+//          int a = input.readInt();
+//          int b = input.readInt();
+//          int c = input.readInt();
+//          int nr = input.readInt();
+// 
+//          Node3d P1 = nodeList.get(a - 1);
+//          Node3d P2 = nodeList.get(b - 1);
+//          Node3d P3 = nodeList.get(c - 1);
+// 
+//          patches.add(new TrianglePatch(P1, P2, P3));
+//       }
+// 
+//       // END reading mesh file
+//    }
+// 
+//    -- 
+// 
+//       Dipl.-Ing. Sebastian Bindick
+// 
+//       Institute for Computational Modeling in Civil Engineering (iRMB) Technische Universität Braunschweig Pockelsstr. 3 (9th Floor) D-38106, Braunschweig, Germany
+// 
+//       phone +49 531/391-7598
+//       fax   +49 531/391-7599
+//       email    bindick@irmb.tu-bs.de
+//       web  www.irmb.tu-bs.de
+// 
+// 
+/*======================================================================*/
+FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromAVSFile(string filename, string meshName, bool removeRedundantNodes)
+{
+   UbFileInputASCII stlfile(filename);
+   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
+   return FeTriFaceMesh3DCreator::readMeshFromAVSFile(&stlfile,meshName,removeRedundantNodes);
+}
+/*======================================================================*/
+FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromAVSFile(UbFileInput *in, string meshName, bool removeRedundantNodes)
+{
+   UBLOG(logINFO,"FeTriFaceMesh3DCreator.readMeshFromAVSFile !!! Dieses Format hat leider redundante Knoten ...");
+
+   vector<FeTriFaceMesh3D::Vertex>    *nodes     = new vector<FeTriFaceMesh3D::Vertex>;
+   vector<FeTriFaceMesh3D::TriFace>   *triangles = new vector<FeTriFaceMesh3D::TriFace>;
+   string dummy;
+
+   in->readLine();
+   int numberNodes = in->readInteger();
+   int numberTris  = in->readInteger();
+   in->readLine();
+
+   double x,y,z;
+   for(int u=0;u<numberNodes;u++)
+   {
+      in->readInteger();
+      x=in->readDouble();
+      y=in->readDouble();
+      z=in->readDouble();
+      in->readLine();
+      nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+   }
+   int id1,id2,id3;
+   for(int u=0;u<numberTris;u++)
+   {
+      in->readInteger();
+      in->readInteger();
+      in->readString();
+      id1 = in->readInteger();
+      id2 = in->readInteger();
+      id3 = in->readInteger();
+      triangles->push_back(FeTriFaceMesh3D::TriFace(id1-1,id2-1,id3-1));
+   }
+
+   FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles);
+   
+   if(removeRedundantNodes) mesh->deleteRedundantNodes();
+
+   mesh->resizeAttributes();
+//   mesh->createVertexTriFaceMap();
+   mesh->calculateValues();
+
+
+   return mesh;
+}
+/*======================================================================*/
+FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
+{
+   UbFileInputASCII stlfile(filename);
+   if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename);
+   return FeTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(&stlfile,meshName,splitAlg,removeRedundantNodes);
+}
+/*======================================================================*/
+FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes)
+{
+   UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromVTKASCIIFile !!! Dieses Format hat leider redundante Knoten ...");
+
+   vector<GbTriFaceMesh3D::Vertex>    *nodes     = new vector<GbTriFaceMesh3D::Vertex>;
+   vector<GbTriFaceMesh3D::TriFace>   *triangles = new vector<GbTriFaceMesh3D::TriFace>;
+   string dummy;
+
+   in->readLine();
+   in->readLine();
+   in->readLine();
+   in->readLine();
+
+   in->readString();
+   int numberNodes = in->readInteger();
+   in->readLine();
+
+   double x,y,z;
+   for(int u=0;u<numberNodes;u++)
+   {
+      x=in->readDouble();
+      y=in->readDouble();
+      z=in->readDouble();
+      nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z));
+   }
+   in->readLine();
+   in->readString();
+   int numberTris  = in->readInteger();
+   in->readLine();
+   UBLOG(logDEBUG1,"numberTris:"<<numberTris);
+
+   int id1,id2,id3;
+   for(int u=0;u<numberTris;u++)
+   {
+      in->readInteger();
+      id1 = in->readInteger();
+      id2 = in->readInteger();
+      id3 = in->readInteger();
+      triangles->push_back(GbTriFaceMesh3D::TriFace(id1,id2,id3));
+      //cout<<u<<" - id1,id2,id3:"<<id1<<","<<id2<<","<<id3<<endl;
+   }
+   UBLOG(logDEBUG1,"Tris gelesen");
+
+   FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles);
+
+   if(removeRedundantNodes) mesh->deleteRedundantNodes();
+   
+   mesh->resizeAttributes();
+//   mesh->createVertexTriFaceMap();
+   mesh->calculateValues();
+
+   UBLOG(logDEBUG1,"mesh erzeugt (with remove redundant nodes = "<< boolalpha <<removeRedundantNodes<<")");
+
+   return mesh;
+}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h b/source/VirtualFluidsBasic/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h
index 43f25b99e1c08e188242e260bead0898896bb1e8..a7e25ea1984fa557ab304ab60a81afeb958937db 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h
@@ -1,82 +1,82 @@
-#ifndef FETRIFACEMESH3DCREATOR_H
-#define FETRIFACEMESH3DCREATOR_H
-
-#include <numerics/geometry3d/creator/GbObject3DCreator.h>
-#include <numerics/geometry3d/fem/FeTriFaceMesh3D.h>
-#include <basics/utilities/UbFileInputASCII.h>
-
-#ifdef CAB_QT 
-#include <qfiledialog.h>    
-#endif
-
-#ifdef CAB_VTK
-//#include <numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h>
-#endif
-
-class FeTriFaceMesh3DCreator : public GbObject3DCreator              
-{                                       
-public:
-   static FeTriFaceMesh3DCreator* getInstance()
-   {
-      static FeTriFaceMesh3DCreator instance;
-      return &instance;
-   }
-   static FeTriFaceMesh3D* readMeshFromFile(std::string filename, std::string meshName, bool removeRedundantNodes=true);
-
-   static FeTriFaceMesh3D* readMeshFromPLYFile(std::string filename, std::string meshName, bool removeRedundantNodes=true);
-   static FeTriFaceMesh3D* readMeshFromPLYFile(UbFileInput* in, std::string meshName, bool removeRedundantNodes=true);
-
-   static FeTriFaceMesh3D* readMeshFromSTLFile(std::string filename, std::string meshName, bool removeRedundantNodes=true); 
-   static FeTriFaceMesh3D* readMeshFromSTLFile(UbFileInput* in, std::string meshName, bool removeRedundantNodes=true);
-
-   static FeTriFaceMesh3D* readMeshFromAVSFile(std::string filename, std::string meshName, bool removeRedundantNodes=true); 
-   static FeTriFaceMesh3D* readMeshFromAVSFile(UbFileInput* in, std::string meshName, bool removeRedundantNodes=true);
-
-   static FeTriFaceMesh3D* readMeshFromVTKASCIIFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); 
-   static FeTriFaceMesh3D* readMeshFromVTKASCIIFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
-
-
-   FeTriFaceMesh3D* createGbObject3D() { return new FeTriFaceMesh3D(); }
-   
-   std::string getGbObject3DTypeID(){ return "FeTriFaceMesh3D"; };
-   std::string toString()           { return "FeTriFaceMesh3DCreator"; }
-
-#ifdef CAB_QT 
-
-
-   FeTriFaceMesh3D* createGbObject3DwithQt()
-   {
-	   //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" );
-	   QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl");
-      //QFileDialog* fd = new QFileDialog( NULL );
-      //fd->setIconText(QString("Hallo"));
-      //fd->show();
-      //TODO: Open File Dialog einbauen.		
-      UbFileInputASCII in( s.toAscii().data() );
-      stringstream stream;
-      stream <<"TriangularMesh3D ";//<<_objCount++;
-      FeTriFaceMesh3D *mesh = NULL;//FeTriFaceMesh3DCreator::readMeshFromSTLFile(&in, stream.str() );
-      return mesh;
-   }
-   //QDialog* getSpecificInstrument()  {  return 0;}
-   void editGbObject3DwithQt(GbObject3D* gbObj)
-   { 
-   }
-#endif
-#ifdef CAB_VTK
-public:
-   Presentator* createObjectPresentator(ObObject *object) { return new vtkGbTriangularMesh3D((GbTriangularMesh3D*)object); }
-#endif
-
-
-private:
-   FeTriFaceMesh3DCreator( const FeTriFaceMesh3DCreator& );                  //no copy allowed 
-   const FeTriFaceMesh3DCreator& operator=( const FeTriFaceMesh3DCreator& ); //no copy allowed
-   FeTriFaceMesh3DCreator() : GbObject3DCreator() {}
-};
-
-#ifndef SWIG
-UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(FeTriFaceMesh3DCreator::getInstance()), CAB_FeTriFaceMesh3DCreator);
-#endif
-
-#endif
+#ifndef FETRIFACEMESH3DCREATOR_H
+#define FETRIFACEMESH3DCREATOR_H
+
+#include <numerics/geometry3d/creator/GbObject3DCreator.h>
+#include <numerics/geometry3d/fem/FeTriFaceMesh3D.h>
+#include <basics/utilities/UbFileInputASCII.h>
+
+#ifdef CAB_QT 
+#include <qfiledialog.h>    
+#endif
+
+#ifdef CAB_VTK
+//#include <numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h>
+#endif
+
+class FeTriFaceMesh3DCreator : public GbObject3DCreator              
+{                                       
+public:
+   static FeTriFaceMesh3DCreator* getInstance()
+   {
+      static FeTriFaceMesh3DCreator instance;
+      return &instance;
+   }
+   static FeTriFaceMesh3D* readMeshFromFile(std::string filename, std::string meshName, bool removeRedundantNodes=true);
+
+   static FeTriFaceMesh3D* readMeshFromPLYFile(std::string filename, std::string meshName, bool removeRedundantNodes=true);
+   static FeTriFaceMesh3D* readMeshFromPLYFile(UbFileInput* in, std::string meshName, bool removeRedundantNodes=true);
+
+   static FeTriFaceMesh3D* readMeshFromSTLFile(std::string filename, std::string meshName, bool removeRedundantNodes=true); 
+   static FeTriFaceMesh3D* readMeshFromSTLFile(UbFileInput* in, std::string meshName, bool removeRedundantNodes=true);
+
+   static FeTriFaceMesh3D* readMeshFromAVSFile(std::string filename, std::string meshName, bool removeRedundantNodes=true); 
+   static FeTriFaceMesh3D* readMeshFromAVSFile(UbFileInput* in, std::string meshName, bool removeRedundantNodes=true);
+
+   static FeTriFaceMesh3D* readMeshFromVTKASCIIFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); 
+   static FeTriFaceMesh3D* readMeshFromVTKASCIIFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true);
+
+
+   FeTriFaceMesh3D* createGbObject3D() { return new FeTriFaceMesh3D(); }
+   
+   std::string getGbObject3DTypeID(){ return "FeTriFaceMesh3D"; };
+   std::string toString()           { return "FeTriFaceMesh3DCreator"; }
+
+#ifdef CAB_QT 
+
+
+   FeTriFaceMesh3D* createGbObject3DwithQt()
+   {
+	   //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" );
+	   QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl");
+      //QFileDialog* fd = new QFileDialog( NULL );
+      //fd->setIconText(QString("Hallo"));
+      //fd->show();
+      //TODO: Open File Dialog einbauen.		
+      UbFileInputASCII in( s.toAscii().data() );
+      stringstream stream;
+      stream <<"TriangularMesh3D ";//<<_objCount++;
+      FeTriFaceMesh3D *mesh = NULL;//FeTriFaceMesh3DCreator::readMeshFromSTLFile(&in, stream.str() );
+      return mesh;
+   }
+   //QDialog* getSpecificInstrument()  {  return 0;}
+   void editGbObject3DwithQt(GbObject3D* gbObj)
+   { 
+   }
+#endif
+#ifdef CAB_VTK
+public:
+   Presentator* createObjectPresentator(ObObject *object) { return new vtkGbTriangularMesh3D((GbTriangularMesh3D*)object); }
+#endif
+
+
+private:
+   FeTriFaceMesh3DCreator( const FeTriFaceMesh3DCreator& );                  //no copy allowed 
+   const FeTriFaceMesh3DCreator& operator=( const FeTriFaceMesh3DCreator& ); //no copy allowed
+   FeTriFaceMesh3DCreator() : GbObject3DCreator() {}
+};
+
+#ifndef SWIG
+UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(FeTriFaceMesh3DCreator::getInstance()), CAB_FeTriFaceMesh3DCreator);
+#endif
+
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/CMakePackage.txt b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/CMakePackage.txt
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/CMakePackage.txt
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/CMakePackage.txt
index 56dbc3800e73aec047b6d09d2e5957bfbf2ef3e3..d68b881fb1cd22061ab27d1fc28c2c13c843b4a6 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/CMakePackage.txt
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/CMakePackage.txt
@@ -1,93 +1,93 @@
-GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
-COLLECT_QT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
-
-#SET(SUBDIRPATH numerics/geometry3d/presentation) 
-#SET(OPTION_LABEL BUILD_GEOMETRY3DPRESENTATION)
-#
-#SET(CURRENT_DIR ${SOURCE_ROOT}/${SUBDIRPATH})
-#
-#IF(${WITH_SUBFOLDERS_FOR_SG} MATCHES YES)  
-#    STRING(REGEX REPLACE "/" "\\\\" SUBDIRPATH ${SUBDIRPATH})
-#ENDIF(${WITH_SUBFOLDERS_FOR_SG} MATCHES YES)
-#
-#OPTION(${OPTION_LABEL} "${CURRENT_DIR}" ON)
-#IF(${OPTION_LABEL})
-#
-#  SET(TEMP_FILES "")
-#  ################################################################
-#  ###             GET HEADER AND SOURCE FILES                  ###
-#  ################################################################
-#  FILE(GLOB HEADER_FILES ${CURRENT_DIR}/*.h  )
-#  FILE(GLOB CPP_FILES    ${CURRENT_DIR}/*.cpp)
-#  
-#  IF(NOT NEED_VTK)
-#    FILE(GLOB VTK_FILES ${CURRENT_DIR}/*vtk*  )
-#    REMOVE(HEADER_FILES ${VTK_FILES} )
-#    REMOVE(CPP_FILES    ${VTK_FILES} )
-#  ENDIF(NOT NEED_VTK)
-#
-#  SET(TEMP_FILES ${HEADER_FILES} ${CPP_FILES})
-#
-#  SOURCE_GROUP(${SUBDIRPATH} FILES ${TEMP_FILES})
-# 
-#  ################################################################
-#  ###             VTK STUFF                                    ###
-#  ################################################################
-#  
-##GANZ SICHER NICHT!!!!! -> bitte NEED_VTK im globalen CMakeLists.txt definieren
-##SET(NEED_VTK "TRUE")
-#
-#  ################################################################
-#  ###             Qt STUFF                                     ###
-#  ################################################################
-#  SET(NEED_QT "YES")
-#  INCLUDE(${SOURCE_ROOT}/CMakeQtMacros.txt)
-#  IF(QT_FOUND)
-#    ################################################################
-#    ###         Qt4      UI FILES                                ###
-#    ################################################################
-#    FILE(GLOB UI_FILES ${CURRENT_DIR}/*.ui)           #collect ui files
-#    QT4_WRAP_UI(${CURRENT_DIR} OUTFILES ${UI_FILES})  #wrap ui files
-#    REMOVE(TEMP_FILES ${OUTFILES} )
-#    SET(TEMP_FILES ${TEMP_FILES} ${OUTFILES} )
-#    
-#    #make subfolders for VS with new files
-#    SOURCE_GROUP(${SUBDIRPATH} FILES ${OUTFILES})
-#    
-#    IF(WIN32)
-#      SET(ALL_SOURCES ${ALL_SOURCES} ${UI_FILES})
-#      SOURCE_GROUP(${SUBDIRPATH} FILES ${UI_FILES})
-#    ENDIF(WIN32)
-#
-#    ################################################################
-#    ###       Qt4        HEADERS TO BE MOCED                     ###
-#    ################################################################
-#    MAKE_DIRECTORY(${CURRENT_DIR}${QTGEN_MOC})
-#    SET(HEADER_FILES_FOR_MOCCHECK ${HEADER_FILES})
-#    REMOVE(HEADER_FILES_FOR_MOCCHECK ${OUTFILES} ) #bereits durch QT4_WRAP_UI bearbeitete Header-files entferne
-#    QT4_GET_TOBEMOCED_HEADERS(MOC_CLASSES ${HEADER_FILES_FOR_MOCCHECK})
-#    IF(MOC_CLASSES)    
-#       SET(MOC_FILES ) #empty MOC_FILES
-#       QT4_WRAP_CPP(${CURRENT_DIR}${QTGEN_MOC} MOC_FILES ${MOC_CLASSES})
-#       REMOVE(TEMP_FILES ${MOC_FILES})
-#       SET(TEMP_FILES ${TEMP_FILES} ${MOC_FILES})
-#       SOURCE_GROUP(${SUBDIRPATH}${QTGEN_MOC} FILES ${MOC_FILES})
-#    ENDIF(MOC_CLASSES)
-#
-#    #MAKE_DIRECTORY(${CURRENT_DIR}${QTGEN_MOC})
-#    #SET(MOC_FILES ) #empty MOC_FILES
-#    #SET(MOC_CLASSES
-#    #        ${CURRENT_DIR}/QGbObject2DViewer.h
-#    #        ${CURRENT_DIR}/QGbObject2DMainWindow.h
-#    #    )
-#
-#    #QT4_WRAP_CPP(${CURRENT_DIR}${QTGEN_MOC} MOC_FILES ${MOC_CLASSES})
-#    #REMOVE(TEMP_FILES ${MOC_FILES})
-#    #SET(TEMP_FILES ${TEMP_FILES} ${MOC_FILES})
-#    #SOURCE_GROUP(${SUBDIRPATH}${QTGEN_MOC} FILES ${MOC_FILES})
-#
-#   ENDIF(QT_FOUND)
-#
-#  SET(ALL_SOURCES ${ALL_SOURCES} ${TEMP_FILES})
-#
-#ENDIF(${OPTION_LABEL})
+GET_FILENAME_COMPONENT( CURRENT_DIR  ${CMAKE_CURRENT_LIST_FILE} PATH) 
+COLLECT_QT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES)
+
+#SET(SUBDIRPATH numerics/geometry3d/presentation) 
+#SET(OPTION_LABEL BUILD_GEOMETRY3DPRESENTATION)
+#
+#SET(CURRENT_DIR ${SOURCE_ROOT}/${SUBDIRPATH})
+#
+#IF(${WITH_SUBFOLDERS_FOR_SG} MATCHES YES)  
+#    STRING(REGEX REPLACE "/" "\\\\" SUBDIRPATH ${SUBDIRPATH})
+#ENDIF(${WITH_SUBFOLDERS_FOR_SG} MATCHES YES)
+#
+#OPTION(${OPTION_LABEL} "${CURRENT_DIR}" ON)
+#IF(${OPTION_LABEL})
+#
+#  SET(TEMP_FILES "")
+#  ################################################################
+#  ###             GET HEADER AND SOURCE FILES                  ###
+#  ################################################################
+#  FILE(GLOB HEADER_FILES ${CURRENT_DIR}/*.h  )
+#  FILE(GLOB CPP_FILES    ${CURRENT_DIR}/*.cpp)
+#  
+#  IF(NOT NEED_VTK)
+#    FILE(GLOB VTK_FILES ${CURRENT_DIR}/*vtk*  )
+#    REMOVE(HEADER_FILES ${VTK_FILES} )
+#    REMOVE(CPP_FILES    ${VTK_FILES} )
+#  ENDIF(NOT NEED_VTK)
+#
+#  SET(TEMP_FILES ${HEADER_FILES} ${CPP_FILES})
+#
+#  SOURCE_GROUP(${SUBDIRPATH} FILES ${TEMP_FILES})
+# 
+#  ################################################################
+#  ###             VTK STUFF                                    ###
+#  ################################################################
+#  
+##GANZ SICHER NICHT!!!!! -> bitte NEED_VTK im globalen CMakeLists.txt definieren
+##SET(NEED_VTK "TRUE")
+#
+#  ################################################################
+#  ###             Qt STUFF                                     ###
+#  ################################################################
+#  SET(NEED_QT "YES")
+#  INCLUDE(${SOURCE_ROOT}/CMakeQtMacros.txt)
+#  IF(QT_FOUND)
+#    ################################################################
+#    ###         Qt4      UI FILES                                ###
+#    ################################################################
+#    FILE(GLOB UI_FILES ${CURRENT_DIR}/*.ui)           #collect ui files
+#    QT4_WRAP_UI(${CURRENT_DIR} OUTFILES ${UI_FILES})  #wrap ui files
+#    REMOVE(TEMP_FILES ${OUTFILES} )
+#    SET(TEMP_FILES ${TEMP_FILES} ${OUTFILES} )
+#    
+#    #make subfolders for VS with new files
+#    SOURCE_GROUP(${SUBDIRPATH} FILES ${OUTFILES})
+#    
+#    IF(WIN32)
+#      SET(ALL_SOURCES ${ALL_SOURCES} ${UI_FILES})
+#      SOURCE_GROUP(${SUBDIRPATH} FILES ${UI_FILES})
+#    ENDIF(WIN32)
+#
+#    ################################################################
+#    ###       Qt4        HEADERS TO BE MOCED                     ###
+#    ################################################################
+#    MAKE_DIRECTORY(${CURRENT_DIR}${QTGEN_MOC})
+#    SET(HEADER_FILES_FOR_MOCCHECK ${HEADER_FILES})
+#    REMOVE(HEADER_FILES_FOR_MOCCHECK ${OUTFILES} ) #bereits durch QT4_WRAP_UI bearbeitete Header-files entferne
+#    QT4_GET_TOBEMOCED_HEADERS(MOC_CLASSES ${HEADER_FILES_FOR_MOCCHECK})
+#    IF(MOC_CLASSES)    
+#       SET(MOC_FILES ) #empty MOC_FILES
+#       QT4_WRAP_CPP(${CURRENT_DIR}${QTGEN_MOC} MOC_FILES ${MOC_CLASSES})
+#       REMOVE(TEMP_FILES ${MOC_FILES})
+#       SET(TEMP_FILES ${TEMP_FILES} ${MOC_FILES})
+#       SOURCE_GROUP(${SUBDIRPATH}${QTGEN_MOC} FILES ${MOC_FILES})
+#    ENDIF(MOC_CLASSES)
+#
+#    #MAKE_DIRECTORY(${CURRENT_DIR}${QTGEN_MOC})
+#    #SET(MOC_FILES ) #empty MOC_FILES
+#    #SET(MOC_CLASSES
+#    #        ${CURRENT_DIR}/QGbObject2DViewer.h
+#    #        ${CURRENT_DIR}/QGbObject2DMainWindow.h
+#    #    )
+#
+#    #QT4_WRAP_CPP(${CURRENT_DIR}${QTGEN_MOC} MOC_FILES ${MOC_CLASSES})
+#    #REMOVE(TEMP_FILES ${MOC_FILES})
+#    #SET(TEMP_FILES ${TEMP_FILES} ${MOC_FILES})
+#    #SOURCE_GROUP(${SUBDIRPATH}${QTGEN_MOC} FILES ${MOC_FILES})
+#
+#   ENDIF(QT_FOUND)
+#
+#  SET(ALL_SOURCES ${ALL_SOURCES} ${TEMP_FILES})
+#
+#ENDIF(${OPTION_LABEL})
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCuboid3DInstrument.cpp
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCuboid3DInstrument.cpp
index 81ea5bb168f179cdfc8837899e7cc6782907b137..0e444b4b7776031dd728f87d32d30a0cb85190a9 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCuboid3DInstrument.cpp
@@ -1,67 +1,67 @@
-#include "./QGbCuboid3DInstrument.h"
-
-/**** Qt ****/
-#include <qlineedit.h>
-#include <qstring.h>
-#include <qcheckbox.h>
-
-/**** CAB ****/
-#include "./../GbCuboid3D.h"
-#include "./../GbPoint3D.h"
-
-
-QGbCuboid3DInstrument::QGbCuboid3DInstrument( QWidget* parent, Qt::WFlags flags ):QDialog(parent, flags)
-{
-	ui.setupUi(this);
-
-	this->gbCuboid = NULL;
-
-}
-
-QGbCuboid3DInstrument::~QGbCuboid3DInstrument()
-{
-}
-
-void QGbCuboid3DInstrument::setGbCuboid3D(GbCuboid3D* cuboid)
-{
-	this->gbCuboid = cuboid;
-	ui.lineEditPoint1X->setText( QString("%1").arg(gbCuboid->getPoint1()->getX1Coordinate() ) );
-	ui.lineEditPoint1Y->setText( QString("%1").arg(gbCuboid->getPoint1()->getX2Coordinate() ) );
-	ui.lineEditPoint1Z->setText( QString("%1").arg(gbCuboid->getPoint1()->getX3Coordinate() ) );
-	ui.lineEditPoint2X->setText( QString("%1").arg(gbCuboid->getPoint2()->getX1Coordinate() ) );
-	ui.lineEditPoint2Y->setText( QString("%1").arg(gbCuboid->getPoint2()->getX2Coordinate() ) );
-	ui.lineEditPoint2Z->setText( QString("%1").arg(gbCuboid->getPoint2()->getX3Coordinate() ) );
-	//this->checkBoxActive->setChecked( cuboid->isActive() );
-	ui.checkBoxActive->setChecked( true );
-}
-
-GbCuboid3D* QGbCuboid3DInstrument::getGbCuboid3D()
-{
-	return this->gbCuboid;
-}
-
-//void QGbCuboid3DInstrument::SetGbObject3D(GbObject3D* gbObj)
-//{
-//		this->SetGbSphere(dynamic_cast<GbSphere3D*>(gbObj));
-//}
-
-void QGbCuboid3DInstrument::on_pBtnOK_clicked()
-{
-	this->gbCuboid->getPoint1()->setX1(ui.lineEditPoint1X->text().toDouble() );
-	this->gbCuboid->getPoint1()->setX2(ui.lineEditPoint1Y->text().toDouble() );
-	this->gbCuboid->getPoint1()->setX3(ui.lineEditPoint1Z->text().toDouble() );
-	this->gbCuboid->getPoint2()->setX1(ui.lineEditPoint2X->text().toDouble() );
-	this->gbCuboid->getPoint2()->setX2(ui.lineEditPoint2Y->text().toDouble() );
-	this->gbCuboid->getPoint2()->setX3(ui.lineEditPoint2Z->text().toDouble() );
-	//this->gbCuboid->setActive( this->checkBoxActive->isChecked() );
-
-	this->gbCuboid->notifyObserversObjectChanged();
-	this->accept();
-}
-
-
-void QGbCuboid3DInstrument::on_pBtnCancel_clicked()
-{
-	this->reject();
-}
-
+#include "./QGbCuboid3DInstrument.h"
+
+/**** Qt ****/
+#include <qlineedit.h>
+#include <qstring.h>
+#include <qcheckbox.h>
+
+/**** CAB ****/
+#include "./../GbCuboid3D.h"
+#include "./../GbPoint3D.h"
+
+
+QGbCuboid3DInstrument::QGbCuboid3DInstrument( QWidget* parent, Qt::WFlags flags ):QDialog(parent, flags)
+{
+	ui.setupUi(this);
+
+	this->gbCuboid = NULL;
+
+}
+
+QGbCuboid3DInstrument::~QGbCuboid3DInstrument()
+{
+}
+
+void QGbCuboid3DInstrument::setGbCuboid3D(GbCuboid3D* cuboid)
+{
+	this->gbCuboid = cuboid;
+	ui.lineEditPoint1X->setText( QString("%1").arg(gbCuboid->getPoint1()->getX1Coordinate() ) );
+	ui.lineEditPoint1Y->setText( QString("%1").arg(gbCuboid->getPoint1()->getX2Coordinate() ) );
+	ui.lineEditPoint1Z->setText( QString("%1").arg(gbCuboid->getPoint1()->getX3Coordinate() ) );
+	ui.lineEditPoint2X->setText( QString("%1").arg(gbCuboid->getPoint2()->getX1Coordinate() ) );
+	ui.lineEditPoint2Y->setText( QString("%1").arg(gbCuboid->getPoint2()->getX2Coordinate() ) );
+	ui.lineEditPoint2Z->setText( QString("%1").arg(gbCuboid->getPoint2()->getX3Coordinate() ) );
+	//this->checkBoxActive->setChecked( cuboid->isActive() );
+	ui.checkBoxActive->setChecked( true );
+}
+
+GbCuboid3D* QGbCuboid3DInstrument::getGbCuboid3D()
+{
+	return this->gbCuboid;
+}
+
+//void QGbCuboid3DInstrument::SetGbObject3D(GbObject3D* gbObj)
+//{
+//		this->SetGbSphere(dynamic_cast<GbSphere3D*>(gbObj));
+//}
+
+void QGbCuboid3DInstrument::on_pBtnOK_clicked()
+{
+	this->gbCuboid->getPoint1()->setX1(ui.lineEditPoint1X->text().toDouble() );
+	this->gbCuboid->getPoint1()->setX2(ui.lineEditPoint1Y->text().toDouble() );
+	this->gbCuboid->getPoint1()->setX3(ui.lineEditPoint1Z->text().toDouble() );
+	this->gbCuboid->getPoint2()->setX1(ui.lineEditPoint2X->text().toDouble() );
+	this->gbCuboid->getPoint2()->setX2(ui.lineEditPoint2Y->text().toDouble() );
+	this->gbCuboid->getPoint2()->setX3(ui.lineEditPoint2Z->text().toDouble() );
+	//this->gbCuboid->setActive( this->checkBoxActive->isChecked() );
+
+	this->gbCuboid->notifyObserversObjectChanged();
+	this->accept();
+}
+
+
+void QGbCuboid3DInstrument::on_pBtnCancel_clicked()
+{
+	this->reject();
+}
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.h b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCuboid3DInstrument.h
similarity index 94%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCuboid3DInstrument.h
index 45555d457bc28da60c0107ae2491d1d95ffb0b69..312fb0efa42b7bd6d6fc08ec55d4e293f727cee8 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCuboid3DInstrument.h
@@ -1,31 +1,31 @@
-#ifndef QGBCUBOID3DINSTRUMENT_H
-#define QGBCUBOID3DINSTRUMENT_H
-
-
-#include "./QGbCuboid3DInstrumentUI.h"
-
-class GbCuboid3D;
-class GbObject3D;
-
-class QGbCuboid3DInstrument : public QDialog
-{
-	Q_OBJECT
-
-public:
-	QGbCuboid3DInstrument( QWidget* parent = 0, Qt::WFlags fl = 0 );
-	~QGbCuboid3DInstrument();
-	void setGbCuboid3D(GbCuboid3D* cuboid);        
-	GbCuboid3D* getGbCuboid3D();
-
-protected:
-	GbCuboid3D* gbCuboid;
-
-private:
-	Ui::QGbCuboid3DInstrument ui;
-
-private slots:
-	void on_pBtnOK_clicked();
-	void on_pBtnCancel_clicked();
-};
-
-#endif   
+#ifndef QGBCUBOID3DINSTRUMENT_H
+#define QGBCUBOID3DINSTRUMENT_H
+
+
+#include "./QGbCuboid3DInstrumentUI.h"
+
+class GbCuboid3D;
+class GbObject3D;
+
+class QGbCuboid3DInstrument : public QDialog
+{
+	Q_OBJECT
+
+public:
+	QGbCuboid3DInstrument( QWidget* parent = 0, Qt::WFlags fl = 0 );
+	~QGbCuboid3DInstrument();
+	void setGbCuboid3D(GbCuboid3D* cuboid);        
+	GbCuboid3D* getGbCuboid3D();
+
+protected:
+	GbCuboid3D* gbCuboid;
+
+private:
+	Ui::QGbCuboid3DInstrument ui;
+
+private slots:
+	void on_pBtnOK_clicked();
+	void on_pBtnCancel_clicked();
+};
+
+#endif   
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.ui b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCuboid3DInstrument.ui
similarity index 100%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCuboid3DInstrument.ui
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCuboid3DInstrument.ui
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCylinder3DInstrument.cpp
similarity index 97%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCylinder3DInstrument.cpp
index 3a1cff7b94a1653db8ade52e20b43943a7a84d5b..34ff20fe1b0b771609467e1317e184b9db87ce9a 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCylinder3DInstrument.cpp
@@ -1,102 +1,102 @@
-#include "./QGbCylinder3DInstrument.h"
-
-/**** Qt ****/
-#include <QtCore/QString>
-#include <QtGui/QLineEdit>
-#include <QtGui/QCheckBox>
-#include <QtGui/QTabWidget>
-
-/**** CAB ****/
-#include "./../GbCylinder3D.h"
-#include "./../GbPoint3D.h"
-
-QGbCylinder3DInstrument::QGbCylinder3DInstrument( QWidget* parent, Qt::WFlags flags )
-{
-	ui.setupUi(this);
-   
-   /*JZ TODO daher Buttons noch ausgeschaltet (29.11.05)*/
-   ui.rBtnXAxis->setEnabled(false);
-   ui.rBtnYAxis->setEnabled(false);
-   ui.rBtnZAxis->setEnabled(false);
-	
-   this->gbCylinder = NULL;
-}
-
-QGbCylinder3DInstrument::~QGbCylinder3DInstrument(void)
-{
-}
-
-void QGbCylinder3DInstrument::setGbCylinder3D(GbCylinder3D* cylinder)
-{
-   this->gbCylinder = cylinder;
-   ui.lineEdit1_X_1->setText( QString("%1").arg(gbCylinder->getPoint1()->x1 ) );
-   ui.lineEdit1_Y_1->setText( QString("%1").arg(gbCylinder->getPoint1()->x2 ) );
-   ui.lineEdit1_Z_1->setText( QString("%1").arg(gbCylinder->getPoint1()->x3 ) );
-   ui.lineEdit1_X_2->setText( QString("%1").arg(gbCylinder->getPoint2()->x1 ) );
-   ui.lineEdit1_Y_2->setText( QString("%1").arg(gbCylinder->getPoint2()->x2 ) );
-   ui.lineEdit1_Z_2->setText( QString("%1").arg(gbCylinder->getPoint2()->x3 ) );
-   ui.dSpBoxRadius1->setValue(gbCylinder->getRadius());
-   ui.checkBoxActive1->setChecked( true );
-   ui.lineEdit2_X->setText( QString("%1").arg(gbCylinder->getPoint1()->x1 ) );
-   ui.lineEdit2_Y->setText( QString("%1").arg(gbCylinder->getPoint1()->x2 ) );
-   ui.lineEdit2_Z->setText( QString("%1").arg(gbCylinder->getPoint1()->x3 ) );
-   ui.dSpBoxRadius2->setValue(gbCylinder->getRadius());
-   ui.checkBoxActive2->setChecked( true );
-   ui.lineEditLength->setText( QString("%1").arg(gbCylinder->getHeight()) );
-   //if (!this->gbCylinder->isParallelToX1Axis()) 
-   //{
-   //   if (!this->gbCylinder->isParallelToX2Axis()) 
-   //   {
-   //      ui.rBtnZAxis->setChecked(true);
-   //   }
-   //   else ui.rBtnYAxis->setChecked(true);
-   //}
-   //else ui.rBtnXAxis->setChecked(true);
-}
-
-GbCylinder3D* QGbCylinder3DInstrument::getGbCylinder3D(void)
-{
-	return this->gbCylinder;
-}
-
-//void QGbSphere3DInstrument::SetGbObject3D(GbObject3D* gbObj)
-//{
-//		this->SetGbSphere(dynamic_cast<GbSphere3D*>(gbObj));
-//}
-
-void QGbCylinder3DInstrument::on_pBtnOK_clicked()
-{
-   if(ui.tabWidget->currentIndex()==0)
-   {
-      this->gbCylinder->setPoint1(  ui.lineEdit1_X_1->text().toDouble(),
-                                    ui.lineEdit1_Y_1->text().toDouble(),
-                                    ui.lineEdit1_Z_1->text().toDouble());
-     
-      this->gbCylinder->setPoint2(  ui.lineEdit1_X_2->text().toDouble(),
-                                    ui.lineEdit1_Y_2->text().toDouble(),
-                                    ui.lineEdit1_Z_2->text().toDouble());
-      this->gbCylinder->setRadius(ui.dSpBoxRadius1->value());
-
-      this->gbCylinder->notifyObserversObjectChanged();
-   }
-   if(ui.tabWidget->currentIndex()==1)
-   {
-      this->gbCylinder->setPoint1(  ui.lineEdit2_X->text().toDouble(),
-                                    ui.lineEdit2_Y->text().toDouble(),
-                                    ui.lineEdit2_Z->text().toDouble());
-      this->gbCylinder->setPoint2(  ui.lineEdit2_X->text().toDouble(),
-                                    ui.lineEdit2_Y->text().toDouble()+ui.lineEditLength->text().toDouble(),
-                                    ui.lineEdit2_Z->text().toDouble());
-      this->gbCylinder->setRadius(ui.dSpBoxRadius2->value());
-
-      this->gbCylinder->notifyObserversObjectChanged();
-   }
-
-   this->accept();
-}
-
-
-void QGbCylinder3DInstrument::on_pBtnCancel_clicked()
-{
-	this->reject();
-}
+#include "./QGbCylinder3DInstrument.h"
+
+/**** Qt ****/
+#include <QtCore/QString>
+#include <QtGui/QLineEdit>
+#include <QtGui/QCheckBox>
+#include <QtGui/QTabWidget>
+
+/**** CAB ****/
+#include "./../GbCylinder3D.h"
+#include "./../GbPoint3D.h"
+
+QGbCylinder3DInstrument::QGbCylinder3DInstrument( QWidget* parent, Qt::WFlags flags )
+{
+	ui.setupUi(this);
+   
+   /*JZ TODO daher Buttons noch ausgeschaltet (29.11.05)*/
+   ui.rBtnXAxis->setEnabled(false);
+   ui.rBtnYAxis->setEnabled(false);
+   ui.rBtnZAxis->setEnabled(false);
+	
+   this->gbCylinder = NULL;
+}
+
+QGbCylinder3DInstrument::~QGbCylinder3DInstrument(void)
+{
+}
+
+void QGbCylinder3DInstrument::setGbCylinder3D(GbCylinder3D* cylinder)
+{
+   this->gbCylinder = cylinder;
+   ui.lineEdit1_X_1->setText( QString("%1").arg(gbCylinder->getPoint1()->x1 ) );
+   ui.lineEdit1_Y_1->setText( QString("%1").arg(gbCylinder->getPoint1()->x2 ) );
+   ui.lineEdit1_Z_1->setText( QString("%1").arg(gbCylinder->getPoint1()->x3 ) );
+   ui.lineEdit1_X_2->setText( QString("%1").arg(gbCylinder->getPoint2()->x1 ) );
+   ui.lineEdit1_Y_2->setText( QString("%1").arg(gbCylinder->getPoint2()->x2 ) );
+   ui.lineEdit1_Z_2->setText( QString("%1").arg(gbCylinder->getPoint2()->x3 ) );
+   ui.dSpBoxRadius1->setValue(gbCylinder->getRadius());
+   ui.checkBoxActive1->setChecked( true );
+   ui.lineEdit2_X->setText( QString("%1").arg(gbCylinder->getPoint1()->x1 ) );
+   ui.lineEdit2_Y->setText( QString("%1").arg(gbCylinder->getPoint1()->x2 ) );
+   ui.lineEdit2_Z->setText( QString("%1").arg(gbCylinder->getPoint1()->x3 ) );
+   ui.dSpBoxRadius2->setValue(gbCylinder->getRadius());
+   ui.checkBoxActive2->setChecked( true );
+   ui.lineEditLength->setText( QString("%1").arg(gbCylinder->getHeight()) );
+   //if (!this->gbCylinder->isParallelToX1Axis()) 
+   //{
+   //   if (!this->gbCylinder->isParallelToX2Axis()) 
+   //   {
+   //      ui.rBtnZAxis->setChecked(true);
+   //   }
+   //   else ui.rBtnYAxis->setChecked(true);
+   //}
+   //else ui.rBtnXAxis->setChecked(true);
+}
+
+GbCylinder3D* QGbCylinder3DInstrument::getGbCylinder3D(void)
+{
+	return this->gbCylinder;
+}
+
+//void QGbSphere3DInstrument::SetGbObject3D(GbObject3D* gbObj)
+//{
+//		this->SetGbSphere(dynamic_cast<GbSphere3D*>(gbObj));
+//}
+
+void QGbCylinder3DInstrument::on_pBtnOK_clicked()
+{
+   if(ui.tabWidget->currentIndex()==0)
+   {
+      this->gbCylinder->setPoint1(  ui.lineEdit1_X_1->text().toDouble(),
+                                    ui.lineEdit1_Y_1->text().toDouble(),
+                                    ui.lineEdit1_Z_1->text().toDouble());
+     
+      this->gbCylinder->setPoint2(  ui.lineEdit1_X_2->text().toDouble(),
+                                    ui.lineEdit1_Y_2->text().toDouble(),
+                                    ui.lineEdit1_Z_2->text().toDouble());
+      this->gbCylinder->setRadius(ui.dSpBoxRadius1->value());
+
+      this->gbCylinder->notifyObserversObjectChanged();
+   }
+   if(ui.tabWidget->currentIndex()==1)
+   {
+      this->gbCylinder->setPoint1(  ui.lineEdit2_X->text().toDouble(),
+                                    ui.lineEdit2_Y->text().toDouble(),
+                                    ui.lineEdit2_Z->text().toDouble());
+      this->gbCylinder->setPoint2(  ui.lineEdit2_X->text().toDouble(),
+                                    ui.lineEdit2_Y->text().toDouble()+ui.lineEditLength->text().toDouble(),
+                                    ui.lineEdit2_Z->text().toDouble());
+      this->gbCylinder->setRadius(ui.dSpBoxRadius2->value());
+
+      this->gbCylinder->notifyObserversObjectChanged();
+   }
+
+   this->accept();
+}
+
+
+void QGbCylinder3DInstrument::on_pBtnCancel_clicked()
+{
+	this->reject();
+}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.h b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCylinder3DInstrument.h
similarity index 95%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCylinder3DInstrument.h
index a22278cc427a3fcbf7104f9924a3d5c30fc38f5a..3ab65d38079601166ee52f09e1436d5d61325629 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCylinder3DInstrument.h
@@ -1,35 +1,35 @@
-#ifndef QGBCYLINDER3DINSTRUMENT_H
-#define QGBCYLINDER3DINSTRUMENT_H
-
-#include <QtGui/QDialog>
-#include <QtGui/QWidget>
-
-#include "./QGbCylinder3DInstrumentUI.h"
-#include "./QGbObject3DInstrument.h"
-
-class GbCylinder3D;
-class GbObject3D;
-
-class QGbCylinder3DInstrument : public QDialog
-{
-
-   Q_OBJECT
-
-public:
-   QGbCylinder3DInstrument( QWidget* parent = 0, Qt::WFlags flags = 0 );
-   ~QGbCylinder3DInstrument();
-   void setGbCylinder3D(GbCylinder3D* cylinder);
-   GbCylinder3D* getGbCylinder3D();
-
-protected:
-   GbCylinder3D* gbCylinder;
-
-private:
-   Ui::QGbCylinder3DInstrument ui;
-
-private slots:
-   void on_pBtnOK_clicked();
-   void on_pBtnCancel_clicked();
-};
-
+#ifndef QGBCYLINDER3DINSTRUMENT_H
+#define QGBCYLINDER3DINSTRUMENT_H
+
+#include <QtGui/QDialog>
+#include <QtGui/QWidget>
+
+#include "./QGbCylinder3DInstrumentUI.h"
+#include "./QGbObject3DInstrument.h"
+
+class GbCylinder3D;
+class GbObject3D;
+
+class QGbCylinder3DInstrument : public QDialog
+{
+
+   Q_OBJECT
+
+public:
+   QGbCylinder3DInstrument( QWidget* parent = 0, Qt::WFlags flags = 0 );
+   ~QGbCylinder3DInstrument();
+   void setGbCylinder3D(GbCylinder3D* cylinder);
+   GbCylinder3D* getGbCylinder3D();
+
+protected:
+   GbCylinder3D* gbCylinder;
+
+private:
+   Ui::QGbCylinder3DInstrument ui;
+
+private slots:
+   void on_pBtnOK_clicked();
+   void on_pBtnCancel_clicked();
+};
+
 #endif
\ No newline at end of file
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.ui b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCylinder3DInstrument.ui
similarity index 100%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/QGbCylinder3DInstrument.ui
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbCylinder3DInstrument.ui
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbObject3DInstrument.cpp
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbObject3DInstrument.cpp
index 9d873fd905cf9a7c9b34210601168c0b4089dd1c..62c4b2bf46d46b2116e849317c16341737b6541a 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbObject3DInstrument.cpp
@@ -1,66 +1,66 @@
-#include "./QGbObject3DInstrument.h"
-
-/**** Qt ****/
-#include <qlineedit.h>
-
-/**** vtk ****/
-#include "./../GbObject3D.h"
-#include "./../../../basics/utilities/UbMath.h"
-
-//#define PI   3.14159265358979323846
-
-QGbObject3DInstrument::QGbObject3DInstrument( QWidget* parent, Qt::WFlags flags )
-{
-	ui.setupUi(this);
-
-	this->gbObject3D = NULL;
-}
-
-QGbObject3DInstrument::~QGbObject3DInstrument()
-{
-}
-
-void QGbObject3DInstrument::setGbObject3D(GbObject3D* obj)
-{                               
-	this->gbObject3D = obj;
-}
-
-GbObject3D* QGbObject3DInstrument::getGbObject3D()
-{
-	return this->gbObject3D;
-}
-
-void QGbObject3DInstrument::on_pBtnOK_clicked()
-{
-	double rx = ui.lineEditRotationX->text().toDouble();
-	double ry = ui.lineEditRotationY->text().toDouble();
-	double rz = ui.lineEditRotationZ->text().toDouble();
-
-	rx *= UbMath::PI /180;     
-	ry *= UbMath::PI /180;
-	rz *= UbMath::PI /180;
-
-	if ( rx != 0.0 || ry != 0.0 || rz != 0.0 ) this->gbObject3D->rotate(rx, ry, rz);
-
-	double sx = ui.lineEditScalingX->text().toDouble();
-	double sy = ui.lineEditScalingY->text().toDouble();
-	double sz = ui.lineEditScalingZ->text().toDouble();
-
-	if ( sx != 0.0 || sy != 0.0 || sz != 0.0 ) this->gbObject3D->scale(sx, sy, sz);
-
-	double x = ui.lineEditTranlationX->text().toDouble();
-	double y = ui.lineEditTranlationY->text().toDouble();
-	double z = ui.lineEditTranlationZ->text().toDouble();
-
-	if ( x != 0.0 || y != 0.0 || z != 0.0 ) this->gbObject3D->translate(x, y, z);
-
-	this->gbObject3D->notifyObserversObjectChanged();
-
-	this->accept();
-}
-
-
-void QGbObject3DInstrument::on_pBtnCancel_clicked()
-{
-	this->reject();
-}
+#include "./QGbObject3DInstrument.h"
+
+/**** Qt ****/
+#include <qlineedit.h>
+
+/**** vtk ****/
+#include "./../GbObject3D.h"
+#include "./../../../basics/utilities/UbMath.h"
+
+//#define PI   3.14159265358979323846
+
+QGbObject3DInstrument::QGbObject3DInstrument( QWidget* parent, Qt::WFlags flags )
+{
+	ui.setupUi(this);
+
+	this->gbObject3D = NULL;
+}
+
+QGbObject3DInstrument::~QGbObject3DInstrument()
+{
+}
+
+void QGbObject3DInstrument::setGbObject3D(GbObject3D* obj)
+{                               
+	this->gbObject3D = obj;
+}
+
+GbObject3D* QGbObject3DInstrument::getGbObject3D()
+{
+	return this->gbObject3D;
+}
+
+void QGbObject3DInstrument::on_pBtnOK_clicked()
+{
+	double rx = ui.lineEditRotationX->text().toDouble();
+	double ry = ui.lineEditRotationY->text().toDouble();
+	double rz = ui.lineEditRotationZ->text().toDouble();
+
+	rx *= UbMath::PI /180;     
+	ry *= UbMath::PI /180;
+	rz *= UbMath::PI /180;
+
+	if ( rx != 0.0 || ry != 0.0 || rz != 0.0 ) this->gbObject3D->rotate(rx, ry, rz);
+
+	double sx = ui.lineEditScalingX->text().toDouble();
+	double sy = ui.lineEditScalingY->text().toDouble();
+	double sz = ui.lineEditScalingZ->text().toDouble();
+
+	if ( sx != 0.0 || sy != 0.0 || sz != 0.0 ) this->gbObject3D->scale(sx, sy, sz);
+
+	double x = ui.lineEditTranlationX->text().toDouble();
+	double y = ui.lineEditTranlationY->text().toDouble();
+	double z = ui.lineEditTranlationZ->text().toDouble();
+
+	if ( x != 0.0 || y != 0.0 || z != 0.0 ) this->gbObject3D->translate(x, y, z);
+
+	this->gbObject3D->notifyObserversObjectChanged();
+
+	this->accept();
+}
+
+
+void QGbObject3DInstrument::on_pBtnCancel_clicked()
+{
+	this->reject();
+}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.h b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbObject3DInstrument.h
similarity index 94%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbObject3DInstrument.h
index 6165be7237f8eb83653a6c1089fc661859231ce0..5c3e556b59d1be37cf7a0794684af2a1967e4ac2 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbObject3DInstrument.h
@@ -1,30 +1,30 @@
-#ifndef QGBOBJECT3DINSTRUMENT_H
-#define QGBOBJECT3DINSTRUMENT_H
-
-#include <QDialog>
-#include "./QGbObject3DInstrumentUI.h"
-
-
-class GbObject3D;
-
-class QGbObject3DInstrument : public QDialog
-{
-	Q_OBJECT
-
-public:
-	QGbObject3DInstrument( QWidget* parent = 0, Qt::WFlags flags = 0 );
-	~QGbObject3DInstrument();
-	void setGbObject3D(GbObject3D* gbObject);           
-	GbObject3D* getGbObject3D();
-
-protected:
-	GbObject3D *gbObject3D;
-
-private:
-	Ui::QGbObject3DInstrument ui;
-
-private slots:
-	void on_pBtnOK_clicked();
-	void on_pBtnCancel_clicked();
-};
-#endif   
+#ifndef QGBOBJECT3DINSTRUMENT_H
+#define QGBOBJECT3DINSTRUMENT_H
+
+#include <QDialog>
+#include "./QGbObject3DInstrumentUI.h"
+
+
+class GbObject3D;
+
+class QGbObject3DInstrument : public QDialog
+{
+	Q_OBJECT
+
+public:
+	QGbObject3DInstrument( QWidget* parent = 0, Qt::WFlags flags = 0 );
+	~QGbObject3DInstrument();
+	void setGbObject3D(GbObject3D* gbObject);           
+	GbObject3D* getGbObject3D();
+
+protected:
+	GbObject3D *gbObject3D;
+
+private:
+	Ui::QGbObject3DInstrument ui;
+
+private slots:
+	void on_pBtnOK_clicked();
+	void on_pBtnCancel_clicked();
+};
+#endif   
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.ui b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbObject3DInstrument.ui
similarity index 100%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/QGbObject3DInstrument.ui
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbObject3DInstrument.ui
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbSphere3DInstrument.cpp
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbSphere3DInstrument.cpp
index fdc1c6078a2ad3c59ae695e069d1440a6c9cf7b3..bb397eda50f014c0dab545780e261cb795f8cb36 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbSphere3DInstrument.cpp
@@ -1,60 +1,60 @@
-#include "./QGbSphere3DInstrument.h"
-
-/**** Qt ****/
-#include <qlineedit.h>
-#include <qstring.h>
-#include <qcheckbox.h>
-
-/**** CAB ****/
-#include "./../GbSphere3D.h"
-
-QGbSphere3DInstrument::QGbSphere3DInstrument( QWidget* parent, Qt::WFlags flags ):QDialog(parent,flags)
-{
-
-	ui.setupUi(this);
-   
-	this->gbSphere = NULL;
-}
-
-QGbSphere3DInstrument::~QGbSphere3DInstrument(void)
-{
-}
-
-void QGbSphere3DInstrument::setGbSphere3D(GbSphere3D* sphere)
-{
-	this->gbSphere = sphere;
-	ui.lineEditX->setText( QString("%1").arg(gbSphere->getX1Centroid() ) );
-	ui.lineEditY->setText( QString("%1").arg(gbSphere->getX2Centroid() ) );
-	ui.lineEditZ->setText( QString("%1").arg(gbSphere->getX3Centroid() ) );
-   ui.lineEditName->setText( QString(gbSphere->getName().c_str()) );
-	ui.lineEditRadius->setText( QString("%1").arg(gbSphere->getRadius() ) );
-	ui.checkBoxActive->setChecked( true );
-}
-
-GbSphere3D* QGbSphere3DInstrument::getGbSphere3D(void)
-{
-	return this->gbSphere;
-}
-
-//void QGbSphere3DInstrument::SetGbObject3D(GbObject3D* gbObj)
-//{
-//		this->SetGbSphere(dynamic_cast<GbSphere3D*>(gbObj));
-//}
-
-void QGbSphere3DInstrument::on_pBtnOK_clicked()
-{
-	this->gbSphere->setCenterX1Coordinate(ui.lineEditX->text().toDouble());
-	this->gbSphere->setCenterX2Coordinate(ui.lineEditY->text().toDouble());
-	this->gbSphere->setCenterX3Coordinate(ui.lineEditZ->text().toDouble());
-	this->gbSphere->setRadius(ui.lineEditRadius->text().toDouble());
-   this->gbSphere->setName(ui.lineEditName->text().toStdString());
-	//this->gbSphere->setActive( this->checkBoxActive->isChecked() );
-	this->gbSphere->notifyObserversObjectChanged();
-	this->accept();
-}
-
-
-void QGbSphere3DInstrument::on_pBtnCancel_clicked()
-{
-	this->reject();
-}
+#include "./QGbSphere3DInstrument.h"
+
+/**** Qt ****/
+#include <qlineedit.h>
+#include <qstring.h>
+#include <qcheckbox.h>
+
+/**** CAB ****/
+#include "./../GbSphere3D.h"
+
+QGbSphere3DInstrument::QGbSphere3DInstrument( QWidget* parent, Qt::WFlags flags ):QDialog(parent,flags)
+{
+
+	ui.setupUi(this);
+   
+	this->gbSphere = NULL;
+}
+
+QGbSphere3DInstrument::~QGbSphere3DInstrument(void)
+{
+}
+
+void QGbSphere3DInstrument::setGbSphere3D(GbSphere3D* sphere)
+{
+	this->gbSphere = sphere;
+	ui.lineEditX->setText( QString("%1").arg(gbSphere->getX1Centroid() ) );
+	ui.lineEditY->setText( QString("%1").arg(gbSphere->getX2Centroid() ) );
+	ui.lineEditZ->setText( QString("%1").arg(gbSphere->getX3Centroid() ) );
+   ui.lineEditName->setText( QString(gbSphere->getName().c_str()) );
+	ui.lineEditRadius->setText( QString("%1").arg(gbSphere->getRadius() ) );
+	ui.checkBoxActive->setChecked( true );
+}
+
+GbSphere3D* QGbSphere3DInstrument::getGbSphere3D(void)
+{
+	return this->gbSphere;
+}
+
+//void QGbSphere3DInstrument::SetGbObject3D(GbObject3D* gbObj)
+//{
+//		this->SetGbSphere(dynamic_cast<GbSphere3D*>(gbObj));
+//}
+
+void QGbSphere3DInstrument::on_pBtnOK_clicked()
+{
+	this->gbSphere->setCenterX1Coordinate(ui.lineEditX->text().toDouble());
+	this->gbSphere->setCenterX2Coordinate(ui.lineEditY->text().toDouble());
+	this->gbSphere->setCenterX3Coordinate(ui.lineEditZ->text().toDouble());
+	this->gbSphere->setRadius(ui.lineEditRadius->text().toDouble());
+   this->gbSphere->setName(ui.lineEditName->text().toStdString());
+	//this->gbSphere->setActive( this->checkBoxActive->isChecked() );
+	this->gbSphere->notifyObserversObjectChanged();
+	this->accept();
+}
+
+
+void QGbSphere3DInstrument::on_pBtnCancel_clicked()
+{
+	this->reject();
+}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.h b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbSphere3DInstrument.h
similarity index 94%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbSphere3DInstrument.h
index 95bb56b3ad635234df26c856c1404826c5239e1a..afe97b1ef80e3f0c09eebdda57fbf098f159e341 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbSphere3DInstrument.h
@@ -1,36 +1,36 @@
-#ifndef QGBSPHERE3DINSTRUMENT_H
-#define QGBSPHERE3DINSTRUMENT_H
-
-#include <QtGui/QDialog>
-#include <QtGui/QWidget>
-
-#include "./QGbSphere3DInstrumentUI.h"
-#include "./QGbObject3DInstrument.h"
-
-class GbSphere3D;
-class GbObject3D;
-
-
-class QGbSphere3DInstrument : public QDialog
-{
-	Q_OBJECT
-
-public:
-	QGbSphere3DInstrument( QWidget* parent = 0, Qt::WFlags flags = 0 );
-	~QGbSphere3DInstrument();
-	void setGbSphere3D(GbSphere3D* sphere);     
-	GbSphere3D* getGbSphere3D();
-	//void SetGbObject3D(GbObject3D*);
-
-protected:
-	GbSphere3D* gbSphere;
-
-private:
-	Ui::QGbSphere3DInstrument ui;
-
-private slots:
-	void on_pBtnOK_clicked();
-	void on_pBtnCancel_clicked();
-};
-
-#endif   
+#ifndef QGBSPHERE3DINSTRUMENT_H
+#define QGBSPHERE3DINSTRUMENT_H
+
+#include <QtGui/QDialog>
+#include <QtGui/QWidget>
+
+#include "./QGbSphere3DInstrumentUI.h"
+#include "./QGbObject3DInstrument.h"
+
+class GbSphere3D;
+class GbObject3D;
+
+
+class QGbSphere3DInstrument : public QDialog
+{
+	Q_OBJECT
+
+public:
+	QGbSphere3DInstrument( QWidget* parent = 0, Qt::WFlags flags = 0 );
+	~QGbSphere3DInstrument();
+	void setGbSphere3D(GbSphere3D* sphere);     
+	GbSphere3D* getGbSphere3D();
+	//void SetGbObject3D(GbObject3D*);
+
+protected:
+	GbSphere3D* gbSphere;
+
+private:
+	Ui::QGbSphere3DInstrument ui;
+
+private slots:
+	void on_pBtnOK_clicked();
+	void on_pBtnCancel_clicked();
+};
+
+#endif   
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.ui b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbSphere3DInstrument.ui
similarity index 100%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/QGbSphere3DInstrument.ui
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/QGbSphere3DInstrument.ui
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/QVTKGbObject3DViewer.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QVTKGbObject3DViewer.cpp
similarity index 95%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/QVTKGbObject3DViewer.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/QVTKGbObject3DViewer.cpp
index 9ddd2d2e2277de467fef2204ce000aaa07cf7c04..46f97bf4af49e4b096d8d067b55f4e4be1d4315f 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/QVTKGbObject3DViewer.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QVTKGbObject3DViewer.cpp
@@ -1,35 +1,35 @@
-#include "./QVTKGbObject3DViewer.h"
-
-/**** Qt ****/
-#include <qtabwidget.h>
-#include <qlabel.h>
-/**** vtk ****/
-
-#include <QVTKWidget.h>
-//#include "QvtkWindow.h"
-
-/**** CAB ****/
-#include "./../../../basics/utilities/UbMath.h"
-#include "./../GbObject3DManager.h"
-
-
-#include "./../../../userinterface/instrument/QManagerPresentatorInstrument.h"
-//#include "./QGbObject3DManagerInstrument.h"
-
-
-
-QVTKGbObject3DViewer::QVTKGbObject3DViewer():QVTKViewer3DApplication()
-{
-	//GbObjectManagerInstrument
-   this->gbObject3DManager = new GbObject3DManager();
-   QManagerPresentatorInstrument* gbObjManInst = new QManagerPresentatorInstrument(gbObject3DManager);
-	//gbObjManInst->setQViewer(this->getViewer());
-	
-	//Instrumente hinzufügen
-	this->addInstrument(gbObjManInst, "Geometries");
-}
-
-QVTKGbObject3DViewer::~QVTKGbObject3DViewer()
-{
-}
-
+#include "./QVTKGbObject3DViewer.h"
+
+/**** Qt ****/
+#include <qtabwidget.h>
+#include <qlabel.h>
+/**** vtk ****/
+
+#include <QVTKWidget.h>
+//#include "QvtkWindow.h"
+
+/**** CAB ****/
+#include "./../../../basics/utilities/UbMath.h"
+#include "./../GbObject3DManager.h"
+
+
+#include "./../../../userinterface/instrument/QManagerPresentatorInstrument.h"
+//#include "./QGbObject3DManagerInstrument.h"
+
+
+
+QVTKGbObject3DViewer::QVTKGbObject3DViewer():QVTKViewer3DApplication()
+{
+	//GbObjectManagerInstrument
+   this->gbObject3DManager = new GbObject3DManager();
+   QManagerPresentatorInstrument* gbObjManInst = new QManagerPresentatorInstrument(gbObject3DManager);
+	//gbObjManInst->setQViewer(this->getViewer());
+	
+	//Instrumente hinzufügen
+	this->addInstrument(gbObjManInst, "Geometries");
+}
+
+QVTKGbObject3DViewer::~QVTKGbObject3DViewer()
+{
+}
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/QVTKGbObject3DViewer.h b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QVTKGbObject3DViewer.h
similarity index 94%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/QVTKGbObject3DViewer.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/QVTKGbObject3DViewer.h
index dc2e7ba4add517e22870cbcd097650338f267e0f..86b4cb83170fb14bfa692823306ac2e785fc5b15 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/QVTKGbObject3DViewer.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/QVTKGbObject3DViewer.h
@@ -1,22 +1,22 @@
-#ifndef QVTKGBOBJECT3DVIEWER_H
-#define QVTGBOBJECT3DKVIEWER_H
-
-#include "./../../../userinterface/viewer3d/QVTKViewer3DApplication.h"
-
-class QVTKWindow;
-class QVTKViewer3D;
-class GbObject3DManager;
-class OctNodeGridManager;
-
-class QVTKGbObject3DViewer : public QVTKViewer3DApplication
-{
-public:
-	QVTKGbObject3DViewer();
-	~QVTKGbObject3DViewer();
-   
-protected:
-
-	GbObject3DManager* gbObject3DManager;
-
-};
-#endif
+#ifndef QVTKGBOBJECT3DVIEWER_H
+#define QVTGBOBJECT3DKVIEWER_H
+
+#include "./../../../userinterface/viewer3d/QVTKViewer3DApplication.h"
+
+class QVTKWindow;
+class QVTKViewer3D;
+class GbObject3DManager;
+class OctNodeGridManager;
+
+class QVTKGbObject3DViewer : public QVTKViewer3DApplication
+{
+public:
+	QVTKGbObject3DViewer();
+	~QVTKGbObject3DViewer();
+   
+protected:
+
+	GbObject3DManager* gbObject3DManager;
+
+};
+#endif
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCuboid3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbCuboid3D.cpp
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCuboid3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbCuboid3D.cpp
index 2b8f66a91310bab57f97509ead907aef21c3be25..bfd53a09c4a053c79f0593bbba8286483a42649b 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCuboid3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbCuboid3D.cpp
@@ -1,144 +1,144 @@
-#include "./vtkGbCuboid3D.h"
-
-#include "./../GbCuboid3D.h"
-#include "./../../../userinterface/presentation/vtkEventCallbacks.h"
-
-#include "vtkCubeSource.h"
-#include "vtkPolyDataMapper.h"
-//#include "math.h"
-
-vtkGbCuboid3D::vtkGbCuboid3D(GbCuboid3D* gbObject)
-{
-	this->gbCuboid = gbObject;
-	this->gbCuboid->addObserver(this);
-
-   this->setName("vtkGbCuboid3D");
-
-	this->source = vtkCubeSource::New();
-   this->mapper = vtkPolyDataMapper::New();
-
-	this->setValues();
-
-	this->mapper->SetInput( this->source->GetOutput() );
-	this->actor->SetMapper( this->mapper );
-}
-
-vtkGbCuboid3D::~vtkGbCuboid3D(void)
-{
-   this->gbCuboid->removeObserver(this);
-	if (this->source) this->source->Delete();
-}
-
-//void vtkGbCuboid3D::ModifiedEventFired()
-//{
-//	//double a_orien[3];
-//	double a_pos[3];
-//	this->actor->GetPosition(a_pos);
-//	//this->actor->GetOrientation(a_orien);
-//	this->actor->SetPosition(0.0,0.0,0.0);
-//	this->actor->SetOrientation(0.0,0.0,0.0);
-//	this->actor->SetScale(1.0,1.0,1.0);
-//
-//	//cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl;
-//	//cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl;
-//
-//	this->gbCuboid->translate(a_pos[0], a_pos[1], a_pos[2]);
-//	this->gbCuboid->notifyObserversObjectChanged();
-//}
-
-void vtkGbCuboid3D::applyActorModifications()
-{
-	if (isModified) 
-	{
-		double pos[3];
-		double scale[3];
-		//double orien[3];
-		this->actor->GetPosition(pos);
-		this->actor->GetScale(scale);
-		//this->actor->GetOrientation(orien);
-
-		this->actor->SetPosition(0.0,0.0,0.0);
-		this->actor->SetOrientation(0.0,0.0,0.0);
-		this->actor->SetScale(1.0,1.0,1.0);
-
-		//cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl;
-		//cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl;
-
-
-		////////////////////////////////////////////////////////////////////////////
-		////Rotieren
-		////[Cy x1 + Sy x3, x2, -Sy x1 + Cy x3, 1]
-		//double center[3];
-		//center[0] = this->gbCuboid->getX1Centroid();
-		//center[1] = this->gbCuboid->getX2Centroid();
-		//center[2] = this->gbCuboid->getX3Centroid();
-
-		////Punkt1
-		//double p1x = this->gbCuboid->getPoint1()->getX1Coordinate();
-		//double p1y = this->gbCuboid->getPoint1()->getX2Coordinate();
-		//double p1z = this->gbCuboid->getPoint1()->getX3Coordinate();
-
-		//p1x = cos(orien[1]) * p1x + sin(orien[1]) * p1z;
-		////p1y = p1y;
-		//p1z = -sin(orien[1]) * p1x + cos(orien[1]) * p1z;
-
-		//this->gbCuboid->getPoint1()->setX1(p1x);
-		//this->gbCuboid->getPoint1()->setX2(p1y);
-		//this->gbCuboid->getPoint1()->setX3(p1z);
-
-		//
-		////Punkt2
-		//double p2x = this->gbCuboid->getPoint2()->getX1Coordinate();
-		//double p2y = this->gbCuboid->getPoint2()->getX2Coordinate();
-		//double p2z = this->gbCuboid->getPoint2()->getX3Coordinate();
-
-		//p2x = cos(orien[1]) * p2x + sin(orien[1]) * p2z;
-		////p1y = p1y;
-		//p2z = -sin(orien[1]) * p2x + cos(orien[1]) * p2z;
-
-		//this->gbCuboid->getPoint2()->setX1(p2x);
-		//this->gbCuboid->getPoint2()->setX2(p2y);
-		//this->gbCuboid->getPoint2()->setX3(p2z);
-		//
-		////////////////////////////////////////////////////////////////////////////
-
-		if (scale[0] != 1.0) this->gbCuboid->scale(scale[0], scale[1], scale[2]);
-		else this->gbCuboid->translate(pos[0], pos[1], pos[2]);
-		this->gbCuboid->notifyObserversObjectChanged();
-
-		//Methode der Basisklasse aufrufen.
-		vtkPoElement3D::applyActorModifications();
-	}
-}
-
-void vtkGbCuboid3D::setValues(void)
-{
-	double bounds[6];
-	bounds[0] = this->gbCuboid->getX1Minimum();
-	bounds[1] = this->gbCuboid->getX1Maximum();
-	bounds[2] = this->gbCuboid->getX2Minimum();
-	bounds[3] = this->gbCuboid->getX2Maximum();
-	bounds[4] = this->gbCuboid->getX3Minimum();
-	bounds[5] = this->gbCuboid->getX3Maximum();
-	this->source->SetBounds(bounds);
-
-//	this->actor->SetVisibility( this->gbCuboid->isActive() );
-}
-
-bool vtkGbCuboid3D::isPointInObject(double const point[3])
-{
-	return this->gbCuboid->isPointInGbObject3D(point[0], point[1], point[2]);
-}
-
-void vtkGbCuboid3D::objectChanged(UbObservable*)
-{
-	this->setValues();
-	this->source->Update();
-}
-
-void vtkGbCuboid3D::objectWillBeDeleted(UbObservable*)
-{
-	//TODO: Hier muss auf jeden Fall noch was geschehen....
-	this->gbCuboid->removeObserver(this);
-	delete this;
-}
+#include "./vtkGbCuboid3D.h"
+
+#include "./../GbCuboid3D.h"
+#include "./../../../userinterface/presentation/vtkEventCallbacks.h"
+
+#include "vtkCubeSource.h"
+#include "vtkPolyDataMapper.h"
+//#include "math.h"
+
+vtkGbCuboid3D::vtkGbCuboid3D(GbCuboid3D* gbObject)
+{
+	this->gbCuboid = gbObject;
+	this->gbCuboid->addObserver(this);
+
+   this->setName("vtkGbCuboid3D");
+
+	this->source = vtkCubeSource::New();
+   this->mapper = vtkPolyDataMapper::New();
+
+	this->setValues();
+
+	this->mapper->SetInput( this->source->GetOutput() );
+	this->actor->SetMapper( this->mapper );
+}
+
+vtkGbCuboid3D::~vtkGbCuboid3D(void)
+{
+   this->gbCuboid->removeObserver(this);
+	if (this->source) this->source->Delete();
+}
+
+//void vtkGbCuboid3D::ModifiedEventFired()
+//{
+//	//double a_orien[3];
+//	double a_pos[3];
+//	this->actor->GetPosition(a_pos);
+//	//this->actor->GetOrientation(a_orien);
+//	this->actor->SetPosition(0.0,0.0,0.0);
+//	this->actor->SetOrientation(0.0,0.0,0.0);
+//	this->actor->SetScale(1.0,1.0,1.0);
+//
+//	//cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl;
+//	//cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl;
+//
+//	this->gbCuboid->translate(a_pos[0], a_pos[1], a_pos[2]);
+//	this->gbCuboid->notifyObserversObjectChanged();
+//}
+
+void vtkGbCuboid3D::applyActorModifications()
+{
+	if (isModified) 
+	{
+		double pos[3];
+		double scale[3];
+		//double orien[3];
+		this->actor->GetPosition(pos);
+		this->actor->GetScale(scale);
+		//this->actor->GetOrientation(orien);
+
+		this->actor->SetPosition(0.0,0.0,0.0);
+		this->actor->SetOrientation(0.0,0.0,0.0);
+		this->actor->SetScale(1.0,1.0,1.0);
+
+		//cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl;
+		//cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl;
+
+
+		////////////////////////////////////////////////////////////////////////////
+		////Rotieren
+		////[Cy x1 + Sy x3, x2, -Sy x1 + Cy x3, 1]
+		//double center[3];
+		//center[0] = this->gbCuboid->getX1Centroid();
+		//center[1] = this->gbCuboid->getX2Centroid();
+		//center[2] = this->gbCuboid->getX3Centroid();
+
+		////Punkt1
+		//double p1x = this->gbCuboid->getPoint1()->getX1Coordinate();
+		//double p1y = this->gbCuboid->getPoint1()->getX2Coordinate();
+		//double p1z = this->gbCuboid->getPoint1()->getX3Coordinate();
+
+		//p1x = cos(orien[1]) * p1x + sin(orien[1]) * p1z;
+		////p1y = p1y;
+		//p1z = -sin(orien[1]) * p1x + cos(orien[1]) * p1z;
+
+		//this->gbCuboid->getPoint1()->setX1(p1x);
+		//this->gbCuboid->getPoint1()->setX2(p1y);
+		//this->gbCuboid->getPoint1()->setX3(p1z);
+
+		//
+		////Punkt2
+		//double p2x = this->gbCuboid->getPoint2()->getX1Coordinate();
+		//double p2y = this->gbCuboid->getPoint2()->getX2Coordinate();
+		//double p2z = this->gbCuboid->getPoint2()->getX3Coordinate();
+
+		//p2x = cos(orien[1]) * p2x + sin(orien[1]) * p2z;
+		////p1y = p1y;
+		//p2z = -sin(orien[1]) * p2x + cos(orien[1]) * p2z;
+
+		//this->gbCuboid->getPoint2()->setX1(p2x);
+		//this->gbCuboid->getPoint2()->setX2(p2y);
+		//this->gbCuboid->getPoint2()->setX3(p2z);
+		//
+		////////////////////////////////////////////////////////////////////////////
+
+		if (scale[0] != 1.0) this->gbCuboid->scale(scale[0], scale[1], scale[2]);
+		else this->gbCuboid->translate(pos[0], pos[1], pos[2]);
+		this->gbCuboid->notifyObserversObjectChanged();
+
+		//Methode der Basisklasse aufrufen.
+		vtkPoElement3D::applyActorModifications();
+	}
+}
+
+void vtkGbCuboid3D::setValues(void)
+{
+	double bounds[6];
+	bounds[0] = this->gbCuboid->getX1Minimum();
+	bounds[1] = this->gbCuboid->getX1Maximum();
+	bounds[2] = this->gbCuboid->getX2Minimum();
+	bounds[3] = this->gbCuboid->getX2Maximum();
+	bounds[4] = this->gbCuboid->getX3Minimum();
+	bounds[5] = this->gbCuboid->getX3Maximum();
+	this->source->SetBounds(bounds);
+
+//	this->actor->SetVisibility( this->gbCuboid->isActive() );
+}
+
+bool vtkGbCuboid3D::isPointInObject(double const point[3])
+{
+	return this->gbCuboid->isPointInGbObject3D(point[0], point[1], point[2]);
+}
+
+void vtkGbCuboid3D::objectChanged(UbObservable*)
+{
+	this->setValues();
+	this->source->Update();
+}
+
+void vtkGbCuboid3D::objectWillBeDeleted(UbObservable*)
+{
+	//TODO: Hier muss auf jeden Fall noch was geschehen....
+	this->gbCuboid->removeObserver(this);
+	delete this;
+}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCuboid3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbCuboid3D.h
similarity index 95%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCuboid3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbCuboid3D.h
index e70fb61c53412a1c81a0f97a422def19ca8e3095..4163d44672b9be917f957a9aba2587adea00b639 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCuboid3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbCuboid3D.h
@@ -1,29 +1,29 @@
-#ifndef VTKGBCUBOID3D_H
-#define VTKGBCUBOID3D_H
-
-#include "./../../../userinterface/presentation/vtkPoElement3D.h"
-
-/**** vtk ****/
-class vtkCubeSource;
-class vtkPolyDataMapper;
-
-class GbCuboid3D;
-
-class vtkGbCuboid3D : public vtkPoElement3D
-{
-public:
-	vtkGbCuboid3D(GbCuboid3D*);
-	~vtkGbCuboid3D(void);
-	void objectChanged(UbObservable*);
-	void objectWillBeDeleted(UbObservable*);
-	//void ModifiedEventFired(void);
-	void applyActorModifications();
-	bool isPointInObject(double const point[3]);
-protected:
-	void setValues();
-
-	GbCuboid3D* gbCuboid;
-	vtkCubeSource* source;
-   vtkPolyDataMapper* mapper;
-};
-#endif   
+#ifndef VTKGBCUBOID3D_H
+#define VTKGBCUBOID3D_H
+
+#include "./../../../userinterface/presentation/vtkPoElement3D.h"
+
+/**** vtk ****/
+class vtkCubeSource;
+class vtkPolyDataMapper;
+
+class GbCuboid3D;
+
+class vtkGbCuboid3D : public vtkPoElement3D
+{
+public:
+	vtkGbCuboid3D(GbCuboid3D*);
+	~vtkGbCuboid3D(void);
+	void objectChanged(UbObservable*);
+	void objectWillBeDeleted(UbObservable*);
+	//void ModifiedEventFired(void);
+	void applyActorModifications();
+	bool isPointInObject(double const point[3]);
+protected:
+	void setValues();
+
+	GbCuboid3D* gbCuboid;
+	vtkCubeSource* source;
+   vtkPolyDataMapper* mapper;
+};
+#endif   
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCylinder3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbCylinder3D.cpp
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCylinder3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbCylinder3D.cpp
index 5f3c4111740f69e6af0d99ea8c0fa4e66d18ac51..77390a14658bc66769cb128db680611946842f17 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCylinder3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbCylinder3D.cpp
@@ -1,103 +1,103 @@
-#include "./vtkGbCylinder3D.h"
-
-#include "./../GbCylinder3D.h"
-#include "./../GbPoint3D.h"
-#include "./../../../userinterface/presentation/vtkEventCallbacks.h"
-
-#include "vtkCylinderSource.h"
-#include "vtkPolyDataMapper.h"
-
-
-vtkGbCylinder3D::vtkGbCylinder3D(GbCylinder3D* gbObject)
-{
-	this->gbCylinder = gbObject;
-	this->gbCylinder->addObserver(this);
-
-   this->setName("vtkGbCylinder3D");
-
-	this->source = vtkCylinderSource::New();
-   this->mapper = vtkPolyDataMapper::New();
-	
-	this->setValues();
-
-	this->mapper->SetInput( this->source->GetOutput() );
-	this->actor->SetMapper( this->mapper );
-
-   //this->applyActorModifications();
-}
-
-vtkGbCylinder3D::~vtkGbCylinder3D(void)
-{
-   this->gbCylinder->removeObserver(this);
-	if (this->source) this->source->Delete();
-}
-
-
-void vtkGbCylinder3D::setValues(void)
-{
-   //this->source->SetCenter(   this->gbCylinder->getX1Centroid(),
-   //                           this->gbCylinder->getX2Centroid(),
-   //                           this->gbCylinder->getX3Centroid());
-   //this->source->SetHeight(this->gbCylinder->getLength());
-   //this->source->SetRadius( this->gbCylinder->getRadius());
-
-   /* JZ Attention not ready still some work TODO*/
-   this->source->SetHeight(this->gbCylinder->getHeight());
-   this->source->SetCenter(this->gbCylinder->getX1Centroid(),
-                           this->gbCylinder->getX2Centroid(),
-                           this->gbCylinder->getX3Centroid());
-   this->source->SetRadius( this->gbCylinder->getRadius() );
-   this->source->SetResolution(10);
-}
-
-void vtkGbCylinder3D::applyActorModifications()
-{
-   //this->actor->SetScale(1.0, this->gbCylinder->getLength(), 1.0);
-   this->source->SetHeight(this->gbCylinder->getHeight());
-   this->actor->SetPosition(  this->gbCylinder->getPoint1()->x1,
-                              this->gbCylinder->getPoint1()->x2,
-                              this->gbCylinder->getPoint1()->x3);
-   this->source->SetRadius( this->gbCylinder->getRadius() );
-
-
-
-   //if (this->isModified)
-	//{
-	//	double pos[3];
-	//	double scale[3];
-	//	this->actor->GetPosition(pos);
-	//	this->actor->GetScale(scale);
-
-	//	this->actor->SetPosition(0.0,0.0,0.0);
-	//	this->actor->SetOrientation(0.0,0.0,0.0);
-	//	this->actor->SetScale(1.0,1.0,1.0);
-
-
-	//	if (scale[0] != 1.0) this->gbCylinder->scale(scale[0], scale[1], scale[2]);
-	//	else this->gbCylinder->translate(pos[0], pos[1], pos[2]);
-	//	this->gbCylinder->notifyObserversObjectChanged();
-
-	//	vtkPoElement3D::applyActorModifications();
-	//}
-}
-
-bool vtkGbCylinder3D::isPointInObject(double const point[3])
-{
-	return this->gbCylinder->isPointInGbObject3D(point[0], point[1], point[2]);
-}
-
-//Wird aufgerufen, wenn sich das zugehörige GBObject3D ändert.
-void vtkGbCylinder3D::objectChanged(UbObservable*)
-{
-   this->setValues();
-//	this->applyActorModifications();
-	this->source->Modified();
-}
-
-void vtkGbCylinder3D::objectWillBeDeleted(UbObservable*)
-{
-	//TODO: Hier muss auf jeden Fall noch was geschehen....
-	this->gbCylinder->removeObserver(this);
-	delete this;
-}
-
+#include "./vtkGbCylinder3D.h"
+
+#include "./../GbCylinder3D.h"
+#include "./../GbPoint3D.h"
+#include "./../../../userinterface/presentation/vtkEventCallbacks.h"
+
+#include "vtkCylinderSource.h"
+#include "vtkPolyDataMapper.h"
+
+
+vtkGbCylinder3D::vtkGbCylinder3D(GbCylinder3D* gbObject)
+{
+	this->gbCylinder = gbObject;
+	this->gbCylinder->addObserver(this);
+
+   this->setName("vtkGbCylinder3D");
+
+	this->source = vtkCylinderSource::New();
+   this->mapper = vtkPolyDataMapper::New();
+	
+	this->setValues();
+
+	this->mapper->SetInput( this->source->GetOutput() );
+	this->actor->SetMapper( this->mapper );
+
+   //this->applyActorModifications();
+}
+
+vtkGbCylinder3D::~vtkGbCylinder3D(void)
+{
+   this->gbCylinder->removeObserver(this);
+	if (this->source) this->source->Delete();
+}
+
+
+void vtkGbCylinder3D::setValues(void)
+{
+   //this->source->SetCenter(   this->gbCylinder->getX1Centroid(),
+   //                           this->gbCylinder->getX2Centroid(),
+   //                           this->gbCylinder->getX3Centroid());
+   //this->source->SetHeight(this->gbCylinder->getLength());
+   //this->source->SetRadius( this->gbCylinder->getRadius());
+
+   /* JZ Attention not ready still some work TODO*/
+   this->source->SetHeight(this->gbCylinder->getHeight());
+   this->source->SetCenter(this->gbCylinder->getX1Centroid(),
+                           this->gbCylinder->getX2Centroid(),
+                           this->gbCylinder->getX3Centroid());
+   this->source->SetRadius( this->gbCylinder->getRadius() );
+   this->source->SetResolution(10);
+}
+
+void vtkGbCylinder3D::applyActorModifications()
+{
+   //this->actor->SetScale(1.0, this->gbCylinder->getLength(), 1.0);
+   this->source->SetHeight(this->gbCylinder->getHeight());
+   this->actor->SetPosition(  this->gbCylinder->getPoint1()->x1,
+                              this->gbCylinder->getPoint1()->x2,
+                              this->gbCylinder->getPoint1()->x3);
+   this->source->SetRadius( this->gbCylinder->getRadius() );
+
+
+
+   //if (this->isModified)
+	//{
+	//	double pos[3];
+	//	double scale[3];
+	//	this->actor->GetPosition(pos);
+	//	this->actor->GetScale(scale);
+
+	//	this->actor->SetPosition(0.0,0.0,0.0);
+	//	this->actor->SetOrientation(0.0,0.0,0.0);
+	//	this->actor->SetScale(1.0,1.0,1.0);
+
+
+	//	if (scale[0] != 1.0) this->gbCylinder->scale(scale[0], scale[1], scale[2]);
+	//	else this->gbCylinder->translate(pos[0], pos[1], pos[2]);
+	//	this->gbCylinder->notifyObserversObjectChanged();
+
+	//	vtkPoElement3D::applyActorModifications();
+	//}
+}
+
+bool vtkGbCylinder3D::isPointInObject(double const point[3])
+{
+	return this->gbCylinder->isPointInGbObject3D(point[0], point[1], point[2]);
+}
+
+//Wird aufgerufen, wenn sich das zugehörige GBObject3D ändert.
+void vtkGbCylinder3D::objectChanged(UbObservable*)
+{
+   this->setValues();
+//	this->applyActorModifications();
+	this->source->Modified();
+}
+
+void vtkGbCylinder3D::objectWillBeDeleted(UbObservable*)
+{
+	//TODO: Hier muss auf jeden Fall noch was geschehen....
+	this->gbCylinder->removeObserver(this);
+	delete this;
+}
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCylinder3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbCylinder3D.h
similarity index 95%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCylinder3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbCylinder3D.h
index b6a37f1979e7c170ec49f7d63cda5dd514f1557f..19da3417b3e00941385cc2a5bb1132257163735a 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbCylinder3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbCylinder3D.h
@@ -1,30 +1,30 @@
-#ifndef VTKGBCYLINDER3D_H
-#define VTKGBCYLINDER3D_H
-
-#include "./../../../userinterface/presentation/vtkPoElement3D.h"
-
-class GbCylinder3D;
-
-class vtkCylinderSource;
-class vtkPolyDataMapper;
-
-
-class vtkGbCylinder3D : public vtkPoElement3D
-{
-public:
-	vtkGbCylinder3D(GbCylinder3D* cylinder);
-	~vtkGbCylinder3D();
-	void objectChanged(UbObservable*);
-	void objectWillBeDeleted(UbObservable*);
-	//void ModifiedEventFired(void);
-	void applyActorModifications();             
-	bool isPointInObject(double const point[3]);
-protected:
-	void setValues();
-
-	GbCylinder3D* gbCylinder;
-   vtkCylinderSource* source;
-   vtkPolyDataMapper* mapper;
-};
-#endif   
-
+#ifndef VTKGBCYLINDER3D_H
+#define VTKGBCYLINDER3D_H
+
+#include "./../../../userinterface/presentation/vtkPoElement3D.h"
+
+class GbCylinder3D;
+
+class vtkCylinderSource;
+class vtkPolyDataMapper;
+
+
+class vtkGbCylinder3D : public vtkPoElement3D
+{
+public:
+	vtkGbCylinder3D(GbCylinder3D* cylinder);
+	~vtkGbCylinder3D();
+	void objectChanged(UbObservable*);
+	void objectWillBeDeleted(UbObservable*);
+	//void ModifiedEventFired(void);
+	void applyActorModifications();             
+	bool isPointInObject(double const point[3]);
+protected:
+	void setValues();
+
+	GbCylinder3D* gbCylinder;
+   vtkCylinderSource* source;
+   vtkPolyDataMapper* mapper;
+};
+#endif   
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbSphere3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbSphere3D.cpp
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbSphere3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbSphere3D.cpp
index 3ab7b25da151d5408fc154a149a05444b36bc849..bac51ecc1300d17e6b24527f22189b562298a0dd 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbSphere3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbSphere3D.cpp
@@ -1,112 +1,112 @@
-#include "./vtkGbSphere3D.h"
-
-#include "./../GbSphere3D.h"
-#include "./../../../userinterface/presentation/vtkEventCallbacks.h"
-
-#include "vtkSphereSource.h"
-#include "vtkPolyDataMapper.h"
-
-
-vtkGbSphere3D::vtkGbSphere3D(GbSphere3D* gbObject):vtkPoElement3D()
-{
-	this->gbSphere = gbObject;
-	this->gbSphere->addObserver(this);
-   
-   this->setName("vtkGbSphere3D");
-
-
-	this->source = vtkSphereSource::New();
-   this->mapper = vtkPolyDataMapper::New();
-	
-	this->setValues();
-
-	this->mapper->SetInput( this->source->GetOutput() );
-	this->actor->SetMapper( this->mapper );
-//	this->actor->GetProperty()->SetRepresentationToWireframe();
-}
-
-vtkGbSphere3D::~vtkGbSphere3D(void)
-{
-   this->gbSphere->removeObserver(this);
-	if (this->source) this->source->Delete();
-}
-
-//void vtkGbSphere3D::ModifiedEventFired()
-//{
-//	////double a_orien[3];
-//	//double a_pos[3];
-//	////double a_scale[3];
-//	//this->actor->GetPosition(a_pos);
-//	////this->actor->GetOrientation(a_orien);
-//	////this->actor->GetScale(a_scale);
-//
-//	//this->actor->SetPosition(0.0,0.0,0.0);
-//	//this->actor->SetOrientation(0.0,0.0,0.0);
-//	//this->actor->SetScale(1.0,1.0,1.0);
-//	//
-//	////cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl;
-//	////cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl;
-//	////cout<<"Scale:"<<a_scale[0]<<","<<a_scale[1]<<","<<a_scale[3]<<endl;
-//
-//	//this->gbSphere->translate(a_pos[0], a_pos[1], a_pos[2]);
-//	//this->gbSphere->notifyObserversObjectChanged();
-//	PoElement3D::ModifiedEventFired();
-//}
-
-void vtkGbSphere3D::setValues(void)
-{
-	this->source->SetCenter(	this->gbSphere->getX1Centroid(),
-								this->gbSphere->getX2Centroid(),
-								this->gbSphere->getX3Centroid()	);
-	
-	this->source->SetRadius( this->gbSphere->getRadius() );
-//	this->actor->SetVisibility( this->gbSphere->isActive() );
-}
-
-void vtkGbSphere3D::applyActorModifications()
-{
-	if (this->isModified)
-	{
-		//double a_orien[3];
-		double pos[3];
-		double scale[3];
-		this->actor->GetPosition(pos);
-		//this->actor->GetOrientation(a_orien);
-		this->actor->GetScale(scale);
-
-		this->actor->SetPosition(0.0,0.0,0.0);
-		this->actor->SetOrientation(0.0,0.0,0.0);
-		this->actor->SetScale(1.0,1.0,1.0);
-
-		//cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl;
-		//cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl;
-		//cout<<"Scale:"<<a_scale[0]<<","<<a_scale[1]<<","<<a_scale[3]<<endl;
-
-		if (scale[0] != 1.0) this->gbSphere->scale(scale[0], scale[1], scale[2]);
-		else this->gbSphere->translate(pos[0], pos[1], pos[2]);
-		this->gbSphere->notifyObserversObjectChanged();
-
-		vtkPoElement3D::applyActorModifications();
-	}
-}
-
-bool vtkGbSphere3D::isPointInObject(double const point[3])
-{
-	return this->gbSphere->isPointInGbObject3D(point[0], point[1], point[2]);
-}
-
-//Wird aufgerufen, wenn sich das zugehörige GBObject3D ändert.
-void vtkGbSphere3D::objectChanged(UbObservable*)
-{
-	this->setValues();
-	this->source->Modified();
-	this->actor->Modified();
-}
-
-void vtkGbSphere3D::objectWillBeDeleted(UbObservable*)
-{
-	//TODO: Hier muss auf jeden Fall noch was geschehen....
-	this->gbSphere->removeObserver(this);
-	delete this;
-}
-
+#include "./vtkGbSphere3D.h"
+
+#include "./../GbSphere3D.h"
+#include "./../../../userinterface/presentation/vtkEventCallbacks.h"
+
+#include "vtkSphereSource.h"
+#include "vtkPolyDataMapper.h"
+
+
+vtkGbSphere3D::vtkGbSphere3D(GbSphere3D* gbObject):vtkPoElement3D()
+{
+	this->gbSphere = gbObject;
+	this->gbSphere->addObserver(this);
+   
+   this->setName("vtkGbSphere3D");
+
+
+	this->source = vtkSphereSource::New();
+   this->mapper = vtkPolyDataMapper::New();
+	
+	this->setValues();
+
+	this->mapper->SetInput( this->source->GetOutput() );
+	this->actor->SetMapper( this->mapper );
+//	this->actor->GetProperty()->SetRepresentationToWireframe();
+}
+
+vtkGbSphere3D::~vtkGbSphere3D(void)
+{
+   this->gbSphere->removeObserver(this);
+	if (this->source) this->source->Delete();
+}
+
+//void vtkGbSphere3D::ModifiedEventFired()
+//{
+//	////double a_orien[3];
+//	//double a_pos[3];
+//	////double a_scale[3];
+//	//this->actor->GetPosition(a_pos);
+//	////this->actor->GetOrientation(a_orien);
+//	////this->actor->GetScale(a_scale);
+//
+//	//this->actor->SetPosition(0.0,0.0,0.0);
+//	//this->actor->SetOrientation(0.0,0.0,0.0);
+//	//this->actor->SetScale(1.0,1.0,1.0);
+//	//
+//	////cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl;
+//	////cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl;
+//	////cout<<"Scale:"<<a_scale[0]<<","<<a_scale[1]<<","<<a_scale[3]<<endl;
+//
+//	//this->gbSphere->translate(a_pos[0], a_pos[1], a_pos[2]);
+//	//this->gbSphere->notifyObserversObjectChanged();
+//	PoElement3D::ModifiedEventFired();
+//}
+
+void vtkGbSphere3D::setValues(void)
+{
+	this->source->SetCenter(	this->gbSphere->getX1Centroid(),
+								this->gbSphere->getX2Centroid(),
+								this->gbSphere->getX3Centroid()	);
+	
+	this->source->SetRadius( this->gbSphere->getRadius() );
+//	this->actor->SetVisibility( this->gbSphere->isActive() );
+}
+
+void vtkGbSphere3D::applyActorModifications()
+{
+	if (this->isModified)
+	{
+		//double a_orien[3];
+		double pos[3];
+		double scale[3];
+		this->actor->GetPosition(pos);
+		//this->actor->GetOrientation(a_orien);
+		this->actor->GetScale(scale);
+
+		this->actor->SetPosition(0.0,0.0,0.0);
+		this->actor->SetOrientation(0.0,0.0,0.0);
+		this->actor->SetScale(1.0,1.0,1.0);
+
+		//cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl;
+		//cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl;
+		//cout<<"Scale:"<<a_scale[0]<<","<<a_scale[1]<<","<<a_scale[3]<<endl;
+
+		if (scale[0] != 1.0) this->gbSphere->scale(scale[0], scale[1], scale[2]);
+		else this->gbSphere->translate(pos[0], pos[1], pos[2]);
+		this->gbSphere->notifyObserversObjectChanged();
+
+		vtkPoElement3D::applyActorModifications();
+	}
+}
+
+bool vtkGbSphere3D::isPointInObject(double const point[3])
+{
+	return this->gbSphere->isPointInGbObject3D(point[0], point[1], point[2]);
+}
+
+//Wird aufgerufen, wenn sich das zugehörige GBObject3D ändert.
+void vtkGbSphere3D::objectChanged(UbObservable*)
+{
+	this->setValues();
+	this->source->Modified();
+	this->actor->Modified();
+}
+
+void vtkGbSphere3D::objectWillBeDeleted(UbObservable*)
+{
+	//TODO: Hier muss auf jeden Fall noch was geschehen....
+	this->gbSphere->removeObserver(this);
+	delete this;
+}
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbSphere3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbSphere3D.h
similarity index 95%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbSphere3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbSphere3D.h
index ec086a6470c0330dbeed2e0566c583f9ff3a50bf..dd6c1f696d60757ba38d7c6bbc7575cfa3467921 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbSphere3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbSphere3D.h
@@ -1,33 +1,33 @@
-#ifndef VTKGBSPHERE3D_H
-#define VTKGBSPHERE3D_H
-
-#include "./../../../userinterface/presentation/vtkPoElement3D.h"
-//#include "./../../../../vtkEventListeners.h"
-
-class GbSphere3D;
-
-class vtkSphereSource;
-class vtkPolyDataMapper;
-
-class vtkGbSphere3D : public vtkPoElement3D
-{
-public:
-	vtkGbSphere3D(GbSphere3D*);
-	~vtkGbSphere3D(void);
-	void objectChanged(UbObservable*);
-	void objectWillBeDeleted(UbObservable*);
-	//void ModifiedEventFired(void);
-	void applyActorModifications(); 
-	bool isPointInObject(double const point[3]);
-
-   virtual string toString() { return "vtkGbSphere3D";  }
-
-protected:
-	void setValues();
-
-	GbSphere3D* gbSphere;
-   vtkPolyDataMapper* mapper;
-	vtkSphereSource* source;
-};
-#endif   
-
+#ifndef VTKGBSPHERE3D_H
+#define VTKGBSPHERE3D_H
+
+#include "./../../../userinterface/presentation/vtkPoElement3D.h"
+//#include "./../../../../vtkEventListeners.h"
+
+class GbSphere3D;
+
+class vtkSphereSource;
+class vtkPolyDataMapper;
+
+class vtkGbSphere3D : public vtkPoElement3D
+{
+public:
+	vtkGbSphere3D(GbSphere3D*);
+	~vtkGbSphere3D(void);
+	void objectChanged(UbObservable*);
+	void objectWillBeDeleted(UbObservable*);
+	//void ModifiedEventFired(void);
+	void applyActorModifications(); 
+	bool isPointInObject(double const point[3]);
+
+   virtual string toString() { return "vtkGbSphere3D";  }
+
+protected:
+	void setValues();
+
+	GbSphere3D* gbSphere;
+   vtkPolyDataMapper* mapper;
+	vtkSphereSource* source;
+};
+#endif   
+
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp
index 92f08be6390098e56a82d6382aa29c56250190e3..f772e7c97b4bcb3948b09f9171b89325ebf78a6f 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp
@@ -1,167 +1,167 @@
-#include "./vtkGbTriangularMesh3D.h"
-
-/**** CAB ****/
-#include "./../GbTriangularMesh3D.h"
-#include "./../GbTriangle3D.h"
-#include "./../../../basics/utilities/UbMath.h"
-
-/**** vtk ****/
-#include "vtkUnstructuredGrid.h"
-#include "vtkDataSetMapper.h"
-#include "vtkPoints.h"
-#include "vtkTriangle.h"
-#include "vtkIdList.h"
-
-/*** temp ****/
-#include "./../GbPoint3D.h"
-#include "vtkMatrix4x4.h"
-
-//#define PI   3.14159265358979323846
-
-vtkGbTriangularMesh3D::vtkGbTriangularMesh3D(GbTriangularMesh3D* mesh)
-{
-	this->gbTriangularMesh = mesh;
-	this->gbTriangularMesh->addObserver(this);
-
-   this->setName("vtkGbTriangularMesh3D");
-
-	this->unstGrid = vtkUnstructuredGrid::New();
-	this->buildGrid();
-
-	
-	this->dataSetMapper = vtkDataSetMapper::New();
-	this->dataSetMapper->SetInput(unstGrid);
-
-	this->actor->SetMapper( this->dataSetMapper );
-}
-
-vtkGbTriangularMesh3D::~vtkGbTriangularMesh3D(void)
-{
-   this->gbTriangularMesh->removeObserver(this);
-	this->unstGrid->Delete();
-	this->dataSetMapper->Delete();
-}
-
-//void vtkGbTriangularMesh3D::ModifiedEventFired()
-//{
-//	double pos[3];
-//	this->actor->GetPosition(pos);
-//
-//	this->actor->SetPosition(0.0,0.0,0.0);
-//	this->actor->SetOrientation(0.0,0.0,0.0);
-//	this->actor->SetScale(1.0,1.0,1.0);
-//
-//	double x1 = pos[0];
-//	double x2 = pos[1];
-//	double x3 = pos[3];
-//
-//	vector<GbPoint3D*>* pointList = this->gbTriangularMesh->getNodes();
-//	for (int pos=0; pos<pointList->size(); pos++) 
-//	{
-//		(*pointList)[pos]->translate(x1,x2,x3);
-//		//((*pointList)[pos])->translate(pos[0], pos[1], pos[3]);
-//	}
-//	this->gbTriangularMesh->notifyObserversObjectChanged();
-//}
-
-void vtkGbTriangularMesh3D::applyActorModifications()
-{
-	if (isModified) 
-	{
-		double pos[3];
-		double orien[3];
-		double scale[3];
-		this->actor->GetPosition(pos);
-		this->actor->GetOrientation(orien);
-		this->actor->GetScale(scale);
-
-      orien[0] = orien[0] / 180 * UbMath::PI;
-		orien[1] = orien[1] / 180 * UbMath::PI;
-		orien[2] = orien[2] / 180 * UbMath::PI;
-
-		//cout<<"Orien:"<<orien[0]<<","<<orien[1]<<","<<orien[3]<<endl;
-		//cout<<"Position:"<<pos[0]<<","<<pos[1]<<","<<pos[3]<<endl;
-		//cout<<"Scale:"<<scale[0]<<","<<scale[1]<<","<<scale[3]<<endl;
-		
-		this->actor->SetPosition(0.0,0.0,0.0);
-		this->actor->SetOrientation(0.0,0.0,0.0);
-		this->actor->SetScale(1.0,1.0,1.0);
-		
-		vector<GbPoint3D*>* pointList = this->gbTriangularMesh->getNodes();
-		for (int index=0; index<(int)pointList->size(); index++) 
-		{
-			(*pointList)[index]->rotate(orien[0], orien[1], orien[2]);
-			(*pointList)[index]->scale(scale[0], scale[1], scale[2]);
-			(*pointList)[index]->translate(pos[0], pos[1], pos[2]);
-		}
-		this->gbTriangularMesh->notifyObserversObjectChanged();
-		//Methode der Basisklasse aufrufen.
-		vtkPoElement3D::applyActorModifications();
-	}
-}
-
-void vtkGbTriangularMesh3D::buildGrid(void)
-{
-	this->unstGrid->Reset();
-
-	vector<GbTriangle3D*>* triangles = this->gbTriangularMesh->getTriangles();
-	double xyz[3];
-	//this.setContext(new PoContext3D());
-
-	vtkPoints* points  = vtkPoints::New();
-	vtkTriangle* triangle = vtkTriangle::New();
-	for(int u=0; u<(int)triangles->size(); u++)
-	{
-		xyz[0] = (*triangles)[u]->getPoint(0)->getX1Coordinate();
-		xyz[1] = (*triangles)[u]->getPoint(0)->getX2Coordinate();
-		xyz[2] = (*triangles)[u]->getPoint(0)->getX3Coordinate();
-		triangle->GetPointIds()->InsertId(0, points->InsertNextPoint(xyz));
-		//points.InsertPoint(u, xyz);       // 3D geometry
-
-		xyz[0] = (*triangles)[u]->getPoint(1)->getX1Coordinate();
-		xyz[1] = (*triangles)[u]->getPoint(1)->getX2Coordinate();
-		xyz[2] = (*triangles)[u]->getPoint(1)->getX3Coordinate();
-		triangle->GetPointIds()->InsertId(1, points->InsertNextPoint(xyz));
-		//points.InsertPoint(u, xyz);       // 3D geometry
-
-		xyz[0] = (*triangles)[u]->getPoint(2)->getX1Coordinate();
-		xyz[1] = (*triangles)[u]->getPoint(2)->getX2Coordinate();
-		xyz[2] = (*triangles)[u]->getPoint(2)->getX3Coordinate();
-		triangle->GetPointIds()->InsertId(2, points->InsertNextPoint(xyz));
-		//points.InsertPoint(u, xyz);       // 3D geometry
-
-		this->insertNextCell( triangle->GetCellType(), triangle->GetPointIds() ); // grid topology
-
-	}
-	this->setPoints(points);
-	//this->source->SetCenter(	this->gbSphere->getX1Centroid(),
-	//	this->gbSphere->getX2Centroid(),
-	//	this->gbSphere->getX3Centroid()	);
-
-	//this->source->SetRadius( this->gbSphere->getRadius() );
-	//this->actor->SetVisibility( this->gbSphere->isActive() );
-	//this->unstGrid->Modified();
-}
-
-int vtkGbTriangularMesh3D::insertNextCell(int type, vtkIdList* idList)
-{
-	return this->unstGrid->InsertNextCell(type, idList);
-}
-
-void vtkGbTriangularMesh3D::setPoints(vtkPoints* points)
-{
-	this->unstGrid->SetPoints(points);
-}
-
-void vtkGbTriangularMesh3D::objectChanged(UbObservable*)
-{
-	this->buildGrid();
-	this->unstGrid->Update();
-}
-
-void vtkGbTriangularMesh3D::objectWillBeDeleted(UbObservable*)
-{
-	//TODO: Hier muss auf jeden Fall noch was geschehen....
-	this->gbTriangularMesh->removeObserver(this);
-	delete this;
-}
+#include "./vtkGbTriangularMesh3D.h"
+
+/**** CAB ****/
+#include "./../GbTriangularMesh3D.h"
+#include "./../GbTriangle3D.h"
+#include "./../../../basics/utilities/UbMath.h"
+
+/**** vtk ****/
+#include "vtkUnstructuredGrid.h"
+#include "vtkDataSetMapper.h"
+#include "vtkPoints.h"
+#include "vtkTriangle.h"
+#include "vtkIdList.h"
+
+/*** temp ****/
+#include "./../GbPoint3D.h"
+#include "vtkMatrix4x4.h"
+
+//#define PI   3.14159265358979323846
+
+vtkGbTriangularMesh3D::vtkGbTriangularMesh3D(GbTriangularMesh3D* mesh)
+{
+	this->gbTriangularMesh = mesh;
+	this->gbTriangularMesh->addObserver(this);
+
+   this->setName("vtkGbTriangularMesh3D");
+
+	this->unstGrid = vtkUnstructuredGrid::New();
+	this->buildGrid();
+
+	
+	this->dataSetMapper = vtkDataSetMapper::New();
+	this->dataSetMapper->SetInput(unstGrid);
+
+	this->actor->SetMapper( this->dataSetMapper );
+}
+
+vtkGbTriangularMesh3D::~vtkGbTriangularMesh3D(void)
+{
+   this->gbTriangularMesh->removeObserver(this);
+	this->unstGrid->Delete();
+	this->dataSetMapper->Delete();
+}
+
+//void vtkGbTriangularMesh3D::ModifiedEventFired()
+//{
+//	double pos[3];
+//	this->actor->GetPosition(pos);
+//
+//	this->actor->SetPosition(0.0,0.0,0.0);
+//	this->actor->SetOrientation(0.0,0.0,0.0);
+//	this->actor->SetScale(1.0,1.0,1.0);
+//
+//	double x1 = pos[0];
+//	double x2 = pos[1];
+//	double x3 = pos[3];
+//
+//	vector<GbPoint3D*>* pointList = this->gbTriangularMesh->getNodes();
+//	for (int pos=0; pos<pointList->size(); pos++) 
+//	{
+//		(*pointList)[pos]->translate(x1,x2,x3);
+//		//((*pointList)[pos])->translate(pos[0], pos[1], pos[3]);
+//	}
+//	this->gbTriangularMesh->notifyObserversObjectChanged();
+//}
+
+void vtkGbTriangularMesh3D::applyActorModifications()
+{
+	if (isModified) 
+	{
+		double pos[3];
+		double orien[3];
+		double scale[3];
+		this->actor->GetPosition(pos);
+		this->actor->GetOrientation(orien);
+		this->actor->GetScale(scale);
+
+      orien[0] = orien[0] / 180 * UbMath::PI;
+		orien[1] = orien[1] / 180 * UbMath::PI;
+		orien[2] = orien[2] / 180 * UbMath::PI;
+
+		//cout<<"Orien:"<<orien[0]<<","<<orien[1]<<","<<orien[3]<<endl;
+		//cout<<"Position:"<<pos[0]<<","<<pos[1]<<","<<pos[3]<<endl;
+		//cout<<"Scale:"<<scale[0]<<","<<scale[1]<<","<<scale[3]<<endl;
+		
+		this->actor->SetPosition(0.0,0.0,0.0);
+		this->actor->SetOrientation(0.0,0.0,0.0);
+		this->actor->SetScale(1.0,1.0,1.0);
+		
+		vector<GbPoint3D*>* pointList = this->gbTriangularMesh->getNodes();
+		for (int index=0; index<(int)pointList->size(); index++) 
+		{
+			(*pointList)[index]->rotate(orien[0], orien[1], orien[2]);
+			(*pointList)[index]->scale(scale[0], scale[1], scale[2]);
+			(*pointList)[index]->translate(pos[0], pos[1], pos[2]);
+		}
+		this->gbTriangularMesh->notifyObserversObjectChanged();
+		//Methode der Basisklasse aufrufen.
+		vtkPoElement3D::applyActorModifications();
+	}
+}
+
+void vtkGbTriangularMesh3D::buildGrid(void)
+{
+	this->unstGrid->Reset();
+
+	vector<GbTriangle3D*>* triangles = this->gbTriangularMesh->getTriangles();
+	double xyz[3];
+	//this.setContext(new PoContext3D());
+
+	vtkPoints* points  = vtkPoints::New();
+	vtkTriangle* triangle = vtkTriangle::New();
+	for(int u=0; u<(int)triangles->size(); u++)
+	{
+		xyz[0] = (*triangles)[u]->getPoint(0)->getX1Coordinate();
+		xyz[1] = (*triangles)[u]->getPoint(0)->getX2Coordinate();
+		xyz[2] = (*triangles)[u]->getPoint(0)->getX3Coordinate();
+		triangle->GetPointIds()->InsertId(0, points->InsertNextPoint(xyz));
+		//points.InsertPoint(u, xyz);       // 3D geometry
+
+		xyz[0] = (*triangles)[u]->getPoint(1)->getX1Coordinate();
+		xyz[1] = (*triangles)[u]->getPoint(1)->getX2Coordinate();
+		xyz[2] = (*triangles)[u]->getPoint(1)->getX3Coordinate();
+		triangle->GetPointIds()->InsertId(1, points->InsertNextPoint(xyz));
+		//points.InsertPoint(u, xyz);       // 3D geometry
+
+		xyz[0] = (*triangles)[u]->getPoint(2)->getX1Coordinate();
+		xyz[1] = (*triangles)[u]->getPoint(2)->getX2Coordinate();
+		xyz[2] = (*triangles)[u]->getPoint(2)->getX3Coordinate();
+		triangle->GetPointIds()->InsertId(2, points->InsertNextPoint(xyz));
+		//points.InsertPoint(u, xyz);       // 3D geometry
+
+		this->insertNextCell( triangle->GetCellType(), triangle->GetPointIds() ); // grid topology
+
+	}
+	this->setPoints(points);
+	//this->source->SetCenter(	this->gbSphere->getX1Centroid(),
+	//	this->gbSphere->getX2Centroid(),
+	//	this->gbSphere->getX3Centroid()	);
+
+	//this->source->SetRadius( this->gbSphere->getRadius() );
+	//this->actor->SetVisibility( this->gbSphere->isActive() );
+	//this->unstGrid->Modified();
+}
+
+int vtkGbTriangularMesh3D::insertNextCell(int type, vtkIdList* idList)
+{
+	return this->unstGrid->InsertNextCell(type, idList);
+}
+
+void vtkGbTriangularMesh3D::setPoints(vtkPoints* points)
+{
+	this->unstGrid->SetPoints(points);
+}
+
+void vtkGbTriangularMesh3D::objectChanged(UbObservable*)
+{
+	this->buildGrid();
+	this->unstGrid->Update();
+}
+
+void vtkGbTriangularMesh3D::objectWillBeDeleted(UbObservable*)
+{
+	//TODO: Hier muss auf jeden Fall noch was geschehen....
+	this->gbTriangularMesh->removeObserver(this);
+	delete this;
+}
diff --git a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h
similarity index 96%
rename from source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h
rename to source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h
index 6d59515f29789949e4cfd3094802d073a61690dc..968f98846794e0ca2095e85d7b922a1eba13994c 100644
--- a/source/ThirdParty/Library/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h
+++ b/source/VirtualFluidsBasic/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h
@@ -1,31 +1,31 @@
-#ifndef VTKGBTRIANGULARMESH3D_H
-#define VTKGBTRIANGULARMESH3D_H
-
-#include "./../../../userinterface/presentation/vtkPoElement3D.h"
-
-class GbTriangularMesh3D;
-class vtkUnstructuredGrid;
-class vtkDataSetMapper;
-class vtkIdList;
-class vtkPoints;
-
-class vtkGbTriangularMesh3D : public vtkPoElement3D
-{
-public:
-	vtkGbTriangularMesh3D(GbTriangularMesh3D* mesh);
-	~vtkGbTriangularMesh3D();
-	void objectChanged(UbObservable* );
-	void objectWillBeDeleted(UbObservable* );
-	int insertNextCell(int, vtkIdList*);
-	void setPoints(vtkPoints*);
-	//void ModifiedEventFired(void);
-	void applyActorModifications();
-protected:
-	void buildGrid();
-
-	GbTriangularMesh3D* gbTriangularMesh;
-	vtkUnstructuredGrid* unstGrid;
-	vtkDataSetMapper* dataSetMapper;
-};
-#endif   
-
+#ifndef VTKGBTRIANGULARMESH3D_H
+#define VTKGBTRIANGULARMESH3D_H
+
+#include "./../../../userinterface/presentation/vtkPoElement3D.h"
+
+class GbTriangularMesh3D;
+class vtkUnstructuredGrid;
+class vtkDataSetMapper;
+class vtkIdList;
+class vtkPoints;
+
+class vtkGbTriangularMesh3D : public vtkPoElement3D
+{
+public:
+	vtkGbTriangularMesh3D(GbTriangularMesh3D* mesh);
+	~vtkGbTriangularMesh3D();
+	void objectChanged(UbObservable* );
+	void objectWillBeDeleted(UbObservable* );
+	int insertNextCell(int, vtkIdList*);
+	void setPoints(vtkPoints*);
+	//void ModifiedEventFired(void);
+	void applyActorModifications();
+protected:
+	void buildGrid();
+
+	GbTriangularMesh3D* gbTriangularMesh;
+	vtkUnstructuredGrid* unstGrid;
+	vtkDataSetMapper* dataSetMapper;
+};
+#endif   
+
diff --git a/source/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.h
index d97af60907b7c97347a3d815ddf2cf0116e8a187..8c4f472bf1a8880bb4731006d9687dd13a2e3046 100644
--- a/source/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.h
+++ b/source/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.h
@@ -14,12 +14,5 @@ public:
    SPtr<BCAlgorithm> clone();
    void addDistributions(SPtr<DistributionArray3D> distributions);
    void applyBC() override;
-private:
-   //friend class boost::serialization::access;
-   //template<class Archive>
-   //void serialize(Archive & ar, const unsigned int version)
-   //{
-   //   ar & boost::serialization::base_object<BCAlgorithm>(*this);
-   //}
 };
 #endif // EqDensityBCAlgorithm_h__
diff --git a/source/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h
index 264540fa2f95b0212dba4fe365aa990b0d3c13ba..aacc41a5a6aafb0bdd9312bc6ccf0e8fc618a874 100644
--- a/source/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h
+++ b/source/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h
@@ -13,15 +13,7 @@ public:
    ~HighViscosityNoSlipBCAlgorithm();
    SPtr<BCAlgorithm> clone();
    void addDistributions(SPtr<DistributionArray3D> distributions);
-
    void applyBC() override;
-private:
-   //friend class boost::serialization::access;
-   //template<class Archive>
-   //void serialize(Archive & ar, const unsigned int version)
-   //{
-   //   ar & boost::serialization::base_object<BCAlgorithm>(*this);
-   //}
 };
 #endif // HighViscosityNoSlipBCAlgorithm_h__
 
diff --git a/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.h
index 8f18a31f6454682ede88b125b35bf1f8e7c5ed8d..402e2e2bb70286533aafb7992a6186d28eb0e360 100644
--- a/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.h
+++ b/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.h
@@ -15,11 +15,5 @@ public:
    void addDistributions(SPtr<DistributionArray3D> distributions);
    void applyBC() override;
 private:
-   //friend class boost::serialization::access;
-   //template<class Archive>
-   //void serialize(Archive & ar, const unsigned int version)
-   //{
-   //   ar & boost::serialization::base_object<BCAlgorithm>(*this);
-   //}
 };
 #endif // NoSlipBCAlgorithm_h__
diff --git a/source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.cpp b/source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.cpp
index 5222ca2becb126dfdda83f290d91f28698665bdd..865e2f1cf2a522a593890e9d3891ff1f31cc44fa 100644
--- a/source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.cpp
+++ b/source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.cpp
@@ -40,10 +40,14 @@ void NonEqDensityBCAlgorithm::applyBC()
    else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::S)) { nx2 += 1; direction = D3Q27System::S; }
    else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::T)) { nx3 -= 1; direction = D3Q27System::T; }
    else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::B)) { nx3 += 1; direction = D3Q27System::B; }
-   else UB_THROW(UbException(UB_EXARGS, "Danger...no orthogonal BC-Flag on density boundary..."));
+   else return; //UB_THROW(UbException(UB_EXARGS, "Danger...no orthogonal BC-Flag on density boundary..."));
 
    LBMReal rho, vx1, vx2, vx3;
    calcMacrosFct(f, rho, vx1, vx2, vx3);
+   //LBMReal vlimit=0.01;
+   //vx1=(fabs(vx1)>vlimit) ? vx1/fabs(vx1)*vlimit : vx1;
+   //vx2=(fabs(vx2)>vlimit) ? vx2/fabs(vx2)*vlimit : vx2;
+   //vx3=(fabs(vx3)>vlimit) ? vx3/fabs(vx3)*vlimit : vx3;
    LBMReal rhoBC = bcPtr->getBoundaryDensity();
    for (int fdir = D3Q27System::STARTF; fdir<=D3Q27System::ENDF; fdir++)
    {
@@ -52,6 +56,7 @@ void NonEqDensityBCAlgorithm::applyBC()
          // Martins NEQ ADDON
          ////original: 15.2.2013:
          LBMReal ftemp = calcFeqsForDirFct(fdir, rho, vx1, vx2, vx3);
+         //rhoBC=(rho>rhoBC)? rhoBC : rho; //Limiter 08.08.2018
          ftemp = calcFeqsForDirFct(fdir, rhoBC, vx1, vx2, vx3)+f[fdir]-ftemp;
          distributions->setDistributionForDirection(ftemp, nx1, nx2, nx3, fdir);
       }
diff --git a/source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.h
index 614c79bf34cb58f535d81af488205e762e6cc236..8cec91d6ec2e709dd23d0190c7422775b80319d0 100644
--- a/source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.h
+++ b/source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.h
@@ -14,12 +14,5 @@ public:
    SPtr<BCAlgorithm> clone();
    void addDistributions(SPtr<DistributionArray3D> distributions);
    void applyBC() override;
-private:
-   //friend class boost::serialization::access;
-   //template<class Archive>
-   //void serialize(Archive & ar, const unsigned int version)
-   //{
-   //   ar & boost::serialization::base_object<BCAlgorithm>(*this);
-   //}
 };
 #endif // NonEqDensityBCAlgorithm_h__
diff --git a/source/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.cpp b/source/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.cpp
index 31e80992a98ce0020d5019bed4d9db0362ca245f..149824f17c7d4472152571e617d9e766fe61a166 100644
--- a/source/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.cpp
+++ b/source/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.cpp
@@ -9,7 +9,6 @@ NonReflectingOutflowBCAlgorithm::NonReflectingOutflowBCAlgorithm()
 {
    BCAlgorithm::type = BCAlgorithm::NonReflectingOutflowBCAlgorithm;
    BCAlgorithm::preCollision = true;
-   step=0;
 }
 //////////////////////////////////////////////////////////////////////////
 NonReflectingOutflowBCAlgorithm::~NonReflectingOutflowBCAlgorithm()
diff --git a/source/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.h
index e2222f044c66c6ea1532fc4dbffb7f9aee3d1337..4effed280e073389eb1804983d6f7e10eb92aee0 100644
--- a/source/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.h
+++ b/source/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.h
@@ -14,13 +14,5 @@ public:
    SPtr<BCAlgorithm> clone();
    void addDistributions(SPtr<DistributionArray3D> distributions);
    void applyBC() override;
-private:
-   int step;
-   //friend class boost::serialization::access;
-   //template<class Archive>
-   //void serialize(Archive & ar, const unsigned int version)
-   //{
-   //   ar & boost::serialization::base_object<BCAlgorithm>(*this);
-   //}
 };
 #endif // NonReflectingDensityBCAlgorithm_h__
diff --git a/source/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.h
index ee3f23a578ea50888662462f9eb83f1cf66d0da8..423cde915386649f63ac259bf76afc1b02381109 100644
--- a/source/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.h
+++ b/source/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.h
@@ -14,12 +14,5 @@ public:
    SPtr<BCAlgorithm> clone();
    void addDistributions(SPtr<DistributionArray3D> distributions);
    void applyBC() override;
-private:
-   //friend class boost::serialization::access;
-   //template<class Archive>
-   //void serialize(Archive & ar, const unsigned int version)
-   //{
-   //   ar & boost::serialization::base_object<BCAlgorithm>(*this);
-   //}
 };
 #endif // SlipBCAlgorithm_h__
diff --git a/source/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.h
index 68e0ff273fda0c0dbd99c7dfdbf8f90466e075b4..6f54bc7666ebd96bd9df5b3b07c698f29ff945fe 100644
--- a/source/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.h
+++ b/source/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.h
@@ -21,12 +21,5 @@ protected:
 private:
    int pass;
    LBMReal fTemp[D3Q27System::ENDF + 1];
-
-   //friend class boost::serialization::access;
-   //template<class Archive>
-   //void serialize(Archive & ar, const unsigned int version)
-   //{
-   //   ar & boost::serialization::base_object<BCAlgorithm>(*this);
-   //}
 };
 #endif // ThinWallNoSlipBCAlgorithm_h__
diff --git a/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.h
index dca549cd4e48467212c31e32d249009a61e353c7..c33ae68167a097eb1cdc298c7de3c7a074ff61ce 100644
--- a/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.h
+++ b/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.h
@@ -13,15 +13,7 @@ public:
    ~VelocityBCAlgorithm();
    SPtr<BCAlgorithm> clone();
    void addDistributions(SPtr<DistributionArray3D> distributions);
-
    void applyBC() override;
-private:
-   //friend class boost::serialization::access;
-   //template<class Archive>
-   //void serialize(Archive & ar, const unsigned int version)
-   //{
-   //   ar & boost::serialization::base_object<BCAlgorithm>(*this);
-   //}
 };
 
 #endif // VelocityBoundaryCondition_h__
diff --git a/source/VirtualFluidsCore/BoundaryConditions/VelocityWithDensityBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/VelocityWithDensityBCAlgorithm.h
index 3de6b699071c6ca8014ff76f0de86def6283dc3d..25ec70608c1b8e54bc443207183b450e337b6884 100644
--- a/source/VirtualFluidsCore/BoundaryConditions/VelocityWithDensityBCAlgorithm.h
+++ b/source/VirtualFluidsCore/BoundaryConditions/VelocityWithDensityBCAlgorithm.h
@@ -20,12 +20,5 @@ public:
    SPtr<BCAlgorithm> clone();
    void addDistributions(SPtr<DistributionArray3D> distributions);
    void applyBC();
-private:
-   //friend class boost::serialization::access;
-   //template<class Archive>
-   //void serialize(Archive & ar, const unsigned int version)
-   //{
-   //   ar & boost::serialization::base_object<BCAlgorithm>(*this);
-   //}
 };
 #endif // NonReflectingVelocityBCAlgorithm_h__
diff --git a/source/VirtualFluidsCore/CMakeLists.txt b/source/VirtualFluidsCore/CMakeLists.txt
index 0999498e28df9af12b08599182cf41e41e01bd91..cb404d1cca19b29e4d05feaae19d7ca38f6f0c2f 100644
--- a/source/VirtualFluidsCore/CMakeLists.txt
+++ b/source/VirtualFluidsCore/CMakeLists.txt
@@ -6,19 +6,11 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 PROJECT(VirtualFluids)
   
 #################################################################
-###   PACKAGES						                        ###
+###   PACKAGES						                          ###
 #################################################################
 SET(WITH_SUBFOLDERS_FOR_SG TRUE)
-#old VirtualFluids
+
 INCLUDE(${SOURCE_ROOT}/ThirdParty/MuParser/CMakePackage.txt)
-#INCLUDE(${SOURCE_ROOT}/ThirdParty/MarchingCubes/CMakePackage.txt)
-#INCLUDE(${SOURCE_ROOT}/ThirdParty/Basics/objects/CMakePackage.txt)
-# INCLUDE(${SOURCE_ROOT}/ThirdParty/Basics/utilities/CMakePackage.txt)
-# #INCLUDE(${SOURCE_ROOT}/ThirdParty/Basics/memory/CMakePackage.txt)
-# INCLUDE(${SOURCE_ROOT}/ThirdParty/Basics/container/CMakePackage.txt)
-# INCLUDE(${SOURCE_ROOT}/ThirdParty/Basics/writer/CMakePackage.txt)
-# #INCLUDE(${SOURCE_ROOT}/ThirdParty/Basics/parallel/CMakePackage.txt)
-# INCLUDE(${SOURCE_ROOT}/ThirdParty/Basics/transmitter/CMakePackage.txt)
 
 #new VirtualFluids
 INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/BoundaryConditions/CMakePackage.txt)
@@ -31,22 +23,16 @@ INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/Grid/CMakePackage.txt)
 INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/Visitors/CMakePackage.txt)
 INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/CoProcessors/CMakePackage.txt)
 INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/Utilities/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/ThirdParty/Library/numerics/geometry3d/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/ThirdParty/Library/numerics/geometry3d/creator/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/ThirdParty/Library/numerics/geometry3d/KdTree/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/ThirdParty/Library/basics/objects/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/ThirdParty/Library/basics/memory/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/ThirdParty/Library/basics/utilities/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/ThirdParty/Library/basics/container/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/ThirdParty/Library/basics/writer/CMakePackage.txt)
-INCLUDE(${SOURCE_ROOT}/ThirdParty/Library/basics/transmitter/CMakePackage.txt)
+
+#old VirtualFluids
+INCLUDE(${SOURCE_ROOT}/VirtualFluidsBasic/VirtualFluidsBasic.cmake)
 
 #FETOL
 IF(${USE_FETOL})
 INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/FETOL/CMakePackage.txt)
 ENDIF()
 
-INCLUDE(${SOURCE_ROOT}/IncludsList.cmake)
+INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/IncludsList.cmake)
 
 #SET(CAB_ADDITIONAL_LINK_LIBRARIES muParserLib ${Boost_LIBRARIES} ${MPI_LIBRARY})
 SET(CAB_ADDITIONAL_LINK_LIBRARIES muParserLib ${MPI_LIBRARY})
@@ -104,6 +90,10 @@ IF(${USE_FETOL})
    SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY})
 ENDIF()
 
+IF(${USE_DEM_COUPLING})
+   INCLUDE(${SOURCE_ROOT}/DemCoupling/DemCoupling.cmake)
+ENDIF()
+
 message("CAB_ADDITIONAL_LINK_LIBRARIES: " ${CAB_ADDITIONAL_LINK_LIBRARIES})
 #################################################################
 ###   CREATE PROJECT                                          ###
diff --git a/source/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp
index 9ce1db8d324aff541a16130e6399c0dbd28661a3..a1e8404ecd6e628577d7b72e7d6df1552441fb80 100644
--- a/source/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp
+++ b/source/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp
@@ -145,6 +145,8 @@ void MPIIOMigrationCoProcessor::process(double step)
       writeDataSet((int)step);
       writeBoundaryConds((int)step);
 
+      writeCpTimeStep(step);
+
       if (comm->isRoot()) UBLOG(logINFO, "Save check point - end");
    }
 }
diff --git a/source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp
index 8fa5fafcbdb7a058ef2dd578109cbbb0fd070207..d4b4df1d02b7af997fd332abf6559fe82ec79556 100644
--- a/source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp
+++ b/source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp
@@ -22,12 +22,10 @@ WriteBoundaryConditionsCoProcessor::WriteBoundaryConditionsCoProcessor()
 }
 //////////////////////////////////////////////////////////////////////////
 WriteBoundaryConditionsCoProcessor::WriteBoundaryConditionsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s,
-   const std::string& path, WbWriter* const writer,
-   SPtr<LBMUnitConverter> conv, SPtr<Communicator> comm)
+   const std::string& path, WbWriter* const writer, SPtr<Communicator> comm)
    : CoProcessor(grid, s),
    path(path),
    writer(writer),
-   conv(conv),
    comm(comm)
 {
    gridRank = comm->getProcessID();
@@ -183,8 +181,8 @@ void WriteBoundaryConditionsCoProcessor::addDataGeo(SPtr<Block3D> block)
                   data[0].push_back(3.0);
                else if (bcArray->getBC(ix1, ix2, ix3)->hasSlipBoundary())
                   data[0].push_back(4.0);
-               else
-                  data[0].push_back(5.0);
+               //else
+               //   data[0].push_back(5.0);
 
 
                if (bcArray->isSolid(ix1, ix2, ix3))
diff --git a/source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h b/source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h
index 24d954b46ccdb075b0f57e1b54ed4f75c4682163..7e43b1c9cdfa630446567251b067c4127b18f547 100644
--- a/source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h
+++ b/source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h
@@ -20,8 +20,7 @@ class WriteBoundaryConditionsCoProcessor : public  CoProcessor
 public:
    WriteBoundaryConditionsCoProcessor();
    WriteBoundaryConditionsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s,
-      const std::string& path, WbWriter* const writer,
-       SPtr<LBMUnitConverter> conv, SPtr<Communicator> comm);
+      const std::string& path, WbWriter* const writer, SPtr<Communicator> comm);
    ~WriteBoundaryConditionsCoProcessor() {}
 
    void process(double step) override;
@@ -38,7 +37,6 @@ private:
    std::vector<std::vector<double> > data;
    std::string path;
    WbWriter* writer;
-   SPtr<LBMUnitConverter> conv;
    bool bcInformation;
    std::vector<std::vector<SPtr<Block3D> > > blockVector;
    int minInitLevel;
diff --git a/source/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.cpp
index 13ea06bcee63fe84a09e3c9fbc1de8f3540c65c8..5ee51000950a8eed7745fca0131236cd0d4afa2f 100644
--- a/source/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.cpp
+++ b/source/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.cpp
@@ -82,7 +82,6 @@ void WriteMacroscopicQuantitiesCoProcessor::collectData(double step)
    piece = subfolder + "/" + piece;
 
    std::vector<std::string> cellDataNames;
-   SPtr<Communicator> comm = Communicator::getInstance();
    std::vector<std::string> pieces = comm->gather(piece);
    if (comm->getProcessID() == comm->getRoot())
    {
diff --git a/source/VirtualFluidsCore/CoProcessors/WriteObjectsCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/WriteObjectsCoProcessor.cpp
deleted file mode 100644
index 2be2868d554cb57889d3d44986844c7925fd2681..0000000000000000000000000000000000000000
--- a/source/VirtualFluidsCore/CoProcessors/WriteObjectsCoProcessor.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-#include "WriteObjectsCoProcessor.h"
-#include "LBMKernel.h"
-#include "BCProcessor.h"
-
-#include "basics/writer/WbWriterVtkXmlBinary.h"
-#include "basics/writer/WbWriterVtkXmlASCII.h"
-
-#include "GbSphere3D.h"
-#include "Communicator.h"
-#include "UbScheduler.h"
-#include "Grid3D.h"
-#include "UbSystem.h"
-
-WriteObjectsCoProcessor::WriteObjectsCoProcessor()
-{
-
-}
-//////////////////////////////////////////////////////////////////////////
-WriteObjectsCoProcessor::WriteObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s,
-   const std::string& path, SPtr<Communicator> comm)
-   : CoProcessor(grid, s),
-   path(path),
-   comm(comm)
-{
-    this->path += "/geo/objects/sphere";
-}
-
-
-void WriteObjectsCoProcessor::addGbObject(SPtr<GbSphere3D> sphere)
-{
-    objects.push_back(sphere);
-}
-
-void WriteObjectsCoProcessor::process(double step)
-{
-   if (scheduler->isDue(step))
-   {
-       std::vector<UbTupleFloat3> nodes;
-       std::vector<UbTupleInt3>   triangles;
-
-       for (size_t i = 0; i < objects.size(); i++)
-       {
-           objects[i]->addSurfaceTriangleSet(nodes, triangles);
-  
-
-       }
-       int stepInt = (int)step;
-       std::string outFilename = WbWriterVtkXmlBinary::getInstance()->writeTriangles(path + UbSystem::toString(stepInt), nodes, triangles);
-
-   }
-     
-
-}
diff --git a/source/VirtualFluidsCore/CoProcessors/WriteObjectsCoProcessor.h b/source/VirtualFluidsCore/CoProcessors/WriteObjectsCoProcessor.h
deleted file mode 100644
index 921accf8cbe4452ecfa26294ba7e2d56310491e9..0000000000000000000000000000000000000000
--- a/source/VirtualFluidsCore/CoProcessors/WriteObjectsCoProcessor.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-*  Author: S. Peters
-*  mail: peters@irmb.tu-bs.de
-*/
-#ifndef WriteObjectsCoProcessor_H
-#define WriteObjectsCoProcessor_H
-
-#include <PointerDefinitions.h>
-#include <string>
-#include <vector>
-
-#include "CoProcessor.h"
-
-class GbSphere3D;
-class Communicator;
-class Grid3D;
-class UbScheduler;
-
-class WriteObjectsCoProcessor : public  CoProcessor
-{
-public:
-    WriteObjectsCoProcessor();
-    WriteObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, SPtr<Communicator> comm);
-   ~WriteObjectsCoProcessor() {}
-   void process(double step) override;
-
-   void addGbObject(SPtr<GbSphere3D> sphere);
-
-private:
-    std::string path;
-    SPtr<Communicator> comm;
-    std::vector<SPtr<GbSphere3D> > objects;
-};
-#endif
diff --git a/source/VirtualFluidsCore/Geometry/VoxelMatrix.h b/source/VirtualFluidsCore/Geometry/VoxelMatrix.h
deleted file mode 100644
index 088d7e6d8b3a50a85ccf98b9ed6ef7160305dcb0..0000000000000000000000000000000000000000
--- a/source/VirtualFluidsCore/Geometry/VoxelMatrix.h
+++ /dev/null
@@ -1,57 +0,0 @@
-//template <class T>
-//struct OriginVoxelMatrix
-//{
-//   CbArray3D<T> matrix;
-//};
-////////////////////////////////////////////////////////////////////////////
-//template <class T>
-//void GbVoxelMatrix3D::readOriginMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian)
-//{
-//   using namespace std;
-//   ifstream in(filename.c_str(), ios::binary);
-//   if (!in) throw UbException(UB_EXARGS, "could not open file "+filename);
-//
-//   in.seekg(0, ios::end);     //Ende springen
-//   fstream::off_type length = in.tellg(); //Position abfragen
-//   in.seekg(0, ios::beg);    //An den Anfang springen 
-//
-//   unsigned long long nofn = (unsigned long long)nodesX1*(unsigned long long)nodesX2*(unsigned long long)nodesX3*(unsigned long long)sizeof(T);
-//   if (nofn!=(unsigned long long)length)
-//   {
-//      throw UbException(UB_EXARGS, "number of nodes("+UbSystem::toString(nofn)+") doesn't match file size("+UbSystem::toString((long)length)+")");
-//   }
-//
-//   GbVoxelMatrix3D::oVoxelMatrix3D<T> = CbArray3D<T>(nodesX1, nodesX2, nodesX3);
-//
-//   T val;
-//   for (int x3 = 0; x3<nodesX3; x3++)
-//      for (int x2 = 0; x2<nodesX2; x2++)
-//         for (int x1 = 0; x1<nodesX1; x1++)
-//         {
-//            in.read((char*)&val, sizeof(T));
-//            if (endian==BigEndian)
-//               UbSystem::swapByteOrder((unsigned char*)(&(val)), sizeof(T));
-//            oVoxelMatrix3D<T>(x1, x2, x3) = val;
-//         }
-//}
-////////////////////////////////////////////////////////////////////////////
-//template <class T>
-//void GbVoxelMatrix3D::writeOriginMatrixFromRawFile(std::string filename)
-//{
-//   using namespace std;
-//
-//   string fn = filename;
-//
-//   FILE *file;
-//   file = fopen(fn.c_str(), "wb");
-//
-//   if (file==NULL)
-//   {
-//      std::string pathf = UbSystem::getPathFromString(fn);
-//      if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "wb"); }
-//      if (file==NULL) throw UbException(UB_EXARGS, "can not open "+fn);
-//   }
-//
-//   fwrite(GbVoxelMatrix3D::oVoxelMatrix3D<T>.getStartAdressOfSortedArray(0, 0, 0), sizeof(T), GbVoxelMatrix3D::oVoxelMatrix3D<T>.getDataVector().size(), file);
-//   fclose(file);
-//}
diff --git a/source/VirtualFluidsCore/Grid/BasicCalculator.cpp b/source/VirtualFluidsCore/Grid/BasicCalculator.cpp
index 285c9cdbd0ced8042276de3ab647b80a16100af8..8d7eafba0dca8905fe137398a604c09dc99e85bd 100644
--- a/source/VirtualFluidsCore/Grid/BasicCalculator.cpp
+++ b/source/VirtualFluidsCore/Grid/BasicCalculator.cpp
@@ -1,339 +1,367 @@
-#include "BasicCalculator.h"
-
-#include "Block3D.h"
-#include "BCProcessor.h"
-#include "LBMKernel.h"
-#include "Block3DConnector.h"
-#include "UbScheduler.h"
-#include "UbLogger.h"
-
-#ifdef _OPENMP
-#include <omp.h>
-#endif
-#define OMP_SCHEDULE guided
-
-//#define TIMING
-//#include "UbTiming.h"
-
-BasicCalculator::BasicCalculator(SPtr<Grid3D> grid, SPtr<UbScheduler> additionalGhostLayerUpdateScheduler, int numberOfTimeSteps) : 
-   Calculator(grid, additionalGhostLayerUpdateScheduler, numberOfTimeSteps)
-{
-
-}
-//////////////////////////////////////////////////////////////////////////
-BasicCalculator::~BasicCalculator()
-{
-
-}
-//////////////////////////////////////////////////////////////////////////
-void BasicCalculator::calculate()
-{
-   UBLOG(logDEBUG1, "OMPCalculator::calculate() - started");
-   int calcStep = 0;
-   try
-   {
-      int minInitLevel = minLevel;
-      int maxInitLevel = maxLevel-minLevel;
-      int straightStartLevel = minInitLevel;
-      int internalIterations = 1<<(maxInitLevel-minInitLevel);
-      int forwardStartLevel;
-      int threshold;
-
-#ifdef TIMING
-      UbTimer timer;
-      double time[6];
-#endif
-
-      for (calcStep = startTimeStep; calcStep<=numberOfTimeSteps; calcStep++)
-      {
-         //coProcess((double)(calcStep-1));
-
-         //////////////////////////////////////////////////////////////////////////
-#ifdef TIMING
-         UBLOG(logINFO, "calcStep = "<<calcStep);
-#endif
-         //////////////////////////////////////////////////////////////////////////
-
-         for (int staggeredStep = 1; staggeredStep<=internalIterations; staggeredStep++)
-         {
-            forwardStartLevel = straightStartLevel;
-            if (staggeredStep==internalIterations) straightStartLevel = minInitLevel;
-            else
-            {
-               for (straightStartLevel = maxInitLevel, threshold = 1;
-                  (staggeredStep&threshold)!=threshold; straightStartLevel--, threshold <<= 1);
-            }
-            //////////////////////////////////////////////////////////////////////////
-#ifdef TIMING
-            timer.resetAndStart();
-#endif
-            //////////////////////////////////////////////////////////////////////////
-            applyPreCollisionBC(straightStartLevel, maxInitLevel);
-
-            //do collision for all blocks
-            calculateBlocks(straightStartLevel, maxInitLevel, calcStep);
-            //////////////////////////////////////////////////////////////////////////
-#ifdef TIMING
-            time[0] = timer.stop();
-            UBLOG(logINFO, "calculateBlocks time = "<<time[0]);
-#endif
-            //////////////////////////////////////////////////////////////////////////
-                        //////////////////////////////////////////////////////////////////////////
-                        //exchange data between blocks
-            exchangeBlockData(straightStartLevel, maxInitLevel);
-            //////////////////////////////////////////////////////////////////////////
-#ifdef TIMING
-            time[1] = timer.stop();
-            UBLOG(logINFO, "exchangeBlockData time = "<<time[1]);
-#endif
-            //////////////////////////////////////////////////////////////////////////
-            applyPostCollisionBC(straightStartLevel, maxInitLevel);
-            //////////////////////////////////////////////////////////////////////////
-#ifdef TIMING
-            time[2] = timer.stop();
-            UBLOG(logINFO, "applyBCs time = "<<time[2]);
-#endif
-            //////////////////////////////////////////////////////////////////////////
-            //swap distributions in kernel
-            swapDistributions(straightStartLevel, maxInitLevel);
-            //////////////////////////////////////////////////////////////////////////
-#ifdef TIMING
-            time[3] = timer.stop();
-            UBLOG(logINFO, "swapDistributions time = "<<time[3]);
-#endif
-            //////////////////////////////////////////////////////////////////////////
-            if (refinement)
-            {
-               if (straightStartLevel<maxInitLevel)
-                  exchangeBlockData(straightStartLevel, maxInitLevel);
-               //////////////////////////////////////////////////////////////////////////
-#ifdef TIMING
-               time[4] = timer.stop();
-               UBLOG(logINFO, "refinement exchangeBlockData time = "<<time[4]);
-#endif
-               //////////////////////////////////////////////////////////////////////////
-               //now ghost nodes have actual values
-               //interpolation of interface nodes between grid levels
-               interpolation(straightStartLevel, maxInitLevel);
-               //////////////////////////////////////////////////////////////////////////
-#ifdef TIMING
-               time[5] = timer.stop();
-               UBLOG(logINFO, "refinement interpolation time = "<<time[5]);
-#endif
-               //////////////////////////////////////////////////////////////////////////
-            }
-         }
-         //exchange data between blocks for visualization
-         //if ((int)additionalGhostLayerUpdateScheduler->getNextDueTime()==calcStep)
-         if (additionalGhostLayerUpdateScheduler->isDue(calcStep))
-         {
-            exchangeBlockData(straightStartLevel, maxInitLevel);
-         }
-         coProcess((double)(calcStep));
-         //now ghost nodes have actual values
-      }
-      UBLOG(logDEBUG1, "OMPCalculator::calculate() - stoped");
-   }
-   catch (std::exception& e)
-   {
-      UBLOG(logERROR, e.what());
-      UBLOG(logERROR, " step = "<<calcStep);
-      //throw;
-      exit(EXIT_FAILURE);
-   }
-}
-//////////////////////////////////////////////////////////////////////////
-void BasicCalculator::calculateBlocks(int startLevel, int maxInitLevel, int calcStep)
-{
-#ifdef _OPENMP
-#pragma omp parallel
-#endif
-   {
-      SPtr<Block3D> blockTemp;
-      try
-      {
-         //startLevel bis maxInitLevel
-         for (int level = startLevel; level<=maxInitLevel; level++)
-         {
-            //timer.resetAndStart();
-            //call LBM kernel
-            int size = (int)blocks[level].size();
-#ifdef _OPENMP
-#pragma omp for schedule(OMP_SCHEDULE)
-#endif
-            for (int i =0; i<size; i++)
-            {
-               blockTemp = blocks[level][i];
-               blockTemp->getKernel()->calculate(calcStep);
-            }
-            //timer.stop();
-            //UBLOG(logINFO, "level = " << level << " blocks = " << blocks[level].size() << " collision time = " << timer.getTotalTime());
-         }
-      }
-      catch (std::exception& e)
-      {
-         UBLOG(logERROR, e.what());
-         //UBLOG(logERROR, blockTemp->toString()<<" step = "<<calcStep);
-         //throw;
-         exit(EXIT_FAILURE);
-      }
-   }
-}
-//////////////////////////////////////////////////////////////////////////
-void BasicCalculator::exchangeBlockData(int startLevel, int maxInitLevel)
-{
-   //startLevel bis maxInitLevel
-   for (int level = startLevel; level<=maxInitLevel; level++)
-   {
-      //connectorsPrepareLocal(localConns[level]);
-      connectorsSendLocal(localConns[level]);
-      //connectorsReceiveLocal(localConns[level]);
-
-      connectorsPrepareRemote(remoteConns[level]);
-      connectorsSendRemote(remoteConns[level]);
-      connectorsReceiveRemote(remoteConns[level]);
-   }
-}
-//////////////////////////////////////////////////////////////////////////
-void BasicCalculator::swapDistributions(int startLevel, int maxInitLevel)
-{
-#ifdef _OPENMP
-#pragma omp parallel
-#endif
-   {
-      //startLevel bis maxInitLevel
-      for (int level = startLevel; level<=maxInitLevel; level++)
-      {
-         int size = (int)blocks[level].size();
-#ifdef _OPENMP
-#pragma omp for schedule(OMP_SCHEDULE)
-#endif
-         for (int i =0; i<size; i++)
-         {
-            blocks[level][i]->getKernel()->swapDistributions();
-         }
-      }
-   }
-}
-//////////////////////////////////////////////////////////////////////////
-void BasicCalculator::connectorsPrepareLocal(std::vector< SPtr<Block3DConnector> >& connectors)
-{
-   int size = (int)connectors.size();
-#ifdef _OPENMP
-#pragma omp parallel for schedule(OMP_SCHEDULE)
-#endif
-   for (int i =0; i<size; i++)
-   {
-      connectors[i]->prepareForReceive();
-      connectors[i]->prepareForSend();
-   }
-}
-//////////////////////////////////////////////////////////////////////////
-void BasicCalculator::connectorsSendLocal(std::vector< SPtr<Block3DConnector> >& connectors)
-{
-   int size = (int)connectors.size();
-#ifdef _OPENMP
-#pragma omp parallel for schedule(OMP_SCHEDULE)
-#endif
-   for (int i =0; i<size; i++)
-   {
-      connectors[i]->fillSendVectors();
-      connectors[i]->sendVectors();
-   }
-}
-//////////////////////////////////////////////////////////////////////////
-void BasicCalculator::connectorsReceiveLocal(std::vector< SPtr<Block3DConnector> >& connectors)
-{
-   int size = (int)connectors.size();
-#ifdef _OPENMP
-#pragma omp parallel for schedule(OMP_SCHEDULE)
-#endif
-   for (int i =0; i<size; i++)
-   {
-      connectors[i]->receiveVectors();
-      connectors[i]->distributeReceiveVectors();
-   }
-}
-void BasicCalculator::connectorsPrepareRemote(std::vector< SPtr<Block3DConnector> >& connectors)
-{
-   int size = (int)connectors.size();
-   for (int i =0; i<size; i++)
-   {
-      connectors[i]->prepareForReceive();
-      connectors[i]->prepareForSend();
-   }
-}
-//////////////////////////////////////////////////////////////////////////
-void BasicCalculator::connectorsSendRemote(std::vector< SPtr<Block3DConnector> >& connectors)
-{
-   int size = (int)connectors.size();
-   for (int i =0; i<size; i++)
-   {
-      connectors[i]->fillSendVectors();
-      connectors[i]->sendVectors();
-   }
-}
-//////////////////////////////////////////////////////////////////////////
-void BasicCalculator::connectorsReceiveRemote(std::vector< SPtr<Block3DConnector> >& connectors)
-{
-   int size = (int)connectors.size();
-   for (int i =0; i<size; i++)
-   {
-      connectors[i]->receiveVectors();
-      connectors[i]->distributeReceiveVectors();
-   }
-}
-//////////////////////////////////////////////////////////////////////////
-void BasicCalculator::interpolation(int startLevel, int maxInitLevel)
-{
-   for (int level = startLevel; level<maxInitLevel; level++)
-   {
-      connectorsPrepareLocal(localInterConns[level]);
-      connectorsPrepareRemote(remoteInterConns[level]);
-   }
-
-   for (int level = startLevel; level<maxInitLevel; level++)
-   {
-      connectorsSendLocal(localInterConns[level]);
-      connectorsSendRemote(remoteInterConns[level]);
-   }
-
-   for (int level = startLevel; level<maxInitLevel; level++)
-   {
-      connectorsReceiveLocal(localInterConns[level]);
-      connectorsReceiveRemote(remoteInterConns[level]);
-   }
-}
-//////////////////////////////////////////////////////////////////////////
-void BasicCalculator::applyPreCollisionBC(int startLevel, int maxInitLevel)
-{
-   //startLevel bis maxInitLevel
-   for (int level = startLevel; level<=maxInitLevel; level++)
-   {
-      int size = (int)blocks[level].size();
-#ifdef _OPENMP
-#pragma omp parallel for schedule(OMP_SCHEDULE)
-#endif
-      for (int i =0; i<size; i++)
-      {
-         blocks[level][i]->getKernel()->getBCProcessor()->applyPreCollisionBC();
-      }
-   }
-}
-//////////////////////////////////////////////////////////////////////////
-void BasicCalculator::applyPostCollisionBC(int startLevel, int maxInitLevel)
-{
-   //startLevel bis maxInitLevel
-   for (int level = startLevel; level<=maxInitLevel; level++)
-   {
-      int size = (int)blocks[level].size();
-#ifdef _OPENMP
-#pragma omp parallel for schedule(OMP_SCHEDULE)
-#endif
-      for (int i =0; i<size; i++)
-      {
-         blocks[level][i]->getKernel()->getBCProcessor()->applyPostCollisionBC();
-      }
-   }
-}
-
+#include "BasicCalculator.h"
+
+#include "Block3D.h"
+#include "BCProcessor.h"
+#include "LBMKernel.h"
+#include "Block3DConnector.h"
+#include "UbScheduler.h"
+#include "UbLogger.h"
+
+#ifdef _OPENMP
+#include <omp.h>
+#endif
+#define OMP_SCHEDULE guided
+
+//#define TIMING
+//#include "UbTiming.h"
+
+BasicCalculator::BasicCalculator(SPtr<Grid3D> grid, SPtr<UbScheduler> additionalGhostLayerUpdateScheduler, int numberOfTimeSteps) : 
+   Calculator(grid, additionalGhostLayerUpdateScheduler, numberOfTimeSteps)
+{
+
+}
+//////////////////////////////////////////////////////////////////////////
+BasicCalculator::~BasicCalculator()
+{
+
+}
+//////////////////////////////////////////////////////////////////////////
+void BasicCalculator::calculate()
+{
+   UBLOG(logDEBUG1, "OMPCalculator::calculate() - started");
+   int calcStep = 0;
+   try
+   {
+      int minInitLevel = minLevel;
+      int maxInitLevel = maxLevel-minLevel;
+      int straightStartLevel = minInitLevel;
+      int internalIterations = 1<<(maxInitLevel-minInitLevel);
+      int forwardStartLevel;
+      int threshold;
+
+#ifdef TIMING
+      UbTimer timer;
+      double time[6];
+#endif
+
+      for (calcStep = startTimeStep; calcStep<=numberOfTimeSteps; calcStep++)
+      {
+         //////////////////////////////////////////////////////////////////////////
+#ifdef TIMING
+         UBLOG(logINFO, "calcStep = "<<calcStep);
+#endif
+         //////////////////////////////////////////////////////////////////////////
+
+         for (int staggeredStep = 1; staggeredStep<=internalIterations; staggeredStep++)
+         {
+            forwardStartLevel = straightStartLevel;
+            if (staggeredStep==internalIterations) straightStartLevel = minInitLevel;
+            else
+            {
+               for (straightStartLevel = maxInitLevel, threshold = 1;
+                  (staggeredStep&threshold)!=threshold; straightStartLevel--, threshold <<= 1);
+            }
+            //////////////////////////////////////////////////////////////////////////
+#ifdef TIMING
+            timer.resetAndStart();
+#endif
+            //////////////////////////////////////////////////////////////////////////
+            applyPreCollisionBC(straightStartLevel, maxInitLevel);
+
+            //do collision for all blocks
+            calculateBlocks(straightStartLevel, maxInitLevel, calcStep);
+            //////////////////////////////////////////////////////////////////////////
+#ifdef TIMING
+            time[0] = timer.stop();
+            UBLOG(logINFO, "calculateBlocks time = "<<time[0]);
+#endif
+            //////////////////////////////////////////////////////////////////////////
+                        //////////////////////////////////////////////////////////////////////////
+                        //exchange data between blocks
+            exchangeBlockData(straightStartLevel, maxInitLevel);
+            //////////////////////////////////////////////////////////////////////////
+#ifdef TIMING
+            time[1] = timer.stop();
+            UBLOG(logINFO, "exchangeBlockData time = "<<time[1]);
+#endif
+            //////////////////////////////////////////////////////////////////////////
+            applyPostCollisionBC(straightStartLevel, maxInitLevel);
+            //////////////////////////////////////////////////////////////////////////
+#ifdef TIMING
+            time[2] = timer.stop();
+            UBLOG(logINFO, "applyBCs time = "<<time[2]);
+#endif
+            //////////////////////////////////////////////////////////////////////////
+            //swap distributions in kernel
+            swapDistributions(straightStartLevel, maxInitLevel);
+            //////////////////////////////////////////////////////////////////////////
+#ifdef TIMING
+            time[3] = timer.stop();
+            UBLOG(logINFO, "swapDistributions time = "<<time[3]);
+#endif
+            //////////////////////////////////////////////////////////////////////////
+            if (refinement)
+            {
+               if (straightStartLevel<maxInitLevel)
+                  exchangeBlockData(straightStartLevel, maxInitLevel);
+               //////////////////////////////////////////////////////////////////////////
+#ifdef TIMING
+               time[4] = timer.stop();
+               UBLOG(logINFO, "refinement exchangeBlockData time = "<<time[4]);
+#endif
+               //////////////////////////////////////////////////////////////////////////
+               //now ghost nodes have actual values
+               //interpolation of interface nodes between grid levels
+               interpolation(straightStartLevel, maxInitLevel);
+               //////////////////////////////////////////////////////////////////////////
+#ifdef TIMING
+               time[5] = timer.stop();
+               UBLOG(logINFO, "refinement interpolation time = "<<time[5]);
+#endif
+               //////////////////////////////////////////////////////////////////////////
+            }
+         }
+         //exchange data between blocks for visualization
+         if (additionalGhostLayerUpdateScheduler->isDue(calcStep))
+         {
+            exchangeBlockData(straightStartLevel, maxInitLevel);
+         }
+         coProcess((double)(calcStep));
+         //now ghost nodes have actual values
+      }
+      UBLOG(logDEBUG1, "OMPCalculator::calculate() - stoped");
+   }
+   catch (std::exception& e)
+   {
+      UBLOG(logERROR, e.what());
+      UBLOG(logERROR, " step = "<<calcStep);
+      //throw;
+      exit(EXIT_FAILURE);
+   }
+   catch (std::string& s)
+   {
+      UBLOG(logERROR, s);
+      exit(EXIT_FAILURE);
+   }
+   catch (...)
+   {
+      UBLOG(logERROR, "unknown exception");
+      exit(EXIT_FAILURE);
+   }
+}
+//////////////////////////////////////////////////////////////////////////
+void BasicCalculator::calculateBlocks(int startLevel, int maxInitLevel, int calcStep)
+{
+#ifdef _OPENMP
+#pragma omp parallel
+#endif
+   {
+      SPtr<Block3D> blockTemp;
+      try
+      {
+         //startLevel bis maxInitLevel
+         for (int level = startLevel; level<=maxInitLevel; level++)
+         {
+            //timer.resetAndStart();
+            //call LBM kernel
+            int size = (int)blocks[level].size();
+#ifdef _OPENMP
+#pragma omp for schedule(OMP_SCHEDULE)
+#endif
+            for (int i =0; i<size; i++)
+            {
+               blockTemp = blocks[level][i];
+               blockTemp->getKernel()->calculate(calcStep);
+            }
+            //timer.stop();
+            //UBLOG(logINFO, "level = " << level << " blocks = " << blocks[level].size() << " collision time = " << timer.getTotalTime());
+         }
+      }
+      catch (std::exception& e)
+      {
+         UBLOG(logERROR, e.what());
+         //UBLOG(logERROR, blockTemp->toString()<<" step = "<<calcStep);
+         //throw;
+         exit(EXIT_FAILURE);
+      }
+   }
+}
+//////////////////////////////////////////////////////////////////////////
+void BasicCalculator::exchangeBlockData(int startLevel, int maxInitLevel)
+{
+   //startLevel bis maxInitLevel
+   for (int level = startLevel; level<=maxInitLevel; level++)
+   {
+      //connectorsPrepareLocal(localConns[level]);
+      connectorsSendLocal(localConns[level]);
+      //connectorsReceiveLocal(localConns[level]);
+
+      connectorsPrepareRemote(remoteConns[level]);
+      connectorsSendRemote(remoteConns[level]);
+      connectorsReceiveRemote(remoteConns[level]);
+   }
+}
+//////////////////////////////////////////////////////////////////////////
+void BasicCalculator::swapDistributions(int startLevel, int maxInitLevel)
+{
+#ifdef _OPENMP
+#pragma omp parallel
+#endif
+   {
+      //startLevel bis maxInitLevel
+      for (int level = startLevel; level<=maxInitLevel; level++)
+      {
+         int size = (int)blocks[level].size();
+#ifdef _OPENMP
+#pragma omp for schedule(OMP_SCHEDULE)
+#endif
+         for (int i =0; i<size; i++)
+         {
+            blocks[level][i]->getKernel()->swapDistributions();
+         }
+      }
+   }
+}
+//////////////////////////////////////////////////////////////////////////
+void BasicCalculator::connectorsPrepareLocal(std::vector< SPtr<Block3DConnector> >& connectors)
+{
+   int size = (int)connectors.size();
+#ifdef _OPENMP
+#pragma omp parallel for schedule(OMP_SCHEDULE)
+#endif
+   for (int i =0; i<size; i++)
+   {
+      connectors[i]->prepareForReceive();
+      connectors[i]->prepareForSend();
+   }
+}
+//////////////////////////////////////////////////////////////////////////
+void BasicCalculator::connectorsSendLocal(std::vector< SPtr<Block3DConnector> >& connectors)
+{
+   int size = (int)connectors.size();
+#ifdef _OPENMP
+#pragma omp parallel for schedule(OMP_SCHEDULE)
+#endif
+   for (int i =0; i<size; i++)
+   {
+      connectors[i]->fillSendVectors();
+      connectors[i]->sendVectors();
+   }
+}
+//////////////////////////////////////////////////////////////////////////
+void BasicCalculator::connectorsReceiveLocal(std::vector< SPtr<Block3DConnector> >& connectors)
+{
+   int size = (int)connectors.size();
+#ifdef _OPENMP
+#pragma omp parallel for schedule(OMP_SCHEDULE)
+#endif
+   for (int i =0; i<size; i++)
+   {
+      connectors[i]->receiveVectors();
+      connectors[i]->distributeReceiveVectors();
+   }
+}
+void BasicCalculator::connectorsPrepareRemote(std::vector< SPtr<Block3DConnector> >& connectors)
+{
+   int size = (int)connectors.size();
+   for (int i =0; i<size; i++)
+   {
+      connectors[i]->prepareForReceive();
+      connectors[i]->prepareForSend();
+   }
+}
+//////////////////////////////////////////////////////////////////////////
+void BasicCalculator::connectorsSendRemote(std::vector< SPtr<Block3DConnector> >& connectors)
+{
+   int size = (int)connectors.size();
+   for (int i =0; i<size; i++)
+   {
+      connectors[i]->fillSendVectors();
+      connectors[i]->sendVectors();
+   }
+}
+//////////////////////////////////////////////////////////////////////////
+void BasicCalculator::connectorsReceiveRemote(std::vector< SPtr<Block3DConnector> >& connectors)
+{
+   int size = (int)connectors.size();
+   for (int i =0; i<size; i++)
+   {
+      connectors[i]->receiveVectors();
+      connectors[i]->distributeReceiveVectors();
+   }
+}
+//////////////////////////////////////////////////////////////////////////
+void BasicCalculator::interpolation(int startLevel, int maxInitLevel)
+{
+   for (int level = startLevel; level<maxInitLevel; level++)
+   {
+      connectorsPrepareLocal(localInterConns[level]);
+      connectorsPrepareRemote(remoteInterConns[level]);
+   }
+
+   for (int level = startLevel; level<maxInitLevel; level++)
+   {
+      connectorsSendLocal(localInterConns[level]);
+      connectorsSendRemote(remoteInterConns[level]);
+   }
+
+   for (int level = startLevel; level<maxInitLevel; level++)
+   {
+      connectorsReceiveLocal(localInterConns[level]);
+      connectorsReceiveRemote(remoteInterConns[level]);
+   }
+}
+//////////////////////////////////////////////////////////////////////////
+void BasicCalculator::applyPreCollisionBC(int startLevel, int maxInitLevel)
+{
+   //startLevel bis maxInitLevel
+   for (int level = startLevel; level<=maxInitLevel; level++)
+   {
+      int size = (int)blocks[level].size();
+#ifdef _OPENMP
+#pragma omp parallel for schedule(OMP_SCHEDULE)
+#endif
+      for (int i =0; i<size; i++)
+      {
+         blocks[level][i]->getKernel()->getBCProcessor()->applyPreCollisionBC();
+      }
+   }
+}
+//////////////////////////////////////////////////////////////////////////
+void BasicCalculator::applyPostCollisionBC(int startLevel, int maxInitLevel)
+{
+   try{
+   //startLevel bis maxInitLevel
+   for (int level = startLevel; level<=maxInitLevel; level++)
+   {
+      int size = (int)blocks[level].size();
+#ifdef _OPENMP
+#pragma omp parallel for schedule(OMP_SCHEDULE)
+#endif
+      for (int i =0; i<size; i++)
+      {
+         blocks[level][i]->getKernel()->getBCProcessor()->applyPostCollisionBC();
+      }
+   }
+}
+   catch (std::exception& e)
+   {
+      UBLOG(logERROR, e.what());
+      //UBLOG(logERROR, " step = "<<calcStep);
+      //throw;
+      exit(EXIT_FAILURE);
+   }
+   catch (std::string& s)
+   {
+      UBLOG(logERROR, s);
+      //throw;
+      exit(EXIT_FAILURE);
+   }
+   catch (...)
+   {
+      UBLOG(logERROR, "unknown exception");
+      //throw;
+      exit(EXIT_FAILURE);
+   }
+}
+
diff --git a/source/VirtualFluidsCore/Grid/Grid3D.cpp b/source/VirtualFluidsCore/Grid/Grid3D.cpp
index 88e6f9d8aa6a3b3c9be31205a94f04b2c48986ad..fa991fd849667fceae00179e13562592778c1d47 100644
--- a/source/VirtualFluidsCore/Grid/Grid3D.cpp
+++ b/source/VirtualFluidsCore/Grid/Grid3D.cpp
@@ -1831,6 +1831,61 @@ void Grid3D::getBlocksByCuboid(int level, double minX1, double minX2, double min
    std::copy(blockset.begin(), blockset.end(), blocks.begin());
 }
 //////////////////////////////////////////////////////////////////////////
+void Grid3D::getAllBlocksByCuboid(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, std::vector<SPtr<Block3D>>& blocks)
+{
+   int coarsestLevel = this->getCoarsestInitializedLevel();
+   int finestLevel   = this->getFinestInitializedLevel();
+
+   //////////////////////////////////////////////////////////////////////////
+   //MINIMALE BLOCK-INDIZES BESTIMMEN
+   //  
+   //min:
+   double dMinX1 = trafo->transformForwardToX1Coordinate(minX1, minX2, minX3)*(1<<finestLevel);
+   double dMinX2 = trafo->transformForwardToX2Coordinate(minX1, minX2, minX3)*(1<<finestLevel);
+   double dMinX3 = trafo->transformForwardToX3Coordinate(minX1, minX2, minX3)*(1<<finestLevel);
+
+   //Achtung, wenn minX1 genau auf grenze zwischen zwei bloecken -> der "kleinere" muss genommen werden,
+   //da beim Transformieren der "groessere" Index rauskommt
+   int iMinX1 = (int)dMinX1; if (UbMath::zero(dMinX1-iMinX1)) iMinX1-=1;
+   int iMinX2 = (int)dMinX2; if (UbMath::zero(dMinX2-iMinX2)) iMinX2-=1;
+   int iMinX3 = (int)dMinX3; if (UbMath::zero(dMinX3-iMinX3)) iMinX3-=1;
+
+   //max (hier kann die Zusatzabfrage vernachlaessigt werden):
+   int iMaxX1 = (int)(trafo->transformForwardToX1Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel));
+   int iMaxX2 = (int)(trafo->transformForwardToX2Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel));
+   int iMaxX3 = (int)(trafo->transformForwardToX3Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel));
+
+   SPtr<Block3D> block;
+
+   //set, um doppelte bloecke zu vermeiden, die u.U. bei periodic auftreten koennen
+   std::set<SPtr<Block3D>> blockset;
+   for (int level=coarsestLevel; level<=finestLevel; level++)
+   {
+      //damit bei negativen werten auch der "kleinere" genommen wird -> floor!
+      int minx1 = (int)std::floor((double)iMinX1/(1<<(finestLevel-level)));
+      int minx2 = (int)std::floor((double)iMinX2/(1<<(finestLevel-level)));
+      int minx3 = (int)std::floor((double)iMinX3/(1<<(finestLevel-level)));
+
+      int maxx1 = iMaxX1/(1<<(finestLevel-level));
+      int maxx2 = iMaxX2/(1<<(finestLevel-level));
+      int maxx3 = iMaxX3/(1<<(finestLevel-level));
+
+      for (int ix1=minx1; ix1<=maxx1; ix1++)
+         for (int ix2=minx2; ix2<=maxx2; ix2++)
+            for (int ix3=minx3; ix3<=maxx3; ix3++)
+               if ((block=this->getBlock(ix1, ix2, ix3, level)))
+               {
+                  if (block)
+                  {
+                     blockset.insert(block);
+                  }
+               }
+   }
+
+   blocks.resize(blockset.size());
+   std::copy(blockset.begin(), blockset.end(), blocks.begin());
+}
+//////////////////////////////////////////////////////////////////////////
 void Grid3D::calcStartCoordinatesAndDelta(SPtr<Block3D> block, double& worldX1, double& worldX2, double& worldX3, double& deltaX)
 {
    int blocklevel  = block->getLevel();
diff --git a/source/VirtualFluidsCore/Grid/Grid3D.h b/source/VirtualFluidsCore/Grid/Grid3D.h
index bf58fcabcfdafa31a67019388d238e5eaa139fa4..35188bc0a1b786b506eb99dbd77979e3edabf29d 100644
--- a/source/VirtualFluidsCore/Grid/Grid3D.h
+++ b/source/VirtualFluidsCore/Grid/Grid3D.h
@@ -52,6 +52,7 @@ public:
    void getBlocksByCuboid(int level, double minX1, double minX2, double minX3, 
                           double maxX1, double maxX2, double maxX3, 
                           std::vector<SPtr<Block3D>>& blocks);
+   void getAllBlocksByCuboid(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, std::vector<SPtr<Block3D>>& blocks);
    //!get blocks for level
    void getBlocks(int level, std::vector<SPtr<Block3D>>& blockVector);
    //!get blocks for level with current rank
diff --git a/source/IncludsList.cmake b/source/VirtualFluidsCore/IncludsList.cmake
similarity index 60%
rename from source/IncludsList.cmake
rename to source/VirtualFluidsCore/IncludsList.cmake
index f78bec3aa2b3793737fa28eebb4817d1111e2556..7c29bdca98e6f16e981a30b9d55be290f0d5bc26 100644
--- a/source/IncludsList.cmake
+++ b/source/VirtualFluidsCore/IncludsList.cmake
@@ -1,43 +1,33 @@
-#directory pathes for header files
-
-INCLUDE_DIRECTORIES(${SOURCE_ROOT})
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/BoundaryConditions)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Connectors)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Data)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Interactors)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/LBM)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Parallel)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Grid)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Visitors)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/CoProcessors)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Utilities)
-
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/ThirdParty)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/ThirdParty/Library)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/ThirdParty/Library/numerics/geometry3d)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/ThirdParty/Library/numerics/geometry3d/Creator)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/ThirdParty/Library/numerics/geometry3d/KdTree)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/ThirdParty/Library/basics/container)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/ThirdParty/Library/basics/memory)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/ThirdParty/Library/basics/objects)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/ThirdParty/Library/basics/transmiitter)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/ThirdParty/Library/basics/utilities)
-INCLUDE_DIRECTORIES(${SOURCE_ROOT}/ThirdParty/Library/basics/writer)
-
-IF(${USE_BOOST})
-   INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
-ENDIF()
-
-INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
-INCLUDE_DIRECTORIES(${METIS_INCLUDEDIR})
-INCLUDE_DIRECTORIES(${ZOLTAN_INCLUDEDIR})
-IF(${USE_VTK})
-    INCLUDE_DIRECTORIES(${VTK_INCLUDE_DIRS})
-ENDIF()
-IF(${USE_FETOL})
-    INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/FETOL)
-    INCLUDE_DIRECTORIES(${YAML_INCLUDEDIR})
-    INCLUDE_DIRECTORIES(${BOND_INCLUDEDIR})
-    INCLUDE_DIRECTORIES(${FETOL_INCLUDEDIR})
-ENDIF()
\ No newline at end of file
+#directory pathes for header files
+
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/BoundaryConditions)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Connectors)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Data)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Interactors)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/LBM)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Parallel)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Grid)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Visitors)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/CoProcessors)
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Utilities)
+
+INCLUDE_DIRECTORIES(${SOURCE_ROOT}/ThirdParty)
+
+IF(${USE_BOOST})
+   INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
+ENDIF()
+
+INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
+INCLUDE_DIRECTORIES(${METIS_INCLUDEDIR})
+INCLUDE_DIRECTORIES(${ZOLTAN_INCLUDEDIR})
+IF(${USE_VTK})
+    INCLUDE_DIRECTORIES(${VTK_INCLUDE_DIRS})
+ENDIF()
+IF(${USE_FETOL})
+    INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/FETOL)
+    INCLUDE_DIRECTORIES(${YAML_INCLUDEDIR})
+    INCLUDE_DIRECTORIES(${BOND_INCLUDEDIR})
+    INCLUDE_DIRECTORIES(${FETOL_INCLUDEDIR})
+ENDIF()
+
diff --git a/source/VirtualFluidsCore/Interactors/Interactor3D.cpp b/source/VirtualFluidsCore/Interactors/Interactor3D.cpp
index d4380b076ca615d3bef1fc1dc3c18379d21234eb..17adeb82a6c894804a3e3acc3b9cd861203bad59 100644
--- a/source/VirtualFluidsCore/Interactors/Interactor3D.cpp
+++ b/source/VirtualFluidsCore/Interactors/Interactor3D.cpp
@@ -22,6 +22,8 @@ const int Interactor3D::FLUID              = (1<<3); //8
 const int Interactor3D::MOVEABLE           = (1<<4); //16  // geometrisch
 const int Interactor3D::CHANGENOTNECESSARY = (1<<5); //32
 
+
+
 //////////////////////////////////////////////////////////////////////////
 Interactor3D::Interactor3D()
   : type(SOLID)
@@ -33,6 +35,7 @@ Interactor3D::Interactor3D(SPtr<Grid3D> grid, int type)
    :   type(type)
      , grid(grid)
 {
+
 }
 //////////////////////////////////////////////////////////////////////////
 Interactor3D::Interactor3D(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, int type)
@@ -41,6 +44,7 @@ Interactor3D::Interactor3D(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, int
      , type(type)
      , accuracy(SIMPLE)
 {
+
 }
 //////////////////////////////////////////////////////////////////////////
 Interactor3D::Interactor3D(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, int type, Interactor3D::Accuracy a)
@@ -49,6 +53,7 @@ Interactor3D::Interactor3D(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, int
    , type(type)
    , accuracy(a)
 {
+
 }
 //////////////////////////////////////////////////////////////////////////
 Interactor3D::~Interactor3D()
@@ -268,7 +273,30 @@ UbTupleDouble3 Interactor3D::getForces()
 {
     UB_THROW( UbException("UbTupleDouble3 getForces() - gehoert in die abgeleitete klasse") );
 }
-
+void Interactor3D::setID(int id)
+{
+   this->id = id;
+}
+//////////////////////////////////////////////////////////////////////////
+int Interactor3D::getID()
+{
+   return id;
+}
+//////////////////////////////////////////////////////////////////////////
+void Interactor3D::setActive()
+{
+   active = true;
+}
+//////////////////////////////////////////////////////////////////////////
+void Interactor3D::setInactive()
+{
+   active = false;
+}
+//////////////////////////////////////////////////////////////////////////
+bool Interactor3D::isActive()
+{
+   return active;
+}
 //////////////////////////////////////////////////////////////////////////
 void Interactor3D::initInteractor(const double& timeStep)
 {
diff --git a/source/VirtualFluidsCore/Interactors/Interactor3D.h b/source/VirtualFluidsCore/Interactors/Interactor3D.h
index ebbe580f3f9d27aa289ded95a53890b394f8827b..e5c7c5d720e46cca0041b4244962b321909e494d 100644
--- a/source/VirtualFluidsCore/Interactors/Interactor3D.h
+++ b/source/VirtualFluidsCore/Interactors/Interactor3D.h
@@ -15,6 +15,7 @@ class GbObject3D;
 class Block3D;
 
 
+
 class Interactor3D : public enableSharedFromThis<Interactor3D>
 {
 public:
@@ -57,6 +58,13 @@ public:
    virtual std::vector<SPtr<Block3D> >& getSolidBlockSet() { return this->solidBlocks; }
    virtual void removeSolidBlocks() { this->solidBlocks.clear(); }
 
+   void setID(int id);
+   int getID();
+
+   void setActive();
+   void setInactive();
+   bool isActive();
+
 protected:
    void setTimeDependent()   { UbSystem::setBit(this->type  , TIMEDEPENDENT); }
    void unsetTimeDependent() { UbSystem::unsetBit(this->type, TIMEDEPENDENT); }
@@ -88,6 +96,9 @@ protected:
    std::vector<SPtr<Block3D> > bcBlocks;
    std::vector<SPtr<Block3D> > solidBlocks;
    int accuracy;
+   
+   bool active;
+   int id;
 
 public:
    static const int SOLID	            ;//= (1<<0); //1
diff --git a/source/VirtualFluidsCore/Interactors/InteractorsHelper.cpp b/source/VirtualFluidsCore/Interactors/InteractorsHelper.cpp
index 38ca4ffe62b1e9a4e1a2042ea1902505a2fd9a2a..c8aea0034857a8c2c05067e55b8924c4015b295f 100644
--- a/source/VirtualFluidsCore/Interactors/InteractorsHelper.cpp
+++ b/source/VirtualFluidsCore/Interactors/InteractorsHelper.cpp
@@ -5,6 +5,8 @@
 #include <Interactor3D.h>
 #include "Block3D.h"
 #include "Communicator.h"
+#include "SetSolidBlocksBlockVisitor.h"
+#include "SetBcBlocksBlockVisitor.h"
 
 
 InteractorsHelper::InteractorsHelper(SPtr<Grid3D> grid, SPtr<Grid3DVisitor> visitor) :
@@ -48,7 +50,9 @@ void InteractorsHelper::deleteSolidBlocks()
 {
     for(SPtr<Interactor3D> interactor : interactors)
     {
-        setBlocks(interactor, SetSolidOrBoundaryBlockVisitor::SOLID);
+        //setBlocks(interactor, SetBcBlocksBlockVisitor::SOLID);
+        SetSolidBlocksBlockVisitor v(interactor);
+        grid->accept(v);
 
         std::vector<SPtr<Block3D>>& sb = interactor->getSolidBlockSet();
         solidBlocks.insert(solidBlocks.end(), sb.begin(), sb.end());
@@ -58,16 +62,13 @@ void InteractorsHelper::deleteSolidBlocks()
     updateGrid();
 }
 //////////////////////////////////////////////////////////////////////////
-void InteractorsHelper::setBlocks(const SPtr<Interactor3D> interactor, SetSolidOrBoundaryBlockVisitor::BlockType type) const
-{
-    SetSolidOrBoundaryBlockVisitor v(interactor, type);
-    grid->accept(v);
-}
-//////////////////////////////////////////////////////////////////////////
 void InteractorsHelper::setBcBlocks()
 {
     for(const SPtr<Interactor3D> interactor : interactors)
-        setBlocks(interactor, SetSolidOrBoundaryBlockVisitor::BC);
+    {
+       SetBcBlocksBlockVisitor v(interactor);
+       grid->accept(v);
+    }
 }
 //////////////////////////////////////////////////////////////////////////
 void InteractorsHelper::updateGrid()
diff --git a/source/VirtualFluidsCore/Interactors/InteractorsHelper.h b/source/VirtualFluidsCore/Interactors/InteractorsHelper.h
index d8407768ddb648713660263f62c61d362cfb3dc8..2b10c626d9b0761274a01d35667cb9b7b46dd5b0 100644
--- a/source/VirtualFluidsCore/Interactors/InteractorsHelper.h
+++ b/source/VirtualFluidsCore/Interactors/InteractorsHelper.h
@@ -3,13 +3,12 @@
 
 #include <vector>
 #include <PointerDefinitions.h>
-#include <SetSolidOrBoundaryBlockVisitor.h>
+
 
 class Interactor3D;
 class Block3D;
 class Grid3D;
 class Grid3DVisitor;
-class SetSolidOrBoundaryBlockVisitor;
 
 class InteractorsHelper
 {
@@ -24,7 +23,6 @@ public:
 
 protected:
    void deleteSolidBlocks();
-   void setBlocks(const SPtr<Interactor3D> interactor, SetSolidOrBoundaryBlockVisitor::BlockType type) const;
    void setBcBlocks();
 
 private:
diff --git a/source/VirtualFluidsCore/Interactors/package.include b/source/VirtualFluidsCore/Interactors/package.include
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/source/VirtualFluidsCore/Parallel/Communicator.h b/source/VirtualFluidsCore/Parallel/Communicator.h
index fa7b98feb06b67e89b5469cb03af70ccd09df7b7..aa2e3d35d1371dbeb789e38d6a75848624b9df8e 100644
--- a/source/VirtualFluidsCore/Parallel/Communicator.h
+++ b/source/VirtualFluidsCore/Parallel/Communicator.h
@@ -41,9 +41,11 @@ public:
    virtual void broadcast(int& value) = 0;
    virtual void broadcast(float& value) = 0;
    virtual void broadcast(double& value) = 0;
+   virtual void broadcast(long int& value) = 0;
    virtual void broadcast(std::vector<int>& values) = 0;
    virtual void broadcast(std::vector<float>& values) = 0;
    virtual void broadcast(std::vector<double>& values) = 0;
+   virtual void broadcast(std::vector<long int>& values) = 0;
 protected:
    Communicator(){}
    Communicator( const Communicator& ){}
diff --git a/source/VirtualFluidsCore/Parallel/MPICommunicator.cpp b/source/VirtualFluidsCore/Parallel/MPICommunicator.cpp
index f5c6090ba42427cfbbf25ee7381132b3cc518612..e2c32cdbcb8779150ea58e75eacd0bc710f5e925 100644
--- a/source/VirtualFluidsCore/Parallel/MPICommunicator.cpp
+++ b/source/VirtualFluidsCore/Parallel/MPICommunicator.cpp
@@ -208,6 +208,11 @@ void MPICommunicator::broadcast(std::vector<double>& values)
    broadcast<double>(values);
 }
 //////////////////////////////////////////////////////////////////////////
+void MPICommunicator::broadcast(std::vector<long int>& values)
+{
+   broadcast<long int>(values);
+}
+//////////////////////////////////////////////////////////////////////////
 void MPICommunicator::broadcast(int& value)
 {
    broadcast<int>(value);
@@ -223,5 +228,8 @@ void MPICommunicator::broadcast(double& value)
    broadcast<double>(value);
 }
 //////////////////////////////////////////////////////////////////////////
-
+void MPICommunicator::broadcast(long int& value)
+{
+   broadcast<long int>(value);
+}
 #endif
diff --git a/source/VirtualFluidsCore/Parallel/MPICommunicator.h b/source/VirtualFluidsCore/Parallel/MPICommunicator.h
index f21eda2db2f43763be35e627fb07eb28416b31e3..f57a7db4c9a1346239142517e54e28360d69cbf5 100644
--- a/source/VirtualFluidsCore/Parallel/MPICommunicator.h
+++ b/source/VirtualFluidsCore/Parallel/MPICommunicator.h
@@ -53,9 +53,11 @@ public:
    void broadcast(int& value);
    void broadcast(float& value);
    void broadcast(double& value);
+   void broadcast(long int& value);
    void broadcast(std::vector<int>& values);
    void broadcast(std::vector<float>& values);
    void broadcast(std::vector<double>& values);
+   void broadcast(std::vector<long int>& values);
 
    template <class T>
    std::vector<T> gather(std::vector<T>& values);
@@ -145,6 +147,7 @@ void MPICommunicator::broadcast(std::vector<T>& values)
    if ((std::string)typeid(T).name()==(std::string)typeid(double).name()) mpiDataType = MPI_DOUBLE;
    else if ((std::string)typeid(T).name()==(std::string)typeid(float).name()) mpiDataType = MPI_FLOAT;
    else if ((std::string)typeid(T).name()==(std::string)typeid(int).name()) mpiDataType = MPI_INT;
+   else if ((std::string)typeid(T).name()==(std::string)typeid(long int).name()) mpiDataType = MPI_LONG_INT;
    else throw UbException(UB_EXARGS, "no MpiDataType for T"+(std::string)typeid(T).name());
 
    int rcount;
@@ -170,6 +173,7 @@ void MPICommunicator::broadcast(T& value)
    if ((std::string)typeid(T).name() == (std::string)typeid(double).name()) mpiDataType = MPI_DOUBLE;
    else if ((std::string)typeid(T).name() == (std::string)typeid(float).name()) mpiDataType = MPI_FLOAT;
    else if ((std::string)typeid(T).name() == (std::string)typeid(int).name()) mpiDataType = MPI_INT;
+   else if ((std::string)typeid(T).name()==(std::string)typeid(long int).name()) mpiDataType = MPI_LONG_INT;
    else throw UbException(UB_EXARGS, "no MpiDataType for T" + (std::string)typeid(T).name());
 
    MPI_Bcast(&value, 1, mpiDataType, this->root, comm);
diff --git a/source/VirtualFluidsCore/Parallel/MetisPartitioner.cpp b/source/VirtualFluidsCore/Parallel/MetisPartitioner.cpp
index a234593cc7bb7a16e33cb331c58eecab5d910e42..31d23197e159933eb4dd6011853c1b45aaa4a38f 100644
--- a/source/VirtualFluidsCore/Parallel/MetisPartitioner.cpp
+++ b/source/VirtualFluidsCore/Parallel/MetisPartitioner.cpp
@@ -27,9 +27,9 @@ int MetisPartitioner::partition(int nofParts, MetisPartitioner::PartType ptype)
    int rc;
    idx_t nvtxs = (idx_t)xadj.size()-1;  // number of nodes
    idx_t ncon = (idx_t)vwgt.size()/nvtxs; // number Of node constraints;
-
    part.resize(nvtxs);
-   int edgecutCount = 0;
+   idx_t edgecutCount = 0;
+   idx_t nofPartsMetis = (idx_t)nofParts;
 
    switch (ptype)
    {
@@ -39,7 +39,7 @@ int MetisPartitioner::partition(int nofParts, MetisPartitioner::PartType ptype)
       //else if( nofParts >  8 ) UBLOG(logWARNING, "MetisPartitioner::Recursive: !!!Warning!!!  best for nofParts<=8 --> Kway is maybe a better option");
       
       rc = METIS_PartGraphRecursive(&nvtxs, &ncon, &xadj[0], &adjncy[0],
-                                    &vwgt[0], vsize, &adjwgt[0], &nofParts, 
+                                    &vwgt[0], vsize, &adjwgt[0], &nofPartsMetis, 
                                     tpwgts, ubvec, options, &edgecutCount, &part[0]);
    	break;
    case MetisPartitioner::KWAY: 
@@ -48,7 +48,7 @@ int MetisPartitioner::partition(int nofParts, MetisPartitioner::PartType ptype)
       //else if( nofParts <  9 ) UBLOG(logWARNING, "MetisPartitioner::Kway: !!!Warning!!!  best for nofParts>8 --> Recursive is maybe a better option");
 
       rc = METIS_PartGraphKway(&nvtxs, &ncon, &xadj[0], &adjncy[0],
-                                &vwgt[0], vsize, &adjwgt[0], &nofParts,
+                                &vwgt[0], vsize, &adjwgt[0], &nofPartsMetis,
                                 tpwgts, ubvec, options, &edgecutCount, &part[0]);
       break;
    }
diff --git a/source/VirtualFluidsCore/Utilities/VoxelMatrixUtil.hpp b/source/VirtualFluidsCore/Utilities/VoxelMatrixUtil.hpp
index 1ef7f15b475bae82e9ff331819544cb02c66ca1f..61a58b6396d30ef9e37eb07b4a1e4a8da6202e8c 100644
--- a/source/VirtualFluidsCore/Utilities/VoxelMatrixUtil.hpp
+++ b/source/VirtualFluidsCore/Utilities/VoxelMatrixUtil.hpp
@@ -4,7 +4,7 @@
 #include "GbCuboid3D.h"
 #include "NoSlipBCAdapter.h"
 #include "D3Q27Interactor.h"
-#include "SetSolidOrBoundaryBlockVisitor.h"
+#include "SetBcBlocksBlockVisitor.h"
 #include "Block3D.h"
 #include "Grid3D.h"
 
@@ -50,7 +50,7 @@ namespace Utilities
       //   vmInt->setDifferencesToGbObject3D(block);
       //}
 
-      SetSolidOrBoundaryBlockVisitor v(vmInt, SetSolidOrBoundaryBlockVisitor::BC);
+      SetBcBlocksBlockVisitor v(vmInt);
       grid->accept(v);
       vmInt->initInteractor();
    }
diff --git a/source/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.cpp
index 2b01489faa32af6f32c8d819370969068accc7d0..7f346a2399a3c6069345018c6f48d2ff508703c4 100644
--- a/source/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.cpp
+++ b/source/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.cpp
@@ -252,7 +252,7 @@ void InitDistributionsBlockVisitor::visit(const SPtr<Grid3D> grid, SPtr<Block3D>
                f[ZERO] = f_ZERO + feq[ZERO];
 
                //calcFeqsFct(f,rho,vx1,vx2,vx3);
-               distributions->setDistribution(f, ix1, ix2, ix3);
+               //distributions->setDistribution(f, ix1, ix2, ix3);
                distributions->setDistributionInv(f, ix1, ix2, ix3);
 
                //distributions->swap();
diff --git a/source/VirtualFluidsCore/Visitors/SetBcBlocksBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/SetBcBlocksBlockVisitor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0e8fcf3404630a6c8e2499618f2d4fac9839b702
--- /dev/null
+++ b/source/VirtualFluidsCore/Visitors/SetBcBlocksBlockVisitor.cpp
@@ -0,0 +1,24 @@
+#include "SetBcBlocksBlockVisitor.h"
+
+#include "Interactor3D.h"
+#include "Grid3DSystem.h"
+#include "Grid3D.h"
+#include "Block3D.h"
+
+SetBcBlocksBlockVisitor::SetBcBlocksBlockVisitor(SPtr<Interactor3D> interactor) : 
+   Block3DVisitor(0, Grid3DSystem::MAXLEVEL), interactor(interactor)
+{
+
+}
+
+void SetBcBlocksBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block)
+{
+   if(block->getRank() == grid->getRank())
+   {
+      if (block->isActive())
+      {
+         interactor->setBCBlock(block);
+      }
+   }
+}
+
diff --git a/source/VirtualFluidsCore/Visitors/SetBcBlocksBlockVisitor.h b/source/VirtualFluidsCore/Visitors/SetBcBlocksBlockVisitor.h
new file mode 100644
index 0000000000000000000000000000000000000000..9070d5de56d8166cddde40814e2c8ffd8f28a3c3
--- /dev/null
+++ b/source/VirtualFluidsCore/Visitors/SetBcBlocksBlockVisitor.h
@@ -0,0 +1,26 @@
+#ifndef SetBcBlocksBlockVisitor_h__
+#define SetBcBlocksBlockVisitor_h__
+
+#include <PointerDefinitions.h>
+
+#include "Block3DVisitor.h"
+
+class Grid3D;
+class Block3D;
+class Interactor3D;
+
+class SetBcBlocksBlockVisitor : public Block3DVisitor
+{
+public:
+   SetBcBlocksBlockVisitor(SPtr<Interactor3D> interactor);
+   virtual ~SetBcBlocksBlockVisitor() {}
+
+   virtual void visit(SPtr<Grid3D> grid, SPtr<Block3D> block);
+
+private:
+   SPtr<Interactor3D> interactor;
+};
+#endif // SetBcBlocksBlockVisitor_h__
+
+
+
diff --git a/source/VirtualFluidsCore/Visitors/SetSolidBlocksBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/SetSolidBlocksBlockVisitor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7c9342f1c6c42960bfa5d9a119fd2dc3847a80fd
--- /dev/null
+++ b/source/VirtualFluidsCore/Visitors/SetSolidBlocksBlockVisitor.cpp
@@ -0,0 +1,23 @@
+#include "SetSolidBlocksBlockVisitor.h"
+
+#include "Interactor3D.h"
+#include "Grid3DSystem.h"
+#include "Grid3D.h"
+#include "Block3D.h"
+
+SetSolidBlocksBlockVisitor::SetSolidBlocksBlockVisitor(SPtr<Interactor3D> interactor) :
+   Block3DVisitor(0, Grid3DSystem::MAXLEVEL), interactor(interactor)
+{
+
+}
+
+void SetSolidBlocksBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block)
+{
+   if (block->getRank() == grid->getRank())
+   {
+      if (block->isActive())
+      {
+         interactor->setSolidBlock(block);
+      }
+   }
+}
\ No newline at end of file
diff --git a/source/VirtualFluidsCore/Visitors/SetSolidBlocksBlockVisitor.h b/source/VirtualFluidsCore/Visitors/SetSolidBlocksBlockVisitor.h
new file mode 100644
index 0000000000000000000000000000000000000000..1f3d549125fe3da8835e3e75c2d0c5f23fc07744
--- /dev/null
+++ b/source/VirtualFluidsCore/Visitors/SetSolidBlocksBlockVisitor.h
@@ -0,0 +1,24 @@
+#ifndef SetSolidBlocksBlockVisitor_h__
+#define SetSolidBlocksBlockVisitor_h__
+
+#include <PointerDefinitions.h>
+
+#include "Block3DVisitor.h"
+
+class Grid3D;
+class Block3D;
+class Interactor3D;
+
+class SetSolidBlocksBlockVisitor : public Block3DVisitor
+{
+public:
+   SetSolidBlocksBlockVisitor(SPtr<Interactor3D> interactor);
+   virtual ~SetSolidBlocksBlockVisitor() {}
+
+   virtual void visit(SPtr<Grid3D> grid, SPtr<Block3D> block);
+
+private:
+   SPtr<Interactor3D> interactor;
+}
+#endif // SetSolidBlocksBlockVisitor_h__
+;
diff --git a/source/VirtualFluidsCore/Visitors/SetSolidOrBoundaryBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/SetSolidOrBoundaryBlockVisitor.cpp
deleted file mode 100644
index dab7b5f0443372663444fe5ffcf5612c99ad445a..0000000000000000000000000000000000000000
--- a/source/VirtualFluidsCore/Visitors/SetSolidOrBoundaryBlockVisitor.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "SetSolidOrBoundaryBlockVisitor.h"
-
-#include "Interactor3D.h"
-#include "Grid3DSystem.h"
-#include "Grid3D.h"
-#include "Block3D.h"
-
-SetSolidOrBoundaryBlockVisitor::SetSolidOrBoundaryBlockVisitor(SPtr<Interactor3D> interactor, BlockType type) : 
-   Block3DVisitor(0, Grid3DSystem::MAXLEVEL), interactor(interactor),
-   type(type)
-{
-
-}
-
-void SetSolidOrBoundaryBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block)
-{
-   if(block->getRank() == grid->getRank())
-   {
-      if (block->isActive())
-      {
-         switch (type)
-         {
-         case SOLID:
-            interactor->setSolidBlock(block);
-            break;
-         case BC:
-            interactor->setBCBlock(block);
-            break;
-         }
-      }
-   }
-}
-
diff --git a/source/VirtualFluidsCore/Visitors/SetSolidOrBoundaryBlockVisitor.h b/source/VirtualFluidsCore/Visitors/SetSolidOrBoundaryBlockVisitor.h
deleted file mode 100644
index d65d12be74fb78169a23fa41d7206cddbe8f3f9c..0000000000000000000000000000000000000000
--- a/source/VirtualFluidsCore/Visitors/SetSolidOrBoundaryBlockVisitor.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef SET_SOLID_OR_TRANS_BLOCK_VISITOR_H
-#define SET_SOLID_OR_TRANS_BLOCK_VISITOR_H
-
-#include <PointerDefinitions.h>
-
-#include "Block3DVisitor.h"
-
-class Grid3D;
-class Block3D;
-class Interactor3D;
-
-class SetSolidOrBoundaryBlockVisitor : public Block3DVisitor
-{
-public:
-   enum BlockType { SOLID, BC };
-public:
-   SetSolidOrBoundaryBlockVisitor(SPtr<Interactor3D> interactor, BlockType type);
-   virtual ~SetSolidOrBoundaryBlockVisitor() {}
-
-   virtual void visit(SPtr<Grid3D> grid, SPtr<Block3D> block);
-
-private:
-   SPtr<Interactor3D> interactor;
-   BlockType type;
-};
-
-#endif
-