Mesh#

Namespace#

namespace mesh#

Mesh-related functionality for working with mesh representations of parts.

The mesh namespace contains code for manipulating or extracting the properties of mesh representations of parts (such as the STL file format).

Concepts#

template<typename F>
concept TriangleFaces#
#include <concepts.h>

An array in which each row represents a triangle by indexing into an array of vertices. For example, [3, 1, 7] represents the triangle formed by the vertices in (zero-indexed) rows 3, 1, and 7 of a vertex coordinates array.

template<typename V>
concept Vectors3D#
#include <concepts.h>

An array in which each row represents a three-dimensional vector. The first column is the x-coordinate, the second column is the y-coordinate, and the third column is the z-coordinate.

template<typename V>
concept Vertices3D#
#include <concepts.h>

An array in which each row contains the three-dimensional coordinates for a vertex. The first column is the x-coordinate, the second column is the y-coordinate, and the third column is the z-coordinate.

Functions#

per_vertex_basis_pro2024#

template<Vectors3D DerivedN, Vectors3D DerivedB>
void modcam::mesh::per_vertex_basis_pro2024(Eigen::PlainObjectBase<DerivedB> &b0, Eigen::PlainObjectBase<DerivedB> &b1, Eigen::PlainObjectBase<DerivedB> &b2, const Eigen::MatrixBase<DerivedN> &vertex_normals)#

Compute an orthonormal set of basis vectors for each vertex in a mesh. Algorithm by [3]

Each vertex in the mesh is assigned a local coordinate system, where the z-axis is aligned with the vertex normal.

Parameters:
  • b0[out] V-by-3 matrix of basis vectors, corresponding to the vertex-local x-axis

  • b1[out] V-by-3 matrix of basis vectors, corresponding to the vertex-local y-axis

  • b2[out] V-by-3 matrix of basis vectors, corresponding to the vertex-local z-axis (aligned with the vertex normal)

  • vertex_normals[in] V-by-3 matrix of mesh vertex 3D normals

per_vertex_normals_max1999#

template<Vertices3D DerivedV, TriangleFaces DerivedF, Vectors3D DerivedN>
void modcam::mesh::per_vertex_normals_max1999(Eigen::PlainObjectBase<DerivedN> &normals, const Eigen::MatrixBase<DerivedV> &vertices, const Eigen::MatrixBase<DerivedF> &faces)#

Compute the per-vertex normal vectors for a set of vertices and faces, as described in [1].

Vertex normals are computed using a weighted sum of their surrounding face (triangle) normals.

Parameters:
  • normals[out] V-by-3 matrix of per-vertex normal vectors If the vertices array is empty, then an empty array is returned. If the faces array is empty, then normals values are set to NaN.

  • vertices[in] V-by-3 matrix of vertex Cartesian coordinates. Each row specifies a vertex’s 3D position.

  • faces[in] F-by-3 matrix of face (triangle) indices. Each row represents a triangle by indexing three vertices (rows) from the vertices array.

principal_curvature_rus2004#

template<Vertices3D DerivedV, TriangleFaces DerivedF, Vectors3D DerivedPD, typename DerivedPV>
void modcam::mesh::principal_curvature_rus2004(Eigen::PlainObjectBase<DerivedPD> &pd1, Eigen::PlainObjectBase<DerivedPD> &pd2, Eigen::PlainObjectBase<DerivedPV> &pv1, Eigen::PlainObjectBase<DerivedPV> &pv2, const Eigen::MatrixBase<DerivedV> &vertices, const Eigen::MatrixBase<DerivedF> &faces)#

Compute the (per-vertex) principal curvature on a triangle mesh using the algorithm described in [4].

While many principal curvature algorithms use a tunable “neighborhood” to compute their estimates, this algorithm uses only 1-ring vertex neighborhoods. Although the algorithm in [4] can be used to compute curvature derivates, that is not done here.

If the vertices array is empty, then all returned arrays are empty. If the faces array is empty, then all returned array values are set to NaN.

Parameters:
  • pd1[out] V-by-3 maximal curvature direction for each vertex.

  • pd2[out] V-by-3 minimal curvature direction for each vertex.

  • pv1[out] V-by-1 maximal curvature value for each vertex.

  • pv2[out] V-by-1 minimal curvature value for each vertex.

  • vertices[in] V-by-3 matrix of vertex Cartesian coordinates. Each row specifies a vertex’s 3D position.

  • faces[in] F-by-3 matrix of face (triangle) indices. Each row represents a triangle by indexing three vertices (rows) from the vertices array.

voronoi_area_mey2003#

template<Vertices3D DerivedV, TriangleFaces DerivedF, typename DerivedVA>
void modcam::mesh::voronoi_area_mey2003(Eigen::PlainObjectBase<DerivedVA> &v_area, const Eigen::MatrixBase<DerivedV> &vertices, const Eigen::MatrixBase<DerivedF> &faces)#

Compute the Voronoi cell areas for the triangles in a mesh as described in [2].

For a non-obtuse triangle, the Voronoi areas are bounded by segments connecting the triangle’s circumcenter to the midpoints of its edges. In the case of an obtuse triangle, we replace the triangle circumcenter with the midpoint of the edge opposite the obtuse angle.

Parameters:
  • v_area[out] F-by-3 matrix of the Voronoi area of each vertex in each triangle. Each value in this array corresponds to a triangle corner in the faces array. If the faces array is empty, then an empty array is returned. If the vertices array is empty, then v_area values are set to zero.

  • vertices[in] V-by-3 (or V-by-2) matrix of vertex Cartesian coordinates. Each row specifies a vertex’s 3D (or 2D) position.

  • faces[in] F-by-3 matrix of face (triangle) indices. Each row represents a triangle by indexing three vertices (rows) from the vertices array.