16#include <lagrange/Mesh.h>
17#include <lagrange/MeshTrait.h>
18#include <lagrange/common.h>
19#include <lagrange/legacy/inline.h>
20#include <lagrange/utils/safe_cast.h>
33template <
typename MeshType1,
typename MeshType2>
34void map_vertex_attributes(
35 const MeshType1& from,
37 const std::vector<typename MeshType1::Index>& vertex_map = {})
39 static_assert(MeshTrait<MeshType1>::is_mesh(),
"Input type is not Mesh");
40 static_assert(MeshTrait<MeshType2>::is_mesh(),
"Input type is not Mesh");
41 using Index =
typename MeshType1::Index;
43 vertex_map.empty() || safe_cast<Index>(vertex_map.size()) == to.get_num_vertices());
45 const auto& vertex_attributes = from.get_vertex_attribute_names();
46 const auto num_vertices = to.get_num_vertices();
47 const bool use_map = safe_cast<Index>(vertex_map.size()) == num_vertices;
48 for (
const auto& name : vertex_attributes) {
49 auto attr = from.get_vertex_attribute_array(name);
50 to.add_vertex_attribute(name);
53 to.set_vertex_attribute_array(name, std::move(attr2));
56 to.set_vertex_attribute_array(name, std::move(attr2));
#define la_runtime_assert(...)
Runtime assertion check.
Definition: assert.h:169
Main namespace for Lagrange.
Definition: AABBIGL.h:30
std::shared_ptr< T > to_shared_ptr(std::unique_ptr< T > &&ptr)
Helper for automatic type deduction for unique_ptr to shared_ptr conversion.
Definition: common.h:88