Polyhedron_3 I/O problem

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Polyhedron_3 I/O problem

Joe C-2
Hi, everyone,

I am testing a simple I/O function of Polyhedron_3. I found that the output has different results from the input. Here is the pseudo code:

// a polyhedron
Polyhedron_3 poly;

// some construction work, not listed....

// test closeness and validity before output
poly.is_closed(); // true
poly.is_valid(); // true

// output
std::ofstream SaveFile("output.off");
SaveFile << poly;
SaveFile.close();

// read in output
poly.clear();
OpenFile.open("output.off");
OpenFile >> poly;
OpenFile.close();

// test closeness and validity after output
poly.is_closed(); // true
poly.is_valid(); // false, different from original one

Notice that the polyhedron "poly" after reading in the output is no longer valid.

Is this CGAL bug or am I missing something here ? My guess is that somehow it messed up because of some numerical problem. I am using Exact_predicates_exact_constructions_kernel.

P.S. if I read in some ".off" model into Polydedron_3, do I lose the original validity of the model as well?

Thanks.
Joe




Reply | Threaded
Open this post in threaded view
|

Re: [?? Probable Spam] Polyhedron_3 I/O problem

cgal_www
Hello Joe

try

// a polyhedron
Polyhedron_3 poly;

// some construction work, not listed....

// test closeness and validity before output
poly.is_closed(); // true
poly.is_valid(); // true

// output
std::ofstream SaveFile("output.off");
SaveFile << poly;
SaveFile.close();

// read in output
Polyhedron_3 poly1;
OpenFile.open("output.off");
OpenFile >> poly1;
OpenFile.close();

// test closeness and validity after output
poly1.is_closed(); // true
poly1.is_valid(); // false, different from original one


I haven't tested the code.

B/Rgds
Max

----- Original Message ----
From: Joe C
To: [hidden email]
Sent: 2008-07-16 07:57:09
Subject: [?? Probable Spam]  [cgal-discuss] Polyhedron_3 I/O problem

>
Hi, everyone,

I am testing a simple I/O function of Polyhedron_3. I found that the output
has different results from the input. Here is the pseudo code:

// a polyhedron
Polyhedron_3 poly;

// some construction work, not listed....

// test closeness and validity before output
poly.is_closed(); // true
poly.is_valid(); // true

// output
std::ofstream SaveFile("output.off");
SaveFile << poly;
SaveFile.close();

// read in output
poly.clear();
OpenFile.open("output.off");
OpenFile >> poly;
OpenFile.close();

// test closeness and validity after output
poly.is_closed(); // true
poly.is_valid(); // false, different from original one

Notice that the polyhedron "poly" after reading in the output is no longer
valid.

Is this CGAL bug or am I missing something here ? My guess is that somehow
it messed up because of some numerical problem. I am using
Exact_predicates_exact_constructions_kernel.

P.S. if I read in some ".off" model into Polydedron_3, do I lose the
original validity of the model as well?

Thanks.
Joe
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss



--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron_3 I/O problem

Peter Hachenberger
In reply to this post by Joe C-2
Hi Joe,

that sounds like unwanted behavior. Can you send me some example file and tell me what the difference is between how it looks like and how it should look like?

Peter

-----"Joe C" [hidden email] wrote: -----

To: [hidden email]
From: "Joe C" [hidden email]
Date: 07/16/2008 01:56AM
cc: "Joe C" [hidden email]
Subject: [cgal-discuss] Polyhedron_3 I/O problem

Hi, everyone,

I am testing a simple I/O function of Polyhedron_3. I found that the output has different results from the input. Here is the pseudo code:

// a polyhedron
Polyhedron_3 poly;

// some construction work, not listed....

// test closeness and validity before output
poly.is_closed(); // true
poly.is_valid(); // true

// output
std::ofstream SaveFile("output.off");
SaveFile << poly;
SaveFile.close();

// read in output
poly.clear();
OpenFile.open("output.off");
OpenFile >> poly;
OpenFile.close();

// test closeness and validity after output
poly.is_closed(); // true
poly.is_valid(); // false, different from original one

