Assimp 找不到 utf8.h 头文件

问题描述 投票:0回答:1

我刚刚开始使用 Assimp 来解析一些 stl 文件。我从源代码构建它并将其作为静态库安装在我的系统中(Manjaro Linux x86_64 - 内核 6.2.6-1)。为了了解库的工作原理,我正在尝试运行以下代码:

#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
#include <assimp/scene.h>

#include <iostream>
#include <memory>

#include <Eigen/Core>

#include <fcl/geometry/bvh/BVH_model.h>



std::shared_ptr<fcl::BVHModel<fcl::OBBRSSd>> loadSTL(const std::string &filename);

int main()
{

    // Load the STL mesh files
    std::shared_ptr<fcl::BVHModel<fcl::OBBRSSd>> Skeleton, Liver, Lungs;

    Skeleton = loadSTL("Skeleton.stl");
    Liver = loadSTL("Liver.stl");
    Lungs = loadSTL("Lungs.stl");


    return 0;
}

// Load an STL file into an FCL mesh object
std::shared_ptr<fcl::BVHModel<fcl::OBBRSSd>> loadSTL(const std::string &filename)
{
    // Create an Assimp importer
    Assimp::Importer importer;

    // Import the STL file -- "aiProcess_Triangulate" post-processing flag automatically triangulates all non-triangular faces during the import process
    const aiScene *scene = importer.ReadFile(filename, aiProcess_Triangulate);

    // Check if the import was successful
    if (!scene)
    {
        std::cerr << "Failed to import STL file: " << importer.GetErrorString() << std::endl;
        return nullptr;
    }

    // Extract the mesh from the scene
    const aiMesh *mesh = scene->mMeshes[0];

    // Create a BVHModel from the mesh
    auto model = std::make_shared<fcl::BVHModel<fcl::OBBRSSd>>();
    model->beginModel();

    for (size_t i = 0UL; i < mesh->mNumFaces; ++i)
    {
        const aiFace &face = mesh->mFaces[i];
        if (face.mNumIndices != 3)
        {
            std::cerr << "Error: non-triangular face in STL file." << std::endl;
            model->endModel();
            return nullptr;
        }

        fcl::Vector3d v1(mesh->mVertices[face.mIndices[0UL]].x, mesh->mVertices[face.mIndices[0UL]].y, mesh->mVertices[face.mIndices[0UL]].z);
        fcl::Vector3d v2(mesh->mVertices[face.mIndices[1UL]].x, mesh->mVertices[face.mIndices[1UL]].y, mesh->mVertices[face.mIndices[1UL]].z);
        fcl::Vector3d v3(mesh->mVertices[face.mIndices[2UL]].x, mesh->mVertices[face.mIndices[2UL]].y, mesh->mVertices[face.mIndices[2UL]].z);

        model->addTriangle(v1, v2, v3);
    }

    model->endModel();

    // Clean up the Assimp data structures
    importer.FreeScene();

    return model;
}

但事实证明 Assimp 无法找到 assimp/types.h 引用的 utf8 标头(见下图)。

我注意到这个文件位于 contrib 文件夹中,但无论我在构建库时在 CMAKE 上设置什么标志,contrib 和 utf8 标头都不会被复制到 inlude 文件夹中。我在这里错过了什么?有没有其他人遇到过类似的问题?

utf-8 assimp
1个回答
0
投票

你使用 hunter 构建还是只使用 master 的默认 cmake 构建? utf8 头文件可以在 repo 的 contrib 部分找到,我在上周进行了更改。 因此,要解决此问题,您只需将 contrib utf8 部分添加到您的 include 中或通过 cmake 使用 hunter 构建。

希望有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.