Wildmeshing Toolkit
Loading...
Searching...
No Matches
mesh_utils.cpp
Go to the documentation of this file.
1#include "mesh_utils.hpp"
2#include <wmtk/TriMesh.hpp>
5
6namespace wmtk::mesh_utils {
8 const TriMesh& m,
10 const Tuple& f)
11{
12 const Tuple v0 = f;
13 const Tuple v1 = m.switch_vertex(f);
14 const Tuple v2 = m.switch_vertex(m.switch_edge(f));
15
16 const Eigen::Vector3d p0 = pos.const_vector_attribute(v0);
17 const Eigen::Vector3d p1 = pos.const_vector_attribute(v1);
18 const Eigen::Vector3d p2 = pos.const_vector_attribute(v2);
19 return ((p0 - p2).cross(p1 - p2));
20}
21
22Eigen::Vector3d
24{
25 return compute_face_normal_area_weighted(m, pos, f).normalized();
26}
27
28Eigen::Vector3d
30{
31 const simplex::SimplexCollection closed_star =
33
34 Eigen::Vector3d n = Eigen::Vector3d::Zero();
35 for (const simplex::Simplex& f : closed_star.simplex_vector(PrimitiveType::Triangle)) {
36 Tuple t = f.tuple();
37 if (!m.is_ccw(t)) {
38 t = m.switch_vertex(t);
39 }
41 }
42 n.normalize();
43 return n;
44}
45
46} // namespace wmtk::mesh_utils
Tuple switch_edge(const Tuple &tuple) const
Definition TriMesh.hpp:117
bool is_ccw(const Tuple &tuple) const final override
returns if a tuple is counterclockwise or not
Definition TriMesh.cpp:170
Tuple switch_vertex(const Tuple &tuple) const
Definition TriMesh.hpp:113
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
ConstMapResult< D > const_vector_attribute(const ArgType &t) const
const std::vector< Simplex > & simplex_vector() const
Return const reference to the simplex vector.
static Simplex vertex(const Mesh &m, const Tuple &t)
Definition Simplex.hpp:56
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
SimplexCollection closed_star(const Mesh &mesh, const Simplex &simplex, const bool sort_and_clean)
The closed star contains the input simplex, all its top dimension cofaces, and their faces.