Polyhedron_3 I/O problem

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Polyhedron_3 I/O problem

BRYang
Hi,

I got some issue with Polyhedron_3 I/O stuff. I have two polyhedron .off files which I downloaded from MIT's website(https://people.csail.mit.edu/sumner/research/deftransfer/data.html#download) and I used Meshlab to export them as .off files.  I use the following code to read in the files

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

/// read the horse.off file
Polyhedron horse;
std::ifstream OpenFile("horse.off");
OpenFile >> horse;
OpenFile.close();
std::cout<< "horse is valid ? " << horse.is_valid() << std::endl; // true
std::cout<< "size of facets ? " << horse.size_of_facets() << std::endl; // This is O.K, size of polyhedron is correct.
----------------------------------

/////////////////////////////////
However, when I use the following code for the camel.off file, the mesh could not be read correctly.
----------------------------------
Polyhedron camel;
std::ifstream OpenFile("camel.off");
OpenFile >> camel;
OpenFile.close();
std::cout<< "camel is valid ? " << camel.is_valid() << std::endl; // true
std::cout<< "size of facets ? " << camel.size_of_facets() << std::endl; // size of polyhedron is incorrect.
----------------------------------

It seems that CGAL does not handle the camel case correctly.
And I checked the following link http://cgal-discuss.949826.n4.nabble.com/Binary-Polyhedron-3-I-O-questions-td951182.html#a951191, and updated the code for camel case to be like this:

-------------------------------
Polyhedron camel;
std::ifstream OpenFile("camel.off",std::ios::binary);
CGAL::set_binary_mode(OpenFile);
OpenFile >> camel;
OpenFile.close();
std::cout<< "camel is valid ? " << camel.is_valid() << std::endl; // true
std::cout<< "size of facets ? " << camel.size_of_facets() << std::endl; // size of polyhedron is incorrect.
-------------------------------

However, the result is still wrong. Is this a bug or am I missing something to read the file correctly?

Thanks.

Monica
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Polyhedron_3 I/O problem

BRYang
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Polyhedron_3 I/O problem

andreas.fabri
In reply to this post by BRYang
Hello,

The problem is that the mesh is not a 2-manifold,
that is there are edges with > 2 incident faces.
I marked those zones red in the screenshot.

What you can do: Look at the polygon soup example:
http://doc.cgal.org/latest/Polygon_mesh_processing/index.html#title27

This allows you to read a polygon soup, and to orient it.
However this will duplicate vertices and produce
a mesh with self intersections.  Some of them are
relatively easy to remove, and we work on it.

Best,

Andreas


On 08/05/2017 07:03, BRYang wrote:

> Hi,
>
> I got some issue with Polyhedron_3 I/O stuff. I have two polyhedron .off
> files which I downloaded from MIT's
> website(https://people.csail.mit.edu/sumner/research/deftransfer/data.html#download)
> and I used Meshlab to export them as .off files.  I use the following code
> to read in the files
>
> ----------------------------------
> typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
> typedef CGAL::Polyhedron_3<Kernel>         Polyhedron;
>
> /// read the horse.off file
> Polyhedron horse;
> std::ifstream OpenFile("horse.off");
> OpenFile >> horse;
> OpenFile.close();
> std::cout<< "horse is valid ? " << horse.is_valid() << std::endl; // true
> std::cout<< "size of facets ? " << horse.size_of_facets() << std::endl; //
> This is O.K, size of polyhedron is correct.
> ----------------------------------
>
> /////////////////////////////////
> However, when I use the following code for the camel.off file, the mesh
> could not be read correctly.
> ----------------------------------
> Polyhedron camel;
> std::ifstream OpenFile("camel.off");
> OpenFile >> camel;
> OpenFile.close();
> std::cout<< "camel is valid ? " << camel.is_valid() << std::endl; // true
> std::cout<< "size of facets ? " << camel.size_of_facets() << std::endl; //
> size of polyhedron is incorrect.
> ----------------------------------
>
> It seems that CGAL does not handle the camel case correctly.
> And I checked the following link
> http://cgal-discuss.949826.n4.nabble.com/Binary-Polyhedron-3-I-O-questions-td951182.html#a951191,
> and updated the code for camel case to be like this:
>
> -------------------------------
> Polyhedron camel;
> std::ifstream OpenFile("camel.off",std::ios::binary);
> CGAL::set_binary_mode(OpenFile);
> OpenFile >> camel;
> OpenFile.close();
> std::cout<< "camel is valid ? " << camel.is_valid() << std::endl; // true
> std::cout<< "size of facets ? " << camel.size_of_facets() << std::endl; //
> size of polyhedron is incorrect.
> -------------------------------
>
> However, the result is still wrong. Is this a bug or am I missing something
> to read the file correctly?
>
> Thanks.
>
> Monica
>
>
>
> --
> View this message in context: http://cgal-discuss.949826.n4.nabble.com/Polyhedron-3-I-O-problem-tp4662716.html
> Sent from the cgal-discuss mailing list archive at Nabble.com.
>
--
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss



mouth.PNG (204K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Polyhedron_3 I/O problem

BRYang
Thank you, Andreas. I will try on it.

Best,
Monica
Loading...