Wildmeshing Toolkit
DiskOptions.cpp
Go to the documentation of this file.
1 #include "DiskOptions.hpp"
2 #include <wmtk/Mesh.hpp>
3 #include <wmtk/TriMesh.hpp>
5 #include "grid_utils.hpp"
6 
7 
9 
10 std::shared_ptr<TriMesh> make_mesh(const DiskOptions& opt)
11 {
12  const size_t size = opt.size;
13 
14  auto mptr = std::make_shared<TriMesh>();
15  TriMesh& m = *mptr;
16  RowVectors3l tris;
17  tris.resize(size, 3);
18  tris.rowwise() = Vector3l(0, 1, 2).transpose();
19  auto mut = tris.rightCols<2>();
20  for (int j = 0; j < size; ++j) {
21  mut.row(j).array() += j;
22  }
23 
24  tris(size - 1, 2) = 1;
25  m.initialize(tris);
26  if (opt.coordinates.has_value()) {
27  const auto& csettings = *opt.coordinates;
28  int vertex_size = size + 1;
29  double radius = csettings.radius;
30  const auto& name = csettings.name;
31  double dtheta = 2.0 * M_PI / size;
32  double theta0 = M_PI * csettings.degree_offset / 180.0;
33 
34 
35  Eigen::Matrix<double, Eigen::Dynamic, 2> P(vertex_size, 2);
36  P.row(0).setZero();
37  for (int j = 0; j < size; ++j) {
38  double theta = theta0 + dtheta * j;
39  double c = std::cos(theta);
40  double s = std::sin(theta);
41  P.row(j + 1) << c, s;
42  }
43  Eigen::Vector2d::ConstMapType o(csettings.center.data());
44  P.rowwise() += o.transpose();
46  }
47  return mptr;
48 }
49 } // namespace wmtk::components::procedural
void initialize(Eigen::Ref< const RowVectors3l > FV, Eigen::Ref< const RowVectors3l > FE, Eigen::Ref< const RowVectors3l > FF, Eigen::Ref< const VectorXl > VF, Eigen::Ref< const VectorXl > EF)
Definition: TriMesh.cpp:175
std::optional< Coordinates > coordinates
Definition: DiskOptions.hpp:21
std::shared_ptr< TriMesh > make_mesh(const DiskOptions &opt)
Definition: DiskOptions.cpp:10
attribute::MeshAttributeHandle set_matrix_attribute(const Mat &data, const std::string &name, const PrimitiveType &type, Mesh &mesh)
Definition: mesh_utils.hpp:9
Vector< int64_t, 3 > Vector3l
Definition: Types.hpp:35
RowVectors< int64_t, 3 > RowVectors3l
Definition: Types.hpp:47