OGS
TetGenInterface.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <vector>
18
19// GeoLib
20#include "GeoLib/Point.h"
21#include "GeoLib/GEOObjects.h"
22
23// forward declaration of class Node and Element
24namespace MeshLib
25{
26 class Node;
27 class Element;
28 class Mesh;
29}
30
31namespace FileIO
32{
40class TetGenInterface final
41{
42public:
44
51 bool readTetGenGeometry (std::string const& geo_fname,
52 GeoLib::GEOObjects &geo_objects);
53
60 MeshLib::Mesh* readTetGenMesh (std::string const& nodes_fname,
61 std::string const& ele_fname);
62
71 static bool writeTetGenSmesh(
72 const std::string& file_name,
73 const GeoLib::GEOObjects& geo_objects,
74 const std::string& geo_name,
75 const std::vector<GeoLib::Point>& attribute_points);
76
84 bool writeTetGenSmesh(const std::string &file_name,
85 const MeshLib::Mesh &mesh,
86 std::vector<MeshLib::Node> &attribute_points) const;
87
88private:
90 std::size_t getNFacets(std::ifstream &input);
91
100 bool parseSmeshFacets(std::ifstream &input,
101 std::vector<GeoLib::Surface*> &surfaces,
102 const std::vector<GeoLib::Point*> &points,
103 const std::vector<std::size_t> &pnt_id_map);
104
113 bool readNodesFromStream(std::ifstream& ins,
114 std::vector<MeshLib::Node*>& nodes);
115
125 static bool parseNodesFileHeader(std::string const& line,
126 std::size_t& n_nodes,
127 std::size_t& dim,
128 std::size_t& n_attributes,
129 bool& boundary_markers);
138 bool parseNodes(std::ifstream &ins,
139 std::vector<MeshLib::Node*> &nodes,
140 std::size_t n_nodes,
141 std::size_t dim);
142
154 bool readElementsFromStream(std::ifstream& ins,
155 std::vector<MeshLib::Element*>& elements,
156 std::vector<int>& materials,
157 const std::vector<MeshLib::Node*>& nodes) const;
166 static bool parseElementsFileHeader(std::string& line,
167 std::size_t& n_tets,
168 std::size_t& n_nodes_per_tet,
169 bool& region_attribute);
181 bool parseElements(std::ifstream& ins,
182 std::vector<MeshLib::Element*> &elements,
183 std::vector<int> &materials,
184 const std::vector<MeshLib::Node*> &nodes,
185 std::size_t n_tets,
186 std::size_t n_nodes_per_tet,
187 bool region_attribute) const;
188
195 void write2dElements(std::ofstream &out,
196 const MeshLib::Mesh &mesh) const;
197
205 void write3dElements(std::ofstream &out,
206 const MeshLib::Mesh &mesh,
207 std::vector<MeshLib::Node> &attribute_points) const;
208
210 static void writeElementToFacets(std::ofstream& out,
211 const MeshLib::Element& element,
212 unsigned& element_count,
213 std::string const& matId);
214
216 bool _zero_based_idx{false};
217
219 bool _boundary_markers{false};
220};
221} // namespace FileIO
Definition of the GEOObjects class.
Definition of the Point class.
bool readElementsFromStream(std::ifstream &ins, std::vector< MeshLib::Element * > &elements, std::vector< int > &materials, const std::vector< MeshLib::Node * > &nodes) const
bool _boundary_markers
true if boundary markers are set, false otherwise
MeshLib::Mesh * readTetGenMesh(std::string const &nodes_fname, std::string const &ele_fname)
bool parseNodes(std::ifstream &ins, std::vector< MeshLib::Node * > &nodes, std::size_t n_nodes, std::size_t dim)
static bool parseElementsFileHeader(std::string &line, std::size_t &n_tets, std::size_t &n_nodes_per_tet, bool &region_attribute)
void write3dElements(std::ofstream &out, const MeshLib::Mesh &mesh, std::vector< MeshLib::Node > &attribute_points) const
bool readNodesFromStream(std::ifstream &ins, std::vector< MeshLib::Node * > &nodes)
static bool parseNodesFileHeader(std::string const &line, std::size_t &n_nodes, std::size_t &dim, std::size_t &n_attributes, bool &boundary_markers)
bool _zero_based_idx
the value is true if the indexing is zero based, else false
bool readTetGenGeometry(std::string const &geo_fname, GeoLib::GEOObjects &geo_objects)
void write2dElements(std::ofstream &out, const MeshLib::Mesh &mesh) const
bool parseElements(std::ifstream &ins, std::vector< MeshLib::Element * > &elements, std::vector< int > &materials, const std::vector< MeshLib::Node * > &nodes, std::size_t n_tets, std::size_t n_nodes_per_tet, bool region_attribute) const
static bool writeTetGenSmesh(const std::string &file_name, const GeoLib::GEOObjects &geo_objects, const std::string &geo_name, const std::vector< GeoLib::Point > &attribute_points)
static void writeElementToFacets(std::ofstream &out, const MeshLib::Element &element, unsigned &element_count, std::string const &matId)
Writes facet information from a 2D element to the stream and increments the total element count accor...
bool parseSmeshFacets(std::ifstream &input, std::vector< GeoLib::Surface * > &surfaces, const std::vector< GeoLib::Point * > &points, const std::vector< std::size_t > &pnt_id_map)
std::size_t getNFacets(std::ifstream &input)
Returns the declared number of facets in the poly file.
Container class for geometric objects.
Definition GEOObjects.h:57