Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Find all neighbours of a certain primitive

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Find all neighbours of a certain primitive


Chronological Thread 
  • From: Rash <>
  • To:
  • Subject: Re: [cgal-discuss] Find all neighbours of a certain primitive
  • Date: Thu, 13 Jun 2019 17:02:44 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=None ; spf=None
  • Ironport-phdr: 9a23:EwpWdRDB7dXbwa9GYgdKUyQJP3N1i/DPJgcQr6AfoPdwSPv+ocbcNUDSrc9gkEXOFd2Cra4d0qyP7vGrCTVIyK3CmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+KPjrFY7OlcS30P2594HObwlSizexfK5+IA+roQjRssQajohvJrsswRbVv3VEfPhby3l1LlyJhRb84cmw/J9n8ytOvv8q6tBNX6bncakmVLJUFDspPXw7683trhnDUBCA5mAAXWUMkxpHGBbK4RfnVZrsqCT6t+592C6HPc3qSL0/RDqv47t3RBLulSwKMSMy/mPKhcxqlK9VvQyvpxJ/zYDXbo+aOvVxcaHBct0VXmdBQsVcWjZdDo+gYYYCDewMNvtYoYnnoFsOqAOzCxW2C+P0yj9Dm3j73bcg3OQ6EQHG3REvEskLsHTVqNX6LrsdUeewzKXS0DrMcepb1DHg44bGdRAhpOuDXbN2ccfJ10YvCRrJgU6LqYD/IjyayPwBvHSU7+V6UeKjkWknqxt+ojWp28wiiZHJi5oWx13E7yl13Yg4KcelREN1ZdOoCoZcuiKZOoduQc4vQHtktSQnxrEcuZO3YjIGxIkmyhLBbfGMbpKG7Qj5VOmLJDd1nHJld6y7hxa16UWv1/DzWtSw3VtFsCZIncPAtnMX2BzI8ciIVOF9/lm/1jaVzQzc9uZEIUUsmaraLZ4u3KIwm4IQvEnDBCP6hUv7gLWLekgq/uWk8fnrb7blq5OEMo97kAD+MqAgmsylBuQ4NxADX3KB9uSn1L3j/FD2Ta5Pjv03lqnWqozVJcMepqKjHgBazJ4v6wyjADe+zNQYgX4HIUpZdxKIlYfpP0jCL+35Dfekn1usjSxrx+vdM736ApTNK2DDn637cbZ87U5c0gszwspF65JaELFSaM70D0T+vdidAh4iOBGv2M7mDs9838UQQzGhGKicZZnbql/AsvgmOOmNaKcQuTL0IP8gofLj2yxq0WQBdLWkiMNEIEuzGe5rdh3APSjcx+wZGGJPhTIQCfTwgQTYAztSY3+5WKd66jxpUNv7X7eGfZikhfm65An+HpBSYTodWFyASCa0LdnCWP4Xcy+IPMJ71DcDUOr5Et5z5VSVrAb/joFfAK/R8ywcu4jk0YEvtejSkRg58jkyA8nPi2w=
  • Openpgp: preference=signencrypt

It works, thank you a lot.

There is a small bug. I would like to find all neighbours, not only the
ones which share a edge. If two triangles share a vertex (but not an
edge), they should be neighbours. Here is an example (same color means
it is a connected surface). There should be only a red and one green
surface. There are 4 surfaces colors.

https://owncloud.ev-bs.de/index.php/s/1qFVNbiwA2Z6o7D

I tried to use:

CGAL::Face_around_target_circulator< Graph >

but I failed. Is there a way to get all triangles which share a vertex
descriptor with surface mesh?

For finding one connected Surface I wrote this code. What could I change
to get all connected faces, even the one only connected via a single vertex?

My code:


void visitAllFaces(const face_descriptor &_fd,
std::map<face_descriptor,size_t> &_maps, std::set<face_descriptor>
&_visited, const size_t _patch_index, const Mesh& _mesh)
{
const size_t key_was_found = _visited.count(_fd);
if(!key_was_found)
{
_visited.insert(_fd);
_maps[_fd] = _patch_index;

for(face_descriptor neigh_fd :
CGAL::faces_around_face(halfedge(_fd, _mesh), _mesh)) // m is your
surface mesh
{
if(neigh_fd !=
boost::graph_traits<CGAL::Surface_mesh<K::Point_3> >::null_face())
{
visitAllFaces(neigh_fd,_maps,_visited, _patch_index,_mesh);
}
}
}
}

Btw. having null faces which just crash (no assert warning) is realy
confusing.


Am 16.05.19 um 08:22 schrieb Mael:
> Hello,
>
> Do you really care for the primitive, or just the neighboring faces? If
> you just want the neighboring faces, and assuming your primitive is
> AABB_face_graph_triangle_primitive, the primitive ID is a
> boost::graph_traits<Surface_mesh>::face_descriptor (i.e.
> Surface_mesh::Face_index) and you can use BGL-like functions provided by
> CGAL such as CGAL::faces_around_face
> <https://doc.cgal.org/latest/BGL/group__PkgBGLIterators.html#ga5a12f39e74a0667374570d61b859bfb1>:
>
> face_descriptor fd = p_id;
> for(face_descriptor neigh_fd : CGAL::faces_around_face(halfedge(fd, sm),
> sm) // sm is your surface mesh
> {
>   etc
> }
>
> See the package BGL
> <https://doc.cgal.org/latest/BGL/group__PkgBGLRef.html> for a lot of
> convenient functions (it requires a data structure to fit a certain
> interface, which CGAL::Surface_mesh does using the 'graph_traits'
> interface).
>
> Best,
> Mael
>
> On 16/05/2019 01:57, Rash wrote:
>> Hi people,
>>
>> I wrote a small raytracer (with CGAL::Surface_mesh<Point> 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<Point> Mesh for my mesh and
>> their is only one mesh in the scene.
>>
>> Kind regards
>> Rashid
>>



Archive powered by MHonArc 2.6.18.

Top of Page