Wildmeshing Toolkit
Loading...
Searching...
No Matches
VertexLaplacianSmooth.cpp
Go to the documentation of this file.
2
3#include <wmtk/Mesh.hpp>
5
6
7namespace wmtk::operations {
8
10 : m_attibute_handle(handle)
11{
12#if !defined(NDEBUG) // pragma to make sure this heldtype isn't useful
14 assert(handle.held_type() == HeldType::Double);
15#endif
16}
17
18
20{
21 const std::vector<simplex::Simplex> one_ring =
23
24 std::visit(
25 [&](const auto& handle) {
26 using T = typename std::decay_t<decltype(handle)>::Type;
28 constexpr static HeldType ht =
29 attribute::MeshAttributeHandle::held_type_from_primitive<T>();
30
31 auto run = [&](auto& accessor) {
32 auto p_mid = accessor.vector_attribute(simplex.tuple());
33 p_mid.setZero();
34 for (const simplex::Simplex& s : one_ring) {
35 p_mid = p_mid + accessor.vector_attribute(s.tuple());
36 }
37 p_mid = p_mid / one_ring.size();
38 };
39
40 if constexpr (ht == HeldType::Double) {
41 auto accessor = mesh.create_accessor<double>(handle);
42 // run on double data
43 run(accessor);
44 }
45 },
47
48 return true;
49}
50
51} // namespace wmtk::operations
attribute::Accessor< T, Mesh, attribute::CachingAttribute< T >, D > create_accessor(const attribute::MeshAttributeHandle &handle)
virtual bool operator()(Mesh &m, const simplex::Simplex &s)
attribute::MeshAttributeHandle m_attibute_handle
VertexLaplacianSmooth(const attribute::MeshAttributeHandle &handle)
const std::vector< Simplex > & simplex_vector() const
Return const reference to the simplex vector.
const Tuple & tuple() const
Definition Simplex.hpp:53
SimplexCollection link(const Mesh &mesh, const simplex::Simplex &simplex, const bool sort_and_clean)
Definition link.cpp:84