1
votes

How do i modify CGAL surface mesh vertex index coordinates? For now i've been trying to change coordinates of vertices like this:

 for (auto vertex_iterator : mesh.vertices()) {
        Point_3 p(1,0,1);
        mesh.point(vertex_iterator) = p;
      }

Code above is just a sample, i'm not assigning same coordinates to all vertices.

After i try to do caluclations with it i get undefined results.

1
auto vertex_iterator is not an iterator at all... - Amadeusz
I don't really see a difference if i use for(vertex_descriptor vertex_iterator : m.vertices()) or auto vertex_iterator. Can you expalin why it's not an iterator? - carak
Because with the modern style for loop the type is the value type of the iterator. But because it is just a name the code is correct even with a wrong name. - Andreas Fabri
@AndreasFabri Thanks for the reply, but isn't it easier for other programmers to understand, if i name it like an iterator? - carak
I fully agree with you. I only wanted to point out that the compiler does not make the distinction, so if there was a bug (which apparently is not the case) this is not due to the wrong name. - Andreas Fabri

1 Answers

2
votes

Actually I don't see what's wrong with your code, and I don't think your problems come from this. Can you give further information about your undefined results ?

A precision though, a Surface_mesh::Vertex_index has no coordinate, it has an associated point, which has coordinates. That is what you access with mesh.point(vertex_index).