14#include <QtXml/QDomDocument>
15#include <boost/algorithm/string/trim.hpp>
32 std::ifstream in(filename.c_str());
35 ERR(
"FEFLOWGeoInterface::readFEFLOWFile(): Could not open file {:s}.",
40 unsigned dimension = 0;
41 std::vector<GeoLib::Point*> points;
42 std::vector<GeoLib::Polyline*> lines;
44 bool isXZplane =
false;
46 std::string line_string;
47 std::stringstream line_stream;
50 std::getline(in, line_string);
53 if (line_string.find(
"CLASS") != std::string::npos)
55 std::getline(in, line_string);
56 line_stream.str(line_string);
59 for (
int i = 0; i < 3; i++)
63 line_stream >> dimension;
68 else if (line_string ==
"GRAVITY")
70 std::getline(in, line_string);
71 line_stream.str(line_string);
73 line_stream >> vec[0] >> vec[1] >> vec[2];
74 if (vec[0] == 0.0 && vec[1] == -1.0 && vec[2] == 0.0)
83 else if (line_string ==
"SUPERMESH")
91 if (isXZplane && !points.empty())
93 for (
auto* pt : points)
99 std::string project_name(
103 geo_objects.
addPointVec(std::move(points), project_name,
114 const std::string& tag,
116 std::vector<GeoLib::Point*>& points)
119 nodesEle.firstChildElement(QString::fromStdString(tag));
124 QString str_pt_list1 = xmlEle.text();
125 std::istringstream ss(str_pt_list1.toStdString());
126 std::string line_str;
129 std::getline(ss, line_str);
130 boost::trim_right(line_str);
131 if (line_str.empty())
135 std::istringstream line_ss(line_str);
136 std::size_t pt_id = 0;
137 std::array<double, 3> pt_xyz;
139 for (
int i = 0; i < dim; i++)
141 line_ss >> pt_xyz[i];
149 std::vector<GeoLib::Point*>& points,
150 std::vector<GeoLib::Polyline*>& lines)
153 std::ostringstream oss;
154 std::string line_string;
157 std::getline(in, line_string);
159 oss << line_string <<
"\n";
160 if (line_string.find(
"</supermesh>") != std::string::npos)
165 const QString strXML(oss.str().c_str());
169 if (!doc.setContent(strXML))
171 ERR(
"FEFLOWGeoInterface::readSuperMesh(): Illegal XML format error");
176 QDomElement docElem = doc.documentElement();
178 QDomElement nodesEle = docElem.firstChildElement(
"nodes");
179 if (nodesEle.isNull())
185 const QString str = nodesEle.attribute(
"count");
186 const long n_points = str.toLong();
187 points.resize(n_points);
189 readPoints(nodesEle,
"fixed", dimension, points);
190 readPoints(nodesEle,
"linear", dimension, points);
191 readPoints(nodesEle,
"parabolic", dimension, points);
195 QDomElement polygonsEle = docElem.firstChildElement(
"polygons");
196 if (polygonsEle.isNull())
202 QDomNode child = polygonsEle.firstChild();
203 while (!child.isNull())
205 if (child.nodeName() !=
"polygon")
207 child = child.nextSibling();
210 QDomElement xmlEle = child.firstChildElement(
"nodes");
215 const QString str = xmlEle.attribute(
"count");
216 const std::size_t n_points = str.toLong();
217 QString str_ptId_list = xmlEle.text().simplified();
220 lines.push_back(line);
221 std::istringstream ss(str_ptId_list.toStdString());
222 for (std::size_t i = 0; i < n_points; i++)
226 line->addPoint(pt_id - 1);
228 line->addPoint(line->getPointID(0));
230 child = child.nextSibling();
Definition of the GEOObjects class.
Definition of the Point class.
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Polygon class.
static void readPoints(QDomElement &nodesEle, const std::string &tag, int dim, std::vector< GeoLib::Point * > &points)
void readFEFLOWFile(const std::string &filename, GeoLib::GEOObjects &geo_objects)
static void readSuperMesh(std::ifstream &in, unsigned dimension, std::vector< GeoLib::Point * > &points, std::vector< GeoLib::Polyline * > &lines)
Container class for geometric objects.
void addPolylineVec(std::vector< Polyline * > &&lines, std::string const &name, PolylineVec::NameIdMap &&ply_names)
void addPointVec(std::vector< Point * > &&points, std::string &name, PointVec::NameIdMap &&pnt_id_name_map, double const eps=std::sqrt(std::numeric_limits< double >::epsilon()))
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
std::map< std::string, std::size_t > NameIdMap
void trim(std::string &str, char ch)
std::string extractBaseNameWithoutExtension(std::string const &pathname)