Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] How to get the primitive from an AABB Tree from the first intersection?

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] How to get the primitive from an AABB Tree from the first intersection?


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] How to get the primitive from an AABB Tree from the first intersection?
  • Date: Mon, 9 Jul 2018 09:35:29 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:Sb6kyhfQLC6rivDM1E1PUnDZlGMj4u6mDksu8pMizoh2WeGdxcS+Zx7h7PlgxGXEQZ/co6odzbaO7ea4ASQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7Ovr6GpLIj8Swyuu+54Dfbx9HiTahYL5+Ngm6oRnMvcQKnIVuLbo8xAHUqXVSYeRWwm1oJVOXnxni48q74YBu/SdNtf8/7sBMSar1cbg2QrxeFzQmLns65Nb3uhnZTAuA/WUTX2MLmRdVGQfF7RX6XpDssivms+d2xSeXMdHqQb0yRD+v6bpgRh31hycdLzM37X/ZisJwgqxYrhyuqRNwzIzIb4+aL/d+YqDQcMkGSWZdUMtcVSpMCZ68YYsVCOoBOP5Vo4fgqVQQthSxHxKsBP/uyjBWgH/9wKs00+M7EQHH2wwgA88FvHDVotrrM6cSVP66zLXSzTTDb/1Zwyvy6JTPchA7ofCAWLx8etfWxEk0EwPFiU+QqY3iPzOJzOgNtmyb4vFvVeKqkWEnqgVxriKzyccrj4nEn4QYwU3K+yV+xYY6P9y4SEhjbNG4H5tfrSWaO5FxQsM4TGFlvjsxxL4euZOjYiQG1JAqywTcZvGHaYSE/AzvWPuLLTp4mH5pYLCyihWo/US+xeDxV9O43EtOoydLiNXBtHAA2hrO4cadUPR95F2u2TOX2gDT9O5EJUc0mLLeK5E7w74wkoMfsErZHiPrgUn2gq+belk+9uin7OTnZbrmppuCOINulg7+NaEultS+AeQ+LAcOQ3CW9fqg2LDn50H0Q7VHguconqXHrZzWP8QWqrKhDw9QyIkj6hK/Dzm80NQfmHkKNElFeBaAj4jzOlHOJ+z4Ae26g1SoizpryPXGMafgApXJNHTMjLDhfbNl505G1AUz1cxf545TCrwZPP3zVVX+tNjBAhAkMgy02ProCMhm1oMFQm+PGa+YMKbKsVCS/O4vIu+MZJUUuDnnMfQl6eTu3jcFngoWcqCtmJcWc3ulBe9OIkODYHOqjM1SP30Nu190d+HggUaeUDNVL1K1RaM7+nl7J4+hCIrfXJGDibed2z2qX9ceMntCDUqNFmuucoGsVPIFaSbUKchkxG9XHYO9QpMsgEn9/DTxzKBqe7KNq38o8Kn73d0w3NX90BQ79Dh6FcOYijjfQGR9n2dOTDgzjvkm/R5Nj2yb2K09uMR2UMRJ7qoQAAg/PJ/Yied9DoKqA1+TTpKyUF+jB+6eL3QxQ9Y2mYJcZk98H5C9lEmG0XfyRbASkLOPCdo/9aeOh3U=

The primitive in this case is a face descriptor that depend on the type of mesh you are using.

In the case of Polyhedron_3, it is a Facet_handle
So you can access the vertices of the facet by using
Halfedge_handle h = (*hit)->halfedge();

then the 3 vertices of the triangle face are
h->vertex(), h->next()->vertex(), h->next()->next()->vertex().

This is somehow what is used here:
https://doc.cgal.org/latest/AABB_tree/index.html#title6

Sebastien.


On 07/03/2018 09:06 AM, Rash wrote:
Hi guys,

for learning CGAL I wanted to write a small ray tracerIt works fine for hit detection and but I am not able to get the primitive which the ray has hit. So I can't compute the normal of the primitve.

#include <CGAL/AABB_tree.h>
#include <CGAL/Polyhedron_3.h>

    typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;


                boost::optional<Primitive_id> hit = tree.first_intersected_primitive(rays[this->transformCoordinates(y,x)]);

//okay we have a hit. Nice but how do we get the primitve?

std::cout << *hit << std::endl; //does not work, strange iterrator
std::cout << hit << std::endl; //does not work
std::cout << &hit << std::endl; //damn
std::cout << boost::get<Point>(&(hit)) << std::endl; //come one
std::cout << boost::get<Point>((hit)) << std::endl; //google doesnt help
std::cout << boost::get<Point>(*hit) << std::endl; //write an email

After using googled for two hours I gave up. Sorry, I am not too familar with boost.

Kind regards
Rashid




Archive powered by MHonArc 2.6.18.

Top of Page