Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Suggestions for how to do 2D nearest neighbour search from 3D points?

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Suggestions for how to do 2D nearest neighbour search from 3D points?


Chronological Thread 
  • From: Matti Lehtonen <>
  • To:
  • Subject: Re: [cgal-discuss] Suggestions for how to do 2D nearest neighbour search from 3D points?
  • Date: Tue, 30 Apr 2013 14:14:52 +0300

Hi,


On 29 April 2013 16:22, Sebastien Loriot (GeometryFactory) <> wrote:
The simplest but probably not the faster is to use Search_traits_adapter
with Search_traits_2 and a property map that creates 2D points on the
fly from 3D points.

The Search_traits_adapter<> approach didn't really work. The application dumps a core while the tree is build
terminate called after throwing an instance of 'CGAL::Assertion_exception'
  what():  CGAL ERROR: assertion violation!
Expr: b = (b && (bbox.min_coord(i) <= tbox.min_coord(i)))
File: /usr/include/CGAL/Point_container.h
Line: 325
or
 terminate called after throwing an instance of 'CGAL::Assertion_exception'
  what():  CGAL ERROR: assertion violation!
Expr: max_span_upper <= c0.max_span_upper()
File: /usr/include/CGAL/Splitters.h
Line: 197
depending, which version of function get() is used.

// Tree - 3D points used like 2D points
struct Property_map_xy_2
{
    typedef Point_2                                value_type;
    typedef const value_type &                    reference;
    typedef const Multi_Classified_Point &        key_type;
    typedef boost::readable_property_map_tag    category;
};
Property_map_xy_2::reference
get
(
    Property_map_xy_2,
    Property_map_xy_2::key_type        p
)
{
    static Point_2    tmp;
    return tmp = Point_2( p.x(), p.y() );
    ///return Point_2( p.x(), p.y() );    ///  with a GCC warning
}
Sho


The approach, where a 3D [storage] tree is used with custom [2D] distance with only Distance_adapter<> won't compile, so the only approaches are
a) store points as tuples or

b)
You are right that [1] is longer to write but will be faster.


Matti L
--
Life is complex. It has real and imaginary parts.



Archive powered by MHonArc 2.6.18.

Top of Page