Specifying an OpenMesh using Eigen3 vectors

This section will show how to build your own custom mesh type using Eigen3 vectors for points, normals or other entities.

First of all you need to include the Eigen header shipped with OpenMesh:

#include <OpenMesh/Core/Geometry/EigenVectorT.hh>

This header contains the external functions and vector traits used by OpenMesh.

Afterwards you can specify your mesh:

struct EigenTraits : OpenMesh::DefaultTraits {
using Point = Eigen::Vector3d;
using Normal = Eigen::Vector3d;
using TexCoord2D = Eigen::Vector2d;
EigenTriMesh mesh;
@ Normal
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:82
@ TexCoord2D
Add 2D texture coordinates (vertices, halfedges)
Definition: Attributes.hh:87
Triangle mesh based on the ArrayKernel.
Definition: TriMesh_ArrayKernelT.hh:96
Base class for all traits.
Definition: Traits.hh:122

Now you can use mesh as any other OpenMesh while using Eigen vectors as the underlying data type.

OpenMesh uses stl vectors for storing its data. This might lead to errors regarding memory alignment with sse instructions: You might need to define -DEIGEN_DONT_VECTORIZE

Project OpenMesh, ©  Visual Computing Institute, RWTH Aachen. Documentation generated using doxygen .