c++ - 如何将曲面网格变成多面体?

标签 c++ geometry cgal

我已经按照here中的建议定义并加载了表面网格。 :typedef OpenMesh::PolyMesh_ArrayKernelT</* MyTraits*/> Surface_mesh; ,还没有使用这样的 算法为Triangulated Surface Mesh Segmentation我需要一个类似的多面体:

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;

但我不知道如何将一个变成另一个。在CGAL中如何做这样的事情?

简化的演示:

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/mesh_segmentation.h>
#include <CGAL/Polygon_mesh_processing/connected_components.h>
#include <CGAL/boost/graph/copy_face_graph.h>
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <iostream>

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef OpenMesh::PolyMesh_ArrayKernelT</* MyTraits*/> Surface_mesh;

int main()
{
    // create and read Polyhedron
    Surface_mesh mesh_in, mesh_out;
    Polyhedron mesh;
    OpenMesh::IO::read_mesh( mesh_in, "data/elephant.off");
    CGAL::copy_face_graph(mesh_in, mesh);

    CGAL::copy_face_graph(mesh, mesh_out);
    if (!OpenMesh::IO::write_mesh(mesh_out, "slon.obj"))
    {
        std::cerr << "write error\n";
        exit(1);
    }
}

由于以下原因无法编译

boost_1_63_0\boost/graph/graph_traits.hpp(57): error C2039: vertex_descriptor: is not a member of "OpenMesh::PolyMesh_ArrayKernelT< OpenMesh::DefaultTraits >"

最佳答案

该算法直接使用此 OpenMesh 数据结构,无需进行复制。但是,如果您碰巧需要复制数据结构,则可以使用函数 CGAL::copy_face_graph() .

关于c++ - 如何将曲面网格变成多面体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43557498/

相关文章:

c++ - 练习 : calculate the variance using arrays

c++ - 动态分配一个全局数组,该数组位于动态分配的结构数组中

math - 如何找到平行六面体的 4d 模拟的超体积?

c++ - 计算 GL_TRIANGLE 的顶点法线

c++ - 有没有一种方法可以计算 CGAL 中 Surface_mesh 对象的 pca?

c++ - 文件结束和 while 循环

c++ - 是否可以将引号 („) 放入 Char

算法:从已知点的星座中找到二维方向?

c++ - CGAL 切片器 : How to perform a mesh cut?

compiler-errors - CGAL surface_mesh封面示例