1

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!

Dominik Mokriš
  • 1,118
  • 1
  • 8
  • 29
  • Is `mesh` the seam_mesh or the underlying surface_mesh ? Did you check that your polyline file was correctly read ? Did you try adding it manually with `Seam_mesh::add_seam()` ? I really don't think it is a `longest_boundary()` behavior problem, either it is a bug, or your seam mesh is not what you think. – mgimeno Jun 18 '20 at 07:24
  • @mgimeno `mesh` is the seam_mesh. I will try adding the seam manually. How can I check that the polyline is correct? All I can think of now would be to try and print the coordinates of its vertices. – Dominik Mokriš Jun 18 '20 at 08:53
  • You can open the file in a stream and test the stream, with something like `std::ifstream in("yourfile.txt"); if(!in) std::cerr<<"file not found"< – mgimeno Jun 18 '20 at 09:21
  • Thanks. Actually, the example already checks if `add_seams` has returned a halfedge. I did not want to post the example (it is from the documentation and the question would be quite long then) but it would probably have been better, because we would have the source code in front of us. – Dominik Mokriš Jun 18 '20 at 09:47
  • In any case @mgimeno's comment helped me understand what was wrong, thanks! – Dominik Mokriš Jun 18 '20 at 09:48

1 Answers1

1

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).

Dominik Mokriš
  • 1,118
  • 1
  • 8
  • 29