chrisidefix / cgal-bindings

Automatically exported from code.google.com/p/cgal-bindings
Boost Software License 1.0
0 stars 0 forks source link

efficient method to retrieve intersected facets indices #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
hi,

I am doing ray/polyhedron  intersections queries using the python binding for 
CGAL (with the class AABB_tree_Polyhedron_3_Facet_handle and its method 
all_intersected_primitives). This method gives me a list of intersected faces 
and I would like to obtain the indices of these intersected faces (i.e numbers 
between 0 and the total number of faces). For each facet in the list of 
intersected faces, i managed to get the corresponding index by iterating over 
all the facet of the polyhedron while incrementing a counter until the 
intersected facet is equal to the facet of the polyhedron being considered. The 
attached file provides the code to test that. This approach is very slow and i 
tried to use the method.
set_id() and id() in the class CGAL_Polyhedron_3.Polyhedron_3_Facet_handle to 
avoid having to iterate over all the facets without success. I would expect the 
method set_id() to allow me to associate an index to each facet and then the 
method id() to retrieve tat index. However the method id() always return -1.  I 
am using the binding at revision c15ccd439e55  (26/07/2013) with  unbuntu 
13.04. Is there a problem in the binding ? Is there a efficient method to 
retrieve the indices of the intersected faces ? thanks

Original issue reported on code.google.com by martin.d...@gmail.com on 9 Aug 2013 at 1:58

Attachments:

GoogleCodeExporter commented 9 years ago
The id is not activated by default in python.
Open SWIG_CGAL/Polyhedron_3/typedefs.h and change 
typedef CGAL::Polyhedron_3<EPIC_Kernel>     Polyhedron_3_;
to
typedef CGAL::Polyhedron_3<EPIC_Kernel, CGAL::Polyhedron_items_with_id_>     
Polyhedron_3_;

then recompile the bindings (you need to "touch CGAL_Polyhedron_3.i" before)

Original comment by sloriot...@gmail.com on 9 Aug 2013 at 2:39

GoogleCodeExporter commented 9 years ago
thanks for the answer. what do you mean by "touch CGAL_Polyhedron_3.i" ? if  
you mean that i need to edit that file, i am not sure what to change as i am 
not familiar with swig. 

Original comment by martin.d...@gmail.com on 9 Aug 2013 at 2:56

GoogleCodeExporter commented 9 years ago
you need to fake you changed it so that cmake rerun swig.
touch is a command doing this (in the shell).

Original comment by sloriot...@gmail.com on 9 Aug 2013 at 3:27

GoogleCodeExporter commented 9 years ago
I got it to work :) following these steps:
1) replace typedef CGAL::Polyhedron_3<EPIC_Kernel>     Polyhedron_3_;
by 
typedef CGAL::Polyhedron_3<EPIC_Kernel, CGAL::Polyhedron_items_with_id_3>     
Polyhedron_3_;
(note the 3 fater "id_")
2) add #include <CGAL/Polyhedron_items_with_id_3.h> in 
CGAL/Polyhedron_3/typedefs.h
3) in the shell after going in the right folder run "touch CGAL_Polyhedron_3.i"
4) re-run make
Thanks !

Original comment by martin.d...@gmail.com on 9 Aug 2013 at 4:09

GoogleCodeExporter commented 9 years ago

Original comment by sloriot...@gmail.com on 9 Aug 2013 at 5:22