13 std::shared_ptr<TetMesh> make_freudenthal_mesh(
const Grid3Options& opt)
15 const auto& d = opt.dimensions;
16 auto vertex_dimensions = opt.dimensions;
17 for (
size_t j = 0; j < d.size(); ++j) {
18 int64_t& v = vertex_dimensions[j];
23 using CoordType = std::array<int64_t, 3>;
25 Eigen::Matrix<int64_t, Eigen::Dynamic, 4> FV(6 * d[0] * d[1] * d[2], 4);
32 for (j = 0; j < d[0]; ++j) {
33 for (k = 0; k < d[1]; ++k) {
34 for (l = 0; l < d[2]; ++l) {
35 auto f = [&](int64_t a, int64_t b, int64_t c) {
36 CoordType coord{{j + a, k + b, l + c}};
37 for (
size_t e = 0; e < 3; ++e) {
39 v = v % vertex_dimensions[e];
58 FV.row(f0_index + 0) << c[0], c[1], c[3], c[4];
59 FV.row(f0_index + 1) << c[5], c[2], c[6], c[7];
60 FV.row(f0_index + 2) << c[4], c[1], c[5], c[3];
61 FV.row(f0_index + 3) << c[4], c[3], c[7], c[5];
62 FV.row(f0_index + 4) << c[3], c[1], c[5], c[2];
63 FV.row(f0_index + 5) << c[2], c[3], c[7], c[5];
68 auto m = std::make_shared<TetMesh>();
70 if (opt.coordinates.has_value()) {
71 int vertex_size = vertex_dimensions[0] * vertex_dimensions[1] * vertex_dimensions[2];
73 const auto& spacing = opt.coordinates->spacing;
74 Eigen::Matrix<double, Eigen::Dynamic, 3> P(vertex_size, 3);
75 for (j = 0; j < vertex_dimensions[0]; ++j) {
76 double x = spacing[0] * j;
77 for (k = 0; k < vertex_dimensions[1]; ++k) {
78 double y = spacing[1] * k;
79 for (l = 0; l < vertex_dimensions[2]; ++l) {
80 double z = spacing[2] * l;
83 P.row(index) << x, y, z;
87 const auto& name = opt.coordinates->name;
99 throw std::runtime_error(
"bcc lattice not implemented yet");
103 throw std::runtime_error(
"failed to select a tiling type");
static const std::array< std::string, 2 > tiling_names
std::shared_ptr< TriMesh > make_mesh(const DiskOptions &opt)
int64_t grid_index(const std::array< int64_t, 3 > &d, const std::array< int64_t, 3 > &i)
attribute::MeshAttributeHandle set_matrix_attribute(const Mat &data, const std::string &name, const PrimitiveType &type, Mesh &mesh)