0

I'm new in cgal and I need to check the intersection of two Polyhedron_3, I know that exist a function called intersection_Polyhedron_3_Polyhedron_3() that make this, but I don't know how to implement it.

Can anyone give an example of how to use this function or another way to check the intersection of two Polyhedron_3?

Rodrigo
  • 11
  • 1

1 Answers1

0

You can use the CGAL::Polygon_mesh_processing::do_intersect() function for that. Named parameters being optional, you can write:

Polyhedron P1,P2;
bool res = CGAL::Polygon_mesh_processing::do_intersect(P1,P2);
sloriot
  • 6,070
  • 18
  • 27
  • I have seen that this function is for polyline not for polyhedra, in the function intersection_Polyhedron_3_Polyhedron_3(const Polyhedron& P, const Polyhedron& Q, OutputIterator out), I just want to know what it is Output_iterator. – Rodrigo Jan 23 '19 at 15:20
  • There are 4 different overloads and the link given points to the version for meshes. – sloriot Jan 23 '19 at 15:51
  • Im going to try again thanks, but I found an output iterator to make the function intersection_Polyhedron_3_Polyhedron_3() worked, it is std::size_t nb_polylines=0, CGAL::Counting_output_iterator out(&nb_polylines), I am not sure what means the number nb_polylines, but I would like to know if there exist an output iterator which one is the polyhedra of the intersection. – Rodrigo Jan 23 '19 at 17:22
  • You should not use this non-documented function, it will be removed in the upcoming (4.14) of CGAL. – sloriot Jan 23 '19 at 17:47
  • Hi, thank you for the advisement, I was trying the other function that you recommended but I have a question about the first example that is in Polygon Mesh Processing user manual in CGAL webpage (https://cgal.geometryfactory.com/~mgimeno/PMP_do_intersect/Polygon_mesh_processing/Polygon_mesh_processing_2refine_fair_example_8cpp-example.html). My question is I have two cubes in off format, one of them is triangulated and the other one not, the program works with the triangulated cube but with the non triangulated cube it returns "Not a valid input file", is because the cube is not triangulated? – Rodrigo Jan 24 '19 at 09:18
  • When I run the function it returns "error: ‘do_intersect’ is not a member of ‘CGAL::Polygon_mesh_processing’" so I went to the header CGAL/Polygon_mesh_processing/intersection.h and I noticed that there is no a function called "do_intersect" otherwise there is a function called "surface_intersection(const TriangleMesh& tm1, const TriangleMesh& tm2, OutputIterator polyline_output, const bool throw_on_self_intersection=false)" I used the iterator "std::size_t nb_polylines=0, CGAL::Counting_output_iterator out(&nb_polylines)" and it works, the function "do_intersect" was eliminated? nb_polylines? – Rodrigo Jan 24 '19 at 10:41
  • What CGAL version are you using? These functions were introduced in [CGAL 4.12](https://www.cgal.org/2018/04/25/cgal412/) – sloriot Jan 24 '19 at 13:56
  • I have cgal 4.11 so I upgraded my repository and checked again the version of libcgal-dev and it still remain 4.11. I am working in a virtual box with Ubuntu 18.04.1 – Rodrigo Jan 24 '19 at 14:22
  • If you simply download the latest version from [here](https://github.com/CGAL/cgal/releases), you can use the header only version by configuring your example using `cmake -DCGAL_DIR=/path/where/you/extracted/CGAL-4.13 /path/of/my/example` – sloriot Jan 26 '19 at 08:56