Wildmeshing Toolkit
Loading...
Searching...
No Matches
cast_attribute.hpp
Go to the documentation of this file.
1#pragma once
2#include <wmtk/Mesh.hpp>
4
5namespace wmtk::utils {
6
7template <typename T>
9 const wmtk::attribute::MeshAttributeHandle& original_handle,
11{
12 std::visit(
13 [&](const auto& typed_handle) noexcept {
14 using ParentHandleType = std::decay_t<decltype(typed_handle)>;
15 using ParentType = typename ParentHandleType::Type;
16
18 new_handle,
19 original_handle);
20 caster.run_on_all();
21 },
22 original_handle.handle());
23}
24template <typename T>
26 const wmtk::attribute::MeshAttributeHandle& original_handle,
27 Mesh& m,
28 const std::string& new_attribute_name)
29{
30 auto new_handle = m.register_attribute<T>(
31 new_attribute_name,
32 original_handle.primitive_type(),
33 original_handle.dimension());
34
35 cast_attribute<T>(original_handle, new_handle);
36 return new_handle;
37}
38} // namespace wmtk::utils
attribute::MeshAttributeHandle register_attribute(const std::string &name, PrimitiveType type, int64_t size, bool replace=false, T default_value=T(0))
void cast_attribute(const wmtk::attribute::MeshAttributeHandle &original_handle, const wmtk::attribute::MeshAttributeHandle &new_handle)