2017-10-18 75 views
0

我想用自CGAL :: Surface_mesh檢索的數據填充自己的結構。CGAL:從表面網格獲取面部數據

您可以通過臉部添加到表面網格..

CGAL::SM_Face_index face = SM_Surface_Mesh.add_face(SM_Vertex_Index, SM_Vertex_Index, SM_Vertex_Index); 

..但一個人如何檢索給出的SM_Face_Index那張臉?我試過篩選文檔,但無濟於事。

InteropMesh * outputMesh = new InteropMesh(); 
uint32_t num = mesh1.number_of_vertices(); 

outputMesh->vertexCount = num; 

outputMesh->vertices = new InteropVector3[num]; 

for (Mesh::Vertex_index vd : mesh1.vertices()) 
{ 
    uint32_t index = vd; //via size_t 

    Point data = mesh1.point(vd); 
    outputMesh->vertices[index].x = (float)data.x(); 
    outputMesh->vertices[index].y = (float)data.y(); 
    outputMesh->vertices[index].z = (float)data.z(); 
} 

outputMesh->indices = new uint32_t[mesh1.number_of_faces() * 3]; 

for (CGAL::SM_Face_index fd : mesh1.faces()) 
{ 
    //? How do I get the three vertex indices? 
} 

回答

0

Surface_mesh數據結構可以表示不止三角形網格。這意味着你可能每面有3個以上的頂點。 一旦你得到一張臉,你可以瀏覽其邊界邊緣,並獲得源和目標頂點。

例如,你可以這樣做: Surface_mesh::Halfedge_index hstart = sm.halfedge(fi), hi=hstart; do{ Surface_mesh::Vertex_index vi = target(hi, sm); hi=sm.next(hi); } while(hi!=hstart)

Surface_mesh::Halfedge_index hf = sm.halfedge(fi); for(Surface_mesh::Halfedge_index hi : halfedges_around_face(hf, sm)) { Surface_mesh::Vertex_index vi = target(hi, sm); } 您也可以自己動手完成它