2017-04-22 144 views
0

我已经定义并加载一个表面网格的建议在heretypedef OpenMesh::PolyMesh_ArrayKernelT</* MyTraits*/> Surface_mesh;,但使用这种 算法Triangulated Surface Mesh Segmentation我需要一个多面体一样:如何将Surface Mesh变成多面体?

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 \升压/图形/ graph_traits.hpp(57):错误C2039: vertex_descriptor的:不是成员的 “OpenMesh :: PolyMesh_ArrayKernelT < OpenMesh :: DefaultTraits>”

回答

2

的算法是瓦特直接用这个OpenMesh数据结构直接操作,不需要做一个拷贝。但是,如果您碰巧需要复制数据结构,则可以使用功能CGAL::copy_face_graph()

+0

增加了编译失败的代码,并使用了建议的'CGAL :: copy_face_graph()'函数 – DuckQueen

+0

您缺少'#include '。 – sloriot