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>
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();
34 const Index num_vertices = mesh.get_num_vertices();
35 const Index num_facets = mesh.get_num_facets();
36 const Index vertex_per_facet = mesh.get_vertex_per_facet();
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++) {
47 if (forward_vertex_map[facets(i, j)] == invalid<Index>()) {
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++) {
58 if (forward_vertex_map[i] == invalid<Index>())
continue;
59 new_vertices.row(forward_vertex_map[i]) = vertices.row(i);
void map_attributes(const SurfaceMesh< Scalar, Index > &source_mesh, SurfaceMesh< Scalar, Index > &target_mesh, span< const Index > mapping_data, span< const Index > mapping_offsets={}, const MapAttributesOptions &options={})
Map attributes from the source mesh to the target mesh.
Definition: map_attributes.cpp:26
InverseMapping< Index > invert_mapping(Index num_source_elements, Function old_to_new, Index num_target_elements=invalid< Index >())
Compute the target-to-source (i.e.
Definition: invert_mapping.h:61
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
void remove_isolated_vertices(SurfaceMesh< Scalar, Index > &mesh)
Removes isolated vertices of a mesh.
Definition: remove_isolated_vertices.cpp:20