OGS
MeshIO.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <string>
18#include <vector>
19
20#include "BaseLib/IO/Writer.h"
21#include "MeshLib/MeshEnums.h"
22
23namespace MeshLib
24{
25class Mesh;
26class Node;
27class Element;
28template <typename T>
29class PropertyVector;
30enum class MeshElemType;
31namespace IO
32{
33namespace Legacy
34{
37{
38public:
41
42 ~MeshIO() override = default;
43
45 MeshLib::Mesh* loadMeshFromFile(const std::string& file_name);
46
48 void setMesh(const MeshLib::Mesh* mesh);
49
50protected:
52 bool write() override;
53
54private:
55 void writeElements(std::vector<MeshLib::Element*> const& ele_vec,
56 MeshLib::PropertyVector<int> const* const material_ids,
57 std::ostream& out) const;
58 static std::size_t readMaterialID(std::istream & in);
60 std::istream& in, const std::vector<MeshLib::Node*>& nodes) const;
61 static std::string ElemType2StringOutput(const MeshLib::MeshElemType t);
62
63 const MeshLib::Mesh* _mesh{nullptr};
64
65}; /* class */
66
67} // end namespace Legacy
68} // end namespace IO
69} // end namespace MeshLib
Definition of mesh-related Enumerations.
Definition of the Writer class.
Base class which enables writing an object to string, stringstream or file.
Definition: Writer.h:31
std::ostringstream out
The stream to write to.
Definition: Writer.h:46
Interface for handling mesh files from OGS-5 and below. (*.msh files)
Definition: MeshIO.h:37
bool write() override
Write mesh to stream.
Definition: MeshIO.cpp:326
MeshLib::Element * readElement(std::istream &in, const std::vector< MeshLib::Node * > &nodes) const
Definition: MeshIO.cpp:176
MeshLib::Mesh * loadMeshFromFile(const std::string &file_name)
Read mesh from file.
Definition: MeshIO.cpp:42
const MeshLib::Mesh * _mesh
Definition: MeshIO.h:63
static std::size_t readMaterialID(std::istream &in)
Definition: MeshIO.cpp:165
~MeshIO() override=default
void setMesh(const MeshLib::Mesh *mesh)
Set mesh for writing.
Definition: MeshIO.cpp:364
void writeElements(std::vector< MeshLib::Element * > const &ele_vec, MeshLib::PropertyVector< int > const *const material_ids, std::ostream &out) const
Definition: MeshIO.cpp:369
static std::string ElemType2StringOutput(const MeshLib::MeshElemType t)
Definition: MeshIO.cpp:407
static const double t
MeshElemType
Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.
Definition: MeshEnums.h:27