Notice that the polyhedron "poly" after reading in the output is no longer valid.

Is this CGAL bug or am I missing something here ? My guess is that somehow it messed up because of some numerical problem. I am using Exact_predicates_exact_constructions_kernel.

P.S. if I read in some ".off" model into Polydedron_3, do I lose the original validity of the model as well?

Thanks.
Joe





Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron_3 I/O problem

Joe C-2
I tried Max's approach, it's not working...

Peter, please see the attached cube.off that I used in my test. It's just a simple cube object. When I read in this file, the polyhedron is not valid though I cannot see anything wrong with the data. The cube looks right in my viewer too, but just not valid.

Joe

On Wed, Jul 16, 2008 at 2:25 AM, Peter Hachenberger <[hidden email]> wrote:
Hi Joe,

that sounds like unwanted behavior. Can you send me some example file and tell me what the difference is between how it looks like and how it should look like?

Peter

-----"Joe C" [hidden email] wrote: -----

From: "Joe C" [hidden email]
Date: 07/16/2008 01:56AM
cc: "Joe C" [hidden email]
Subject: [cgal-discuss] Polyhedron_3 I/O problem


Hi, everyone,

I am testing a simple I/O function of Polyhedron_3. I found that the output has different results from the input. Here is the pseudo code:

// a polyhedron
Polyhedron_3 poly;

// some construction work, not listed....

// test closeness and validity before output
poly.is_closed(); // true
poly.is_valid(); // true

// output
std::ofstream SaveFile("output.off");
SaveFile << poly;
SaveFile.close();

// read in output
poly.clear();
OpenFile.open("output.off");
OpenFile >> poly;
OpenFile.close();

// test closeness and validity after output
poly.is_closed(); // true
poly.is_valid(); // false, different from original one

Notice that the polyhedron "poly" after reading in the output is no longer valid.

Is this CGAL bug or am I missing something here ? My guess is that somehow it messed up because of some numerical problem. I am using Exact_predicates_exact_constructions_kernel.

P.S. if I read in some ".off" model into Polydedron_3, do I lose the original validity of the model as well?

Thanks.
Joe







