Wildmeshing Toolkit
mesh_utils.cpp
Go to the documentation of this file.
1 #include "mesh_utils.hpp"
2 #include <wmtk/TriMesh.hpp>
5 
6 namespace 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 
24 {
25  return compute_face_normal_area_weighted(m, pos, f).normalized();
26 }
27 
30 {
33 
34  Eigen::Vector3d n = Eigen::Vector3d::Zero();
36  Tuple t = f.tuple();
37  if (!m.is_ccw(t)) {
38  t = m.switch_vertex(t);
39  }
40  n += compute_face_normal_area_weighted(m, pos, t);
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
TODO this needs dimension?
Definition: TriMesh.cpp:169
Tuple switch_vertex(const Tuple &tuple) const
Definition: TriMesh.hpp:113
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Definition: Accessor.hpp:25
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
Definition: mesh_utils.cpp:23
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
Definition: mesh_utils.cpp:29
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.
Definition: closed_star.cpp:13
Vector< double, 3 > Vector3d
Definition: Types.hpp:39