Subject: CGAL users discussion list
List archive
- From: Philipp Moeller <>
- To: rcasero <>
- Cc:
- Subject: Re: [cgal-discuss] Re: Getting index of facet closest to a point
- Date: Thu, 06 Jun 2013 01:16:44 +0200
- Organization: GeometryFactory
rcasero
<>
writes:
> 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
>
> https://code.google.com/p/gerardus/source/browse/trunk/matlab/CgalToolbox/CgalClosestTriFacet.cpp?r=1128#236
>
> The face index can be read doing
>
> // closest facet (facet indexes start at index 1)
> f[i] = &(*pp.second) - &(triangles[0]) + 1;
Which is what the call to std::distance does. Your version is probably
slower though. :)
>
>
> Thanks again for your help!
>
> Best regards,
>
> Ramon.
>
>
>
>
> On 3 June 2013 12:30, Sebastien Loriot (GeometryFactory) [via cgal-discuss]
> <>
> 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
>> >
>> > 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
>> > Sent from the cgal-discuss mailing list archive at Nabble.com.
>> >
>>
>>
>> --
>> 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
>> To unsubscribe from Getting index of facet closest to a point, click
>> here<http://cgal-discuss.949826.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4657635&code=cmNhc2Vyb0BnbWFpbC5jb218NDY1NzYzNXwtMTQ5MjY4MjU4MA==>
>> .
>> NAML<http://cgal-discuss.949826.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
>
> --
> 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:
> http://cgal-discuss.949826.n4.nabble.com/Getting-index-of-facet-closest-to-a-point-tp4657635p4657648.html
> Sent from the cgal-discuss mailing list archive at Nabble.com.
--
Philipp Moeller
GeometryFactory
- [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.