Merge branch 'Spatial_searching-fix_search_traits_adapter-local'

documentation bugfix and adding static assertion guards in adapter classes

  Tested in CGAL-4.4-Ic-132
This commit is contained in:
Sébastien Loriot 2014-02-27 07:43:04 +01:00
commit 4300adcfb0
16 changed files with 69 additions and 36 deletions

View File

@ -244,6 +244,15 @@ and <code>src/</code> directories).
<li> The generator ipelet now generates point in a selected zone</li>
<li> Hilbert sort ipelet implements two policies</li>
</ul>
<h3>dD Spatial Searching</h3>
<ul>
<li>Fix a documentation bug: The property map passed as template parameter to the classes
<code>Search_traits_adapter</code> and <code>Distance_adapter</code> must be a
lvalue property map. To avoid incorrect usage, a static assertion has been added
in the CGAL code to prevent the user from instantiating these classes with an
incorrect property map type.</li>
</ul>
</div>
<h2 id="release4.3">Release 4.3 </h2>

View File

@ -12,7 +12,7 @@ in a nearest neighbor search algorithm, this class must be used as distance.
`Key` is a type that is associated to a point of type `Base_distance::Point_d`.
`PointPropertyMap` is a model of `ReadablePropertyMap`
`PointPropertyMap` is a model of `LvaluePropertyMap`
with `Key` as `key_type` and `Base_distance::Point_d` as `value_type`.
`Base_distance` is a model of either `GeneralDistance` or `OrthogonalDistance`.
@ -84,7 +84,7 @@ must be used as distance.
`Key` is a type that is associated to a point of type `Base_distance::Point_d`.
`PointPropertyMap` is a model of `ReadablePropertyMap`
`PointPropertyMap` is a model of `LvaluePropertyMap`
with `Key` as `key_type` and `Base_distance::Point_d` as `value_type`.
`BaseTraits` is a model of either `SearchTraits` or `RangeSearchTraits`.

View File

@ -79,7 +79,7 @@ classes that are described in the reference pages.
- `CGAL::Euclidean_distance_sphere_point<Traits>`
- `CGAL::Manhattan_distance_iso_box_point<Traits>`
- `CGAL::Weighted_Minkowski_distance<Traits>`
- `CGAL::Distance_for_point_adapter<Key,PointPropertyMap,Base_distance>`
- `CGAL::Distance_adapter<Key,PointPropertyMap,Base_distance>`
## %Splitter Classes ##
- `CGAL::Sliding_midpoint<Traits, SpatialSeparator>`

View File

@ -12,21 +12,23 @@ typedef Kernel::Point_3 Point_3;
typedef std::size_t Point;
//definition of the property map and get
//function as friend function to have access to
//private member
//definition of a non-mutable lvalue property map,
//with the get function as a friend function to give it
//access to the private member
class My_point_property_map{
const std::vector<Point_3>& points;
public:
typedef Point_3 value_type;
typedef const value_type& reference;
typedef Point key_type;
typedef boost::readable_property_map_tag category;
typedef boost::lvalue_property_map_tag category;
My_point_property_map(const std::vector<Point_3>& pts):points(pts){}
reference operator[](key_type k) const {return points[k];}
friend reference get(const My_point_property_map& ppmap,key_type i)
{return ppmap.points[i];}
{return ppmap[i];}
};

View File

