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
This commit is contained in:
wmayer
2024-06-17 19:55:35 +02:00
committed by wwmayer
parent 4a11652263
commit 27c61ef137
2 changed files with 9 additions and 14 deletions

View File

@@ -50,6 +50,7 @@
#include <vector>
// boost
#include <boost/algorithm/string.hpp>
#include <boost/bind/bind.hpp>
#include <boost/lexical_cast.hpp>

View File

@@ -26,11 +26,12 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <boost/algorithm/string.hpp>
#include <Inventor/events/SoMouseButtonEvent.h>
#include <Inventor/nodes/SoCamera.h>
#include <Inventor/nodes/SoEventCallback.h>
#include <QAction>
#include <QApplication>
#include <QMessageBox>
@@ -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<const SMDS_MeshNode*> 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));