From 5704cb49cf620638515e97cac0dabc89f73377c0 Mon Sep 17 00:00:00 2001 From: Karsten Rink <karsten.rink@ufz.de> Date: Wed, 12 Nov 2014 12:48:53 +0100 Subject: [PATCH] changing the sequence in which rasters are read for tet meshes from low to high --- Gui/DataView/MeshLayerEditDialog.cpp | 10 ++++------ MeshLib/MeshGenerators/LayeredMeshGenerator.cpp | 2 +- MeshLib/MeshGenerators/LayeredMeshGenerator.h | 2 +- MeshLib/MeshGenerators/LayeredVolume.cpp | 4 ++-- MeshLib/MeshGenerators/MeshLayerMapper.cpp | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Gui/DataView/MeshLayerEditDialog.cpp b/Gui/DataView/MeshLayerEditDialog.cpp index 231275565f0..0eb92d64dbc 100644 --- a/Gui/DataView/MeshLayerEditDialog.cpp +++ b/Gui/DataView/MeshLayerEditDialog.cpp @@ -217,15 +217,13 @@ MeshLib::Mesh* MeshLayerEditDialog::createTetMesh() MeshLib::Mesh* tg_mesh (nullptr); if (_use_rasters) { - std::vector<std::string> raster_paths(nLayers+1); + std::vector<std::string> raster_paths; for (int i=nLayers; i>=0; --i) - raster_paths[i] = this->_edits[i]->text().toStdString(); + raster_paths.push_back(this->_edits[i]->text().toStdString()); LayeredVolume lv; - lv.createLayers(*_msh, raster_paths); + if (lv.createLayers(*_msh, raster_paths)) + tg_mesh = lv.getMesh("SubsurfaceMesh"); - tg_mesh = lv.getMesh("SubsurfaceMesh"); - - QString file_path(""); if (tg_mesh) { std::vector<MeshLib::Node> tg_attr (lv.getAttributePoints()); diff --git a/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp b/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp index 6303dc9fa47..241af740760 100644 --- a/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp +++ b/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp @@ -56,7 +56,7 @@ MeshLib::Mesh* LayeredMeshGenerator::getMesh(std::string const& mesh_name) const return result; } -double LayeredMeshGenerator::calcEpsilon(GeoLib::Raster const& high, GeoLib::Raster const& low) +double LayeredMeshGenerator::calcEpsilon(GeoLib::Raster const& low, GeoLib::Raster const& high) { const double max (*std::max_element(high.begin(), high.end())); const double min (*std::min_element( low.begin(), low.end())); diff --git a/MeshLib/MeshGenerators/LayeredMeshGenerator.h b/MeshLib/MeshGenerators/LayeredMeshGenerator.h index ca6e1ca72ae..461c4120953 100644 --- a/MeshLib/MeshGenerators/LayeredMeshGenerator.h +++ b/MeshLib/MeshGenerators/LayeredMeshGenerator.h @@ -80,7 +80,7 @@ protected: double minimum_thickness = std::numeric_limits<double>::epsilon()) const; /// Calculates a data-dependent epsilon value - double calcEpsilon(GeoLib::Raster const& high, GeoLib::Raster const& low); + double calcEpsilon(GeoLib::Raster const& low, GeoLib::Raster const& high); /// Checks if all raster files actually exist bool allRastersExist(std::vector<std::string> const& raster_paths) const; diff --git a/MeshLib/MeshGenerators/LayeredVolume.cpp b/MeshLib/MeshGenerators/LayeredVolume.cpp index 1bbaba483d9..c051b565f5d 100644 --- a/MeshLib/MeshGenerators/LayeredVolume.cpp +++ b/MeshLib/MeshGenerators/LayeredVolume.cpp @@ -41,11 +41,11 @@ bool LayeredVolume::createRasterLayers(const MeshLib::Mesh &mesh, const std::vec if (top==nullptr) top = new MeshLib::Mesh(mesh); - if (!MeshLayerMapper::layerMapping(*top, *rasters[0], noDataReplacementValue)) + if (!MeshLayerMapper::layerMapping(*top, *rasters.back(), noDataReplacementValue)) return false; MeshLib::Mesh* bottom (new MeshLib::Mesh(*top)); - if (!MeshLayerMapper::layerMapping(*bottom, *rasters.back(), 0)) + if (!MeshLayerMapper::layerMapping(*bottom, *rasters[0], 0)) { delete top; return false; diff --git a/MeshLib/MeshGenerators/MeshLayerMapper.cpp b/MeshLib/MeshGenerators/MeshLayerMapper.cpp index 79ae86356e5..416006b8972 100644 --- a/MeshLib/MeshGenerators/MeshLayerMapper.cpp +++ b/MeshLib/MeshGenerators/MeshLayerMapper.cpp @@ -156,7 +156,7 @@ void MeshLayerMapper::addLayerToMesh(const MeshLib::Mesh &dem_mesh, unsigned lay // add nodes for new layer for (std::size_t i=0; i<nNodes; ++i) - _nodes.push_back(getNewLayerNode(*nodes[i], *_nodes[last_layer_node_offset + i], raster, _nodes.size())); + _nodes.push_back(getNewLayerNode(*nodes[i], *_nodes[last_layer_node_offset + i], raster, _nodes.size(), _elevation_epsilon)); std::vector<MeshLib::Element*> const& elems = dem_mesh.getElements(); std::size_t const nElems (dem_mesh.getNElements()); -- GitLab