From 6117e25a15414bc3c2481eb237e34d1e705214bb Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <dmitri.naumov@ufz.de>
Date: Thu, 14 Apr 2016 21:43:44 +0200
Subject: [PATCH] [MeL] Pass rasters to LayeredMeshGenerator.

---
 .../MeshGenerators/LayeredMeshGenerator.cpp    | 18 ++++++------------
 MeshLib/MeshGenerators/LayeredMeshGenerator.h  |  4 ++--
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp b/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp
index bb02e14ac49..ec7b5ee08a5 100644
--- a/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp
+++ b/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp
@@ -19,8 +19,6 @@
 
 #include <logog/include/logog.hpp>
 
-#include "FileIO/AsciiRasterInterface.h"
-
 #include "GeoLib/Raster.h"
 
 #include "MeshLib/Mesh.h"
@@ -37,19 +35,15 @@ LayeredMeshGenerator::LayeredMeshGenerator()
 {
 }
 
-bool LayeredMeshGenerator::createLayers(MeshLib::Mesh const& mesh,
-                                        std::vector<std::string> const& raster_paths,
-                                        double minimum_thickness,
-                                        double noDataReplacementValue)
+bool LayeredMeshGenerator::createLayers(
+    MeshLib::Mesh const& mesh,
+    std::vector<GeoLib::Raster const*> const& rasters,
+    double minimum_thickness,
+    double noDataReplacementValue)
 {
-    if (mesh.getDimension() != 2 || !FileIO::allRastersExist(raster_paths))
+    if (mesh.getDimension() != 2)
         return false;
 
-    std::vector<GeoLib::Raster const*> rasters;
-    rasters.reserve(raster_paths.size());
-    for (auto path = raster_paths.begin(); path != raster_paths.end(); ++path)
-        rasters.push_back(FileIO::AsciiRasterInterface::readRaster(*path));
-
     bool result = createRasterLayers(mesh, rasters, minimum_thickness, noDataReplacementValue);
     std::for_each(rasters.begin(), rasters.end(), [](GeoLib::Raster const*const raster){ delete raster; });
     return result;
diff --git a/MeshLib/MeshGenerators/LayeredMeshGenerator.h b/MeshLib/MeshGenerators/LayeredMeshGenerator.h
index 522b962069f..6917043bae6 100644
--- a/MeshLib/MeshGenerators/LayeredMeshGenerator.h
+++ b/MeshLib/MeshGenerators/LayeredMeshGenerator.h
@@ -39,13 +39,13 @@ public:
 	/**
 	* Returns a subsurface representation of a region represented by a 2D  mesh by reading raster files and calling the appropriate construction method.
 	* @param mesh                    The 2D surface mesh that is used as a basis for the subsurface mesh
-	* @param raster_paths            Containing all the raster-file-names for the subsurface layers from bottom to top (starting with the bottom of the oldest layer and ending with the DEM)
+	* @param rasters                 Containing all the rasters for the subsurface layers from bottom to top (starting with the bottom of the oldest layer and ending with the DEM)
 	* @param minimum_thickness       Minimum thickness of each of the newly created layers (i.e. nodes with a vertical distance smaller than this will be collapsed)
 	* @param noDataReplacementValue  Default z-coordinate if there are mesh nodes not located on the DEM raster (i.e. raster_paths[0])
 	* @result true if the subsurface representation has been created, false if there was an error
 	*/
 	virtual bool createLayers(MeshLib::Mesh const& mesh,
-	                          std::vector<std::string> const& raster_paths,
+	                          std::vector<GeoLib::Raster const*> const& rasters,
 	                          double minimum_thickness,
 	                          double noDataReplacementValue = 0.0) final;
 
-- 
GitLab