Radium Engine  1.5.20
Loading...
Searching...
No Matches
OpenMesh.hpp
1
2#pragma once
3
4#include <Core/RaCore.hpp>
5#include <Core/Types.hpp>
6
7#include <Eigen/Core>
8#include <Eigen/Geometry>
9#include <OpenMesh/Core/Mesh/Traits.hh>
10#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
11
12// We use Eigen::Matrix as base type to represent matrices in OpenMesh.
13
14// This is not standard, and several namespace functions are not available in OpenMesh
15// for Eigen::Matrix.
16// We need these functions to be defined before including OpenMesh, otherwise some
17// compilers (e.g. MSVC) will not be able to compile the code.
18namespace Eigen {
19
20template <typename Derived>
21typename Derived::Scalar dot( Eigen::MatrixBase<Derived> const& v1,
22 Eigen::MatrixBase<Derived> const& v2 ) {
23 return v1.dot( v2 );
24}
25
26template <typename Derived>
27typename Derived::Scalar norm( Eigen::MatrixBase<Derived> const& v1 ) {
28 return v1.norm();
29}
30
31template <typename Derived>
32Eigen::MatrixBase<Derived>& normalize( Eigen::MatrixBase<Derived>& v1 ) {
33 v1.normalize();
34 return v1;
35}
36
37template <typename Derived>
38Eigen::MatrixBase<Derived>& vectorize( Eigen::MatrixBase<Derived>& v1, Scalar a ) {
39 v1.setConstant( a );
40 return v1;
41}
42
43template <typename Derived>
44typename Derived::Scalar sqrnorm( Eigen::MatrixBase<Derived> const& v1 ) {
45 return v1.squaredNorm();
46}
47
48template <typename Derived>
49typename Derived::template cross_product_return_type<Derived>::type
50cross( Eigen::MatrixBase<Derived> const& v1, Eigen::MatrixBase<Derived> const& v2 ) {
51 return v1.cross( v2 );
52}
53} // namespace Eigen
54
55namespace OpenMesh {
56template <>
57struct vector_traits<Ra::Core::Vector3> {
58 using vector_type = Ra::Core::Vector3;
59 using value_type = Scalar;
60 static const size_t size_ = 3;
61 static size_t size() { return 3; }
62};
63} // namespace OpenMesh
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3