From ca1d3536d9af5c99a98f31a165f145acf6793ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 25 May 2011 09:23:01 +0000 Subject: [PATCH] *use Point_dimension_d in adapter_d *remove const in Kernel_d result_type functors --- .../include/CGAL/Kernel_d/function_objectsCd.h | 4 ++-- .../include/CGAL/Kernel_d/function_objectsHd.h | 6 +++--- .../sp_sort_using_property_map_2.cpp | 2 +- .../sp_sort_using_property_map_3.cpp | 7 ++++--- .../sp_sort_using_property_map_d.cpp | 15 ++++++++++----- .../include/CGAL/Spatial_sort_traits_adapter_d.h | 10 ++++++++++ 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/Kernel_d/include/CGAL/Kernel_d/function_objectsCd.h b/Kernel_d/include/CGAL/Kernel_d/function_objectsCd.h index 1f742684f0d..ae5887d33f1 100644 --- a/Kernel_d/include/CGAL/Kernel_d/function_objectsCd.h +++ b/Kernel_d/include/CGAL/Kernel_d/function_objectsCd.h @@ -42,7 +42,7 @@ class Compute_coordinateCd { typedef typename K::Point_d Point_d; public: typedef FT result_type; - const result_type + result_type operator()(const Point_d& p, int i) const { return p.cartesian(i); @@ -55,7 +55,7 @@ class Point_dimensionCd { typedef typename K::Point_d Point_d; public: typedef int result_type; - const result_type + result_type operator()(const Point_d& p) const { return p.dimension(); diff --git a/Kernel_d/include/CGAL/Kernel_d/function_objectsHd.h b/Kernel_d/include/CGAL/Kernel_d/function_objectsHd.h index 0d692f48997..2e719d9b6b8 100644 --- a/Kernel_d/include/CGAL/Kernel_d/function_objectsHd.h +++ b/Kernel_d/include/CGAL/Kernel_d/function_objectsHd.h @@ -41,7 +41,7 @@ class Compute_coordinateHd { typedef typename K::Point_d Point_d; public: typedef FT result_type; - const result_type + result_type operator()(const Point_d& p, int i) const { return p.cartesian(i); @@ -54,7 +54,7 @@ class Point_dimensionHd { typedef typename K::Point_d Point_d; public: typedef int result_type; - const result_type + result_type operator()(const Point_d& p) const { return p.dimension(); @@ -67,7 +67,7 @@ class Less_coordinateHd { typedef typename K::Point_d Point_d; public: typedef bool result_type; - const result_type + result_type operator()(const Point_d& p, const Point_d& q, int i) const { int d = p.dimension(); diff --git a/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_2.cpp b/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_2.cpp index 1076ddd3363..091da4ae35c 100644 --- a/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_2.cpp +++ b/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_2.cpp @@ -22,7 +22,7 @@ get(const First_of_pair&, const First_of_pair::key_type& k) { return k.first; } -typedef CGAL::Spatial_sort_traits_adapter_2 Search_traits_2; +typedef CGAL::Spatial_sort_traits_adapter_2 Search_traits_2; int main() { diff --git a/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_3.cpp b/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_3.cpp index 9c4c3032647..ab48feafc9f 100644 --- a/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_3.cpp +++ b/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_3.cpp @@ -4,10 +4,11 @@ #include #include -typedef CGAL::Simple_cartesian Kernel; -typedef Kernel::Point_3 Point_3; +typedef CGAL::Simple_cartesian Kernel; +typedef Kernel::Point_3 Point_3; //using a pointer as a special property map type -typedef CGAL::Spatial_sort_traits_adapter_3 Search_traits_3; +typedef + CGAL::Spatial_sort_traits_adapter_3 Search_traits_3; int main() { diff --git a/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_d.cpp b/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_d.cpp index c13b829b713..64aa5fdf48f 100644 --- a/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_d.cpp +++ b/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_d.cpp @@ -41,15 +41,20 @@ int main() std::vector indices; indices.reserve(points.size()); - std::copy(boost::counting_iterator(0), - boost::counting_iterator(points.size()), - std::back_inserter(indices)); + std::copy( + boost::counting_iterator(0), + boost::counting_iterator(points.size()), + std::back_inserter(indices) ); - CGAL::spatial_sort( indices.begin(),indices.end(),Search_traits_d(Vect_ppmap(points)) ); + CGAL::spatial_sort( + indices.begin(), + indices.end(), + Search_traits_d(Vect_ppmap(points)) ); + std::vector::iterator it=indices.begin(); for (;it!=indices.end();++it) std::cout << points[*it].second << " "; - std::cout << "\n"; + std::cout << std::endl; std::cout << "done" << std::endl; diff --git a/Spatial_sorting/include/CGAL/Spatial_sort_traits_adapter_d.h b/Spatial_sorting/include/CGAL/Spatial_sort_traits_adapter_d.h index 5115f58f3d5..b569046bb42 100644 --- a/Spatial_sorting/include/CGAL/Spatial_sort_traits_adapter_d.h +++ b/Spatial_sorting/include/CGAL/Spatial_sort_traits_adapter_d.h @@ -43,6 +43,15 @@ public: + struct Point_dimension_d: public Base_traits::Point_dimension_d{ + Point_dimension_d(const PointPropertyMap& ppmap,const typename Base_traits::Point_dimension_d& base): + Base_traits::Point_dimension_d(base),ppmap_(ppmap){} + const PointPropertyMap& ppmap_; + int operator()(Arg_type p) const { + return static_cast(this)->operator()(get(ppmap_,p)); + } + }; + struct Less_coordinate_d: public Base_traits::Less_coordinate_d{ Less_coordinate_d(const PointPropertyMap& ppmap,const typename Base_traits::Less_coordinate_d& base): Base_traits::Less_coordinate_d(base),ppmap_(ppmap){} @@ -64,6 +73,7 @@ public: + Point_dimension_d point_dimension_d_object () const {return Point_dimension_d(ppmap_,static_cast(this)->point_dimension_d_object() );} Less_coordinate_d less_coordinate_d_object () const {return Less_coordinate_d(ppmap_,static_cast(this)->less_coordinate_d_object() );} Compute_coordinate_d compute_coordinate_d_object () const {return Compute_coordinate_d(ppmap_,static_cast(this)->compute_coordinate_d_object() );}