1

I am using CGAL for a project of mine. I create a AABB tree out of a mesh file (.off). First I extract Polyhedron from my mesh, then I get the triangles and finally I insert them in the tree. All of this went smoothly.

The problem is when I use the do_intersect function of the tree. Given two points, A and B, I would like to know if the ray or segment connecting the two insersect with something.

Most of the time this works properly, sometimes I get the floating point error. 'sometimes' means with a very few subsets of points.

Is there a reason for this?

Here there is a snippet of my code:

glm::vec3 pointA, pointB; // assume this are filled with some values
// the elements inside points above are floats.
Point_3 pA(pointA.x, pointA.y, pointA.z);
Point_3 pB(pointB.x, pointB.y, pointB.z);
Segment segment_query(pA, pB);
my_tree->do_intersect(segment_query); // here sometimes crashes

Before anybody asks pointB is a specific point on the surface of the mesh and it does not give any problems with most of points so I would assume the error is not related to it. Instead pointA is somewhere in the space.

Thank you for you answers.

heinecoder
  • 11
  • 1
  • what kernel are you using? you need one with exact predicates here like for example `CGAL::Exact_predicates_inexact_constructions_kernel`. – sloriot Jun 07 '17 at 11:41
  • Here it is, just the same you pointed out: `typedef CGAL::Exact_predicates_inexact_constructions_kernel K;` – heinecoder Jun 08 '17 at 09:42
  • do you have some degenerate triangles in your input mesh? – sloriot Jun 08 '17 at 13:17
  • I don't think so, can you give me some example? Or some way to check it? I am using a manifold mesh. – heinecoder Jun 08 '17 at 17:35
  • Try running your code in debug (i.e. with assertions ON) and you will get a message in case of degenerate triangles. – sloriot Jun 09 '17 at 05:10
  • I checked the triangles, none of them are degenerate. – heinecoder Jun 13 '17 at 12:26
  • In that case, I'd be interested in getting a minimal example showing the pb (a segment and a mesh should be sufficient I guess) – sloriot Jun 13 '17 at 16:06
  • I solved my issues avoiding to query the AABB tree in parallel and with few changes in my code. The points I was referring above where generated randomly and the same point sometimes triggered the error, others didn't. Needless to say now I generate points in a more proper way and I don't get the error anymore. – heinecoder Jul 03 '17 at 12:56

0 Answers0