Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Binary Polyhedron_3 I/O questions

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Binary Polyhedron_3 I/O questions


Chronological Thread 
  • From: "Rui Guo" <>
  • To:
  • Subject: Re: [cgal-discuss] Binary Polyhedron_3 I/O questions
  • Date: Wed, 19 Nov 2008 11:17:34 +0800
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=BtOJTGVsib6fJwAj+Ec5ASsq4+AmJBIG8QcqhZmdLjop0+/Qo2oPd3uUltXLgNn3G+ WBHAvRdjLUfThfZ45tIrNueFOTMqZPuIVuvfpHmFSWMseeXXOIR+beU83gjgMCXSvTJp OC4Wgk0qD3DxTMwShgTqAoyp4ZLj9/hikOd1o=

It seems that the operator>> is the std::operator>>.
As a default behavior, the standard iftream recognize the file as ansii, and read the file through std::operator>>.
However, the binary file is not a pure binary file, it's first line is ansii.
So it reads the file assuming it is ansii, poly_binary is initialized with zero facets since it read the facets' number as zero, and is_valid() is ok since an empty Polyhedron is valid.

#include <CGAL/IO/Polyhedron_iostream.h>
use CGAL::operator>>

I've seen the source. In the modified operator>>, CGAL::scan_OFF is performed.
The CGAL::operator>> could automatically identify if the file is binary or ascii, because the first line of each OFF file contains the information in ansii, then it can go on in ansii mode or binary mode.

I am a newer in CGAL, I wish I could help.



2008/11/19 Joe C <>
Yes, I did set stream mode to binary when generating the binary file. I also tried setting mode to binary when reading the binary file even though the manual says the operator >> will automatically identify if it's binary or ascii. But it is still not working, need more help on this issue....


On Mon, Nov 17, 2008 at 6:16 PM, Rui Guo <> wrote:
Chapter 63 IO Streams in manul may help.
You need to set stream mode to binary.


2008/11/18 Joe C <>

Hi,

I got some issue with Polyhedron_3 I/O stuff. I have two polyhedron .off files in ascii mode (poly_ascii.off) and binary mode (poly_binary.off) respectively. They are the same polyhedron, the only difference is that one is in ascii mode and the other is in binary mode. I use the following code snipet to read in the files

typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel>         Polyhedron;

// Read in ascii file
Polyhedron poly_ascii;
std::ifstream OpenFile("poly_ascii.off");
OpenFile >> poly_ascii;
OpenFile.close();

std::cout<< "poly is valid ? " << poly_ascii.is_valid() << std::endl; // true
std::cout<< "size of facets ? " << poly_ascii.size_of_facets() << std::endl; // This is O.K, size of polyhedron is correct.

/////////////////////////////////
// Read in binary file, replacing the above code
Polyhedron poly_binary;
std::ifstream OpenFile("poly_binary.off");
OpenFile >> poly_binary;
OpenFile.close();

std::cout<< "poly is valid ? " << poly_binary.is_valid() << std::endl; // true
std::cout<< "size of facets ? " << poly_binary.size_of_facets() << std::endl; // This is NOT O.K, size of polyhedron is zero.


It seems that CGAL does not handle the binary case correctly. Is this a bug or am I missing something to read the binary file right?

Thanks.

Joe







Archive powered by MHonArc 2.6.16.

Top of Page