1
votes

Given 2 open Polyhedron3 made of triangles in CGAL, I want to cut the first one with the second one. That is, all intersecting triangle facets from poly2 should cut facets from poly1 and create new edges (and faces) in poly1 following the path of intersection. In the end, I need the list of edges/half edges which are part of the intersection path.

I'm using a typedef CGAL::Simple_cartesian Kernel.

While this looks like a boolean operation, it's not because there's no 'inside' or 'outside' for open meshes. The way I tried to implement it is:

  • build an AABB for mesh 1 (to be cut)
  • find intersecting faces from mesh1 cut by the first triangle of mesh 2
  • compute intersection infos using cgal : this returns the intersection description, but with some problems:

    1. cgal will sometimes return 'wrong' intersections (for exemple, segments of 0 length)
    2. the first mesh is not cut in the operation. Given the intersection description, I have to cut triangles myself (unless there's a function I've overlooked in cgal to cut a face/triangle given an intersection). This is not a trivial problem, as there are lots of corner cases
    3. repeat with next face of poly2

My algorithm sorts of works, but I sometimes have problems : path not closed, small numerical accuracy problem, and it's not very fast.

So here's (at last) my question : what would be the recommended way to implement such an operation in a robust way ? Which kernel would you recommend?

1
Try compiling and running the Polyhedron demo. There is a plugin called corefinement that should do what you want. You need to click in the A/B column to set A and B before calling the plugin. Then a right click on the generated object will let you extract the parts you're interested in.sloriot
Hi,Thank you very much! I'm trying this right away. I'll post the result here if it solves my problem :-)Pascal Ognibene

1 Answers

0
votes

Following sloriot comment, I've spent some time playing with the code of the CGAL polyhedron demo. Indeed it contains a plugin corefinement which does what I want. I've not finished integrating all changes in my own code base but I believe I can mark this question as answered.

All thanks to SLoriot for his suggestion!

Pascal