Skip to content
Snippets Groups Projects
Unverified Commit 19b527ca authored by Dmitri Naumov's avatar Dmitri Naumov Committed by GitHub
Browse files

Merge pull request #2655 from TomFischer/Cleanup

Cleanup of clang-tidy warnings
parents bb8e9c69 eda1854c
No related branches found
No related tags found
No related merge requests found
Showing
with 64 additions and 50 deletions
/**
* \file LastSavedFileDirectory.h
* \file
* \author Karsten Rink
* \date 2014-02-04
* \brief Manages the last directory used for saving a file
......
/**
* \file AddLayerToMeshDialog.cpp
* \file
* \author Karsten Rink
* \date 2016-01-18
* \brief Implementation of the AddLayerToMeshDialog class.
......
/**
* \file AddLayerToMeshDialog.h
* \file
* \author Karsten Rink
* \date 2016-01-18
* \brief Definition of the AddLayerToMeshDialog class.
......
/**
* \file CreateStructuredGridDialog.cpp
* \file
* \author Karsten Rink
* \date 2016-02-04
* \brief Implementation of the CreateStructuredGridDialog class.
......
/**
* \file CreateStructuredGridDialog.h
* \file
* \author Karsten Rink
* \date 2016-02-04
* \brief Definition of the CreateStructuredGridDialog class.
......
/**
* \file DataExplorerSettingsDialog.cpp
* \file
* \author Karsten Rink
* \date 2014-02-05
* \brief Implementation of the DataExplorerSettingsDialog class.
......
/**
* \file DataExplorerSettingsDialog.h
* \file
* \author Karsten Rink
* \date 2014-02-05
* \brief Definition of the DataExplorerSettingsDialog class.
......
......@@ -34,7 +34,9 @@ float DiagramList::calcMinXValue()
_coords.begin(), _coords.end(),
[](auto const& c0, auto const& c1) { return c0.first < c1.first; });
if (min != _coords.end())
{
return min->first;
}
return std::numeric_limits<float>::max();
}
......
/**
* \file MeshAnalysisDialog.cpp
* \file
* \author Karsten Rink
* \date 2014-02-24
* \brief Implementation of the MeshAnalysisDialog class.
......
/**
* \file MeshAnalysisDialog.h
* \file
* \author Karsten Rink
* \date 2014-02-24
* \brief Definition of the MeshAnalysisDialog class.
......
/**
* \file SaveMeshDialog.cpp
* \file
* \author Karsten Rink
* \date 2014-10-27
* \brief Implementation of the SaveMeshDialog class.
......
/**
* \file SaveMeshDialog.h
* \file
* \author Karsten Rink
* \date 2014-10-27
* \brief Definition of the SaveMeshDialog class.
......
/**
* \file SurfaceExtractionDialog.cpp
* \file
* \author Karsten Rink
* \date 2015-01-29
* \brief Implementation of the SaveMeshDialog class.
......
/**
* \file SurfaceExtractionDialog.h
* \file
* \author Karsten Rink
* \date 2015-01-29
* \brief Definition of the SurfaceExtractionDialog class.
......
......@@ -32,6 +32,17 @@
#include "MeshLib/MeshEnums.h"
#include "MeshLib/Node.h"
namespace
{
template <typename It>
std::array<double, 3> parsePointCoordinates(It& it)
{
return {std::strtod((++it)->c_str(), nullptr),
std::strtod((++it)->c_str(), nullptr),
std::strtod((++it)->c_str(), nullptr)};
}
} // namespace
namespace FileIO
{
int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes,
......@@ -50,7 +61,6 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes,
std::string cName;
std::string sName;
std::list<std::string>::const_iterator it;
auto* pnt = new GeoLib::Point();
GeoLib::StationBorehole* newBorehole = nullptr;
/* skipping first line because it contains field names */
......@@ -66,19 +76,19 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes,
if (*fields.begin() == cName) // add new layer
{
it = fields.begin();
(*pnt)[0] = strtod((++it)->c_str(), nullptr);
(*pnt)[1] = strtod((++it)->c_str(), nullptr);
(*pnt)[2] = strtod((++it)->c_str(), nullptr);
auto const pnt = parsePointCoordinates(it);
// check if current layer has a thickness of 0.0.
// if so skip it since it will mess with the vtk-visualisation
// later on!
if ((*pnt)[2] != depth)
if (pnt[2] != depth)
{
if (newBorehole == nullptr)
OGS_FATAL("Trying to access a nullptr.");
newBorehole->addSoilLayer(
(*pnt)[0], (*pnt)[1], (*pnt)[2], sName);
pnt[0], pnt[1], pnt[2], sName);
sName = (*(++it));
depth = (*pnt)[2];
depth = pnt[2];
}
else
WARN(
......@@ -95,13 +105,11 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes,
}
cName = *fields.begin();
it = fields.begin();
(*pnt)[0] = strtod((++it)->c_str(), nullptr);
(*pnt)[1] = strtod((++it)->c_str(), nullptr);
(*pnt)[2] = strtod((++it)->c_str(), nullptr);
auto const pnt = parsePointCoordinates(it);
sName = (*(++it));
newBorehole = GeoLib::StationBorehole::createStation(
cName, (*pnt)[0], (*pnt)[1], (*pnt)[2], 0);
depth = (*pnt)[2];
cName, pnt[0], pnt[1], pnt[2], 0);
depth = pnt[2];
}
}
else
......
......@@ -116,23 +116,20 @@ DataType datasetFound(std::ifstream& in)
{
return DataType::VSET;
}
else if (isKeyword(DataType::PLINE, line))
if (isKeyword(DataType::PLINE, line))
{
return DataType::PLINE;
}
else if (isKeyword(DataType::TSURF, line))
if (isKeyword(DataType::TSURF, line))
{
return DataType::TSURF;
}
else if (isKeyword(DataType::MODEL3D, line))
if (isKeyword(DataType::MODEL3D, line))
{
return DataType::MODEL3D;
}
else
{
ERR("No known identifier found...");
return DataType::UNDEFINED;
}
ERR("No known identifier found...");
return DataType::UNDEFINED;
}
return DataType::UNDEFINED;
}
......@@ -274,7 +271,7 @@ bool parseNodes(std::ifstream& in,
return true;
}
else if (line.substr(0, 4) == "TRGL")
if (line.substr(0, 4) == "TRGL")
{
in.seekg(pos);
return true;
......@@ -537,7 +534,9 @@ MeshLib::Mesh* createMesh(std::ifstream& in, DataType type,
return_val = parser(in, nodes, elems, node_id_map, mesh_prop);
if (return_val)
{
return new MeshLib::Mesh(mesh_name, nodes, elems, mesh_prop);
}
ERR("Error parsing %s %s.", dataType2ShortString(type).c_str(),
mesh_name.c_str());
clearData(nodes, elems);
......
......@@ -323,13 +323,13 @@ bool TetGenInterface::parseNodes(std::ifstream &ins,
std::size_t dim)
{
std::string line;
auto* coordinates(new double[dim]);
nodes.reserve(n_nodes);
std::size_t k(0);
while (k < n_nodes && !ins.fail())
{
getline(ins, line);
std::vector<double> coordinates(dim);
std::getline(ins, line);
if (ins.fail())
{
ERR("TetGenInterface::parseNodes(): Error reading node %d.", k);
......@@ -354,7 +354,6 @@ bool TetGenInterface::parseNodes(std::ifstream &ins,
}
} else {
ERR("TetGenInterface::parseNodes(): Error reading ID of node %d.", k);
delete [] coordinates;
return false;
}
// read coordinates
......@@ -373,27 +372,26 @@ bool TetGenInterface::parseNodes(std::ifstream &ins,
else
{
ERR("TetGenInterface::parseNodes(): error reading coordinate %d of node %d.", i, k);
delete [] coordinates;
return false;
}
}
nodes.push_back(new MeshLib::Node(coordinates, id-offset));
nodes.push_back(new MeshLib::Node(coordinates.data(), id-offset));
// read attributes and boundary markers ... - at the moment we do not use this information
++k;
}
delete [] coordinates;
return true;
}
bool TetGenInterface::readElementsFromStream(std::ifstream &ins,
std::vector<MeshLib::Element*> &elements,
std::vector<int> &materials,
const std::vector<MeshLib::Node*> &nodes) const
bool TetGenInterface::readElementsFromStream(
std::ifstream& ins,
std::vector<MeshLib::Element*>& elements,
std::vector<int>& materials,
const std::vector<MeshLib::Node*>& nodes) const
{
std::string line;
getline (ins, line);
std::getline(ins, line);
std::size_t n_tets;
std::size_t n_nodes_per_tet;
bool region_attributes;
......@@ -401,15 +399,16 @@ bool TetGenInterface::readElementsFromStream(std::ifstream &ins,
while (!ins.fail())
{
BaseLib::simplify(line);
if (line.empty() || line.compare(0,1,"#") == 0)
if (line.empty() || line.compare(0, 1, "#") == 0)
{
// this line is a comment - skip
getline (ins, line);
std::getline(ins, line);
continue;
}
// read header line
bool header_okay = parseElementsFileHeader(line, n_tets, n_nodes_per_tet, region_attributes);
bool header_okay = parseElementsFileHeader(
line, n_tets, n_nodes_per_tet, region_attributes);
if (!header_okay)
{
return false;
......
/**
* \file XmlNumInterface.cpp
* \file
* \author Karsten Rink
* \date 2014-08-05
* \brief Implementation of the XmlNumInterface class.
......
/**
* \file XmlNumInterface.h
* \file
* \author Karsten Rink
* \date 2014-08-05
* \brief Definition of the XmlNumInterface class.
......
......@@ -74,9 +74,13 @@ int main(int argc, char* argv[])
FileIO::Gocad::DataType t(FileIO::Gocad::DataType::ALL);
if (export_lines_arg.isSet())
{
t = FileIO::Gocad::DataType::PLINE;
}
if (export_surfaces_arg.isSet())
{
t = FileIO::Gocad::DataType::TSURF;
}
std::vector<std::unique_ptr<MeshLib::Mesh>> meshes;
if (!FileIO::Gocad::GocadAsciiReader::readFile(file_name, meshes, t))
{
......@@ -90,7 +94,9 @@ int main(int argc, char* argv[])
for (auto& mesh : meshes)
{
if (mesh == nullptr)
{
continue;
}
INFO("Writing mesh \"%s\"", mesh->getName().c_str());
int data_mode = (write_binary) ? 2 : 0;
bool compressed = (write_binary);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment