14#include <lagrange/Mesh.h>
15#include <lagrange/MeshTrait.h>
16#include <lagrange/create_mesh.h>
17#include <lagrange/legacy/inline.h>
20namespace subdivision {
37 std::enable_if_t<lagrange::MeshTraitHelper::is_mesh<MeshType>::value>* =
nullptr>
40 static_assert(MeshTrait<MeshType>::is_mesh(),
"Input type is not Mesh");
43 using Scalar =
typename MeshType::Scalar;
44 using Index =
typename MeshType::Index;
45 using VertexArray =
typename MeshType::VertexArray;
46 using FacetArray =
typename MeshType::FacetArray;
48 mesh.initialize_edge_data();
53 VertexArray V(nv + ne, mesh.get_dim());
54 FacetArray F(nf * 4, 3);
55 V.topRows(nv) = mesh.get_vertices();
56 for (Index e = 0; e < ne; ++e) {
59 Scalar(0.5) * (mesh.get_vertices().row(v[0]) + mesh.get_vertices().row(v[1]));
62 const Index v0 = mesh.get_facets()(f, 0);
63 const Index v1 = mesh.get_facets()(f, 1);
64 const Index v2 = mesh.get_facets()(f, 2);
65 const Index e0 = nv + mesh.
get_edge(f, 0);
66 const Index e1 = nv + mesh.
get_edge(f, 1);
67 const Index e2 = nv + mesh.
get_edge(f, 2);
68 F.row(4 * f + 0) << v0, e0, e2;
69 F.row(4 * f + 1) << v1, e1, e0;
70 F.row(4 * f + 2) << v2, e2, e1;
71 F.row(4 * f + 3) << e0, e1, e2;
Index get_num_vertices() const
Retrieves the number of vertices.
Definition: SurfaceMesh.h:671
std::array< Index, 2 > get_edge_vertices(Index e) const
Retrieve edge endpoints.
Definition: SurfaceMesh.cpp:2457
Index get_edge(Index f, Index lv) const
Gets the edge index corresponding to (f, lv) – (f, lv+1).
Definition: SurfaceMesh.cpp:2435
Index get_num_edges() const
Retrieves the number of edges.
Definition: SurfaceMesh.h:692
Index get_num_facets() const
Retrieves the number of facets.
Definition: SurfaceMesh.h:678
Index get_vertex_per_facet() const
Retrieves the number of vertex per facet in a regular mesh.
Definition: SurfaceMesh.cpp:2118
#define la_runtime_assert(...)
Runtime assertion check.
Definition: assert.h:169
SurfaceMesh< Scalar, Index > midpoint_subdivision(const SurfaceMesh< Scalar, Index > &mesh)
Performs one step of midpoint subdivision for triangle meshes.
Definition: midpoint_subdivision.cpp:22
Main namespace for Lagrange.
Definition: AABBIGL.h:30
auto create_mesh(const Eigen::MatrixBase< DerivedV > &vertices, const Eigen::MatrixBase< DerivedF > &facets)
This function create a new mesh given the vertex and facet arrays by copying data into the Mesh objec...
Definition: create_mesh.h:39