Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Boolean operations on triangular meshes

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Boolean operations on triangular meshes


Chronological Thread 
  • From: Taus Møller <>
  • To:
  • Subject: Re: [cgal-discuss] Boolean operations on triangular meshes
  • Date: Wed, 18 Nov 2015 14:05:23 +0100
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=None ; spf=None
  • Ironport-phdr: 9a23:SM7ycBYTpXkOi8SAPmu0J0n/LSx+4OfEezUN459isYplN5qZpcSybnLW6fgltlLVR4KTs6sC0LqL9f65EjBaqb+681k8M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aJBzzOEJPK/jvHcaK1oLsh730pcSYP18ArQH+SI0xBS3+lR/WuMgSjNkqAYcK4TyNnEF1ff9Lz3hjP1OZkkW0zM6x+Jl+73YY4Kp5pIYTGZj8ZLkyGLxEECw9YSdy/9zurRCFTA2V53JaXH9RiQtNGwGC7Rf0WdD6vSL+8+Z8wyKHJtalcbdhUjur6+JnSQTjlTwcHz8/6mDezMJq34xBpxf0mxVi2Mbx8IWROeA2Kr/QePsTXWtGRcFfS2pKBYbqPNhHNPYIIesN99q1nFAJtxbrXQQ=

I have been struggling (and still is) with this exact problem for
quite some time. There are quite a few issues and challenges in
relation to this, and the documentation is largely useless on the
issues related to use with C#. I have done boolean operations
successfully but continually struggle with making it robust.

The steps you are doing are pretty much the same as i have opted for.
I have, however, discarded the idea of having my own mesh format, and
simply use the wrapper as my "mesh type". I will try to outline my
experiences and hopefully they will help you.

First, my advice would be to actually make you own boolean operations.
At least if you need it for anything more than proof of concept. The
performance of boolean operations in CGAL is horrendous. I have tried
inquiring about method to speed them up, but it seem that is just the
way it is. As an example doing a simple union between two meshes of
around 400 triangles takes around 8 seconds, which is frankly
ridiculous. My understanding is that this performance is the price you
pay for having exact math in the calculation. This advantage is
however mostly lost due to the fact you pulling the meshes out of
CGAL. This is additionally compounded by the need to converted to and
from Nef polyhedra. We are primarily using CGAL because implementing
Booleans is hard(!) and we currently have the resources to do it.
Additionally, CGAL provides a lot of additional functionality that is
very convenient. Also, to be fair, it is my experience that appart
from booleans CGAL is actually very quick.

Second, If you need to use doubles (and you do) for boolean operation
you have to use the Exact_predicates_exact_constructions_kernel as you
kernel. Any other kernel either doesn't support double or doesn't
support Nefs.

To convert to Polyhedron_3 i found the best way was to implement
Modifier_base as outlined here:
http://doc.cgal.org/4.7/Polyhedron/Polyhedron_2polyhedron_prog_incr_builder_8cpp-example.html.
This way you can provide you mesh as vertex list and triangle indices
and get a Polyhedron_3 from it.


In relation to robustness, before you convert to nef you have to be
absolutely sure that you Polyhedron mesh is valid, closed and not self
intersecting. If there is any kind of issue with the mesh, CGAL fails
in a very unhelpful way. I am currently struggling to ensure mesh
integrity on Polyhedron_3 meshes. CGAL does provide some useful
functionality for this, but still leaves a lot to be desired.

Hope it helps

On 16 November 2015 at 21:52, SirM2X
<>
wrote:
> I'm very new to CGAL and I need to use some of its functionalities in my
> project. Currently, I need to write a C# wrapper around CGAL in order to be
> able to perform Boolean operations (intersection, union, etc.) on 3D
> triangular meshes. The meshes are created (or read) by my high-level C#
> program and are stored in a format similar to OpenGL's vertex buffer objects
> (i.e. every mesh has a set of vertices and triangle indices).
>
> I've read some of CGAL's manuals regarding CSG operation and I know that I
> have to use Nef polyhedra to achieve what I need (based on
> http://doc.cgal.org/latest/Nef_3/index.html). I'm thinking about doing the
> following steps:
>
> 1) Send the meshes to my wrapper.
> 2) Convert the meshes to Polyhedron_3 instances.
> 3) Convert Polyhedron_3 instances to Nef_polyhedron_3 instances.
> 4) Perform Boolean operations on the Nef polyhedra instances.
> 5) Convert Nef polyhedra back to Polyhedron_3.
> 6) Convert Polyhedron_3 to my C# mesh format.
>
> My first question is regarding step 2 above: how can I convert
> vertices/faces to a Polyhedron_3 instance? I saw this other post
> (http://cgal-discuss.949826.n4.nabble.com/Create-Polyhedron-from-given-Planes-td4568074.html#a4570518)
> but I'm still clueless.
>
> My second question is, how robust is CGAL towards imperfect meshes? The
> meshes that I deal with have lots of wholes/imperfections in them (the Carve
> CSG library (https://code.google.com/p/carve/) fails to perform CSG
> operations on these meshes). Will CGAL handle these bad meshes?
>
> Finally, my meshes have floating point vertices. Will that be a problem with
> Nef_polyhedron_3?
>
> Thanks in advance :)
>
>
>
> --
> View this message in context:
> http://cgal-discuss.949826.n4.nabble.com/Boolean-operations-on-triangular-meshes-tp4661345.html
> Sent from the cgal-discuss mailing list archive at Nabble.com.
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://sympa.inria.fr/sympa/info/cgal-discuss
>
>



--
Regards
Taus Møller
Software Developer, Apiosoft



Archive powered by MHonArc 2.6.18.

Top of Page