他の答えの1つは私にはうまくいきませんでした。b/cイテレータは逆参照する必要がありました。これは、OpenMesh4.1を使用して行う方法です
。ベストプラクティスは多少変更されている可能性があります。OpenMesh 6.2がリリースされましたが、まだ切り替えていません。
MyMesh mesh; // create the mesh instance
... // build your mesh
// use an edge iterator to iterate over all the edges
for (MyMesh::EdgeIter eit = mesh.edges_begin(); eit != mesh.edges_end(); ++eit)
{
// check for boundary. (one halfedge won't be valid if boundary)
// note: you have to dereference the edge iterator
if (!mesh.is_boundary(*eit))
{
// if you want vertex handles use:
auto vh1 = mesh.to_vertex_handle(mesh.halfedge_handle(*eit, 0));
auto vh2 = mesh.from_vertex_handle(mesh.halfedge_handle(*eit, 0));
// if you want handles of faces adjacent to the edge use:
auto fh1 = mesh.face_handle(mesh.halfedge_handle(*eit, 0));
auto fh2 = mesh.opposite_face_handle(mesh.halfedge_handle(*eit, 0));
// if you need normal vectors of those faces use:
auto face1Norm = mesh.normal(fh1);
auto face2Norm = mesh.normal(fh2);
}
else // boundary. One of the half edges won't be valid
std::cout << "found a boundary edge. skipping it" << std::endl;
}