From 69e5f46ef617a2518bbf815efb9f493c6fa0fe5c Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <dmitri.naumov@ufz.de> Date: Wed, 22 May 2019 18:24:43 +0200 Subject: [PATCH] [MeL] Update checkMesh min/max bounds calls. Avoids variable shadowing (vec_bounds). Simplifies handling of error cases w/o using any sentinel values. Using sentinel values for integers or doubles artificially restricts the range of possible values used and can lead to unadvert (incorrect) errors. --- Applications/Utils/MeshEdit/checkMesh.cpp | 29 +++++++++++------------ 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Applications/Utils/MeshEdit/checkMesh.cpp b/Applications/Utils/MeshEdit/checkMesh.cpp index 8fbf8053fbf..462abd7bbb7 100644 --- a/Applications/Utils/MeshEdit/checkMesh.cpp +++ b/Applications/Utils/MeshEdit/checkMesh.cpp @@ -116,26 +116,25 @@ int main(int argc, char *argv[]) std::vector<std::string> const& vec_names (mesh->getProperties().getPropertyVectorNames()); INFO("There are %d properties in the mesh:", vec_names.size()); - for (const auto & vec_name : vec_names) + for (const auto& vec_name : vec_names) { - auto vec_bounds (MeshLib::MeshInformation::getValueBounds<int>(*mesh, vec_name)); - if (vec_bounds.second != std::numeric_limits<int>::max()) + if (auto const vec_bounds = + MeshLib::MeshInformation::getValueBounds<int>(*mesh, vec_name)) { - INFO("\t%s: [%d, %d]", vec_name.c_str(), vec_bounds.first, - vec_bounds.second); + INFO("\t%s: [%d, %d]", vec_name.c_str(), vec_bounds->first, + vec_bounds->second); + } + else if (auto const vec_bounds = + MeshLib::MeshInformation::getValueBounds<double>(*mesh, + vec_name)) + { + INFO("\t%s: [%g, %g]", vec_name.c_str(), vec_bounds->first, + vec_bounds->second); } else { - auto vec_bounds (MeshLib::MeshInformation::getValueBounds<double>(*mesh, vec_name)); - if (vec_bounds.second != std::numeric_limits<double>::max()) - { - INFO("\t%s: [%g, %g]", vec_name.c_str(), vec_bounds.first, - vec_bounds.second); - } - else - { - INFO("\t%s: Unknown properties", vec_name.c_str()); - } + INFO("\t%s: Could not get value bounds for property vector.", + vec_name.c_str()); } } -- GitLab