14#include <lagrange/Mesh.h>
15#include <lagrange/MeshTrait.h>
16#include <lagrange/common.h>
17#include <lagrange/legacy/inline.h>
18#include <lagrange/utils/safe_cast.h>
23template <
typename MeshType>
26 static_assert(MeshTrait<MeshType>::is_mesh(),
"Input type is not Mesh");
29 auto corner_attributes = from.get_corner_attribute_names();
30 for (
const auto& name : corner_attributes) {
31 auto attr = from.get_corner_attribute_array(name);
32 to.add_corner_attribute(name);
33 to.set_corner_attribute_array(name,
to_shared_ptr(attr->clone()));
43template <
typename MeshType>
44void map_corner_attributes(
47 const std::vector<typename MeshType::Index>& facet_map)
49 static_assert(MeshTrait<MeshType>::is_mesh(),
"Input type is not Mesh");
50 using Index =
typename MeshType::Index;
52 const Index dim = from.get_dim();
58 auto corner_map_fn = [&](Eigen::Index i,
59 std::vector<std::pair<Eigen::Index, double>>& weights) {
60 const auto to_fid = i / 3;
61 const auto to_cid = i % 3;
63 weights.emplace_back(facet_map[to_fid] * 3 + to_cid, 1.0);
66 const auto to_num_corners = to.get_num_facets() * 3;
67 const auto& corner_attributes = from.get_corner_attribute_names();
68 for (
const auto& name : corner_attributes) {
69 auto attr = from.get_corner_attribute_array(name);
70 auto attr2 =
to_shared_ptr(attr->row_slice(to_num_corners, corner_map_fn));
71 if (!to.has_corner_attribute(name)) {
72 to.add_corner_attribute(name);
74 to.set_corner_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