I wrote a small raytracer (with CGAL::Surface_mesh Mesh) with tree acceleration in cgal. I would like to find all neighbours of a hit primitive.
Ray_intersection hit = tree.first_intersection(rays[y][x]);
if(hit)
{
const Point& point = boost::get<Point>(hit->first);
const Primitive_id& primitive_id = boost::get<Primitive_id>(hit->second);
//i need the neighbours of the hit primitive
}
How do I this? I found this documentation but it seems to work only for points not primitives:
https://doc.cgal.org/latest/Spatial_searching/index.html
And it searches for its euclidan distance not for being connected together.
Is there something like:
std::vector<Primitive_id&> ids = getNeighoursOfPrimive(primitive_id);
Like I said I am using CGAL::Surface_mesh Mesh for my mesh and their is only one mesh in the scene.
You can use the range returned by vertices_around_face()
to get all vertices of a face, then for each vertex you can use the range returned by halfedges_around_target()
to get one halfedge per face incident to that vertex (or you can do it by hand using a combinaison of next and opposite).