Skip to content
Snippets Groups Projects
Commit eda1854c authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[App/IO] GMS; Localize variable usage.

parent c8cff770
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,17 @@ ...@@ -32,6 +32,17 @@
#include "MeshLib/MeshEnums.h" #include "MeshLib/MeshEnums.h"
#include "MeshLib/Node.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 namespace FileIO
{ {
int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes, int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes,
...@@ -58,7 +69,6 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes, ...@@ -58,7 +69,6 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes,
/* read all stations */ /* read all stations */
while (std::getline(in, line)) while (std::getline(in, line))
{ {
std::array<double, 3> pnt;
std::list<std::string> fields = BaseLib::splitString(line, '\t'); std::list<std::string> fields = BaseLib::splitString(line, '\t');
if (fields.size() >= 5) if (fields.size() >= 5)
...@@ -66,9 +76,7 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes, ...@@ -66,9 +76,7 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes,
if (*fields.begin() == cName) // add new layer if (*fields.begin() == cName) // add new layer
{ {
it = fields.begin(); it = fields.begin();
pnt[0] = strtod((++it)->c_str(), nullptr); auto const pnt = parsePointCoordinates(it);
pnt[1] = strtod((++it)->c_str(), nullptr);
pnt[2] = strtod((++it)->c_str(), nullptr);
// check if current layer has a thickness of 0.0. // check if current layer has a thickness of 0.0.
// if so skip it since it will mess with the vtk-visualisation // if so skip it since it will mess with the vtk-visualisation
...@@ -97,9 +105,7 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes, ...@@ -97,9 +105,7 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes,
} }
cName = *fields.begin(); cName = *fields.begin();
it = fields.begin(); it = fields.begin();
pnt[0] = strtod((++it)->c_str(), nullptr); auto const pnt = parsePointCoordinates(it);
pnt[1] = strtod((++it)->c_str(), nullptr);
pnt[2] = strtod((++it)->c_str(), nullptr);
sName = (*(++it)); sName = (*(++it));
newBorehole = GeoLib::StationBorehole::createStation( newBorehole = GeoLib::StationBorehole::createStation(
cName, pnt[0], pnt[1], pnt[2], 0); cName, pnt[0], pnt[1], pnt[2], 0);
......
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