Wildmeshing Toolkit
Loading...
Searching...
No Matches
mesh_utils.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <wmtk/Mesh.hpp>
4
5#include <string>
6
7namespace wmtk::mesh_utils {
8template <typename Mat>
10 const Mat& data,
11 const std::string& name,
12 const PrimitiveType& type,
13 Mesh& mesh)
14{
16 mesh.template register_attribute<typename Mat::Scalar>(name, type, data.cols());
17
18
19 auto thandle = handle.as<typename Mat::Scalar>();
20
21 auto accessor = mesh.create_accessor(thandle);
22 const auto tuples = mesh.get_all(type);
23 for (size_t i = 0; i < tuples.size(); ++i) {
24 const auto& t = tuples[i];
25 accessor.vector_attribute(t) = data.row(i).transpose();
26 }
27
28 return handle;
29}
30
34Eigen::Vector3d
36
40Eigen::Vector3d compute_face_normal(const TriMesh& m, const attribute::Accessor<double>& pos, const Tuple& f);
41
45Eigen::Vector3d
47
48} // namespace wmtk::mesh_utils
attribute::Accessor< T, Mesh, D > create_accessor(const attribute::MeshAttributeHandle &handle)
std::vector< Tuple > get_all(PrimitiveType type) const
Generate a vector of Tuples from global vertex/edge/triangle/tetrahedron index.
Definition Mesh.cpp:18
The Tuple is the basic navigation tool in our mesh data structure.
Definition Tuple.hpp:19
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Definition Accessor.hpp:28
auto as() const -> const held_handle_type< held_type_from_primitive< T >()> &
Eigen::Vector3d compute_face_normal(const TriMesh &m, const attribute::Accessor< double > &pos, const Tuple &f)
compute the normalized face normal based on the vertex positions
Eigen::Vector3d compute_face_normal_area_weighted(const TriMesh &m, const attribute::Accessor< double > &pos, const Tuple &f)
compute area vector of face
Definition mesh_utils.cpp:7
Eigen::Vector3d compute_vertex_normal(const TriMesh &m, const attribute::Accessor< double > &pos, const Tuple &v)
compute the normalized vertex normal from the incident area weighted face normals
attribute::MeshAttributeHandle set_matrix_attribute(const Mat &data, const std::string &name, const PrimitiveType &type, Mesh &mesh)
Definition mesh_utils.hpp:9