Wildmeshing Toolkit
EigenMatrixWriter.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <map>
4 #include <wmtk/Types.hpp>
5 #include <wmtk/io/MeshWriter.hpp>
7 
8 namespace wmtk::utils {
10 {
11 public:
12  EigenMatrixWriter() = default;
13  ~EigenMatrixWriter() = default;
14 
17  void get_TV_matrix(MatrixX<int64_t>& matrix);
18  void get_FV_matrix(MatrixX<int64_t>& matrix);
19  void get_EV_matrix(MatrixX<int64_t>& matrix);
20 
21  void
22  get_double_matrix(const std::string& name, const PrimitiveType type, MatrixX<double>& matrix);
23  void
24  get_int64_t_matrix(const std::string& name, const PrimitiveType type, MatrixX<int64_t>& matrix);
25  void get_char_matrix(const std::string& name, const PrimitiveType type, MatrixX<char>& matrix);
27  const std::string& name,
28  const PrimitiveType type,
29  MatrixX<Rational>& matrix);
30 
31  /*These are useless, just override*/
32  void write_top_simplex_type(const PrimitiveType type) override;
33  void write_absolute_id(const std::vector<int64_t>& id) override;
34  void write_capacities(const std::vector<int64_t>& capacities) override;
35  bool write(const int dim) override { return true; }
36 
37 
38  void write(
39  const std::string& name,
40  const int64_t type,
41  const int64_t stride,
42  const std::vector<char>& val,
43  const char default_val) override;
44 
45  void write(
46  const std::string& name,
47  const int64_t type,
48  const int64_t stride,
49  const std::vector<int64_t>& val,
50  const int64_t default_val) override;
51 
52  void write(
53  const std::string& name,
54  const int64_t type,
55  const int64_t stride,
56  const std::vector<double>& val,
57  const double default_val) override;
58 
59  void write(
60  const std::string& name,
61  const int64_t type,
62  const int64_t stride,
63  const std::vector<Rational>& val,
64  const Rational& default_val) override;
65 
66 private:
67  std::map<std::pair<std::string, PrimitiveType>, MatrixX<double>> doubles;
68  std::map<std::pair<std::string, PrimitiveType>, MatrixX<int64_t>> int64_ts;
69  std::map<std::pair<std::string, PrimitiveType>, MatrixX<char>> chars;
70  std::map<std::pair<std::string, PrimitiveType>, MatrixX<Rational>> Rationals;
71 
72  template <typename T>
73  void write_internal(
74  std::map<std::pair<std::string, PrimitiveType>, MatrixX<T>>& Ts,
75  const std::string& name,
76  const int64_t type,
77  const int64_t stride,
78  const std::vector<T>& val,
79  const T& default_val);
80 };
81 
82 } // namespace wmtk::utils
std::map< std::pair< std::string, PrimitiveType >, MatrixX< double > > doubles
std::map< std::pair< std::string, PrimitiveType >, MatrixX< char > > chars
void get_position_matrix(MatrixX< double > &matrix)
std::map< std::pair< std::string, PrimitiveType >, MatrixX< int64_t > > int64_ts
void write_internal(std::map< std::pair< std::string, PrimitiveType >, MatrixX< T >> &Ts, const std::string &name, const int64_t type, const int64_t stride, const std::vector< T > &val, const T &default_val)
void get_Rational_matrix(const std::string &name, const PrimitiveType type, MatrixX< Rational > &matrix)
void write_top_simplex_type(const PrimitiveType type) override
void get_EV_matrix(MatrixX< int64_t > &matrix)
void get_TV_matrix(MatrixX< int64_t > &matrix)
bool write(const int dim) override
void get_char_matrix(const std::string &name, const PrimitiveType type, MatrixX< char > &matrix)
void write_absolute_id(const std::vector< int64_t > &id) override
void get_int64_t_matrix(const std::string &name, const PrimitiveType type, MatrixX< int64_t > &matrix)
void get_FV_matrix(MatrixX< int64_t > &matrix)
void write_capacities(const std::vector< int64_t > &capacities) override
std::map< std::pair< std::string, PrimitiveType >, MatrixX< Rational > > Rationals
void get_double_matrix(const std::string &name, const PrimitiveType type, MatrixX< double > &matrix)
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Definition: Types.hpp:14