Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triangulation operator<< prints the infinite vertex #8064

Open
mglisse opened this issue Mar 8, 2024 · 2 comments
Open

Triangulation operator<< prints the infinite vertex #8064

mglisse opened this issue Mar 8, 2024 · 2 comments

Comments

@mglisse
Copy link
Member

mglisse commented Mar 8, 2024

(from https://sympa.inria.fr/sympa/arc/cgal-discuss/2024-03/msg00000.html)

When printing a triangulation with operator<<, the dD class has a surprising behavior: it prints the infinite vertex. In practice, this can give

8
3 -1 2 -3
3 1 -2 -3
3 -1 -2 -3
3 1 2 3
3 -1 2 -3
3 1 -2 3
3 -1 -2 3
3 -1 2 3
3 1 2 -3

i.e. it announces 8 points then prints 9, where the first one randomly happens to match one of the other points.

See

// infinite vertex has index 0 (among all the vertices)
index_of_vertex[tr.infinite_vertex()] = i++;
if(IO::is_ascii(os))
os << *tr.infinite_vertex() <<"\n";
else
write(os, *tr.infinite_vertex());
which explicitly prints the infinite vertex and compare with the code in Triangulation_3
V[tr.infinite_vertex()] = 0;
for(i=1; i <= n; i++)
{
os << *TV[i];
which skips it and starts with the first finite vertex.

Note that while printing the point of the infinite vertex is a bad idea, printing its data/info looks like it could be useful.
Unlike Triangulation, Triangulation_3 does not print the info field of Triangulation_vertex_base_with_info_3 though.

@afabri
Copy link
Member

afabri commented Sep 17, 2024

@mglisse do you agree that as a first step we just do not write the infinite vertex?

@mglisse
Copy link
Member Author

mglisse commented Sep 17, 2024

@mglisse do you agree that as a first step we just do not write the infinite vertex?

Ok.
It will be a small regression in that the info of the infinite vertex will be lost, but hopefully that causes less trouble than the extra vertex?
I don't know if there are tests already that check that << and >> do something consistent.
An alternative would be to print a recognizable placeholder in place of the coordinates of the infinite vertex (so the line is still there in the output, with the data of the infinite vertex).
I never use those functions myself...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants