C++ 错误C2338:您混合了不同的数字类型

C++ 错误C2338:您混合了不同的数字类型,c++,casting,eigen,C++,Casting,Eigen,我在库的第eigen/src/Core/AssignEvaluator.h(834)行收到这个错误: 错误C2338:您\u混合了\u不同的\u数字\u类型\u需要\u使用\u矩阵的\u转换\u方法\u显式转换\u数字\u类型\u 根据编译器日志,我认为错误是由代码中的这一行触发的: class IndexedMesh { const TriangleMesh* m_tm; // ... } Vec3d IndexedMesh::normal_by_face_id(

我在库的第eigen/src/Core/AssignEvaluator.h(834)行收到这个错误:

错误C2338:您\u混合了\u不同的\u数字\u类型\u需要\u使用\u矩阵的\u转换\u方法\u显式转换\u数字\u类型\u

根据编译器日志,我认为错误是由代码中的这一行触发的:

class IndexedMesh {
    
    const TriangleMesh* m_tm;

    // ...
}

Vec3d IndexedMesh::normal_by_face_id(int face_id) const {
    return m_tm->normal_by_face_id(face_id); // => Error is thrown here
}

Vec3f TriangleMesh::normal_by_face_id(int face_id) const
{
    return Vec3f();
}
完整的编译器日志如下所示:

c:\users\m3\repos\qt3d-editor\editorlib\deps\eigen\eigen\src/Core/AssignEvaluator.h(834): error C2338: YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY
c:\users\m3\repos\qt3d-editor\editorlib\deps\eigen\eigen\src/Core/PlainObjectBase.h(732): note: see reference to function template instantiation 'void Eigen::internal::call_assignment_no_alias<Derived,Eigen::Matrix<float,3,1,2,3,1>,Eigen::internal::assign_op<double,float>>(Dst &,const Src &,const Func &)' being compiled
        with
        [
            Derived=Eigen::Matrix<double,3,1,2,3,1>,
            Dst=Eigen::Matrix<double,3,1,2,3,1>,
            Src=Eigen::Matrix<float,3,1,2,3,1>,
            Func=Eigen::internal::assign_op<double,float>
        ]
c:\users\m3\repos\qt3d-editor\editorlib\deps\eigen\eigen\src/Core/PlainObjectBase.h(537): note: see reference to function template instantiation 'Derived &Eigen::PlainObjectBase<Derived>::_set_noalias<Eigen::Matrix<float,3,1,2,3,1>>(const Eigen::DenseBase<Eigen::Matrix<float,3,1,2,3,1>> &)' being compiled
        with
        [
            Derived=Eigen::Matrix<double,3,1,2,3,1>
        ]
c:\users\m3\repos\qt3d-editor\editorlib\deps\eigen\eigen\src/Core/PlainObjectBase.h(537): note: see reference to function template instantiation 'Derived &Eigen::PlainObjectBase<Derived>::_set_noalias<Eigen::Matrix<float,3,1,2,3,1>>(const Eigen::DenseBase<Eigen::Matrix<float,3,1,2,3,1>> &)' being compiled
        with
        [
            Derived=Eigen::Matrix<double,3,1,2,3,1>
        ]
c:\users\m3\repos\qt3d-editor\editorlib\deps\eigen\eigen\src/Core/Matrix.h(378): note: see reference to function template instantiation 'Eigen::PlainObjectBase<Eigen::Matrix<double,3,1,2,3,1>>::PlainObjectBase<Derived>(const Eigen::DenseBase<Derived> &)' being compiled
        with
        [
            Derived=Eigen::Matrix<float,3,1,2,3,1>
        ]
c:\users\m3\repos\qt3d-editor\editorlib\deps\eigen\eigen\src/Core/Matrix.h(377): note: see reference to function template instantiation 'Eigen::PlainObjectBase<Eigen::Matrix<double,3,1,2,3,1>>::PlainObjectBase<Derived>(const Eigen::DenseBase<Derived> &)' being compiled
        with
        [
            Derived=Eigen::Matrix<float,3,1,2,3,1>
        ]
..\..\qt3d-editor\editorlib\src\libslic3r\SLA\IndexedMesh.cpp(119): note: see reference to function template instantiation 'Eigen::Matrix<double,3,1,2,3,1>::Matrix<Derived>(const Eigen::EigenBase<Derived> &)' being compiled
        with
        [
            Derived=Eigen::Matrix<float,3,1,2,3,1>
        ]
..\..\qt3d-editor\editorlib\src\libslic3r\SLA\IndexedMesh.cpp(119): note: see reference to function template instantiation 'Eigen::Matrix<double,3,1,2,3,1>::Matrix<Derived>(const Eigen::EigenBase<Derived> &)' being compiled
        with
        [
            Derived=Eigen::Matrix<float,3,1,2,3,1>
        ]
c:\users\m3\repos\qt3d editor\editorlib\deps\eigen\eigen\src/Core/AssignEvaluator.h(834):错误C2338:您混合了不同的数值类型,您需要使用矩阵基的方法显式转换数值类型
c:\users\m3\repos\qt3d editor\editorlib\deps\eigen\eigen\src/Core/PlainObjectBase.h(732):注意:请参阅正在编译的函数模板实例化“void eigen::internal::call_assignment_no_alias(Dst&,const src&,const Func&)”的参考
具有
[
派生=特征::矩阵,
Dst=特征::矩阵,
Src=特征::矩阵,
Func=Eigen::internal::assign\u op
]
c:\users\m3\repos\qt3d editor\editorlib\deps\eigen\eigen\src/Core/PlainObjectBase.h(537):注意:请参阅正在编译的函数模板实例化“派生和特征::PlainObjectBase::_set\u noalias(const eigen::DenseBase&)”
具有
[
派生=特征::矩阵
]
c:\users\m3\repos\qt3d editor\editorlib\deps\eigen\eigen\src/Core/PlainObjectBase.h(537):注意:请参阅正在编译的函数模板实例化“派生和特征::PlainObjectBase::_set\u noalias(const eigen::DenseBase&)”
具有
[
派生=特征::矩阵
]
c:\users\m3\repos\qt3d editor\editorlib\deps\eigen\eigen\src/Core/Matrix.h(378):注意:请参阅正在编译的函数模板实例化“eigen::PlainObjectBase::PlainObjectBase(const eigen::DenseBase&)”的参考
具有
[
派生=特征::矩阵
]
c:\users\m3\repos\qt3d editor\editorlib\deps\eigen\eigen\src/Core/Matrix.h(377):注意:请参阅正在编译的函数模板实例化“eigen::PlainObjectBase::PlainObjectBase(const eigen::DenseBase&)”的参考
具有
[
派生=特征::矩阵
]
..\..\qt3d编辑器\editorlib\src\libslic3r\SLA\IndexedMesh.cpp(119):注意:请参阅正在编译的函数模板实例化“Eigen::Matrix::Matrix(const Eigen::EigenBase&)”的参考
具有
[
派生=特征::矩阵
]
..\..\qt3d编辑器\editorlib\src\libslic3r\SLA\IndexedMesh.cpp(119):注意:请参阅正在编译的函数模板实例化“Eigen::Matrix::Matrix(const Eigen::EigenBase&)”的参考
具有
[
派生=特征::矩阵
]

错误原因是
Vec3d
Vec3f
之间的类型不匹配

//方法的调用方:
Vec3d IndexedMesh::法线乘以面id(整数面id)常量{
按面id(面id)返回m_tm->normal_;
}
//坏方法:
Vec3f三角形网格::法线乘以面id(整数面id)常量
{
返回Vec3f();
}
//精细方法:
Vec3d三角形网格::法线乘以面id(整数面id)常量
{
返回Vec3d();
}