Loading [MathJax]/extensions/tex2jax.js
OGS
TetGenInterface.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <vector>
18
19// GeoLib
20#include "GeoLib/GEOObjects.h"
21#include "GeoLib/Point.h"
22
23// forward declaration of class Node and Element
24namespace MeshLib
25{
26class Node;
27class Element;
28class Mesh;
29} // namespace MeshLib
30
31namespace FileIO
32{
33// clang-format off
41// clang-format on
42class TetGenInterface final
43{
44public:
46
53 bool readTetGenGeometry(std::string const& geo_fname,
54 GeoLib::GEOObjects& geo_objects);
55
63 MeshLib::Mesh* readTetGenMesh(std::string const& nodes_fname,
64 std::string const& ele_fname);
65
76 static bool writeTetGenSmesh(
77 const std::string& file_name,
78 const GeoLib::GEOObjects& geo_objects,
79 const std::string& geo_name,
80 const std::vector<GeoLib::Point>& attribute_points);
81
91 bool writeTetGenSmesh(const std::string& file_name,
92 const MeshLib::Mesh& mesh,
93 std::vector<MeshLib::Node>& attribute_points) const;
94
95private:
97 std::size_t getNFacets(std::ifstream& input);
98
109 bool parseSmeshFacets(std::ifstream& input,
110 std::vector<GeoLib::Surface*>& surfaces,
111 const std::vector<GeoLib::Point*>& points,
112 const std::vector<std::size_t>& pnt_id_map);
113
122 bool readNodesFromStream(std::ifstream& ins,
123 std::vector<MeshLib::Node*>& nodes);
124
135 static bool parseNodesFileHeader(std::string const& line,
136 std::size_t& n_nodes,
137 std::size_t& dim,
138 std::size_t& n_attributes,
139 bool& boundary_markers);
148 bool parseNodes(std::ifstream& ins,
149 std::vector<MeshLib::Node*>& nodes,
150 std::size_t n_nodes,
151 std::size_t dim);
152
164 bool readElementsFromStream(std::ifstream& ins,
165 std::vector<MeshLib::Element*>& elements,
166 std::vector<int>& materials,
167 const std::vector<MeshLib::Node*>& nodes) const;
176 static bool parseElementsFileHeader(std::string& line,
177 std::size_t& n_tets,
178 std::size_t& n_nodes_per_tet,
179 bool& region_attribute);
195 bool parseElements(std::ifstream& ins,
196 std::vector<MeshLib::Element*>& elements,
197 std::vector<int>& materials,
198 const std::vector<MeshLib::Node*>& nodes,
199 std::size_t n_tets,
200 std::size_t n_nodes_per_tet,
201 bool region_attribute) const;
202
209 void write2dElements(std::ofstream& out, const MeshLib::Mesh& mesh) const;
210
218 void write3dElements(std::ofstream& out,
219 const MeshLib::Mesh& mesh,
220 std::vector<MeshLib::Node>& attribute_points) const;
221
224 static void writeElementToFacets(std::ofstream& out,
225 const MeshLib::Element& element,
226 unsigned& element_count,
227 std::string const& matId);
228
230 bool _zero_based_idx{false};
231
233 bool _boundary_markers{false};
234};
235} // 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)
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