Subject: CGAL users discussion list
List archive
- From: rcasero <>
- To:
- Subject: [cgal-discuss] Re: Getting index of facet closest to a point
- Date: Tue, 4 Jun 2013 14:19:56 -0700 (PDT)
Hi Sebastien,
Thanks for your reply. Using an std::vector is a great idea. Although, I have been thinking about it, and given that std::vector allocates memory in a sequential block, it's not necessary to do a search.
As we get the memory address of the Triangle element, we can obtain the facet index subtracting the memory address of the first element. I have implemented it here
The face index can be read doing
// closest facet (facet indexes start at index 1) |
f[i] = &(*pp.second) - &(triangles[0]) + 1; |
Thanks again for your help!
Best regards,
Ramon.
On 3 June 2013 12:30, Sebastien Loriot (GeometryFactory) [via cgal-discuss] <[hidden email]> wrote:
pp.second is an iterator in the container containing the triangles.
You can for example, change std::list<Triangle_3> to
std::vector<Triangle_3> and use std::distance(triangles.begin(),
pp.second) to get the index.
Sebastien.
On 06/01/2013 02:02 AM, rcasero wrote:>
> Dear all,
>
> I have a triangulation and I'm trying to find the closest facet to a point
> using an AABB tree, but after much googling, and unsuccessfully trying to
> find the methods available to facets in the CGAL source code, I'd like to
> ask for a hand here.
>
> I tinkered with the code in the manual, "64.3.3 Tree of Polyhedron
> Triangle Facets for Distance Queries"
>
> http://www.cgal.org/Manual/latest/doc_html/cgal_manual/AABB_tree/Chapter_main.html#Subsection_64.3.3
> and "64.3.1 Tree of Triangles, for Intersection and Distance Queries"
>
> http://www.cgal.org/Manual/latest/doc_html/cgal_manual/AABB_tree/Chapter_main.html#Subsection_64.3.1
>> Sent from the cgal-discuss mailing list archive at Nabble.com.
> I am able to compile and run the code, but what I've been unable to do is
> once I get to this
>
> Point_and_primitive_id pp = tree.closest_point_and_primitive(query);
> Primitive f = pp.second; // closest primitive id
>
> how to get an index to the facet (triangle) that is closest to the point.
> That is, if I have created my triangulation with something like this, using
> 10 triangles
>
> for (int i = 0; i< 10; ++i) {
> // read a triangle
> x0 = ...
> x1 = ...
> x2 = ...
>
> // add triangle to the list of triangles in the surface
> triangles.push_back(Triangle(x0, x1, x2));
> }
>
> how I can tell from pp.second above which of the 10 triangles is the
> solution.
>
> Best regards,
>
> Ramon.
>
>
>
> --
> View this message in context: http://cgal-discuss.949826.n4.nabble.com/Getting-index-of-facet-closest-to-a-point-tp4657635.html
>
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss
If you reply to this email, your message will be added to the discussion below:http://cgal-discuss.949826.n4.nabble.com/Getting-index-of-facet-closest-to-a-point-tp4657635p4657638.html
Dr. Ramón Casero Cañas
Oxford e-Research Centre (OeRC)
University of Oxford
7 Keble Rd
Oxford OX1 3QG
tlf +44 (0) 1865 610739
web http://www.cs.ox.ac.uk/people/Ramon.CaseroCanas
photos http://www.flickr.com/photos/rcasero/
View this message in context: Re: Getting index of facet closest to a point
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Getting index of facet closest to a point, rcasero, 06/01/2013
- Re: [cgal-discuss] Getting index of facet closest to a point, Sebastien Loriot (GeometryFactory), 06/03/2013
- [cgal-discuss] Re: Getting index of facet closest to a point, rcasero, 06/04/2013
- Re: [cgal-discuss] Re: Getting index of facet closest to a point, Philipp Moeller, 06/06/2013
- [cgal-discuss] Re: Getting index of facet closest to a point, rcasero, 06/04/2013
- Re: [cgal-discuss] Getting index of facet closest to a point, Sebastien Loriot (GeometryFactory), 06/03/2013
Archive powered by MHonArc 2.6.18.