BWAPI
|
00001 // Copyright (c) 2007 INRIA Sophia-Antipolis (France). 00002 // All rights reserved. 00003 // 00004 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public License as 00006 // published by the Free Software Foundation; version 2.1 of the License. 00007 // See the file LICENSE.LGPL distributed with CGAL. 00008 // 00009 // Licensees holding a valid commercial license may use this file in 00010 // accordance with the commercial license agreement provided with the software. 00011 // 00012 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00013 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00014 // 00015 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Spatial_sorting/include/CGAL/spatial_sort.h $ 00016 // $Id: spatial_sort.h 36875 2007-03-07 11:37:05Z spion $ 00017 // 00018 // Author(s) : Christophe Delage 00019 00020 #ifndef CGAL_SPATIAL_SORT_H 00021 #define CGAL_SPATIAL_SORT_H 00022 00023 #include <CGAL/basic.h> 00024 00025 #include <CGAL/Hilbert_sort_2.h> 00026 #include <CGAL/Hilbert_sort_3.h> 00027 00028 #include <CGAL/Multiscale_sort.h> 00029 00030 CGAL_BEGIN_NAMESPACE 00031 00032 namespace CGALi { 00033 00034 template <class RandomAccessIterator, class Kernel> 00035 void spatial_sort (RandomAccessIterator begin, RandomAccessIterator end, 00036 const Kernel &k, typename Kernel::Point_2 *) 00037 { 00038 typedef Hilbert_sort_2<Kernel> Sort; 00039 (Multiscale_sort<Sort> (Sort (k, 4), 16, 0.25)) (begin, end); 00040 } 00041 00042 template <class RandomAccessIterator, class Kernel> 00043 void spatial_sort (RandomAccessIterator begin, RandomAccessIterator end, 00044 const Kernel &k, typename Kernel::Point_3 *) 00045 { 00046 typedef Hilbert_sort_3<Kernel> Sort; 00047 (Multiscale_sort<Sort> (Sort (k, 8), 64, 0.125)) (begin, end); 00048 } 00049 } 00050 00051 template <class RandomAccessIterator, class Kernel> 00052 void spatial_sort (RandomAccessIterator begin, RandomAccessIterator end, 00053 const Kernel &k) 00054 { 00055 typedef std::iterator_traits<RandomAccessIterator> ITraits; 00056 typedef typename ITraits::value_type value_type; 00057 00058 CGALi::spatial_sort (begin, end, k, static_cast<value_type *> (0)); 00059 } 00060 00061 template <class RandomAccessIterator> 00062 void spatial_sort (RandomAccessIterator begin, RandomAccessIterator end) 00063 { 00064 typedef std::iterator_traits<RandomAccessIterator> ITraits; 00065 typedef typename ITraits::value_type value_type; 00066 typedef CGAL::Kernel_traits<value_type> KTraits; 00067 typedef typename KTraits::Kernel Kernel; 00068 00069 spatial_sort (begin, end, Kernel()); 00070 } 00071 00072 CGAL_END_NAMESPACE 00073 00074 #endif//CGAL_SPATIAL_SORT_H