Wildmeshing Toolkit
TriangleFanOptions.cpp
Go to the documentation of this file.
1 #include "TriangleFanOptions.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 TriangleFanOptions& 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(number - 1, 2) = 1;
25  m.initialize(tris);
26  if (opt.coordinates.has_value()) {
27  int vertex_size = size + 2;
28  const auto& csettings = *opt.coordinates;
29  const auto& name = csettings.name;
30  double radius = csettings.radius;
31  Eigen::Vector2d::ConstMapType degree_range(csettings.degrees.data());
32  double diff = degree_range.y() - degree_range.x();
33  double dtheta = diff * M_PI / 180.0 / size;
34  double theta0 = M_PI * degree_range.x() / 18.0;
35 
36 
37  Eigen::Matrix<double, Eigen::Dynamic, 2> P(vertex_size, 2);
38  P.row(0).setZero();
39  for (int j = 0; j <= size; ++j) {
40  double theta = dtheta * j + theta0;
41  double c = radius * std::cos(theta);
42  double s = radius * std::sin(theta);
43  P.row(j + 1) << c, s;
44  }
45  Eigen::Vector2d::ConstMapType o(csettings.center.data());
46  P.rowwise() += o.transpose();
48  }
49  return mptr;
50 }
51 } // 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:176
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