diff --git a/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp b/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp index 34e9b4ddbd0b7ca0d221e8a05bfbb3048b00f995..32d7355b64c59faf7d66200a512ab814217d8579 100644 --- a/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp +++ b/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp @@ -20,7 +20,7 @@ #include "DirectConditionGenerator.h" -#include "GeoLib/IO/AsciiRasterInterface.h" +#include "Applications/FileIO/AsciiRasterInterface.h" #include "Raster.h" #include "MeshSurfaceExtraction.h" @@ -37,7 +37,7 @@ DirectConditionGenerator::directToSurfaceNodes(const MeshLib::Mesh& mesh, if (_direct_values.empty()) { GeoLib::Raster* raster( - GeoLib::IO::AsciiRasterInterface::readRaster(filename)); + FileIO::AsciiRasterInterface::readRaster(filename)); if (!raster) { ERR("Error in DirectConditionGenerator::directToSurfaceNodes() - " @@ -72,17 +72,15 @@ DirectConditionGenerator::directToSurfaceNodes(const MeshLib::Mesh& mesh, const std::vector< std::pair<std::size_t,double> >& DirectConditionGenerator::directWithSurfaceIntegration(MeshLib::Mesh &mesh, const std::string &filename, double scaling) { if (!_direct_values.empty()) { - ERR( - "Error in DirectConditionGenerator::directWithSurfaceIntegration()" + ERR("Error in DirectConditionGenerator::directWithSurfaceIntegration()" "- Data vector contains outdated values..."); return _direct_values; } std::unique_ptr<GeoLib::Raster> raster( - GeoLib::IO::AsciiRasterInterface::readRaster(filename)); + FileIO::AsciiRasterInterface::readRaster(filename)); if (!raster) { - ERR( - "Error in DirectConditionGenerator::directWithSurfaceIntegration()" + ERR("Error in DirectConditionGenerator::directWithSurfaceIntegration()" "- could not load raster file."); return _direct_values; } diff --git a/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp b/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp index ed19652f2c5c5c20c9d65d33ec4a1657cbb4fb10..a3866cd621cde34c5c2f212fb3222f74b2087a45 100644 --- a/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp @@ -22,7 +22,7 @@ #include "StringTools.h" #include "Mesh.h" -#include "GeoLib/IO/AsciiRasterInterface.h" +#include "Applications/FileIO/AsciiRasterInterface.h" #include "TetGenInterface.h" #include <QCheckBox> @@ -190,7 +190,7 @@ MeshLib::Mesh* MeshLayerEditDialog::createPrismMesh() for (int i=nLayers; i>=0; --i) raster_paths.push_back(this->_edits[i]->text().toStdString()); - auto const rasters = GeoLib::IO::readRasters(raster_paths); + auto const rasters = FileIO::readRasters(raster_paths); if (rasters && mapper.createLayers(*_msh, *rasters, minimum_thickness)) { INFO("Mesh construction time: %d ms.", myTimer0.elapsed()); @@ -231,7 +231,7 @@ MeshLib::Mesh* MeshLayerEditDialog::createTetMesh() raster_paths.push_back(this->_edits[i]->text().toStdString()); LayeredVolume lv; - auto const rasters = GeoLib::IO::readRasters(raster_paths); + auto const rasters = FileIO::readRasters(raster_paths); if (rasters && lv.createLayers(*_msh, *rasters, minimum_thickness)) tg_mesh = lv.getMesh("SubsurfaceMesh").release(); diff --git a/Applications/DataExplorer/DataView/MshView.cpp b/Applications/DataExplorer/DataView/MshView.cpp index e01d5ddc1e1fd740595f182637042a3369d73ef1..bf7379b00bfc9a772905880be527c15d28e6857c 100644 --- a/Applications/DataExplorer/DataView/MshView.cpp +++ b/Applications/DataExplorer/DataView/MshView.cpp @@ -25,7 +25,7 @@ #include "SHPInterface.h" #include "TetGenInterface.h" -#include "GeoLib/IO/AsciiRasterInterface.h" +#include "Applications/FileIO/AsciiRasterInterface.h" #include "MeshLib/Mesh.h" #include "MeshLib/Node.h" @@ -166,7 +166,7 @@ void MshView::openMap2dMeshDialog() if (dlg.useRasterMapping()) { std::unique_ptr<GeoLib::Raster> raster{ - GeoLib::IO::AsciiRasterInterface::readRaster(dlg.getRasterPath())}; + FileIO::AsciiRasterInterface::readRaster(dlg.getRasterPath())}; if (!raster) { OGSError::box(QString::fromStdString( diff --git a/Applications/DataExplorer/VtkVis/VtkRaster.cpp b/Applications/DataExplorer/VtkVis/VtkRaster.cpp index c3f03ca787369413468b7745cd0e22a6591ad17a..676608acfc906c5b3a9fa9347d330dd17182ea59 100644 --- a/Applications/DataExplorer/VtkVis/VtkRaster.cpp +++ b/Applications/DataExplorer/VtkVis/VtkRaster.cpp @@ -35,7 +35,7 @@ #include <memory> #include <logog/include/logog.hpp> -#include "GeoLib/IO/AsciiRasterInterface.h" +#include "Applications/FileIO/AsciiRasterInterface.h" #include "GeoLib/Raster.h" @@ -47,9 +47,9 @@ vtkImageAlgorithm* VtkRaster::loadImage(const std::string &fileName, std::unique_ptr<GeoLib::Raster> raster(nullptr); if (fileInfo.suffix().toLower() == "asc") - raster.reset(GeoLib::IO::AsciiRasterInterface::getRasterFromASCFile(fileName)); + raster.reset(FileIO::AsciiRasterInterface::getRasterFromASCFile(fileName)); else if (fileInfo.suffix().toLower() == "grd") - raster.reset(GeoLib::IO::AsciiRasterInterface::getRasterFromSurferFile(fileName)); + raster.reset(FileIO::AsciiRasterInterface::getRasterFromSurferFile(fileName)); if (raster) return VtkRaster::loadImageFromArray(raster->begin(), raster->getHeader()); else if ((fileInfo.suffix().toLower() == "tif") || (fileInfo.suffix().toLower() == "tiff")) diff --git a/GeoLib/IO/AsciiRasterInterface.cpp b/Applications/FileIO/AsciiRasterInterface.cpp similarity index 97% rename from GeoLib/IO/AsciiRasterInterface.cpp rename to Applications/FileIO/AsciiRasterInterface.cpp index d8eca1d222ad5d15e6f40171ff31e8e5f87798f0..d308d507a8ae43fc184b775587193efc3350b733 100644 --- a/GeoLib/IO/AsciiRasterInterface.cpp +++ b/Applications/FileIO/AsciiRasterInterface.cpp @@ -21,9 +21,7 @@ #include "GeoLib/Raster.h" -namespace GeoLib -{ -namespace IO +namespace FileIO { GeoLib::Raster* AsciiRasterInterface::readRaster(std::string const& fname) @@ -241,8 +239,7 @@ boost::optional<std::vector<GeoLib::Raster const*>> readRasters( std::vector<GeoLib::Raster const*> rasters; rasters.reserve(raster_paths.size()); for (auto const& path : raster_paths) - rasters.push_back(GeoLib::IO::AsciiRasterInterface::readRaster(path)); + rasters.push_back(FileIO::AsciiRasterInterface::readRaster(path)); return boost::make_optional(rasters); } -} // end namespace IO -} // end namespace GeoLib +} // end namespace FileIO diff --git a/GeoLib/IO/AsciiRasterInterface.h b/Applications/FileIO/AsciiRasterInterface.h similarity index 96% rename from GeoLib/IO/AsciiRasterInterface.h rename to Applications/FileIO/AsciiRasterInterface.h index 3705826698535e4397934f20335f7cb52a965864..a2343f74f5cf1404722317d74504e0a6e6bda6ea 100644 --- a/GeoLib/IO/AsciiRasterInterface.h +++ b/Applications/FileIO/AsciiRasterInterface.h @@ -21,9 +21,7 @@ #include "GeoLib/Raster.h" -namespace GeoLib -{ -namespace IO +namespace FileIO { /** * Interface for reading and writing a number of ASCII raster formats. @@ -58,7 +56,6 @@ private: /// otherwise the returned vector contains pointers to the read rasters. boost::optional<std::vector<GeoLib::Raster const*>> readRasters( std::vector<std::string> const& raster_paths); -} // end namespace IO -} // end namespace GeoLib +} // end namespace FileIO #endif /* ASCIIRASTERINTERFACE_H_ */ diff --git a/GeoLib/IO/CsvInterface.cpp b/Applications/FileIO/CsvInterface.cpp similarity index 98% rename from GeoLib/IO/CsvInterface.cpp rename to Applications/FileIO/CsvInterface.cpp index 8a2ffa2f60809a23f48eec1a12bc7fccc1c659e1..ce2878960cf3a51b5ce117d150be8905acfd5bad 100644 --- a/GeoLib/IO/CsvInterface.cpp +++ b/Applications/FileIO/CsvInterface.cpp @@ -18,8 +18,7 @@ #include "GeoLib/Point.h" -namespace GeoLib { -namespace IO { +namespace FileIO { int CsvInterface::readPoints(std::string const& fname, char delim, std::vector<GeoLib::Point*> &points) @@ -182,5 +181,4 @@ std::size_t CsvInterface::findColumn(std::string const& line, char delim, std::s return count; } -} // end namespace IO -} // end namespace GeoLib +} // end namespace FileIO diff --git a/GeoLib/IO/CsvInterface.h b/Applications/FileIO/CsvInterface.h similarity index 99% rename from GeoLib/IO/CsvInterface.h rename to Applications/FileIO/CsvInterface.h index f01cbab2efb4933e4cb10f490d2081a13294c291..e78597c96e5eb72235f4e02fb1fe883096c19601 100644 --- a/GeoLib/IO/CsvInterface.h +++ b/Applications/FileIO/CsvInterface.h @@ -31,8 +31,7 @@ namespace GeoLib { class Point; } -namespace GeoLib { -namespace IO { +namespace FileIO { /** * Interface for reading CSV file formats. @@ -181,7 +180,6 @@ private: static std::size_t findColumn(std::string const& line, char delim, std::string const& column_name); }; -} // IO -} // GeoLib +} // FileIO #endif /* CSVINTERFACE_H_ */ diff --git a/Applications/Utils/MeshEdit/CMakeLists.txt b/Applications/Utils/MeshEdit/CMakeLists.txt index ab14a7dc8510fa9c1f25bacd408ff0f3479dbae4..bf0b42ad9fd7b7ac327a2604c5c024e95025b97b 100644 --- a/Applications/Utils/MeshEdit/CMakeLists.txt +++ b/Applications/Utils/MeshEdit/CMakeLists.txt @@ -56,7 +56,10 @@ target_link_libraries(AddTopLayer MeshLib) set_target_properties(AddTopLayer PROPERTIES FOLDER Utilities) add_executable(createLayeredMeshFromRasters createLayeredMeshFromRasters.cpp) -target_link_libraries(createLayeredMeshFromRasters MeshLib) +target_link_libraries(createLayeredMeshFromRasters + MeshLib + ApplicationsFileIO +) set_target_properties(createLayeredMeshFromRasters PROPERTIES FOLDER Utilities) add_executable(CreateBoundaryConditionsAlongPolylines diff --git a/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp b/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp index 93ab64c13f8ba59aa69fe5a299f28348596f3bc5..fb8dae413445e68efb971fc300c87b01f077f66b 100644 --- a/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp +++ b/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp @@ -23,8 +23,8 @@ #include "BaseLib/FileTools.h" #include "MeshLib/IO/readMeshFromFile.h" -#include "GeoLib/IO/AsciiRasterInterface.h" #include "MeshLib/IO/writeMeshToFile.h" +#include "Applications/FileIO/AsciiRasterInterface.h" #include "MeshLib/Mesh.h" #include "MeshLib/MeshGenerators/MeshLayerMapper.h" @@ -114,7 +114,7 @@ int main (int argc, char* argv[]) return EXIT_FAILURE; MeshLib::MeshLayerMapper mapper; - if (auto rasters = GeoLib::IO::readRasters(raster_paths)) + if (auto rasters = FileIO::readRasters(raster_paths)) { if (!mapper.createLayers(*sfc_mesh, *rasters, min_thickness)) return EXIT_FAILURE; diff --git a/Applications/Utils/SimpleMeshCreation/CMakeLists.txt b/Applications/Utils/SimpleMeshCreation/CMakeLists.txt index 6a81a133ae9b1e33da3c5b891a8c29d0351e443c..9792f3b516b117488eb44b79916829e4feb7f155 100644 --- a/Applications/Utils/SimpleMeshCreation/CMakeLists.txt +++ b/Applications/Utils/SimpleMeshCreation/CMakeLists.txt @@ -2,7 +2,10 @@ if(OGS_BUILD_GUI) add_executable(createMeshElemPropertiesFromASCRaster createMeshElemPropertiesFromASCRaster.cpp) set_target_properties(createMeshElemPropertiesFromASCRaster PROPERTIES FOLDER Utilities) - target_link_libraries(createMeshElemPropertiesFromASCRaster MeshLib) + target_link_libraries(createMeshElemPropertiesFromASCRaster + ApplicationsFileIO + MeshLib + ) ADD_VTK_DEPENDENCY(createMeshElemPropertiesFromASCRaster) endif() # OGS_BUILD_GUI (VtkVis-target is existing) diff --git a/Applications/Utils/SimpleMeshCreation/createMeshElemPropertiesFromASCRaster.cpp b/Applications/Utils/SimpleMeshCreation/createMeshElemPropertiesFromASCRaster.cpp index 481fa39185fee7a12eca417c45085b50b0f60a50..8a74156be5cd1199a808c422f525746f0be7ceaf 100644 --- a/Applications/Utils/SimpleMeshCreation/createMeshElemPropertiesFromASCRaster.cpp +++ b/Applications/Utils/SimpleMeshCreation/createMeshElemPropertiesFromASCRaster.cpp @@ -22,7 +22,7 @@ #include "MeshLib/IO/readMeshFromFile.h" #include "MeshLib/IO/writeMeshToFile.h" -#include "GeoLib/IO/AsciiRasterInterface.h" +#include "Applications/FileIO/AsciiRasterInterface.h" #include "GeoLib/Raster.h" @@ -127,7 +127,7 @@ int main (int argc, char* argv[]) // read raster and if required manipulate it auto raster = std::unique_ptr<GeoLib::Raster>( - GeoLib::IO::AsciiRasterInterface::getRasterFromASCFile(raster_arg.getValue())); + FileIO::AsciiRasterInterface::getRasterFromASCFile(raster_arg.getValue())); GeoLib::RasterHeader header (raster->getHeader()); if (refinement_arg.getValue() > 1) { raster->refineRaster(refinement_arg.getValue()); @@ -137,7 +137,7 @@ int main (int argc, char* argv[]) raster_arg.getValue())); new_raster_fname += "-" + std::to_string(header.n_rows) + "x" + std::to_string(header.n_cols) + ".asc"; - GeoLib::IO::AsciiRasterInterface::writeRasterAsASC(*raster, new_raster_fname); + FileIO::AsciiRasterInterface::writeRasterAsASC(*raster, new_raster_fname); } } diff --git a/MeshGeoToolsLib/GeoMapper.cpp b/MeshGeoToolsLib/GeoMapper.cpp index 7d20f1e0dfa609c1fb84052f1f9c69f3a503bf9c..8816ed23d69d62fe28a416a4e409607aa589c192 100644 --- a/MeshGeoToolsLib/GeoMapper.cpp +++ b/MeshGeoToolsLib/GeoMapper.cpp @@ -19,7 +19,7 @@ #include <logog/include/logog.hpp> -#include "GeoLib/IO/AsciiRasterInterface.h" +#include "Applications/FileIO/AsciiRasterInterface.h" #include "MeshLib/IO/readMeshFromFile.h" #include "GeoLib/AABB.h" @@ -50,7 +50,7 @@ GeoMapper::~GeoMapper() void GeoMapper::mapOnDEM(const std::string &file_name) { - _raster = GeoLib::IO::AsciiRasterInterface::getRasterFromASCFile(file_name); + _raster = FileIO::AsciiRasterInterface::getRasterFromASCFile(file_name); if (! _raster) { ERR("GeoMapper::mapOnDEM(): failed to load %s", file_name.c_str()); return; diff --git a/Tests/FileIO/TestCsvReader.cpp b/Tests/FileIO/TestCsvReader.cpp index be85b8c58f64f0c0ee9fde04d7e8ad826533b6dc..8076f413a3c2d7b2f30cda325e29b1fbba3ab9aa 100644 --- a/Tests/FileIO/TestCsvReader.cpp +++ b/Tests/FileIO/TestCsvReader.cpp @@ -17,7 +17,7 @@ #include "gtest/gtest.h" #include "BaseLib/BuildInfo.h" -#include "GeoLib/IO/CsvInterface.h" +#include "Applications/FileIO/CsvInterface.h" #include "GeoLib/Point.h" class CsvInterfaceTest : public ::testing::Test @@ -56,9 +56,9 @@ TEST_F(CsvInterfaceTest, SimpleReadPoints) { std::vector<GeoLib::Point*> points; std::vector<GeoLib::Point*> points2; - _result = GeoLib::IO::CsvInterface::readPoints(_file_name, '\t', points); + _result = FileIO::CsvInterface::readPoints(_file_name, '\t', points); ASSERT_EQ(0, _result); - _result = GeoLib::IO::CsvInterface::readPoints(_file_name, '\t', points2, "x", "y", "z"); + _result = FileIO::CsvInterface::readPoints(_file_name, '\t', points2, "x", "y", "z"); ASSERT_EQ(0, _result); ASSERT_TRUE(points.size() == 10); ASSERT_TRUE(points2.size() == 10); @@ -77,7 +77,7 @@ TEST_F(CsvInterfaceTest, SimpleReadPoints) TEST_F(CsvInterfaceTest, StringInPointColumn) { std::vector<GeoLib::Point*> points; - _result = GeoLib::IO::CsvInterface::readPoints(_file_name, '\t', points, "x", "y", "name"); + _result = FileIO::CsvInterface::readPoints(_file_name, '\t', points, "x", "y", "name"); ASSERT_EQ(10, _result); ASSERT_TRUE(points.empty()); } @@ -86,11 +86,11 @@ TEST_F(CsvInterfaceTest, StringInPointColumn) TEST_F(CsvInterfaceTest, WrongColumnName) { std::vector<GeoLib::Point*> points; - _result = GeoLib::IO::CsvInterface::readPoints(_file_name, '\t', points, "x", "y", "wrong_column_name"); + _result = FileIO::CsvInterface::readPoints(_file_name, '\t', points, "x", "y", "wrong_column_name"); ASSERT_EQ(-1, _result); ASSERT_TRUE(points.empty()); - _result = GeoLib::IO::CsvInterface::readPoints(_file_name, '\t', points, "wrong_column_name", "y", "id"); + _result = FileIO::CsvInterface::readPoints(_file_name, '\t', points, "wrong_column_name", "y", "id"); ASSERT_EQ(-1, _result); ASSERT_TRUE(points.empty()); } @@ -99,7 +99,7 @@ TEST_F(CsvInterfaceTest, WrongColumnName) TEST_F(CsvInterfaceTest, MissingValues) { std::vector<GeoLib::Point*> points; - _result = GeoLib::IO::CsvInterface::readPoints(_file_name, '\t', points, "z", "value1", "value_two"); + _result = FileIO::CsvInterface::readPoints(_file_name, '\t', points, "z", "value1", "value_two"); ASSERT_EQ(3, _result); ASSERT_EQ(7, points.size()); ASSERT_NEAR(437.539, (*points[4])[2], std::numeric_limits<double>::epsilon()); @@ -111,7 +111,7 @@ TEST_F(CsvInterfaceTest, MissingValues) TEST_F(CsvInterfaceTest, Points2D) { std::vector<GeoLib::Point*> points; - _result = GeoLib::IO::CsvInterface::readPoints(_file_name, '\t', points, "x", "y"); + _result = FileIO::CsvInterface::readPoints(_file_name, '\t', points, "x", "y"); ASSERT_EQ(0, _result); ASSERT_EQ(10, points.size()); for (auto & point : points) @@ -126,11 +126,11 @@ TEST_F(CsvInterfaceTest, CoordinateOrder) std::vector<GeoLib::Point*> points1; std::vector<GeoLib::Point*> points2; std::vector<GeoLib::Point*> points3; - _result = GeoLib::IO::CsvInterface::readPoints(_file_name, '\t', points1, "id", "y", "z"); + _result = FileIO::CsvInterface::readPoints(_file_name, '\t', points1, "id", "y", "z"); ASSERT_EQ(0, _result); - _result = GeoLib::IO::CsvInterface::readPoints(_file_name, '\t', points2, "id", "z", "y"); + _result = FileIO::CsvInterface::readPoints(_file_name, '\t', points2, "id", "z", "y"); ASSERT_EQ(0, _result); - _result = GeoLib::IO::CsvInterface::readPoints(_file_name, '\t', points3, "y", "id", "z"); + _result = FileIO::CsvInterface::readPoints(_file_name, '\t', points3, "y", "id", "z"); ASSERT_EQ(0, _result); ASSERT_EQ(10, points1.size()); ASSERT_EQ(10, points2.size()); @@ -156,12 +156,12 @@ TEST_F(CsvInterfaceTest, CoordinateOrder) TEST_F(CsvInterfaceTest, GetColumn) { std::vector<std::string> names; - _result = GeoLib::IO::CsvInterface::readColumn<std::string>(_file_name, '\t', names, "name"); + _result = FileIO::CsvInterface::readColumn<std::string>(_file_name, '\t', names, "name"); ASSERT_EQ(0, _result); ASSERT_EQ(10, names.size()); std::vector<double> values; - _result = GeoLib::IO::CsvInterface::readColumn<double>(_file_name, '\t', values, "value_two"); + _result = FileIO::CsvInterface::readColumn<double>(_file_name, '\t', values, "value_two"); ASSERT_EQ(2, _result); ASSERT_EQ(8, values.size()); } @@ -170,7 +170,7 @@ TEST_F(CsvInterfaceTest, GetColumn) TEST_F(CsvInterfaceTest, NonExistingColumn) { std::vector<double> values; - _result = GeoLib::IO::CsvInterface::readColumn<double>(_file_name, '\t', values, "value2"); + _result = FileIO::CsvInterface::readColumn<double>(_file_name, '\t', values, "value2"); ASSERT_EQ(-1, _result); ASSERT_TRUE(values.empty()); } @@ -179,12 +179,12 @@ TEST_F(CsvInterfaceTest, NonExistingColumn) TEST_F(CsvInterfaceTest, WrongDataType) { std::vector<double> values; - _result = GeoLib::IO::CsvInterface::readColumn<double>(_file_name, '\t', values, "name"); + _result = FileIO::CsvInterface::readColumn<double>(_file_name, '\t', values, "name"); ASSERT_EQ(10, _result); ASSERT_TRUE(values.empty()); std::vector<std::string> names; - _result = GeoLib::IO::CsvInterface::readColumn<std::string>(_file_name, '\t', names, "value1"); + _result = FileIO::CsvInterface::readColumn<std::string>(_file_name, '\t', names, "value1"); ASSERT_EQ(2, _result); ASSERT_EQ(8, names.size()); }