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:
using Point = Eigen::Vector3d;
using Normal = Eigen::Vector3d;
};
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.
- Note
- OpenMesh uses stl vectors for storing its data. This might lead to errors regarding memory alignment with sse instructions: http://eigen.tuxfamily.org/dox/group__TopicStlContainers.html You might need to define -DEIGEN_DONT_VECTORIZE