Open janetournois opened 3 years ago
note : the reader has moved to another file in master
but still can't read binary OFF
I do not know if we can call that a bug. The exist an official "binary OFF", and that is a different file format.
Here you are talking of the ASCII OFF format, produced by older versions of CGAL, with an std::ostream
where CGAL::set_binary_mode
was called. That produced an invalid OFF file, where all the file was in ASCII, but the coordinates of the 3D points, that were in the file in binary.
Maybe that patch can be sufficient:
diff --git a/Stream_support/include/CGAL/IO/OFF/File_scanner_OFF.h b/Stream_support/include/CGAL/IO/OFF/File_scanner_OFF.h
index 90c1ed4305f..e956d9b9062 100644
--- a/Stream_support/include/CGAL/IO/OFF/File_scanner_OFF.h
+++ b/Stream_support/include/CGAL/IO/OFF/File_scanner_OFF.h
@@ -88,6 +88,7 @@ public:
// Read all numbers in the line
std::istringstream issline(line);
+ set_mode(issline, get_mode(m_in));
entries.clear();
double d;
while(issline >> IO::iformat(d)){
@@ -539,6 +540,7 @@ public:
std::getline(is, col);
//split it into strings
std::istringstream iss(col);
+ set_mode(iss, get_mode(m_in));
//holds the rgb values
unsigned char rgb[3]{};
int index =0;
@@ -702,6 +704,7 @@ public:
// Read all numbers in the line
std::istringstream issline(line);
+ set_mode(issline, get_mode(m_in));
entries.clear();
double d;
while(issline >> IO::iformat(d)){
It copies the CGAL I/O mode of the input stream to the temporary std::istringstream
. And then CGAL::iformat(double)
should do whatever has to be done.
AFAIR, this issue could be closed as it is not a bug, right? @janetournois @MaelRL
Well we still can't read binary off files, so I would not say it's solved, but it seems we don't want to re-introduce it. I was just concerned by the fact that some users could have created some files with CGAL in the past, that they cannot open anymore with recent versions.
Shall a note in CHANGES.md
be the minimum we should do?
Has anyone tried the patch I suggested at https://github.com/CGAL/cgal/issues/5788#issuecomment-872223637? If the solution was as simple as that, then that would solve our issue.
I'll give it a try
(sorry, I clicked too fast)
@lrineau the patch is not enough. Actually, the if(binary())
at the beginning of scan_vertex()
returns false, and get_mode(m_in)
returns ASCII
...
Issue Details
The function
read_off()
fromSurface_mesh.h
is not able anymore to read a binary OFF file.Source Code
From what I found, commit 26c86d28be1908a972b1fbb85777b735767b227b (introduced in CGAL-4.14.3) is responsible for that issue. The following patch is enough to fix the issue (reading of binary off files is fixed), but I believe it breaks something that the initial commit was itself fixing (?)
Environment