Wildmeshing Toolkit
Loading...
Searching...
No Matches
MeshData.hpp
1#pragma once
2
3#include <Eigen/Core>
4#include <cstdint>
5#include <map>
6#include <nlohmann/json.hpp>
7#include <string>
8#include <variant>
9#include <vector>
10
11namespace wmtk {
12
13// Values agree with VTK's linear cell types. Connectivity always indexes rows of V.
14enum class CellType {
15 Point = 1,
16 Edge = 3,
17 Triangle = 5,
18 Quad = 9,
19 Tetrahedron = 10,
20 Prism = 13,
21 Pyramid = 14
22};
23template <typename T>
24using DataMatrix = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
25using AttributeValues = std::variant<DataMatrix<double>, DataMatrix<int64_t>, DataMatrix<uint8_t>>;
26
28{
29 AttributeValues values = DataMatrix<double>();
30 // Optional labels for columns, e.g. the names of overlapping material tags.
31 std::vector<std::string> labels;
32
33 Eigen::Index rows() const;
34 Eigen::Index cols() const;
35 DataMatrix<double> doubles() const;
36 DataMatrix<int64_t> integers() const;
37};
38using MeshAttributes = std::map<std::string, MeshAttribute>;
39
41{
42 DataMatrix<int64_t> connectivity;
43 MeshAttributes attributes;
44};
45
46// An owning interchange value, independent of the mutable topology/attribute machinery.
48{
49 DataMatrix<double> V{0, 3};
50 MeshAttributes vertex_attributes;
51 std::map<CellType, CellData> cells;
52
53 void validate() const;
54 const CellData& cell(CellType type) const;
55};
56
57using MeshMap = std::map<std::string, MeshData>;
58using ComponentResult = std::pair<MeshMap, nlohmann::json>;
59
60int cell_size(CellType type);
61int cell_dimension(CellType type);
62
63} // namespace wmtk
Definition MeshData.hpp:41
Definition MeshData.hpp:28
Definition MeshData.hpp:48