From 27c61ef137ebb2b2932b854ef0935146ff72f025 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 17 Jun 2024 19:55:35 +0200 Subject: [PATCH] FEM: Fix several issues * Move global (non-static) variables into anonymous namespace to avoid possible linking issues that may cause UB * Fix compiler warnings * Do not reinvent the wheel and use boost::to_upper_copy instead of own implementation --- src/Mod/Fem/Gui/PreCompiled.h | 1 + src/Mod/Fem/Gui/TaskCreateElementSet.cpp | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/Mod/Fem/Gui/PreCompiled.h b/src/Mod/Fem/Gui/PreCompiled.h index 72680e1d24..0961599685 100644 --- a/src/Mod/Fem/Gui/PreCompiled.h +++ b/src/Mod/Fem/Gui/PreCompiled.h @@ -50,6 +50,7 @@ #include // boost +#include #include #include diff --git a/src/Mod/Fem/Gui/TaskCreateElementSet.cpp b/src/Mod/Fem/Gui/TaskCreateElementSet.cpp index 9529efb17a..566d58c77f 100644 --- a/src/Mod/Fem/Gui/TaskCreateElementSet.cpp +++ b/src/Mod/Fem/Gui/TaskCreateElementSet.cpp @@ -26,11 +26,12 @@ #include "PreCompiled.h" #ifndef _PreComp_ +#include + #include #include #include - #include #include #include @@ -68,6 +69,10 @@ using namespace Gui; using namespace FemGui; using namespace std; +std::string TaskCreateElementSet::currentProject = ""; + +namespace +{ std::string inp_file = "abaqusOutputFileEraseElements.inp"; std::string createdMesh = "cDUMMY"; @@ -75,8 +80,6 @@ std::string startResultMesh = "StartResultMesh"; // StartResultMesh"; std::string newResultMesh = "NewResultMesh"; std::string newFemMesh = "NewFemMesh"; -std::string TaskCreateElementSet::currentProject = ""; - std::string uniqueMesh = ""; std::string newProject = ""; std::string resultMesh = "Result"; @@ -86,19 +89,9 @@ std::string highLightMesh; // name of highlighted mesh std::string meshType; // type of - either 'result' or 'femmesh' int passResult = 0; int passFemMesh = 0; -int maxProject = 10; double** nodeCoords; // these are node coords int* nodeNumbers; // these are node numbers - probably not required[100]; - -string myToUpper(std::string str) -{ - for (int i = 0; i < str.length(); i++) { - str[i] = toupper(str[i]); - } - return str; -} - void addFaceToMesh(const std::vector nodes, SMESHDS_Mesh* MeshDS, int EID) { int nbNodes = nodes.size(); @@ -446,6 +439,7 @@ void writeToFile(std::string fileName, fclose(fptr); return; } +} // namespace TaskCreateElementSet::TaskCreateElementSet(Fem::FemSetElementNodesObject* pcObject, QWidget* parent) : TaskBox(Gui::BitmapFactory().pixmap("FEM_CreateElementsSet"), @@ -626,7 +620,7 @@ void TaskCreateElementSet::DefineNodes(const Base::Polygon2d& polygon, highLightMesh = selection[0].FeatName; meshType = "NULL"; - std::size_t found = myToUpper(highLightMesh).find(myToUpper(resultMesh)); + std::size_t found = boost::to_upper_copy(highLightMesh).find(boost::to_upper_copy(resultMesh)); actualResultMesh = highLightMesh; // highLightMesh.find(myToUpper(resultMesh));