Wildmeshing Toolkit
Loading...
Searching...
No Matches
MshReader.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Core>
4#include <filesystem>
5#include <memory>
6#include <wmtk/Mesh.hpp>
7#include <wmtk/Types.hpp>
9
10#include <mshio/mshio.h>
11
12namespace wmtk::io {
13
15{
16public:
19 std::shared_ptr<Mesh> read(
20 const std::filesystem::path& filename,
21 const bool ignore_z_if_zero,
22 const std::vector<std::string>& extra_facet_attributes = {});
23 std::shared_ptr<Mesh> read(
24 const std::filesystem::path& filename,
25 const int64_t embedded_dimension,
26 const std::vector<std::vector<std::string>>& extra_attributes);
27 std::shared_ptr<Mesh> read(
28 const std::filesystem::path& filename,
29 const int64_t embedded_dimension = -1);
30
31private:
32 const mshio::NodeBlock* get_vertex_block(int DIM) const;
33
34 const mshio::ElementBlock* get_simplex_element_block(int DIM) const;
35
36 size_t get_num_vertices(int DIM) const;
37
38 size_t get_num_simplex_elements(int DIM) const;
39
40 template <int DIM>
41 void extract_vertices();
42
43 template <int DIM>
45
46
47 template <int DIM>
48 void extract();
49
50
51 template <int DIM>
52 void validate();
53
54 int get_mesh_dimension() const;
55 int get_embedded_dimension() const;
56
57 std::shared_ptr<Mesh> generate(
58 const std::optional<std::vector<std::vector<std::string>>>& extra_attributes = {});
59
60 template <int DIM>
61 auto generateT() -> std::shared_ptr<wmtk::utils::mesh_type_from_dimension_t<DIM>>;
62
63 template <int DIM>
64 auto construct() -> std::shared_ptr<wmtk::utils::mesh_type_from_dimension_t<DIM>>;
65
66
67 // std::vector<std::string> get_vertex_attribute_names(int DIM) const;
68
69 // std::vector<std::string> get_element_attribute_names(int DIM) const;
70
71 // void extract_vertex_attribute(
72 // std::shared_ptr<wmtk::TetMesh> m,
73 // const std::string& attr_name,
74 // int DIM);
75
76 void extract_element_attribute(wmtk::Mesh& m, const std::string& attr_name, PrimitiveType pt);
77
78 // template <int DIM, typename Fn>
79 // bool extract_element_attribute(const std::string& attr_name, int DIM);
80
81
82 // template <int DIM, typename Fn>
83 // void extract_element_attribute(const std::string& attr_name, Fn&& set_attr);
84
85
86private:
87 mshio::MshSpec m_spec;
89
90
91 Eigen::MatrixXd V;
93
94 static const int64_t AUTO_EMBEDDED_DIMENSION = -2;
95};
96
97} // namespace wmtk::io
98namespace wmtk {
100}
const mshio::ElementBlock * get_simplex_element_block(int DIM) const
Definition MshReader.cpp:88
size_t get_num_simplex_elements(int DIM) const
mshio::MshSpec m_spec
Definition MshReader.hpp:87
int get_mesh_dimension() const
Definition MshReader.cpp:28
auto construct() -> std::shared_ptr< wmtk::utils::mesh_type_from_dimension_t< DIM > >
int get_embedded_dimension() const
static const int64_t AUTO_EMBEDDED_DIMENSION
Definition MshReader.hpp:94
auto generateT() -> std::shared_ptr< wmtk::utils::mesh_type_from_dimension_t< DIM > >
std::shared_ptr< Mesh > generate(const std::optional< std::vector< std::vector< std::string > > > &extra_attributes={})
std::shared_ptr< Mesh > read(const std::filesystem::path &filename, const bool ignore_z_if_zero, const std::vector< std::string > &extra_facet_attributes={})
Definition MshReader.cpp:38
int64_t m_embedded_dimension
Definition MshReader.hpp:88
size_t get_num_vertices(int DIM) const
Definition MshReader.cpp:98
const mshio::NodeBlock * get_vertex_block(int DIM) const
Definition MshReader.cpp:78
Eigen::MatrixXd V
Definition MshReader.hpp:91
void extract_simplex_elements()
void extract_element_attribute(wmtk::Mesh &m, const std::string &attr_name, PrimitiveType pt)
MatrixX< int64_t > MatrixXl
Definition Types.hpp:56