Search code examples
c++meshcgalparameterization

CGAL seam_mesh: how to include the seam in the halfedge_descriptor of the boundary?


I am parametrizing a simple mesh (see the picture below) with the seam_Polyhedron_3.cpp example of CGAL 4.14.

simple example mesh

I identified the vertices to "cut it open" that I wrote into a seam file (they lie along one polyline connecting the lower and upper boundary):



73 75 80 120

However, I am confused about what the line

halfedge_descriptor bhd = CGAL::Polygon_mesh_processing::longest_border(mesh).first;

returns: it seems to iterate through the lower boundary only. This I could check by counting the vertices on the boundary,

typedef typename boost::graph_traits<Mesh>::vertex_descriptor Mesh_vertex_descriptor;
Mesh_vertex_descriptor beg = source(bhd, mesh);
int i=0;
do
{
    i++;
    bhd = next(bhd, mesh);
}
while(source(bhd, mesh) != beg);
std::cout << "There were " << i << " vertices on the boundary." << std::endl;

which returned 34 (which, in turn, is the number of vertices on the lower boundary).

Question: How can I modify the construction of bhd so that it encompasses the entire (virtual) boundary? I.e., the iteration I just showed should iterate through the lower boundary, seam upwards, upper boundary and the seam downwards and return 32 + 3 + 32 + 3 = 70?

So far I tried to find an alternative to longest_boundary and to see if there is a possibility to modify the behaviour through the named parameters. I also tried adding the vertices on the lower and upper boundaries to the mesh but this does not change anything, as noted in the documentation of Seam_mesh. Reversing the order of the seam vertices also made no visible change.

Thanks in advance!


Solution

  • The comment of @mgimeno helped me understand what was wrong. I post it as an answer in case someone else will be confused about the structure of .selection.txt files in future (see also a related discussion).

    Here once again the mesh but with the labels of the vertices along which I want to cut.

    mesh with labeled vertices

    Tip: To find these numbers in your mesh, open it in Meshlab and click Render > Show Labels. It works well with meshes in .off format but is likely to run into problemw with .stl, where the order of vertices is not specified.

    Based on the documentation of Seam_mesh::add_seam(..) we need to add three seam edges. Each of these edges is given by the indices of its endpoints. A correct format of seam.selection.txt is then

    
    
    73 75 75 80 80 120
    

    Note the duplicities (each vertex is there once as a starting point and once as an endpoint) and the two leading empty lines.

    The boundary now has 70 vertices (I was repeatedly off-by-one in the original version of my question).