45 const std::string& filename)
47 std::ifstream in(filename.c_str());
50 ERR(
"GMSInterface::readBoreholeFromGMS(): Could not open file {:s}.",
55 double depth(-9999.0);
59 std::list<std::string>::const_iterator it;
63 std::getline(in, line);
66 while (std::getline(in, line))
70 if (fields.size() >= 5)
72 if (*fields.begin() == cName)
75 auto const pnt = parsePointCoordinates(it);
82 if (newBorehole ==
nullptr)
84 newBorehole->
addSoilLayer(pnt[0], pnt[1], pnt[2], sName);
91 "GMSInterface::readBoreholeFromGMS(): Skipped layer "
92 "'{:s}' in borehole '{:s}' because of thickness 0.0.",
98 if (newBorehole !=
nullptr)
100 newBorehole->
setDepth((*newBorehole)[2] - depth);
101 boreholes.push_back(newBorehole);
103 cName = *fields.begin();
105 auto const pnt = parsePointCoordinates(it);
108 cName, pnt[0], pnt[1], pnt[2], 0);
114 ERR(
"GMSInterface::readBoreholeFromGMS(): Error reading format.");
118 if (newBorehole !=
nullptr)
120 newBorehole->
setDepth((*newBorehole)[2] - depth);
121 boreholes.push_back(newBorehole);
125 if (boreholes.empty())
133 const std::vector<GeoLib::Point*>* stations,
const std::string& filename)
135 std::ofstream out(filename.c_str(), std::ios::out);
139 <<
"\t" << std::fixed <<
"X"
148 for (
auto station_as_point : *stations)
150 auto const* station =
152 std::vector<GeoLib::Point*>
const& profile = station->
getProfile();
153 std::vector<std::string>
const& soilNames = station->getSoilNames();
154 std::string current_soil_name;
156 std::size_t nLayers = profile.size();
157 for (std::size_t i = 1; i < nLayers; i++)
159 if ((i > 1) && (soilNames[i] == soilNames[i - 1]))
163 current_soil_name = soilNames[i];
165 out << station->getName() <<
"\t" << std::fixed
166 << (*(profile[i - 1]))[0] <<
"\t" << (*(profile[i - 1]))[1]
167 <<
"\t" << (*(profile[i - 1]))[2] <<
"\t"
168 << current_soil_name <<
"\n";
170 out << station->getName() <<
"\t" << std::fixed
171 << (*(profile[nLayers - 1]))[0] <<
"\t"
172 << (*(profile[nLayers - 1]))[1] <<
"\t"
173 << (*(profile[nLayers - 1]))[2] <<
"\t" << current_soil_name
184 std::ifstream in(filename.c_str());
187 ERR(
"GMSInterface::readMesh(): Could not open file {:s}.", filename);
192 std::getline(in, line);
193 if (line !=
"MESH3D" && line !=
"MESH2D")
195 ERR(
"GMSInterface::readMesh(): Could not read expected file "
199 bool const is_3d = (line ==
"MESH3D");
202 INFO(
"Reading SMS/GMS mesh...");
203 std::vector<MeshLib::Node*> nodes;
204 std::vector<MeshLib::Element*> elements;
205 std::vector<int> mat_ids;
206 std::map<unsigned, unsigned> id_map;
215 while (std::getline(in, line))
219 std::stringstream str(line);
220 str >> dummy >>
id >> x[0] >> x[1] >> x[2];
222 id_map.insert(std::pair<unsigned, unsigned>(
id, count++));
223 nodes.push_back(node);
230 in.open(filename.c_str());
231 std::getline(in, line);
232 unsigned node_idx[6];
234 while (std::getline(in, line))
236 std::string element_id(line.substr(0, 3));
237 std::stringstream str(line);
239 if (element_id ==
"MES")
241 str >> dummy >> mesh_name;
242 mesh_name = mesh_name.substr(1, mesh_name.length() - 2);
244 else if (!is_3d && element_id ==
"E3T")
246 str >> dummy >>
id >> node_idx[0] >> node_idx[1] >> node_idx[2] >>
248 std::array<MeshLib::Node*, 3> tri_nodes;
249 for (
unsigned k(0); k < 3; k++)
251 tri_nodes[k] = nodes[id_map.find(node_idx[k])->second];
254 mat_ids.push_back(mat_id);
256 else if (!is_3d && element_id ==
"E6T")
258 str >> dummy >>
id >> node_idx[0] >> node_idx[3] >> node_idx[1] >>
259 node_idx[4] >> node_idx[2] >> node_idx[5] >> mat_id;
260 std::array<MeshLib::Node*, 3> tri_nodes;
261 for (
unsigned k(0); k < 3; k++)
263 tri_nodes[k] = nodes[id_map.find(node_idx[k])->second];
266 mat_ids.push_back(mat_id);
268 else if (is_3d && element_id ==
"E6W")
270 str >> dummy >>
id >> node_idx[0] >> node_idx[1] >> node_idx[2] >>
271 node_idx[3] >> node_idx[4] >> node_idx[5] >> mat_id;
272 std::array<MeshLib::Node*, 6> prism_nodes;
273 for (
unsigned k(0); k < 6; k++)
275 prism_nodes[k] = nodes[id_map.find(node_idx[k])->second];
278 mat_ids.push_back(mat_id);
280 else if (is_3d && element_id ==
"E4T")
282 str >> dummy >>
id >> node_idx[0] >> node_idx[1] >> node_idx[2] >>
283 node_idx[3] >> mat_id;
284 std::array<MeshLib::Node*, 4> tet_nodes;
285 for (
unsigned k(0); k < 4; k++)
287 tet_nodes[k] = nodes[id_map.find(node_idx[k])->second];
290 mat_ids.push_back(mat_id);
293 else if (is_3d && (element_id ==
"E4P" || element_id ==
"E5P"))
295 str >> dummy >>
id >> node_idx[0] >> node_idx[1] >> node_idx[2] >>
296 node_idx[3] >> node_idx[4] >> mat_id;
297 std::array<MeshLib::Node*, 5> pyramid_nodes;
298 for (
unsigned k(0); k < 5; k++)
300 pyramid_nodes[k] = nodes[id_map.find(node_idx[k])->second];
303 mat_ids.push_back(mat_id);
305 else if (element_id ==
"ND ")
312 "GMSInterface::readMesh() - Element type '{:s}' not "
323 if (mat_ids.size() == elements.size())
329 ERR(
"Could not create PropertyVector for material ids.");
333 opt_pv->reserve(mat_ids.size());
334 std::copy(mat_ids.cbegin(), mat_ids.cend(),
335 std::back_inserter(*opt_pv));
339 ERR(
"Ignoring Material IDs information (does not match number of "
static StationBorehole * createStation(const std::string &name, double x, double y, double z, double depth, const std::string &date="")
Creates a new borehole object based on the given parameters.