cube.off (270 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron_3 I/O problem

Peter Hachenberger
Hi Joe,

that's odd. The file is OK and I'm also told that it is valid by
Polyhedron_3. My program looks something like the following:

typedef CGAL::Homogeneous<CGAL::Gmpz> Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron_3;

int main()
{
    Polyhedron_3 poly;
    std::ifstream in("cube.off");
    in >> poly;
    std::cout << "valid " << poly.is_valid();
}

That works nicely

Peter

-----"Joe C" [hidden email] wrote: -----

To: [hidden email]
From: "Joe C" [hidden email]
Date: 07/16/2008 07:01PM
Subject: Re: [cgal-discuss] Polyhedron_3 I/O problem

I tried Max's approach, it's not working...

Peter, please see the attached cube.off that I used in my test. It's just a simple cube object. When I read in this file, the polyhedron is not valid though I cannot see anything wrong with the data. The cube looks right in my viewer too, but just not valid.

Joe

On Wed, Jul 16, 2008 at 2:25 AM, Peter Hachenberger < [hidden email]> wrote:
Hi Joe,

that sounds like unwanted behavior. Can you send me some example file and tell me what the difference is between how it looks like and how it should look like?

Peter

-----"Joe C" [hidden email] wrote: -----

From: "Joe C" [hidden email]
Date: 07/16/2008 01:56AM
cc: "Joe C" [hidden email]
Subject: [cgal-discuss] Polyhedron_3 I/O problem


Hi, everyone,

I am testing a simple I/O function of Polyhedron_3. I found that the output has different results from the input. Here is the pseudo code:

// a polyhedron
Polyhedron_3 poly;

// some construction work, not listed....

// test closeness and validity before output
poly.is_closed(); // true
poly.is_valid(); // true

// output
std::ofstream SaveFile("output.off");
SaveFile << poly;
SaveFile.close();

// read in output
poly.clear();
OpenFile.open("output.off");
OpenFile >> poly;
OpenFile.close();

// test closeness and validity after output
poly.is_closed(); // true
poly.is_valid(); // false, different from original one

Notice that the polyhedron "poly" after reading in the output is no longer valid.

Is this CGAL bug or am I missing something here ? My guess is that somehow it messed up because of some numerical problem. I am using Exact_predicates_exact_constructions_kernel.

P.S. if I read in some ".off" model into Polydedron_3, do I lose the original validity of the model as well?

Thanks.
Joe








cube.off (270 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Polyhedron_3 I/O problem

Joe C-2
Hi, Peter,

Your code works fine. I just realized that I was using non - default parameters for is_valid(). I was using is_valid(false, 1). If I use is_valid(true, 1), I got the message as:

level 4: normalized_border_is_valid( verbose = true)
begin CGAL::HalfedgeDS_const_decorator<HDS>::normalized_border_is_valid( verb=tr
ue):
    non-border edges: 18
    first border edge does not start at border_halfedges_begin()
end of CGAL::HalfedgeDS_const_decorator<HDS>::normalized_border_is_valid(): stru
cture is NOT VALID.
end of CGAL::HalfedgeDS_const_decorator<HDS>::is_valid(): structure is NOT VALID
.
counting halfedges failed.
end of CGAL::Polyhedron_3<...>::is_valid(): structure is NOT VALID.

I think that's because my cube is closed, and no border halfedges, which might cause this error message.

As long as I use is_valid() without specifying any parameters, it's working fine.

However, if I use another cube2.off (see attached), I am told that the cube2 polyhedron is closed and valid, but the size_of_facets() and the size_of_vertices() return zero. Any ideas why this happens?

Thank you for your help.

Joe


On Wed, Jul 16, 2008 at 11:22 AM, Peter Hachenberger <[hidden email]> wrote:
Hi Joe,

that's odd. The file is OK and I'm also told that it is valid by
Polyhedron_3. My program looks something like the following:

typedef CGAL::Homogeneous<CGAL::Gmpz> Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron_3;

int main()
{
    Polyhedron_3 poly;
    std::ifstream in("cube.off");
    in >> poly;
    std::cout << "valid " << poly.is_valid();
}

That works nicely


Peter

-----"Joe C" [hidden email] wrote: -----

To: [hidden email]
From: "Joe C" [hidden email]
Date: 07/16/2008 07:01PM
Subject: Re: [cgal-discuss] Polyhedron_3 I/O problem


I tried Max's approach, it's not working...

Peter, please see the attached cube.off that I used in my test. It's just a simple cube object. When I read in this file, the polyhedron is not valid though I cannot see anything wrong with the data. The cube looks right in my viewer too, but just not valid.

Joe

On Wed, Jul 16, 2008 at 2:25 AM, Peter Hachenberger < [hidden email]> wrote:
Hi Joe,

that sounds like unwanted behavior. Can you send me some example file and tell me what the difference is between how it looks like and how it should look like?

Peter

-----"Joe C" [hidden email] wrote: -----

From: "Joe C" [hidden email]
Date: 07/16/2008 01:56AM
cc: "Joe C" [hidden email]
Subject: [cgal-discuss] Polyhedron_3 I/O problem


Hi, everyone,

I am testing a simple I/O function of Polyhedron_3. I found that the output has different results from the input. Here is the pseudo code:

// a polyhedron
Polyhedron_3 poly;

// some construction work, not listed....

// test closeness and validity before output
poly.is_closed(); // true
poly.is_valid(); // true

// output
std::ofstream SaveFile("output.off");
SaveFile << poly;
SaveFile.close();

// read in output
poly.clear();
OpenFile.open("output.off");
OpenFile >> poly;
OpenFile.close();

// test closeness and validity after output
poly.is_closed(); // true
poly.is_valid(); // false, different from original one

Notice that the polyhedron "poly" after reading in the output is no longer valid.

Is this CGAL bug or am I missing something here ? My guess is that somehow it messed up because of some numerical problem. I am using Exact_predicates_exact_constructions_kernel.

P.S. if I read in some ".off" model into Polydedron_3, do I lose the original validity of the model as well?

Thanks.
Joe









Cube2.off (310 bytes) Download Attachment