【问题标题】:How to turn a Surface Mesh into a Polyhedron?如何将表面网格变成多面体?
【发布时间】:2017-04-22 09:24:15
【问题描述】:

我已经按照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):错误 C2039: vertex_descriptor:不是成员 "OpenMesh::PolyMesh_ArrayKernelT<:defaulttraits>"

【问题讨论】:

    标签: c++ geometry cgal


    【解决方案1】:

    该算法直接使用这个 OpenMesh 数据结构,无需复制。但是,如果你碰巧需要复制数据结构,你可以使用函数CGAL::copy_face_graph()

    【讨论】:

    • 添加了编译失败并使用建议的CGAL::copy_face_graph()函数的演示代码
    • 你不见了#include &lt;CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h&gt;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-17
    • 1970-01-01
    • 2016-04-23
    • 1970-01-01
    • 2018-02-10
    • 1970-01-01
    相关资源
    最近更新 更多