2017-04-22 142 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