@ -22,15 +22,12 @@
#define CGAL_SEARCH_TRAITS_WITH_INFO
#include <CGAL/Kd_tree_rectangle.h>
#include <boost/mpl/has_xxx.hpp>
#include <CGAL/Euclidean_distance.h> //for default distance specialization
#include <CGAL/property_map.h>
#include <boost/version.hpp>
#if BOOST_VERSION >= 104000
#include <boost/property_map/property_map.hpp>
#else
#include <boost/property_map.hpp>
#endif
#include <boost/mpl/has_xxx.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
namespace CGAL{
@ -74,6 +71,10 @@ struct Get_iso_box_d<T,true>
template <class Point_with_info,class PointPropertyMap,class Base_traits>
class Search_traits_adapter : public Base_traits{
PointPropertyMap ppmap;
BOOST_STATIC_ASSERT( ( boost::is_same< boost::lvalue_property_map_tag,
typename boost::property_traits<PointPropertyMap>::category
>::value ) );
public:
typedef Base_traits Base;
typedef typename internal::Get_iso_box_d<Base>::type Iso_box_d;
@ -126,6 +127,10 @@ template <class Point_with_info,class PointPropertyMap,class Base_distance>
class Distance_adapter : public Base_distance {
PointPropertyMap ppmap;
typedef typename Base_distance::FT FT;
BOOST_STATIC_ASSERT( ( boost::is_same< boost::lvalue_property_map_tag,
typename boost::property_traits<PointPropertyMap>::category
>::value ) );
public:
Distance_adapter( const PointPropertyMap& ppmap_=PointPropertyMap(),

View File

@ -27,8 +27,9 @@ typedef CGAL::K_neighbor_search<SearchTraits> K_neighbor_searc
typedef Orthogonal_k_neighbor_search::Distance Distance;
//typdefs for Point_with_info
typedef Point_with_info_helper<SearchTraits::Point_d>::type Point_with_info;
typedef CGAL::Search_traits_adapter<Point_with_info,Point_property_map,SearchTraits> Traits_with_info;
typedef CGAL::Distance_adapter <Point_with_info,Point_property_map,Distance> Distance_adapter;
typedef Point_property_map<SearchTraits::Point_d> Ppmap;
typedef CGAL::Search_traits_adapter<Point_with_info,Ppmap,SearchTraits> Traits_with_info;
typedef CGAL::Distance_adapter <Point_with_info,Ppmap,Distance> Distance_adapter;
typedef CGAL::Orthogonal_k_neighbor_search<Traits_with_info,Distance_adapter> Orthogonal_k_neighbor_search_with_info;
typedef CGAL::K_neighbor_search<Traits_with_info,Distance_adapter> K_neighbor_search_with_info;

View File

@ -16,8 +16,9 @@ typedef CGAL::Search_traits<double, Point, const double*, Construct_coord_iterat
typedef CGAL::Orthogonal_k_neighbor_search<Traits, Distance> K_neighbor_search;
//typdefs for Point_with_info
typedef Point_with_info_helper<Point>::type Point_with_info;
typedef CGAL::Search_traits_adapter<Point_with_info,Point_property_map,Traits> Traits_with_info;
typedef CGAL::Distance_adapter <Point_with_info,Point_property_map,Distance> Distance_adapter;
typedef Point_property_map<Point> Ppmap;
typedef CGAL::Search_traits_adapter<Point_with_info,Ppmap,Traits> Traits_with_info;
typedef CGAL::Distance_adapter <Point_with_info,Ppmap,Distance> Distance_adapter;
typedef CGAL::Orthogonal_k_neighbor_search<Traits_with_info, Distance_adapter> K_neighbor_search_with_info;
const unsigned int N = 1000;

View File

@ -23,7 +23,8 @@ typedef CGAL::Counting_iterator<Random_points_iterator> N_Random_points_iterator
typedef CGAL::Search_traits_2<K> Traits;
//for Point_with_info
typedef Point_with_info_helper<Point>::type Point_with_info;
typedef CGAL::Search_traits_adapter<Point_with_info,Point_property_map,Traits> Traits_with_info;
typedef Point_property_map<Point> Ppmap;
typedef CGAL::Search_traits_adapter<Point_with_info,Ppmap,Traits> Traits_with_info;
template <class Traits>

View File

@ -21,7 +21,8 @@ typedef CGAL::Random_points_in_square_2<Point> Random_points_iterator;
typedef CGAL::Counting_iterator<Random_points_iterator> N_Random_points_iterator;
typedef CGAL::Search_traits_2<K> Traits;
typedef Point_with_info_helper<Point>::type Point_with_info;
typedef CGAL::Search_traits_adapter<Point_with_info,Point_property_map,Traits> Traits_with_info;
typedef Point_property_map<Point> Ppmap;
typedef CGAL::Search_traits_adapter<Point_with_info,Ppmap,Traits> Traits_with_info;
template <class SearchTraits>
void run(std::list<Point> all_points)

View File

@ -16,8 +16,9 @@ typedef CGAL::Manhattan_distance_iso_box_point<TreeTraits> Distance;
typedef CGAL::K_neighbor_search<TreeTraits, Distance> Neighbor_search;
//typdefs for Point_with_info
typedef Point_with_info_helper<Point_d>::type Point_with_info;
typedef CGAL::Search_traits_adapter<Point_with_info,Point_property_map,TreeTraits> Traits_with_info;
typedef CGAL::Distance_adapter <Point_with_info,Point_property_map,Distance> Distance_adapter;
typedef Point_property_map<Point_d> Ppmap;
typedef CGAL::Search_traits_adapter<Point_with_info,Ppmap,TreeTraits> Traits_with_info;
typedef CGAL::Distance_adapter <Point_with_info,Ppmap,Distance> Distance_adapter;
typedef CGAL::K_neighbor_search<Traits_with_info, Distance_adapter> Neighbor_search_with_info;
const unsigned int K = 8;

View File

@ -21,8 +21,9 @@ typedef CGAL::K_neighbor_search<TreeTraits, Distance> Neighbor_search;
typedef CGAL::Random_points_in_square_2<Point> Random_points_iterator;
//typdefs for Point_with_info
typedef Point_with_info_helper<Point>::type Point_with_info;
typedef CGAL::Search_traits_adapter<Point_with_info,Point_property_map,TreeTraits> Traits_with_info;
typedef CGAL::Distance_adapter <Point_with_info,Point_property_map,Distance> Distance_adapter;
typedef Point_property_map<Point> Ppmap;
typedef CGAL::Search_traits_adapter<Point_with_info,Ppmap,TreeTraits> Traits_with_info;
typedef CGAL::Distance_adapter <Point_with_info,Ppmap,Distance> Distance_adapter;
typedef CGAL::K_neighbor_search<Traits_with_info, Distance_adapter> Neighbor_search_with_info;

View File

@ -39,8 +39,9 @@ typedef Orthogonal_incremental_neighbor_search::iterator NN_iterator;
typedef Orthogonal_incremental_neighbor_search::Point_with_transformed_distance Point_with_transformed_distance;
//typdefs for Point_with_info
typedef Point_with_info_helper<Point>::type Point_with_info;
typedef CGAL::Search_traits_adapter<Point_with_info,Point_property_map,TreeTraits> Traits_with_info;
typedef CGAL::Distance_adapter <Point_with_info,Point_property_map,Distance> Distance_adapter;
typedef Point_property_map<Point> Ppmap;
typedef CGAL::Search_traits_adapter<Point_with_info,Ppmap,TreeTraits> Traits_with_info;
typedef CGAL::Distance_adapter <Point_with_info,Ppmap,Distance> Distance_adapter;
typedef CGAL::Incremental_neighbor_search<Traits_with_info,Distance_adapter> Orthogonal_incremental_neighbor_search_with_info;

View File

@ -16,8 +16,9 @@ typedef CGAL::Search_traits_2<K> TreeTrai
typedef CGAL::Orthogonal_k_neighbor_search<TreeTraits> Neighbor_search;
//typdefs fo Point_with_info
typedef Point_with_info_helper<Point>::type Point_with_info;
typedef CGAL::Search_traits_adapter<Point_with_info,Point_property_map,TreeTraits> Traits_with_info;
typedef CGAL::Distance_adapter <Point_with_info,Point_property_map,Neighbor_search::Distance> Distance_adapter;
typedef Point_property_map<Point> Ppmap;
typedef CGAL::Search_traits_adapter<Point_with_info,Ppmap,TreeTraits> Traits_with_info;
typedef CGAL::Distance_adapter <Point_with_info,Ppmap,Neighbor_search::Distance> Distance_adapter;
typedef CGAL::Orthogonal_k_neighbor_search<Traits_with_info,Distance_adapter> Neighbor_search_with_info;
template <class K_search>

View File

@ -16,17 +16,24 @@ struct Point_with_info_helper{
typedef My_point_with_info<Point_> type;
};
template <class Point>
struct Point_property_map{
template <class Point>
friend const Point& get(Point_property_map,const My_point_with_info<Point>& p) {return p.point();}
typedef Point value_type;
typedef const value_type& reference;
typedef const My_point_with_info<Point>& key_type;
typedef boost::lvalue_property_map_tag category;
reference operator[](key_type k) const {return k.point();}
friend reference get(const Point_property_map& ppmap, key_type i)
{return ppmap[i];}
};
template <class Point>
const Point& get_point(const Point& p) {return p;}
template <class Point>
const Point& get_point(const My_point_with_info<Point>& p) {return get(Point_property_map(),p);}
const Point& get_point(const My_point_with_info<Point>& p) {return get(Point_property_map<Point>(),p);}
template <class Point>
struct Create_point_with_info : public std::unary_function<Point,Point>{

View File

@ -19,7 +19,8 @@ typedef CGAL::Counting_iterator<Random_points_iterator> N_Random_points_iterator
typedef CGAL::Search_traits_3<K> Traits;
//for Point_with_info
typedef Point_with_info_helper<Point>::type Point_with_info;
typedef CGAL::Search_traits_adapter<Point_with_info,Point_property_map,Traits> Traits_with_info;
typedef Point_property_map<Point> Ppmap;
typedef CGAL::Search_traits_adapter<Point_with_info,Ppmap,Traits> Traits_with_info;
const int N=10000;

View File

@ -29,8 +29,9 @@ typedef CGAL::Search_traits_3<K> TreeTraits;
typedef CGAL::Euclidean_distance<TreeTraits> Distance;
#endif
typedef Point_with_info_helper<Point>::type Point_with_info;
typedef CGAL::Search_traits_adapter<Point_with_info,Point_property_map,TreeTraits> Traits_with_info;
typedef CGAL::Distance_adapter <Point_with_info,Point_property_map,Distance> Distance_adapter;
typedef Point_property_map<Point> Ppmap;
typedef CGAL::Search_traits_adapter<Point_with_info,Ppmap,TreeTraits> Traits_with_info;
typedef CGAL::Distance_adapter <Point_with_info,Ppmap,Distance> Distance_adapter;
typedef std::vector<Point> Vector;