Wildmeshing Toolkit
Loading...
Searching...
No Matches
cast_attribute.hpp
Go to the documentation of this file.
1
#pragma once
2
#include <
wmtk/Mesh.hpp
>
3
#include <
wmtk/operations/attribute_update/CastAttributeTransferStrategy.hpp
>
4
5
namespace
wmtk::utils
{
6
7
template
<
typename
T>
8
void
cast_attribute
(
9
const
wmtk::attribute::MeshAttributeHandle
& original_handle,
10
const
wmtk::attribute::MeshAttributeHandle
& new_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
17
wmtk::operations::attribute_update::CastAttributeTransferStrategy<T, ParentType>
caster(
18
new_handle,
19
original_handle);
20
caster.
run_on_all
();
21
},
22
original_handle.
handle
());
23
}
24
template
<
typename
T>
25
wmtk::attribute::MeshAttributeHandle
cast_attribute
(
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
CastAttributeTransferStrategy.hpp
Mesh.hpp
wmtk::Mesh
Definition
Mesh.hpp:95
wmtk::Mesh::register_attribute
attribute::MeshAttributeHandle register_attribute(const std::string &name, PrimitiveType type, int64_t size, bool replace=false, T default_value=T(0))
Definition
Mesh_attributes.cpp:11
wmtk::attribute::MeshAttributeHandle
Definition
MeshAttributeHandle.hpp:28
wmtk::attribute::MeshAttributeHandle::dimension
int64_t dimension() const
Definition
MeshAttributeHandle.cpp:44
wmtk::attribute::MeshAttributeHandle::handle
HandleVariant & handle()
Definition
MeshAttributeHandle.hpp:132
wmtk::attribute::MeshAttributeHandle::primitive_type
PrimitiveType primitive_type() const
Definition
MeshAttributeHandle.hpp:224
wmtk::operations::AttributeTransferStrategyBase::run_on_all
void run_on_all() const
Definition
AttributeTransferStrategyBase.cpp:19
wmtk::operations::attribute_update::CastAttributeTransferStrategy
Definition
CastAttributeTransferStrategy.hpp:18
wmtk::utils
Definition
array_to_map.hpp:3
wmtk::utils::cast_attribute
void cast_attribute(const wmtk::attribute::MeshAttributeHandle &original_handle, const wmtk::attribute::MeshAttributeHandle &new_handle)
Definition
cast_attribute.hpp:8
src
wmtk
utils
cast_attribute.hpp
Generated by
1.9.8