Is a way to get table of edges with first and second vertices indexes?
This is a way to enumerate vertices of mesh:
Surface_mesh m;
// ... fill m points...
// enumerate points:
for (auto& vertex : m.points()) {
verts.push_back(std::vector<float>{ (float)CGAL::to_double(vertex.x()), (float)CGAL::to_double(vertex.y()), (float)CGAL::to_double(vertex.z()) });
}
This is a way to enumerate face's vertex indices of mesh:
for (auto& fi : m.faces() ){
auto& hf = m.halfedge(fi);
std::vector<unsigned int> vect_vert_id;
for (auto& hi : halfedges_around_face(hf, m)){
vertex_descriptor& vi = target(hi, m);
vect_vert_id.push_back(vi.idx()); // index of vertex in face
}
// vect_vert_id - list of vertices of face
}
But how to get list of edges vertices id as list of pairs? (id1, id2),(id2, id3), ...
I try to use faces to get all edges (use halfedges_around_face to get all indexes in one face then got list of second face, remove duplicate edges vertices and so on...)
Some info about CGAL Surface Mesh
There's a method edges()
to get the Edge_range
and iterate through all the edges of the Surface_mesh
.
Then for each edge there is a method vertex (Edge_index e, unsigned int i) const
which can be called twice vertex(e,0)
and vertex(e,1)
to get the 2 vertices of the edge.