14#include <lagrange/Mesh.h>
15#include <lagrange/MeshTrait.h>
16#include <lagrange/SurfaceMesh.h>
17#include <lagrange/attributes/map_attributes.h>
18#include <lagrange/common.h>
19#include <lagrange/create_mesh.h>
20#include <lagrange/legacy/inline.h>
28 std::enable_if_t<lagrange::MeshTraitHelper::is_mesh<MeshType>::value>* =
nullptr>
29std::unique_ptr<MeshType> remove_isolated_vertices(
const MeshType& mesh)
31 static_assert(MeshTrait<MeshType>::is_mesh(),
"Input type is not Mesh");
32 using Index =
typename MeshType::Index;
33 const Index dim = mesh.get_dim();
39 std::vector<Index> forward_vertex_map(num_vertices,
invalid<Index>());
41 const auto& vertices = mesh.get_vertices();
42 auto facets = mesh.get_facets();
45 for (Index i = 0; i < num_facets; i++) {
46 for (Index j = 0; j < vertex_per_facet; j++) {
48 forward_vertex_map[facets(i, j)] = count;
51 facets(i, j) = forward_vertex_map[facets(i, j)];
55 const Index new_num_vertices = count;
56 typename MeshType::VertexArray new_vertices(new_num_vertices, dim);
57 for (Index i = 0; i < num_vertices; i++) {
59 new_vertices.row(forward_vertex_map[i]) = vertices.row(i);
65 map_attributes(mesh, *mesh2, invert_mapping(forward_vertex_map, new_num_vertices));
Index get_num_vertices() const
Retrieves the number of vertices.
Definition SurfaceMesh.h:671
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:2130
constexpr T invalid()
You can use invalid<T>() to get a value that can represent "invalid" values, such as invalid indices ...
Definition invalid.h:40
Main namespace for Lagrange.
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