11 std::shared_ptr<TriMesh> make_diagonal_mesh(
const Grid2Options& opt)
13 const auto d = opt.dimensions;
14 auto vertex_dimensions = opt.dimensions;
15 for (
size_t j = 0; j < d.size(); ++j) {
16 int64_t& v = vertex_dimensions[j];
21 using CoordType = std::array<int64_t, 2>;
23 Eigen::Matrix<int64_t, Eigen::Dynamic, 3> FV(2 * d[0] * d[1], 3);
29 for (j = 0; j < d[0]; ++j) {
30 for (k = 0; k < d[1]; ++k) {
31 auto f = [&](int64_t a, int64_t b) {
32 CoordType coord{{j + a, k + b}};
33 for (
size_t e = 0; e < 2; ++e) {
35 v = v % vertex_dimensions[e];
49 int64_t f1_index = f0_index + 1;
51 FV.row(f0_index) << c[0][0], c[0][1], c[1][0];
52 FV.row(f1_index) << c[1][1], c[1][0], c[0][1];
56 auto m = std::make_shared<TriMesh>();
58 if (opt.coordinates.has_value()) {
59 int vertex_size = vertex_dimensions[0] * vertex_dimensions[1];
61 const auto& spacing = opt.coordinates->spacing;
62 Eigen::Matrix<double, Eigen::Dynamic, 2> P(vertex_size, 2);
63 for (j = 0; j < vertex_dimensions[0]; ++j) {
64 double x = spacing[0] * j;
65 for (k = 0; k < vertex_dimensions[1]; ++k) {
66 double y = spacing[1] * k;
72 const auto& name = opt.coordinates->name;
84 throw std::runtime_error(
"bcc lattice not implemented yet");
88 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)