mirror of https://github.com/CGAL/cgal
Clean whitespace / tabs in Spatial_sorting/include (cosmetic only)
This commit is contained in:
parent
902183b701
commit
5c41b10d2b
|
|
@ -45,7 +45,7 @@ times the original size of the set, Hilbert sort is applied on the
|
|||
second subset.
|
||||
|
||||
*/
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Traits, class PolicyTag>
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Traits, class PolicyTag>
|
||||
void
|
||||
spatial_sort( RandomAccessIterator begin,
|
||||
RandomAccessIterator end,
|
||||
|
|
|
|||
|
|
@ -19,26 +19,26 @@
|
|||
namespace CGAL {
|
||||
|
||||
template <class K, class Hilbert_policy, class ConcurrencyTag = Sequential_tag >
|
||||
class Hilbert_sort_2;
|
||||
class Hilbert_sort_2;
|
||||
|
||||
template <class K, class ConcurrencyTag>
|
||||
class Hilbert_sort_2<K, Hilbert_sort_median_policy, ConcurrencyTag >
|
||||
template <class K, class ConcurrencyTag>
|
||||
class Hilbert_sort_2<K, Hilbert_sort_median_policy, ConcurrencyTag >
|
||||
: public Hilbert_sort_median_2<K, ConcurrencyTag>
|
||||
{
|
||||
public:
|
||||
Hilbert_sort_2 (const K &k=K() , std::ptrdiff_t limit=1 )
|
||||
: Hilbert_sort_median_2<K, ConcurrencyTag> (k,limit)
|
||||
{}
|
||||
public:
|
||||
Hilbert_sort_2 (const K &k=K(), std::ptrdiff_t limit=1 )
|
||||
: Hilbert_sort_median_2<K, ConcurrencyTag> (k,limit)
|
||||
{}
|
||||
};
|
||||
|
||||
template <class K, class ConcurrencyTag>
|
||||
class Hilbert_sort_2<K, Hilbert_sort_middle_policy, ConcurrencyTag >
|
||||
class Hilbert_sort_2<K, Hilbert_sort_middle_policy, ConcurrencyTag >
|
||||
: public Hilbert_sort_middle_2<K>
|
||||
{
|
||||
public:
|
||||
Hilbert_sort_2 (const K &k=K() , std::ptrdiff_t limit=1 )
|
||||
: Hilbert_sort_middle_2<K> (k,limit)
|
||||
{}
|
||||
public:
|
||||
Hilbert_sort_2 (const K &k=K(), std::ptrdiff_t limit=1 )
|
||||
: Hilbert_sort_middle_2<K> (k,limit)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace CGAL
|
||||
|
|
|
|||
|
|
@ -18,27 +18,27 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template <class K, class Hilbert_policy, class ConcurrencyTag = Sequential_tag>
|
||||
class Hilbert_sort_3;
|
||||
template <class K, class Hilbert_policy, class ConcurrencyTag = Sequential_tag>
|
||||
class Hilbert_sort_3;
|
||||
|
||||
template <class K, class ConcurrencyTag>
|
||||
template <class K, class ConcurrencyTag>
|
||||
class Hilbert_sort_3<K, Hilbert_sort_median_policy, ConcurrencyTag >
|
||||
: public Hilbert_sort_median_3<K, ConcurrencyTag>
|
||||
: public Hilbert_sort_median_3<K, ConcurrencyTag>
|
||||
{
|
||||
public:
|
||||
Hilbert_sort_3 (const K &k=K() , std::ptrdiff_t limit=1 )
|
||||
: Hilbert_sort_median_3<K, ConcurrencyTag> (k,limit)
|
||||
{}
|
||||
public:
|
||||
Hilbert_sort_3 (const K &k=K(), std::ptrdiff_t limit=1 )
|
||||
: Hilbert_sort_median_3<K, ConcurrencyTag> (k,limit)
|
||||
{}
|
||||
};
|
||||
|
||||
template <class K, class ConcurrencyTag >
|
||||
class Hilbert_sort_3<K, Hilbert_sort_middle_policy, ConcurrencyTag >
|
||||
template <class K, class ConcurrencyTag >
|
||||
class Hilbert_sort_3<K, Hilbert_sort_middle_policy, ConcurrencyTag >
|
||||
: public Hilbert_sort_middle_3<K>
|
||||
{
|
||||
public:
|
||||
Hilbert_sort_3 (const K &k=K() , std::ptrdiff_t limit=1 )
|
||||
: Hilbert_sort_middle_3<K> (k,limit)
|
||||
{}
|
||||
public:
|
||||
Hilbert_sort_3 (const K &k=K(), std::ptrdiff_t limit=1 )
|
||||
: Hilbert_sort_middle_3<K> (k,limit)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace CGAL
|
||||
|
|
|
|||
|
|
@ -21,25 +21,27 @@ namespace CGAL {
|
|||
|
||||
namespace internal {
|
||||
|
||||
template <class RandomAccessIterator, class Cmp>
|
||||
RandomAccessIterator
|
||||
hilbert_split (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
Cmp cmp = Cmp ())
|
||||
{
|
||||
if (begin >= end) return begin;
|
||||
#if defined(CGAL_HILBERT_SORT_WITH_MEDIAN_POLICY_CROSS_PLATFORM_BEHAVIOR)
|
||||
RandomAccessIterator middle = begin + (end - begin) / 2;
|
||||
CGAL::nth_element (begin, middle, end, cmp);
|
||||
return middle;
|
||||
#else
|
||||
RandomAccessIterator middle = begin + (end - begin) / 2;
|
||||
std::nth_element (begin, middle, end, cmp);
|
||||
return middle;
|
||||
#endif
|
||||
|
||||
}
|
||||
template <class RandomAccessIterator, class Cmp>
|
||||
RandomAccessIterator
|
||||
hilbert_split (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
Cmp cmp = Cmp ())
|
||||
{
|
||||
if (begin >= end)
|
||||
return begin;
|
||||
|
||||
#if defined(CGAL_HILBERT_SORT_WITH_MEDIAN_POLICY_CROSS_PLATFORM_BEHAVIOR)
|
||||
RandomAccessIterator middle = begin + (end - begin) / 2;
|
||||
CGAL::nth_element (begin, middle, end, cmp);
|
||||
return middle;
|
||||
#else
|
||||
RandomAccessIterator middle = begin + (end - begin) / 2;
|
||||
std::nth_element (begin, middle, end, cmp);
|
||||
return middle;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif//CGAL_HILBERT_SORT_BASE_H
|
||||
|
|
|
|||
|
|
@ -19,26 +19,26 @@
|
|||
namespace CGAL {
|
||||
|
||||
template <class K, class Hilbert_policy >
|
||||
class Hilbert_sort_d;
|
||||
class Hilbert_sort_d;
|
||||
|
||||
template <class K>
|
||||
class Hilbert_sort_d<K, Hilbert_sort_median_policy >
|
||||
: public Hilbert_sort_median_d<K>
|
||||
class Hilbert_sort_d<K, Hilbert_sort_median_policy >
|
||||
: public Hilbert_sort_median_d<K>
|
||||
{
|
||||
public:
|
||||
Hilbert_sort_d (const K &k=K() , std::ptrdiff_t limit=1 )
|
||||
: Hilbert_sort_median_d<K> (k,limit)
|
||||
{}
|
||||
public:
|
||||
Hilbert_sort_d (const K &k=K() , std::ptrdiff_t limit=1 )
|
||||
: Hilbert_sort_median_d<K> (k,limit)
|
||||
{}
|
||||
};
|
||||
|
||||
template <class K>
|
||||
class Hilbert_sort_d<K, Hilbert_sort_middle_policy >
|
||||
: public Hilbert_sort_middle_d<K>
|
||||
class Hilbert_sort_d<K, Hilbert_sort_middle_policy >
|
||||
: public Hilbert_sort_middle_d<K>
|
||||
{
|
||||
public:
|
||||
Hilbert_sort_d (const K &k=K() , std::ptrdiff_t limit=1 )
|
||||
: Hilbert_sort_middle_d<K> (k,limit)
|
||||
{}
|
||||
public:
|
||||
Hilbert_sort_d (const K &k=K() , std::ptrdiff_t limit=1 )
|
||||
: Hilbert_sort_middle_d<K> (k,limit)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace CGAL
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
#include <CGAL/config.h>
|
||||
#include <CGAL/tags.h>
|
||||
#include <functional>
|
||||
#include <cstddef>
|
||||
#include <CGAL/Hilbert_sort_base.h>
|
||||
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
|
@ -24,124 +22,132 @@
|
|||
#include <tbb/parallel_invoke.h>
|
||||
#endif
|
||||
|
||||
#include <functional>
|
||||
#include <cstddef>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
namespace internal {
|
||||
template <class K, int x, bool up> struct Hilbert_cmp_2;
|
||||
|
||||
template <class K, int x>
|
||||
struct Hilbert_cmp_2<K,x,true>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_2,
|
||||
typename K::Point_2, bool>
|
||||
{
|
||||
typedef typename K::Point_2 Point;
|
||||
K k;
|
||||
Hilbert_cmp_2 (const K &_k = K()) : k(_k) {}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return Hilbert_cmp_2<K,x,false> (k) (q, p);
|
||||
}
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct Hilbert_cmp_2<K,0,false>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_2,
|
||||
typename K::Point_2, bool>
|
||||
{
|
||||
typedef typename K::Point_2 Point;
|
||||
K k;
|
||||
Hilbert_cmp_2 (const K &_k = K()) : k(_k) {}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return k.less_x_2_object() (p, q);
|
||||
}
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct Hilbert_cmp_2<K,1,false>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_2,
|
||||
typename K::Point_2, bool>
|
||||
{
|
||||
typedef typename K::Point_2 Point;
|
||||
K k;
|
||||
Hilbert_cmp_2 (const K &_k = K()) : k(_k) {}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return k.less_y_2_object() (p, q);
|
||||
}
|
||||
};
|
||||
}
|
||||
template <class K, int x, bool up> struct Hilbert_cmp_2;
|
||||
|
||||
template <class K, int x>
|
||||
struct Hilbert_cmp_2<K,x,true>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_2, typename K::Point_2, bool>
|
||||
{
|
||||
typedef typename K::Point_2 Point;
|
||||
K k;
|
||||
Hilbert_cmp_2 (const K &_k = K()) : k(_k) {}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return Hilbert_cmp_2<K,x,false> (k) (q, p);
|
||||
}
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct Hilbert_cmp_2<K,0,false>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_2, typename K::Point_2, bool>
|
||||
{
|
||||
typedef typename K::Point_2 Point;
|
||||
K k;
|
||||
Hilbert_cmp_2 (const K &_k = K()) : k(_k) {}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return k.less_x_2_object() (p, q);
|
||||
}
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct Hilbert_cmp_2<K,1,false>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_2, typename K::Point_2, bool>
|
||||
{
|
||||
typedef typename K::Point_2 Point;
|
||||
K k;
|
||||
Hilbert_cmp_2 (const K &_k = K()) : k(_k) {}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return k.less_y_2_object() (p, q);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template <class K, class ConcurrencyTag>
|
||||
class Hilbert_sort_median_2
|
||||
{
|
||||
public:
|
||||
typedef Hilbert_sort_median_2<K, ConcurrencyTag> Self;
|
||||
typedef K Kernel;
|
||||
typedef typename Kernel::Point_2 Point;
|
||||
|
||||
private:
|
||||
Kernel _k;
|
||||
std::ptrdiff_t _limit;
|
||||
typedef K Kernel;
|
||||
typedef typename Kernel::Point_2 Point;
|
||||
|
||||
template <int x, bool up> struct Cmp : public internal::Hilbert_cmp_2<Kernel,x,up>
|
||||
{ Cmp (const Kernel &k) : internal::Hilbert_cmp_2<Kernel,x,up> (k) {} };
|
||||
private:
|
||||
Kernel _k;
|
||||
std::ptrdiff_t _limit;
|
||||
|
||||
template <int x, bool up>
|
||||
struct Cmp
|
||||
: public internal::Hilbert_cmp_2<Kernel,x,up>
|
||||
{
|
||||
Cmp (const Kernel &k) : internal::Hilbert_cmp_2<Kernel,x,up> (k) {}
|
||||
};
|
||||
|
||||
public:
|
||||
Hilbert_sort_median_2 (const Kernel &k = Kernel(), std::ptrdiff_t limit = 1)
|
||||
: _k(k), _limit (limit)
|
||||
{}
|
||||
|
||||
template <int x, bool upx, bool upy, class RandomAccessIterator>
|
||||
void recursive_sort (RandomAccessIterator begin, RandomAccessIterator end) const
|
||||
{
|
||||
const int y = (x + 1) % 2;
|
||||
if (end - begin <= _limit) return;
|
||||
|
||||
RandomAccessIterator m0 = begin, m4 = end;
|
||||
|
||||
RandomAccessIterator m2 = internal::hilbert_split (m0, m4, Cmp< x, upx> (_k));
|
||||
RandomAccessIterator m1 = internal::hilbert_split (m0, m2, Cmp< y, upy> (_k));
|
||||
RandomAccessIterator m3 = internal::hilbert_split (m2, m4, Cmp< y, !upy> (_k));
|
||||
|
||||
recursive_sort<y, upy, upx> (m0, m1);
|
||||
recursive_sort<x, upx, upy> (m1, m2);
|
||||
recursive_sort<x, upx, upy> (m2, m3);
|
||||
recursive_sort<y,!upy,!upx> (m3, m4);
|
||||
}
|
||||
Hilbert_sort_median_2 (const Kernel &k = Kernel(), std::ptrdiff_t limit = 1)
|
||||
: _k(k), _limit (limit)
|
||||
{}
|
||||
|
||||
template <int x, bool upx, bool upy, class RandomAccessIterator>
|
||||
struct Recursive_sort {
|
||||
void recursive_sort (RandomAccessIterator begin, RandomAccessIterator end) const
|
||||
{
|
||||
const int y = (x + 1) % 2;
|
||||
if (end - begin <= _limit)
|
||||
return;
|
||||
|
||||
RandomAccessIterator m0 = begin, m4 = end;
|
||||
|
||||
RandomAccessIterator m2 = internal::hilbert_split (m0, m4, Cmp< x, upx> (_k));
|
||||
RandomAccessIterator m1 = internal::hilbert_split (m0, m2, Cmp< y, upy> (_k));
|
||||
RandomAccessIterator m3 = internal::hilbert_split (m2, m4, Cmp< y, !upy> (_k));
|
||||
|
||||
recursive_sort<y, upy, upx> (m0, m1);
|
||||
recursive_sort<x, upx, upy> (m1, m2);
|
||||
recursive_sort<x, upx, upy> (m2, m3);
|
||||
recursive_sort<y,!upy,!upx> (m3, m4);
|
||||
}
|
||||
|
||||
template <int x, bool upx, bool upy, class RandomAccessIterator>
|
||||
struct Recursive_sort
|
||||
{
|
||||
const Self& hs;
|
||||
RandomAccessIterator begin,end;
|
||||
|
||||
|
||||
Recursive_sort(const Self& hs, RandomAccessIterator begin, RandomAccessIterator end)
|
||||
: hs(hs), begin(begin), end(end)
|
||||
{}
|
||||
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
hs.recursive_sort<x,upx,upy>(begin,end);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class RandomAccessIterator, class Comp>
|
||||
struct Hilbert_split
|
||||
{
|
||||
RandomAccessIterator& res;
|
||||
RandomAccessIterator begin, end;
|
||||
const Comp& comp;
|
||||
|
||||
|
||||
Hilbert_split(RandomAccessIterator& res, RandomAccessIterator begin, RandomAccessIterator end, const Comp comp)
|
||||
: res(res), begin(begin), end(end), comp(comp)
|
||||
{}
|
||||
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
res = internal::hilbert_split(begin, end, comp);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <int x, bool upx, bool upy, class RandomAccessIterator>
|
||||
void sort (RandomAccessIterator begin, RandomAccessIterator end, Parallel_tag) const
|
||||
{
|
||||
|
|
@ -150,19 +156,20 @@ public:
|
|||
CGAL_USE(end);
|
||||
CGAL_static_assertion_msg (!(boost::is_convertible<ConcurrencyTag, Parallel_tag>::value),
|
||||
"Parallel_tag is enabled but TBB is unavailable.");
|
||||
#else
|
||||
#else
|
||||
const int y = (x + 1) % 2;
|
||||
if (end - begin <= _limit) return;
|
||||
|
||||
if (end - begin <= _limit)
|
||||
return;
|
||||
|
||||
RandomAccessIterator m0 = begin, m4 = end;
|
||||
|
||||
|
||||
if((end - begin) > 1024){
|
||||
RandomAccessIterator m1, m2, m3;
|
||||
m2 = internal::hilbert_split (m0, m4, Cmp< x, upx> (_k));
|
||||
|
||||
|
||||
tbb::parallel_invoke(Hilbert_split<RandomAccessIterator, Cmp< y, upy> > (m1, m0, m2, Cmp< y, upy> (_k)),
|
||||
Hilbert_split<RandomAccessIterator, Cmp< y, !upy> > (m3, m2, m4, Cmp< y, !upy> (_k)));
|
||||
|
||||
|
||||
tbb::parallel_invoke(Recursive_sort<y, upy, upx, RandomAccessIterator> (*this, m0, m1),
|
||||
Recursive_sort<x, upx, upy, RandomAccessIterator> (*this, m1, m2),
|
||||
Recursive_sort<x, upx, upy, RandomAccessIterator> (*this, m2, m3),
|
||||
|
|
@ -175,10 +182,10 @@ public:
|
|||
|
||||
template <int x, bool upx, bool upy, class RandomAccessIterator>
|
||||
void sort (RandomAccessIterator begin, RandomAccessIterator end, Sequential_tag) const
|
||||
{
|
||||
{
|
||||
recursive_sort<0, false, false>(begin, end);
|
||||
}
|
||||
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void operator() (RandomAccessIterator begin, RandomAccessIterator end) const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,156 +27,154 @@
|
|||
namespace CGAL {
|
||||
|
||||
namespace internal {
|
||||
template <class K, int x, bool up> struct Hilbert_cmp_3;
|
||||
template <class K, int x, bool up> struct Hilbert_cmp_3;
|
||||
|
||||
template <class K, int x>
|
||||
struct Hilbert_cmp_3<K,x,true>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_3,
|
||||
typename K::Point_3, bool>
|
||||
{
|
||||
typedef typename K::Point_3 Point;
|
||||
K k;
|
||||
Hilbert_cmp_3 (const K &_k = K()) : k(_k) {}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return Hilbert_cmp_3<K,x,false> (k) (q, p);
|
||||
}
|
||||
};
|
||||
template <class K, int x>
|
||||
struct Hilbert_cmp_3<K,x,true>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_3, typename K::Point_3, bool>
|
||||
{
|
||||
typedef typename K::Point_3 Point;
|
||||
K k;
|
||||
Hilbert_cmp_3 (const K &_k = K()) : k(_k) {}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return Hilbert_cmp_3<K,x,false> (k) (q, p);
|
||||
}
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct Hilbert_cmp_3<K,0,false>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_3,
|
||||
typename K::Point_3, bool>
|
||||
{
|
||||
typedef typename K::Point_3 Point;
|
||||
K k;
|
||||
Hilbert_cmp_3 (const K &_k = K()) : k(_k) {}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return k.less_x_3_object() (p, q);
|
||||
}
|
||||
};
|
||||
template <class K>
|
||||
struct Hilbert_cmp_3<K,0,false>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_3, typename K::Point_3, bool>
|
||||
{
|
||||
typedef typename K::Point_3 Point;
|
||||
K k;
|
||||
Hilbert_cmp_3 (const K &_k = K()) : k(_k) {}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return k.less_x_3_object() (p, q);
|
||||
}
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct Hilbert_cmp_3<K,1,false>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_3,
|
||||
typename K::Point_3, bool>
|
||||
{
|
||||
typedef typename K::Point_3 Point;
|
||||
K k;
|
||||
Hilbert_cmp_3 (const K &_k = K()) : k(_k) {}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return k.less_y_3_object() (p, q);
|
||||
}
|
||||
};
|
||||
template <class K>
|
||||
struct Hilbert_cmp_3<K,1,false>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_3, typename K::Point_3, bool>
|
||||
{
|
||||
typedef typename K::Point_3 Point;
|
||||
K k;
|
||||
Hilbert_cmp_3 (const K &_k = K()) : k(_k) {}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return k.less_y_3_object() (p, q);
|
||||
}
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct Hilbert_cmp_3<K,2,false>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_3,
|
||||
typename K::Point_3, bool>
|
||||
{
|
||||
typedef typename K::Point_3 Point;
|
||||
K k;
|
||||
Hilbert_cmp_3 (const K &_k = K()) : k(_k) {}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return k.less_z_3_object() (p, q);
|
||||
}
|
||||
};
|
||||
}
|
||||
template <class K>
|
||||
struct Hilbert_cmp_3<K,2,false>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_3, typename K::Point_3, bool>
|
||||
{
|
||||
typedef typename K::Point_3 Point;
|
||||
K k;
|
||||
Hilbert_cmp_3 (const K &_k = K()) : k(_k) {}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return k.less_z_3_object() (p, q);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template <class K, class ConcurrencyTag>
|
||||
class Hilbert_sort_median_3
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Hilbert_sort_median_3<K, ConcurrencyTag> Self;
|
||||
typedef K Kernel;
|
||||
typedef typename Kernel::Point_3 Point;
|
||||
typedef K Kernel;
|
||||
typedef typename Kernel::Point_3 Point;
|
||||
|
||||
private:
|
||||
Kernel _k;
|
||||
std::ptrdiff_t _limit;
|
||||
Kernel _k;
|
||||
std::ptrdiff_t _limit;
|
||||
|
||||
template <int x, bool up> struct Cmp : public internal::Hilbert_cmp_3<Kernel,x,up>
|
||||
{ Cmp (const Kernel &k) : internal::Hilbert_cmp_3<Kernel,x,up> (k) {} };
|
||||
template <int x, bool up>
|
||||
struct Cmp
|
||||
: public internal::Hilbert_cmp_3<Kernel,x,up>
|
||||
{
|
||||
Cmp (const Kernel &k) : internal::Hilbert_cmp_3<Kernel,x,up> (k) {}
|
||||
};
|
||||
|
||||
public:
|
||||
Hilbert_sort_median_3 (const Kernel &k = Kernel(), std::ptrdiff_t limit = 1)
|
||||
: _k(k), _limit (limit)
|
||||
{}
|
||||
|
||||
|
||||
template <int x, bool upx, bool upy, bool upz, class RandomAccessIterator>
|
||||
void recursive_sort (RandomAccessIterator begin, RandomAccessIterator end) const
|
||||
{
|
||||
const int y = (x + 1) % 3, z = (x + 2) % 3;
|
||||
if (end - begin <= _limit) return;
|
||||
|
||||
RandomAccessIterator m0 = begin, m8 = end;
|
||||
|
||||
RandomAccessIterator m4 = internal::hilbert_split (m0, m8, Cmp< x, upx> (_k));
|
||||
RandomAccessIterator m2 = internal::hilbert_split (m0, m4, Cmp< y, upy> (_k));
|
||||
RandomAccessIterator m1 = internal::hilbert_split (m0, m2, Cmp< z, upz> (_k));
|
||||
RandomAccessIterator m3 = internal::hilbert_split (m2, m4, Cmp< z, !upz> (_k));
|
||||
RandomAccessIterator m6 = internal::hilbert_split (m4, m8, Cmp< y, !upy> (_k));
|
||||
RandomAccessIterator m5 = internal::hilbert_split (m4, m6, Cmp< z, upz> (_k));
|
||||
RandomAccessIterator m7 = internal::hilbert_split (m6, m8, Cmp< z, !upz> (_k));
|
||||
|
||||
recursive_sort<z, upz, upx, upy> (m0, m1);
|
||||
recursive_sort<y, upy, upz, upx> (m1, m2);
|
||||
recursive_sort<y, upy, upz, upx> (m2, m3);
|
||||
recursive_sort<x, upx,!upy,!upz> (m3, m4);
|
||||
recursive_sort<x, upx,!upy,!upz> (m4, m5);
|
||||
recursive_sort<y,!upy, upz,!upx> (m5, m6);
|
||||
recursive_sort<y,!upy, upz,!upx> (m6, m7);
|
||||
recursive_sort<z,!upz,!upx, upy> (m7, m8);
|
||||
}
|
||||
Hilbert_sort_median_3 (const Kernel &k = Kernel(), std::ptrdiff_t limit = 1)
|
||||
: _k(k), _limit (limit)
|
||||
{}
|
||||
|
||||
template <int x, bool upx, bool upy, bool upz, class RandomAccessIterator>
|
||||
struct Recursive_sort {
|
||||
void recursive_sort (RandomAccessIterator begin, RandomAccessIterator end) const
|
||||
{
|
||||
const int y = (x + 1) % 3, z = (x + 2) % 3;
|
||||
if (end - begin <= _limit) return;
|
||||
|
||||
RandomAccessIterator m0 = begin, m8 = end;
|
||||
|
||||
RandomAccessIterator m4 = internal::hilbert_split (m0, m8, Cmp< x, upx> (_k));
|
||||
RandomAccessIterator m2 = internal::hilbert_split (m0, m4, Cmp< y, upy> (_k));
|
||||
RandomAccessIterator m1 = internal::hilbert_split (m0, m2, Cmp< z, upz> (_k));
|
||||
RandomAccessIterator m3 = internal::hilbert_split (m2, m4, Cmp< z, !upz> (_k));
|
||||
RandomAccessIterator m6 = internal::hilbert_split (m4, m8, Cmp< y, !upy> (_k));
|
||||
RandomAccessIterator m5 = internal::hilbert_split (m4, m6, Cmp< z, upz> (_k));
|
||||
RandomAccessIterator m7 = internal::hilbert_split (m6, m8, Cmp< z, !upz> (_k));
|
||||
|
||||
recursive_sort<z, upz, upx, upy> (m0, m1);
|
||||
recursive_sort<y, upy, upz, upx> (m1, m2);
|
||||
recursive_sort<y, upy, upz, upx> (m2, m3);
|
||||
recursive_sort<x, upx,!upy,!upz> (m3, m4);
|
||||
recursive_sort<x, upx,!upy,!upz> (m4, m5);
|
||||
recursive_sort<y,!upy, upz,!upx> (m5, m6);
|
||||
recursive_sort<y,!upy, upz,!upx> (m6, m7);
|
||||
recursive_sort<z,!upz,!upx, upy> (m7, m8);
|
||||
}
|
||||
|
||||
template <int x, bool upx, bool upy, bool upz, class RandomAccessIterator>
|
||||
struct Recursive_sort
|
||||
{
|
||||
const Self& hs;
|
||||
RandomAccessIterator begin,end;
|
||||
|
||||
|
||||
Recursive_sort(const Self& hs, RandomAccessIterator begin, RandomAccessIterator end)
|
||||
: hs(hs), begin(begin), end(end)
|
||||
{}
|
||||
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
hs.recursive_sort<x,upx,upy,upz>(begin,end);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class RandomAccessIterator, class Comp>
|
||||
struct Hilbert_split
|
||||
{
|
||||
RandomAccessIterator& res;
|
||||
RandomAccessIterator begin, end;
|
||||
const Comp& comp;
|
||||
|
||||
|
||||
Hilbert_split(RandomAccessIterator& res, RandomAccessIterator begin, RandomAccessIterator end, const Comp comp)
|
||||
: res(res), begin(begin), end(end), comp(comp)
|
||||
{}
|
||||
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
res = internal::hilbert_split(begin, end, comp);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <int x, bool upx, bool upy, bool upz, class RandomAccessIterator>
|
||||
void sort (RandomAccessIterator begin, RandomAccessIterator end, Parallel_tag) const
|
||||
{
|
||||
#ifndef CGAL_LINKED_WITH_TBB
|
||||
|
||||
CGAL_USE(begin);
|
||||
CGAL_USE(end);
|
||||
CGAL_static_assertion_msg (!(boost::is_convertible<ConcurrencyTag, Parallel_tag>::value),
|
||||
"Parallel_tag is enabled but TBB is unavailable.");
|
||||
#else
|
||||
#else
|
||||
const int y = (x + 1) % 3, z = (x + 2) % 3;
|
||||
if ((end - begin) <= _limit) return;
|
||||
|
||||
|
|
@ -184,42 +182,41 @@ public:
|
|||
if((end - begin) > 1024){
|
||||
RandomAccessIterator m1, m2, m3, m4, m5, m6, m7;
|
||||
m4 = internal::hilbert_split(m0, m8, Cmp<x, upx>(_k));
|
||||
|
||||
tbb::parallel_invoke(Hilbert_split<RandomAccessIterator,Cmp<y, upy> >(m2,m0,m4,Cmp<y, upy>(_k)),
|
||||
Hilbert_split<RandomAccessIterator,Cmp<y, !upy> >(m6,m4,m8,Cmp<y, !upy>(_k)));
|
||||
|
||||
|
||||
tbb::parallel_invoke(Hilbert_split<RandomAccessIterator,Cmp<z, upz> >(m1,m0,m2,Cmp<z, upz>(_k)),
|
||||
Hilbert_split<RandomAccessIterator,Cmp<z, !upz> >(m3,m2,m4,Cmp<z, !upz>(_k)),
|
||||
Hilbert_split<RandomAccessIterator,Cmp<z, upz> >(m5,m4,m6,Cmp<z, upz>(_k)),
|
||||
Hilbert_split<RandomAccessIterator,Cmp<z, !upz> >(m7,m6,m8,Cmp<z, !upz>(_k)));
|
||||
|
||||
tbb::parallel_invoke(Recursive_sort<z, upz, upx, upy, RandomAccessIterator>(*this, m0, m1),
|
||||
Recursive_sort<y, upy, upz, upx, RandomAccessIterator>(*this, m1, m2),
|
||||
Recursive_sort<y, upy, upz, upx, RandomAccessIterator>(*this, m2, m3),
|
||||
Recursive_sort<x, upx, !upy, !upz, RandomAccessIterator>(*this, m3, m4),
|
||||
Recursive_sort<x, upx, !upy, !upz, RandomAccessIterator>(*this, m4, m5),
|
||||
Recursive_sort<y, !upy, upz, !upx, RandomAccessIterator>(*this, m5, m6),
|
||||
Recursive_sort<y, !upy, upz, !upx, RandomAccessIterator>(*this, m6, m7),
|
||||
Recursive_sort<z, !upz, !upx, upy, RandomAccessIterator>(*this, m7, m8));
|
||||
tbb::parallel_invoke(Hilbert_split<RandomAccessIterator,Cmp<y, upy> >(m2, m0, m4, Cmp<y, upy>(_k)),
|
||||
Hilbert_split<RandomAccessIterator,Cmp<y, !upy> >(m6, m4, m8, Cmp<y, !upy>(_k)));
|
||||
|
||||
|
||||
tbb::parallel_invoke(Hilbert_split<RandomAccessIterator,Cmp<z, upz> >(m1, m0, m2, Cmp<z, upz>(_k)),
|
||||
Hilbert_split<RandomAccessIterator,Cmp<z, !upz> >(m3, m2, m4, Cmp<z, !upz>(_k)),
|
||||
Hilbert_split<RandomAccessIterator,Cmp<z, upz> >(m5, m4, m6, Cmp<z, upz>(_k)),
|
||||
Hilbert_split<RandomAccessIterator,Cmp<z, !upz> >(m7, m6, m8, Cmp<z, !upz>(_k)));
|
||||
|
||||
tbb::parallel_invoke(Recursive_sort<z, upz, upx, upy, RandomAccessIterator>(*this, m0, m1),
|
||||
Recursive_sort<y, upy, upz, upx, RandomAccessIterator>(*this, m1, m2),
|
||||
Recursive_sort<y, upy, upz, upx, RandomAccessIterator>(*this, m2, m3),
|
||||
Recursive_sort<x, upx, !upy, !upz, RandomAccessIterator>(*this, m3, m4),
|
||||
Recursive_sort<x, upx, !upy, !upz, RandomAccessIterator>(*this, m4, m5),
|
||||
Recursive_sort<y, !upy, upz, !upx, RandomAccessIterator>(*this, m5, m6),
|
||||
Recursive_sort<y, !upy, upz, !upx, RandomAccessIterator>(*this, m6, m7),
|
||||
Recursive_sort<z, !upz, !upx, upy, RandomAccessIterator>(*this, m7, m8));
|
||||
} else {
|
||||
recursive_sort<0, false, false, false>(begin, end);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template <int x, bool upx, bool upy, bool upz, class RandomAccessIterator>
|
||||
void sort (RandomAccessIterator begin, RandomAccessIterator end, Sequential_tag) const
|
||||
{
|
||||
recursive_sort<0, false, false, false>(begin, end);
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void operator() (RandomAccessIterator begin, RandomAccessIterator end) const
|
||||
{
|
||||
sort <0, false, false, false> (begin, end, ConcurrencyTag());
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void operator() (RandomAccessIterator begin, RandomAccessIterator end) const
|
||||
{
|
||||
sort <0, false, false, false> (begin, end, ConcurrencyTag());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace CGAL
|
||||
|
|
|
|||
|
|
@ -23,138 +23,139 @@ namespace CGAL {
|
|||
|
||||
namespace internal {
|
||||
|
||||
template <class K>
|
||||
struct Hilbert_cmp_d
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_d,
|
||||
typename K::Point_d, bool>
|
||||
{
|
||||
typedef typename K::Point_d Point;
|
||||
K k;
|
||||
int axe;
|
||||
bool orient;
|
||||
Hilbert_cmp_d (int a, bool o, const K &_k = K())
|
||||
: k(_k), axe(a), orient(o) {}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return (orient ? (k.less_coordinate_d_object() (q,p,axe) )
|
||||
: (k.less_coordinate_d_object() (p,q,axe) ));
|
||||
}
|
||||
};
|
||||
template <class K>
|
||||
struct Hilbert_cmp_d
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_d,
|
||||
typename K::Point_d, bool>
|
||||
{
|
||||
typedef typename K::Point_d Point;
|
||||
K k;
|
||||
int axe;
|
||||
bool orient;
|
||||
Hilbert_cmp_d (int a, bool o, const K &_k = K()) : k(_k), axe(a), orient(o) {}
|
||||
|
||||
}
|
||||
bool operator() (const Point &p, const Point &q) const
|
||||
{
|
||||
return (orient ? (k.less_coordinate_d_object() (q,p,axe) )
|
||||
: (k.less_coordinate_d_object() (p,q,axe) ));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template <class K>
|
||||
class Hilbert_sort_median_d
|
||||
{
|
||||
public:
|
||||
typedef K Kernel;
|
||||
typedef typename Kernel::Point_d Point;
|
||||
typedef std::vector< bool > Starting_position;
|
||||
typedef K Kernel;
|
||||
typedef typename Kernel::Point_d Point;
|
||||
typedef std::vector< bool > Starting_position;
|
||||
|
||||
private:
|
||||
Kernel _k;
|
||||
std::ptrdiff_t _limit;
|
||||
mutable int _dimension;
|
||||
mutable int two_to_dim;
|
||||
Kernel _k;
|
||||
std::ptrdiff_t _limit;
|
||||
mutable int _dimension;
|
||||
mutable int two_to_dim;
|
||||
|
||||
struct Cmp : public internal::Hilbert_cmp_d<Kernel>
|
||||
{ Cmp (int a, bool dir, const Kernel &k)
|
||||
: internal::Hilbert_cmp_d<Kernel> (a,dir,k) {} };
|
||||
struct Cmp
|
||||
: public internal::Hilbert_cmp_d<Kernel>
|
||||
{
|
||||
Cmp (int a, bool dir, const Kernel &k) : internal::Hilbert_cmp_d<Kernel> (a,dir,k) {}
|
||||
};
|
||||
|
||||
public:
|
||||
Hilbert_sort_median_d(const Kernel &k = Kernel(), std::ptrdiff_t limit = 1)
|
||||
: _k(k), _limit (limit)
|
||||
{}
|
||||
Hilbert_sort_median_d(const Kernel &k = Kernel(), std::ptrdiff_t limit = 1)
|
||||
: _k(k), _limit (limit)
|
||||
{}
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
Starting_position start, int direction) const
|
||||
{
|
||||
if (end - begin <= _limit) return;
|
||||
template <class RandomAccessIterator>
|
||||
void sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
Starting_position start, int direction) const
|
||||
{
|
||||
if (end - begin <= _limit)
|
||||
return;
|
||||
|
||||
int nb_directions = _dimension;
|
||||
int nb_splits = two_to_dim;
|
||||
int nb_directions = _dimension;
|
||||
int nb_splits = two_to_dim;
|
||||
|
||||
if ( (end-begin) < (two_to_dim/2) ) { // not many points
|
||||
nb_splits = 1;
|
||||
nb_directions = 0;
|
||||
while ( (end-begin) > nb_splits) {
|
||||
++nb_directions;
|
||||
nb_splits *= 2; // compute 2^nb_directions
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<RandomAccessIterator> places(nb_splits +1);
|
||||
std::vector<int> dir (nb_splits +1);
|
||||
places[0]=begin;
|
||||
places[nb_splits]=end;
|
||||
|
||||
int last_dir = (direction + nb_directions) % _dimension;
|
||||
int current_dir = direction;
|
||||
int current_level_step =nb_splits;
|
||||
do{
|
||||
int half_step = current_level_step/2;
|
||||
int left=0;
|
||||
int middle = half_step;
|
||||
int right=current_level_step;
|
||||
bool orient = start[current_dir];
|
||||
do{
|
||||
dir[middle] = current_dir;
|
||||
places[middle] = internal::hilbert_split
|
||||
(places[left], places[right], Cmp (current_dir,orient,_k));
|
||||
left =right;
|
||||
right+=current_level_step;
|
||||
middle+=current_level_step;
|
||||
orient = ! orient;
|
||||
}while( left< nb_splits);
|
||||
current_level_step = half_step;
|
||||
current_dir = (current_dir +1) % _dimension;
|
||||
}while (current_dir != last_dir);
|
||||
|
||||
if ( end-begin < two_to_dim) return; // less than 2^dim points
|
||||
|
||||
/////////////start recursive calls
|
||||
last_dir = (direction + _dimension -1) % _dimension;
|
||||
// first step is special
|
||||
sort( places[0], places[1], start, last_dir);
|
||||
|
||||
for(int i=1; i<two_to_dim-1; i +=2){
|
||||
sort( places[i ], places[i+1], start, dir[i+1]);
|
||||
sort( places[i+1], places[i+2], start, dir[i+1]);
|
||||
start[dir[i+1]] = ! start[dir[i+1]];
|
||||
start[last_dir] = ! start[last_dir];
|
||||
}
|
||||
|
||||
//last step is special
|
||||
sort( places[two_to_dim-1], places[two_to_dim], start, last_dir);
|
||||
}
|
||||
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void operator() (RandomAccessIterator begin, RandomAccessIterator end) const
|
||||
{
|
||||
_dimension = _k.point_dimension_d_object()(*begin);
|
||||
two_to_dim = 1;
|
||||
Starting_position start(_dimension);
|
||||
|
||||
typename std::iterator_traits<RandomAccessIterator>::difference_type N=end-begin;
|
||||
N*=2;
|
||||
for (int i=0; i<_dimension; ++i) start[i]=false; // we start below in all coordinates
|
||||
for (int i=0; i<_dimension; ++i) {
|
||||
two_to_dim *= 2; // compute 2^_dimension
|
||||
N/=2;
|
||||
if (N==0) break; // not many points, this number of dimension is enough
|
||||
if ( (end-begin) < (two_to_dim/2) ) { // not many points
|
||||
nb_splits = 1;
|
||||
nb_directions = 0;
|
||||
while ( (end-begin) > nb_splits) {
|
||||
++nb_directions;
|
||||
nb_splits *= 2; // compute 2^nb_directions
|
||||
}
|
||||
|
||||
|
||||
// we start with direction 0;
|
||||
sort (begin, end, start, 0);
|
||||
}
|
||||
|
||||
std::vector<RandomAccessIterator> places(nb_splits +1);
|
||||
std::vector<int> dir (nb_splits +1);
|
||||
places[0]=begin;
|
||||
places[nb_splits]=end;
|
||||
|
||||
int last_dir = (direction + nb_directions) % _dimension;
|
||||
int current_dir = direction;
|
||||
int current_level_step =nb_splits;
|
||||
do{
|
||||
int half_step = current_level_step/2;
|
||||
int left=0;
|
||||
int middle = half_step;
|
||||
int right=current_level_step;
|
||||
bool orient = start[current_dir];
|
||||
do{
|
||||
dir[middle] = current_dir;
|
||||
places[middle] = internal::hilbert_split
|
||||
(places[left], places[right], Cmp (current_dir,orient,_k));
|
||||
left =right;
|
||||
right+=current_level_step;
|
||||
middle+=current_level_step;
|
||||
orient = ! orient;
|
||||
}while( left< nb_splits);
|
||||
current_level_step = half_step;
|
||||
current_dir = (current_dir +1) % _dimension;
|
||||
}while (current_dir != last_dir);
|
||||
|
||||
if ( end-begin < two_to_dim) return; // less than 2^dim points
|
||||
|
||||
/////////////start recursive calls
|
||||
last_dir = (direction + _dimension -1) % _dimension;
|
||||
// first step is special
|
||||
sort( places[0], places[1], start, last_dir);
|
||||
|
||||
for(int i=1; i<two_to_dim-1; i +=2){
|
||||
sort( places[i ], places[i+1], start, dir[i+1]);
|
||||
sort( places[i+1], places[i+2], start, dir[i+1]);
|
||||
start[dir[i+1]] = ! start[dir[i+1]];
|
||||
start[last_dir] = ! start[last_dir];
|
||||
}
|
||||
|
||||
//last step is special
|
||||
sort( places[two_to_dim-1], places[two_to_dim], start, last_dir);
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void operator() (RandomAccessIterator begin, RandomAccessIterator end) const
|
||||
{
|
||||
_dimension = _k.point_dimension_d_object()(*begin);
|
||||
two_to_dim = 1;
|
||||
Starting_position start(_dimension);
|
||||
|
||||
typename std::iterator_traits<RandomAccessIterator>::difference_type N=end-begin;
|
||||
N*=2;
|
||||
for (int i=0; i<_dimension; ++i)
|
||||
start[i]=false; // we start below in all coordinates
|
||||
|
||||
for (int i=0; i<_dimension; ++i) {
|
||||
two_to_dim *= 2; // compute 2^_dimension
|
||||
N/=2;
|
||||
if (N==0)
|
||||
break; // not many points, this number of dimension is enough
|
||||
}
|
||||
|
||||
// we start with direction 0;
|
||||
sort (begin, end, start, 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif//CGAL_HILBERT_SORT_MEDIAN_d_H
|
||||
|
|
|
|||
|
|
@ -16,135 +16,135 @@
|
|||
#include <functional>
|
||||
#include <cstddef>
|
||||
#include <CGAL/Hilbert_sort_middle_base.h>
|
||||
#include <CGAL/Polygon_2_algorithms.h>
|
||||
#include <CGAL/Polygon_2_algorithms.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
namespace internal {
|
||||
template <class K, int x, bool up> struct Fixed_hilbert_cmp_2;
|
||||
template <class K, int x, bool up> struct Fixed_hilbert_cmp_2;
|
||||
|
||||
template <class K, int x>
|
||||
struct Fixed_hilbert_cmp_2<K,x,true>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_2,
|
||||
typename K::Point_2, bool>
|
||||
{
|
||||
typedef typename K::Point_2 Point;
|
||||
K k;
|
||||
double value;
|
||||
Fixed_hilbert_cmp_2 (double v, const K &_k = K()) : k(_k),value(v) {}
|
||||
bool operator() (const Point &p) const
|
||||
{
|
||||
return ! Fixed_hilbert_cmp_2<K,x,false> (value, k) (p);
|
||||
}
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct Fixed_hilbert_cmp_2<K,0,false>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_2,
|
||||
typename K::Point_2, bool>
|
||||
{
|
||||
typedef typename K::Point_2 Point;
|
||||
K k;
|
||||
double value;
|
||||
Fixed_hilbert_cmp_2 (double v, const K &_k = K()) : k(_k),value(v) {}
|
||||
bool operator() (const Point &p) const
|
||||
{
|
||||
return to_double(k.compute_x_2_object()(p)) < value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct Fixed_hilbert_cmp_2<K,1,false>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_2,
|
||||
typename K::Point_2, bool>
|
||||
{
|
||||
typedef typename K::Point_2 Point;
|
||||
K k;
|
||||
double value;
|
||||
Fixed_hilbert_cmp_2 (double v, const K &_k = K()) : k(_k),value(v) {}
|
||||
bool operator() (const Point &p) const
|
||||
{
|
||||
return to_double(k.compute_y_2_object()(p)) < value;
|
||||
}
|
||||
};
|
||||
}
|
||||
template <class K, int x>
|
||||
struct Fixed_hilbert_cmp_2<K,x,true>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_2,
|
||||
typename K::Point_2, bool>
|
||||
{
|
||||
typedef typename K::Point_2 Point;
|
||||
K k;
|
||||
double value;
|
||||
Fixed_hilbert_cmp_2 (double v, const K &_k = K()) : k(_k),value(v) {}
|
||||
bool operator() (const Point &p) const
|
||||
{
|
||||
return ! Fixed_hilbert_cmp_2<K,x,false> (value, k) (p);
|
||||
}
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct Fixed_hilbert_cmp_2<K,0,false>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_2,
|
||||
typename K::Point_2, bool>
|
||||
{
|
||||
typedef typename K::Point_2 Point;
|
||||
K k;
|
||||
double value;
|
||||
Fixed_hilbert_cmp_2 (double v, const K &_k = K()) : k(_k),value(v) {}
|
||||
bool operator() (const Point &p) const
|
||||
{
|
||||
return to_double(k.compute_x_2_object()(p)) < value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct Fixed_hilbert_cmp_2<K,1,false>
|
||||
: public CGAL::cpp98::binary_function<typename K::Point_2,
|
||||
typename K::Point_2, bool>
|
||||
{
|
||||
typedef typename K::Point_2 Point;
|
||||
K k;
|
||||
double value;
|
||||
Fixed_hilbert_cmp_2 (double v, const K &_k = K()) : k(_k),value(v) {}
|
||||
bool operator() (const Point &p) const
|
||||
{
|
||||
return to_double(k.compute_y_2_object()(p)) < value;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template <class K>
|
||||
class Hilbert_sort_middle_2
|
||||
{
|
||||
public:
|
||||
typedef K Kernel;
|
||||
typedef typename Kernel::Point_2 Point;
|
||||
|
||||
private:
|
||||
Kernel _k;
|
||||
std::ptrdiff_t _limit;
|
||||
typedef K Kernel;
|
||||
typedef typename Kernel::Point_2 Point;
|
||||
|
||||
template <int x, bool up> struct Cmp : public internal::Fixed_hilbert_cmp_2<Kernel,x,up>
|
||||
{ Cmp (double v, const Kernel &k) : internal::Fixed_hilbert_cmp_2<Kernel,x,up> (v, k) {} };
|
||||
private:
|
||||
Kernel _k;
|
||||
std::ptrdiff_t _limit;
|
||||
|
||||
template <int x, bool up>
|
||||
struct Cmp
|
||||
: public internal::Fixed_hilbert_cmp_2<Kernel,x,up>
|
||||
{
|
||||
Cmp (double v, const Kernel &k) : internal::Fixed_hilbert_cmp_2<Kernel,x,up> (v, k) {}
|
||||
};
|
||||
|
||||
public:
|
||||
Hilbert_sort_middle_2 (const Kernel &k = Kernel(), std::ptrdiff_t limit = 1)
|
||||
: _k(k), _limit (limit)
|
||||
{}
|
||||
Hilbert_sort_middle_2 (const Kernel &k = Kernel(), std::ptrdiff_t limit = 1)
|
||||
: _k(k), _limit (limit)
|
||||
{}
|
||||
|
||||
template <int x, bool upx, bool upy, class RandomAccessIterator>
|
||||
void sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
double xmin, double ymin, double xmax, double ymax) const
|
||||
{
|
||||
const int y = (x + 1) % 2;
|
||||
if (end - begin <= _limit) return;
|
||||
template <int x, bool upx, bool upy, class RandomAccessIterator>
|
||||
void sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
double xmin, double ymin, double xmax, double ymax) const
|
||||
{
|
||||
const int y = (x + 1) % 2;
|
||||
if (end - begin <= _limit) return;
|
||||
|
||||
double xmed= (xmin+xmax)/2;
|
||||
double ymed= (ymin+ymax)/2;
|
||||
double xmed= (xmin+xmax)/2;
|
||||
double ymed= (ymin+ymax)/2;
|
||||
|
||||
RandomAccessIterator m0 = begin, m4 = end;
|
||||
RandomAccessIterator m0 = begin, m4 = end;
|
||||
|
||||
RandomAccessIterator m2 =
|
||||
internal::fixed_hilbert_split (m0, m4, Cmp< x, upx> (xmed,_k));
|
||||
RandomAccessIterator m1 =
|
||||
internal::fixed_hilbert_split (m0, m2, Cmp< y, upy> (ymed,_k));
|
||||
RandomAccessIterator m3 =
|
||||
internal::fixed_hilbert_split (m2, m4, Cmp< y, !upy> (ymed,_k));
|
||||
RandomAccessIterator m2 = internal::fixed_hilbert_split (m0, m4, Cmp< x, upx> (xmed,_k));
|
||||
RandomAccessIterator m1 = internal::fixed_hilbert_split (m0, m2, Cmp< y, upy> (ymed,_k));
|
||||
RandomAccessIterator m3 = internal::fixed_hilbert_split (m2, m4, Cmp< y, !upy> (ymed,_k));
|
||||
|
||||
if (m1!=m4)
|
||||
sort<y, upy, upx> (m0, m1, ymin, xmin, ymed, xmed);
|
||||
if (m1!=m0 || m2!=m4)
|
||||
sort<x, upx, upy> (m1, m2, xmin, ymed, xmed, ymax);
|
||||
if (m2!=m0 || m3!=m4)
|
||||
sort<x, upx, upy> (m2, m3, xmed, ymed, xmax, ymax);
|
||||
if (m3!=m0)
|
||||
sort<y,!upy,!upx> (m3, m4, ymed, xmax, ymin, xmed);
|
||||
if (m1!=m4)
|
||||
sort<y, upy, upx> (m0, m1, ymin, xmin, ymed, xmed);
|
||||
if (m1!=m0 || m2!=m4)
|
||||
sort<x, upx, upy> (m1, m2, xmin, ymed, xmed, ymax);
|
||||
if (m2!=m0 || m3!=m4)
|
||||
sort<x, upx, upy> (m2, m3, xmed, ymed, xmax, ymax);
|
||||
if (m3!=m0)
|
||||
sort<y,!upy,!upx> (m3, m4, ymed, xmax, ymin, xmed);
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void operator() (RandomAccessIterator begin, RandomAccessIterator end) const
|
||||
{
|
||||
//Bbox_2 box=bbox_2(begin, end); BUG: WE NEED TO FIX THIS
|
||||
|
||||
K k;
|
||||
double xmin=to_double(k.compute_x_2_object()(*begin)),
|
||||
ymin=to_double(k.compute_y_2_object()(*begin)),
|
||||
xmax=xmin,
|
||||
ymax=ymin;
|
||||
|
||||
for(RandomAccessIterator it=begin+1; it<end; ++it){
|
||||
if ( to_double(k.compute_x_2_object()(*it)) < xmin)
|
||||
xmin = to_double(k.compute_x_2_object()(*it));
|
||||
if ( to_double(k.compute_y_2_object()(*it)) < ymin)
|
||||
ymin = to_double(k.compute_y_2_object()(*it));
|
||||
if ( to_double(k.compute_x_2_object()(*it)) > xmax)
|
||||
xmax = to_double(k.compute_x_2_object()(*it));
|
||||
if ( to_double(k.compute_y_2_object()(*it)) > ymax)
|
||||
ymax = to_double(k.compute_y_2_object()(*it));
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void operator() (RandomAccessIterator begin, RandomAccessIterator end) const
|
||||
{
|
||||
//Bbox_2 box=bbox_2(begin, end); BUG: WE NEED TO FIX THIS
|
||||
|
||||
K k;
|
||||
double xmin=to_double(k.compute_x_2_object()(*begin)),
|
||||
ymin=to_double(k.compute_y_2_object()(*begin)),
|
||||
xmax=xmin,
|
||||
ymax=ymin;
|
||||
|
||||
for(RandomAccessIterator it=begin+1; it<end; ++it){
|
||||
if ( to_double(k.compute_x_2_object()(*it)) < xmin)
|
||||
xmin = to_double(k.compute_x_2_object()(*it));
|
||||
if ( to_double(k.compute_y_2_object()(*it)) < ymin)
|
||||
ymin = to_double(k.compute_y_2_object()(*it));
|
||||
if ( to_double(k.compute_x_2_object()(*it)) > xmax)
|
||||
xmax = to_double(k.compute_x_2_object()(*it));
|
||||
if ( to_double(k.compute_y_2_object()(*it)) > ymax)
|
||||
ymax = to_double(k.compute_y_2_object()(*it));
|
||||
}
|
||||
|
||||
sort <0, false, false> (begin, end, xmin, ymin, xmax, ymax);
|
||||
}
|
||||
sort <0, false, false> (begin, end, xmin, ymin, xmax, ymax);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif//CGAL_HILBERT_SORT_MIDDLE_2_H
|
||||
|
|
|
|||
|
|
@ -19,17 +19,19 @@ namespace CGAL {
|
|||
|
||||
namespace internal {
|
||||
|
||||
template <class RandomAccessIterator, class Cmp>
|
||||
RandomAccessIterator
|
||||
fixed_hilbert_split (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
Cmp cmp = Cmp ())
|
||||
{
|
||||
if (begin >= end) return begin;
|
||||
template <class RandomAccessIterator, class Cmp>
|
||||
RandomAccessIterator
|
||||
fixed_hilbert_split (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
Cmp cmp = Cmp ())
|
||||
{
|
||||
if (begin >= end)
|
||||
return begin;
|
||||
|
||||
return std::partition (begin, end, cmp);
|
||||
}
|
||||
return std::partition (begin, end, cmp);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif//CGAL_HILBERT_SORT_MIDDLE_BASE_H
|
||||
|
|
|
|||
|
|
@ -22,28 +22,28 @@ namespace CGAL {
|
|||
template <class Sort>
|
||||
class Multiscale_sort
|
||||
{
|
||||
Sort _sort;
|
||||
std::ptrdiff_t _threshold;
|
||||
double _ratio;
|
||||
Sort _sort;
|
||||
std::ptrdiff_t _threshold;
|
||||
double _ratio;
|
||||
|
||||
public:
|
||||
Multiscale_sort (const Sort &sort = Sort(), std::ptrdiff_t threshold = 1, double ratio = 0.5)
|
||||
: _sort (sort), _threshold (threshold), _ratio (ratio)
|
||||
{
|
||||
CGAL_precondition (0. <= ratio && ratio <= 1.);
|
||||
}
|
||||
Multiscale_sort (const Sort &sort = Sort(), std::ptrdiff_t threshold = 1, double ratio = 0.5)
|
||||
: _sort (sort), _threshold (threshold), _ratio (ratio)
|
||||
{
|
||||
CGAL_precondition (0. <= ratio && ratio <= 1.);
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void operator() (RandomAccessIterator begin, RandomAccessIterator end) const
|
||||
{
|
||||
typedef typename std::iterator_traits<RandomAccessIterator>::difference_type difference_type;
|
||||
RandomAccessIterator middle = begin;
|
||||
if (end - begin >= _threshold) {
|
||||
middle = begin + difference_type (double(end - begin) * _ratio);
|
||||
this->operator() (begin, middle);
|
||||
}
|
||||
_sort (middle, end);
|
||||
template <class RandomAccessIterator>
|
||||
void operator() (RandomAccessIterator begin, RandomAccessIterator end) const
|
||||
{
|
||||
typedef typename std::iterator_traits<RandomAccessIterator>::difference_type difference_type;
|
||||
RandomAccessIterator middle = begin;
|
||||
if (end - begin >= _threshold) {
|
||||
middle = begin + difference_type (double(end - begin) * _ratio);
|
||||
this->operator() (begin, middle);
|
||||
}
|
||||
_sort (middle, end);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace CGAL
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
//
|
||||
// Author(s) : Sebastien Loriot
|
||||
|
||||
|
||||
#ifndef CGAL_SPATIAL_SORT_TRAITS_ADAPTER_2_H
|
||||
#define CGAL_SPATIAL_SORT_TRAITS_ADAPTER_2_H
|
||||
|
||||
|
|
@ -19,47 +18,51 @@
|
|||
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
|
||||
namespace CGAL{
|
||||
|
||||
|
||||
using ::get;
|
||||
|
||||
template<class Base_traits,class PointPropertyMap>
|
||||
class Spatial_sort_traits_adapter_2:public Base_traits{
|
||||
template<class Base_traits, class PointPropertyMap>
|
||||
class Spatial_sort_traits_adapter_2
|
||||
: public Base_traits
|
||||
{
|
||||
PointPropertyMap ppmap_;
|
||||
public:
|
||||
Spatial_sort_traits_adapter_2(Base_traits base=Base_traits()):Base_traits(base){}
|
||||
|
||||
Spatial_sort_traits_adapter_2(const PointPropertyMap& ppmap,Base_traits base=Base_traits())
|
||||
:Base_traits(base),ppmap_(ppmap){}
|
||||
Spatial_sort_traits_adapter_2(const PointPropertyMap& ppmap, Base_traits base=Base_traits())
|
||||
:Base_traits(base), ppmap_(ppmap){}
|
||||
|
||||
typedef Base_traits Gt;
|
||||
typedef typename boost::property_traits<PointPropertyMap>::key_type Point_2;
|
||||
typedef typename boost::call_traits<Point_2>::param_type Arg_type;
|
||||
|
||||
struct Less_x_2 : public Base_traits::Less_x_2{
|
||||
Less_x_2(const PointPropertyMap& ppmap,const typename Base_traits::Less_x_2& base):
|
||||
Base_traits::Less_x_2(base),ppmap_(ppmap){}
|
||||
struct Less_x_2
|
||||
: public Base_traits::Less_x_2
|
||||
{
|
||||
Less_x_2(const PointPropertyMap& ppmap, const typename Base_traits::Less_x_2& base):
|
||||
Base_traits::Less_x_2(base), ppmap_(ppmap){}
|
||||
const PointPropertyMap& ppmap_;
|
||||
bool operator()(Arg_type p,Arg_type q) const {
|
||||
return static_cast<const typename Base_traits::Less_x_2*>(this)->operator()(get(ppmap_,p),get(ppmap_,q));
|
||||
bool operator()(Arg_type p, Arg_type q) const {
|
||||
return static_cast<const typename Base_traits::Less_x_2*>(this)->operator()(get(ppmap_,p), get(ppmap_,q));
|
||||
}
|
||||
};
|
||||
|
||||
struct Less_y_2 : public Base_traits::Less_y_2{
|
||||
Less_y_2(const PointPropertyMap& ppmap,const typename Base_traits::Less_y_2& base):
|
||||
Base_traits::Less_y_2(base),ppmap_(ppmap){}
|
||||
struct Less_y_2
|
||||
: public Base_traits::Less_y_2
|
||||
{
|
||||
Less_y_2(const PointPropertyMap& ppmap, const typename Base_traits::Less_y_2& base):
|
||||
Base_traits::Less_y_2(base), ppmap_(ppmap){}
|
||||
const PointPropertyMap& ppmap_;
|
||||
bool operator()(Arg_type p,Arg_type q) const {
|
||||
return static_cast<const typename Base_traits::Less_y_2*>(this)->operator()(get(ppmap_,p),get(ppmap_,q));
|
||||
bool operator()(Arg_type p, Arg_type q) const {
|
||||
return static_cast<const typename Base_traits::Less_y_2*>(this)->operator()(get(ppmap_,p), get(ppmap_,q));
|
||||
}
|
||||
};
|
||||
|
||||
Less_x_2 less_x_2_object () const {return Less_x_2(ppmap_,static_cast<const Gt*>(this)->less_x_2_object() );}
|
||||
Less_y_2 less_y_2_object () const {return Less_y_2(ppmap_,static_cast<const Gt*>(this)->less_y_2_object() );}
|
||||
|
||||
Less_x_2 less_x_2_object () const {return Less_x_2(ppmap_, static_cast<const Gt*>(this)->less_x_2_object() );}
|
||||
Less_y_2 less_y_2_object () const {return Less_y_2(ppmap_, static_cast<const Gt*>(this)->less_y_2_object() );}
|
||||
|
||||
const PointPropertyMap& point_property_map() const {return ppmap_;}
|
||||
|
||||
};
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
|
|
@ -17,57 +17,63 @@
|
|||
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
|
||||
namespace CGAL{
|
||||
|
||||
using ::get;
|
||||
|
||||
template<class Base_traits,class PointPropertyMap>
|
||||
class Spatial_sort_traits_adapter_3:public Base_traits{
|
||||
|
||||
template<class Base_traits, class PointPropertyMap>
|
||||
class Spatial_sort_traits_adapter_3
|
||||
: public Base_traits
|
||||
{
|
||||
PointPropertyMap ppmap_;
|
||||
public:
|
||||
Spatial_sort_traits_adapter_3(Base_traits base=Base_traits()):Base_traits(base){}
|
||||
|
||||
Spatial_sort_traits_adapter_3(const PointPropertyMap& ppmap,Base_traits base=Base_traits())
|
||||
:Base_traits(base),ppmap_(ppmap){}
|
||||
Spatial_sort_traits_adapter_3(const PointPropertyMap& ppmap, Base_traits base=Base_traits())
|
||||
:Base_traits(base), ppmap_(ppmap){}
|
||||
|
||||
typedef Base_traits Gt;
|
||||
typedef typename boost::property_traits<PointPropertyMap>::key_type Point_3;
|
||||
typedef typename boost::call_traits<Point_3>::param_type Arg_type;
|
||||
|
||||
struct Less_x_3 : public Base_traits::Less_x_3{
|
||||
Less_x_3(const PointPropertyMap& ppmap,const typename Base_traits::Less_x_3& base):
|
||||
Base_traits::Less_x_3(base),ppmap_(ppmap){}
|
||||
struct Less_x_3
|
||||
: public Base_traits::Less_x_3
|
||||
{
|
||||
Less_x_3(const PointPropertyMap& ppmap, const typename Base_traits::Less_x_3& base):
|
||||
Base_traits::Less_x_3(base), ppmap_(ppmap){}
|
||||
const PointPropertyMap& ppmap_;
|
||||
bool operator()(Arg_type p,Arg_type q) const {
|
||||
return static_cast<const typename Base_traits::Less_x_3*>(this)->operator()(get(ppmap_,p),get(ppmap_,q));
|
||||
bool operator()(Arg_type p, Arg_type q) const {
|
||||
return static_cast<const typename Base_traits::Less_x_3*>(this)->operator()(get(ppmap_,p), get(ppmap_,q));
|
||||
}
|
||||
};
|
||||
|
||||
struct Less_y_3 : public Base_traits::Less_y_3{
|
||||
Less_y_3(const PointPropertyMap& ppmap,const typename Base_traits::Less_y_3& base):
|
||||
struct Less_y_3
|
||||
: public Base_traits::Less_y_3
|
||||
{
|
||||
Less_y_3(const PointPropertyMap& ppmap, const typename Base_traits::Less_y_3& base):
|
||||
Base_traits::Less_y_3(base),ppmap_(ppmap){}
|
||||
const PointPropertyMap& ppmap_;
|
||||
bool operator()(Arg_type p,Arg_type q) const {
|
||||
return static_cast<const typename Base_traits::Less_y_3*>(this)->operator()(get(ppmap_,p),get(ppmap_,q));
|
||||
bool operator()(Arg_type p, Arg_type q) const {
|
||||
return static_cast<const typename Base_traits::Less_y_3*>(this)->operator()(get(ppmap_,p), get(ppmap_,q));
|
||||
}
|
||||
};
|
||||
|
||||
struct Less_z_3 : public Base_traits::Less_z_3{
|
||||
Less_z_3(const PointPropertyMap& ppmap,const typename Base_traits::Less_z_3& base):
|
||||
Base_traits::Less_z_3(base),ppmap_(ppmap){}
|
||||
struct Less_z_3
|
||||
: public Base_traits::Less_z_3
|
||||
{
|
||||
Less_z_3(const PointPropertyMap& ppmap, const typename Base_traits::Less_z_3& base):
|
||||
Base_traits::Less_z_3(base), ppmap_(ppmap){}
|
||||
const PointPropertyMap& ppmap_;
|
||||
bool operator()(Arg_type p,Arg_type q) const {
|
||||
return static_cast<const typename Base_traits::Less_z_3*>(this)->operator()(get(ppmap_,p),get(ppmap_,q));
|
||||
bool operator()(Arg_type p, Arg_type q) const {
|
||||
return static_cast<const typename Base_traits::Less_z_3*>(this)->operator()(get(ppmap_,p), get(ppmap_,q));
|
||||
}
|
||||
};
|
||||
|
||||
Less_x_3 less_x_3_object () const {return Less_x_3(ppmap_,static_cast<const Gt*>(this)->less_x_3_object() );}
|
||||
Less_y_3 less_y_3_object () const {return Less_y_3(ppmap_,static_cast<const Gt*>(this)->less_y_3_object() );}
|
||||
Less_z_3 less_z_3_object () const {return Less_z_3(ppmap_,static_cast<const Gt*>(this)->less_z_3_object() );}
|
||||
|
||||
Less_x_3 less_x_3_object () const {return Less_x_3(ppmap_, static_cast<const Gt*>(this)->less_x_3_object() );}
|
||||
Less_y_3 less_y_3_object () const {return Less_y_3(ppmap_, static_cast<const Gt*>(this)->less_y_3_object() );}
|
||||
Less_z_3 less_z_3_object () const {return Less_z_3(ppmap_, static_cast<const Gt*>(this)->less_z_3_object() );}
|
||||
|
||||
const PointPropertyMap& point_property_map() const {return ppmap_;}
|
||||
|
||||
};
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
|
|
@ -20,58 +20,60 @@
|
|||
namespace CGAL{
|
||||
|
||||
using ::get;
|
||||
|
||||
template<class Base_traits,class PointPropertyMap>
|
||||
class Spatial_sort_traits_adapter_d:public Base_traits{
|
||||
|
||||
template<class Base_traits, class PointPropertyMap>
|
||||
class Spatial_sort_traits_adapter_d
|
||||
: public Base_traits
|
||||
{
|
||||
PointPropertyMap ppmap_;
|
||||
public:
|
||||
Spatial_sort_traits_adapter_d(Base_traits base=Base_traits()):Base_traits(base){}
|
||||
Spatial_sort_traits_adapter_d(Base_traits base=Base_traits()) : Base_traits(base){}
|
||||
|
||||
Spatial_sort_traits_adapter_d(const PointPropertyMap& ppmap,Base_traits base=Base_traits())
|
||||
:Base_traits(base),ppmap_(ppmap){}
|
||||
Spatial_sort_traits_adapter_d(const PointPropertyMap& ppmap, Base_traits base=Base_traits())
|
||||
:Base_traits(base), ppmap_(ppmap){}
|
||||
|
||||
typedef Base_traits Gt;
|
||||
typedef typename boost::property_traits<PointPropertyMap>::key_type Point_d;
|
||||
typedef typename boost::call_traits<Point_d>::param_type Arg_type;
|
||||
|
||||
|
||||
|
||||
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){}
|
||||
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<const typename Base_traits::Point_dimension_d*>(this)->operator()(get(ppmap_,p));
|
||||
return static_cast<const typename Base_traits::Point_dimension_d*>(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){}
|
||||
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){}
|
||||
const PointPropertyMap& ppmap_;
|
||||
bool operator()(Arg_type p,Arg_type q,int i) const {
|
||||
return static_cast<const typename Base_traits::Less_coordinate_d*>(this)->operator()(get(ppmap_,p),get(ppmap_,q),i);
|
||||
bool operator()(Arg_type p, Arg_type q, int i) const {
|
||||
return static_cast<const typename Base_traits::Less_coordinate_d*>(this)->operator()(get(ppmap_,p), get(ppmap_,q), i);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct Compute_coordinate_d: public Base_traits::Compute_coordinate_d{
|
||||
Compute_coordinate_d(const PointPropertyMap& ppmap,const typename Base_traits::Compute_coordinate_d& base):
|
||||
Base_traits::Compute_coordinate_d(base),ppmap_(ppmap){}
|
||||
struct Compute_coordinate_d
|
||||
: public Base_traits::Compute_coordinate_d
|
||||
{
|
||||
Compute_coordinate_d(const PointPropertyMap& ppmap, const typename Base_traits::Compute_coordinate_d& base):
|
||||
Base_traits::Compute_coordinate_d(base), ppmap_(ppmap){}
|
||||
const PointPropertyMap& ppmap_;
|
||||
bool operator()(Arg_type p,int i) const {
|
||||
return static_cast<const typename Base_traits::Compute_coordinate_d*>(this)->operator()(get(ppmap_,p),i);
|
||||
bool operator()(Arg_type p, int i) const {
|
||||
return static_cast<const typename Base_traits::Compute_coordinate_d*>(this)->operator()(get(ppmap_,p), i);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Point_dimension_d point_dimension_d_object () const {return Point_dimension_d(ppmap_,static_cast<const Gt*>(this)->point_dimension_d_object() );}
|
||||
Less_coordinate_d less_coordinate_d_object () const {return Less_coordinate_d(ppmap_,static_cast<const Gt*>(this)->less_coordinate_d_object() );}
|
||||
Compute_coordinate_d compute_coordinate_d_object () const {return Compute_coordinate_d(ppmap_,static_cast<const Gt*>(this)->compute_coordinate_d_object() );}
|
||||
|
||||
Point_dimension_d point_dimension_d_object () const {return Point_dimension_d(ppmap_, static_cast<const Gt*>(this)->point_dimension_d_object() );}
|
||||
Less_coordinate_d less_coordinate_d_object () const {return Less_coordinate_d(ppmap_, static_cast<const Gt*>(this)->less_coordinate_d_object() );}
|
||||
Compute_coordinate_d compute_coordinate_d_object () const {return Compute_coordinate_d(ppmap_, static_cast<const Gt*>(this)->compute_coordinate_d_object() );}
|
||||
|
||||
const PointPropertyMap& point_property_map() const {return ppmap_;}
|
||||
|
||||
};
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
|
|
@ -27,120 +27,115 @@
|
|||
#include <algorithm>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
||||
namespace internal {
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Kernel, class Policy>
|
||||
void hilbert_sort (RandomAccessIterator begin,
|
||||
RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy /*policy*/,
|
||||
typename Kernel::Point_2 *)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::difference_type Diff_t;
|
||||
boost::rand48 random;
|
||||
boost::random_number_generator<boost::rand48, Diff_t> rng(random);
|
||||
CGAL::cpp98::random_shuffle(begin,end, rng);
|
||||
(Hilbert_sort_2<Kernel, Policy, ConcurrencyTag> (k))(begin, end);
|
||||
}
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Kernel, class Policy>
|
||||
void hilbert_sort (RandomAccessIterator begin,
|
||||
RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy /*policy*/,
|
||||
typename Kernel::Point_3 *)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::difference_type Diff_t;
|
||||
boost::rand48 random;
|
||||
boost::random_number_generator<boost::rand48, Diff_t> rng(random);
|
||||
CGAL::cpp98::random_shuffle(begin,end, rng);
|
||||
(Hilbert_sort_3<Kernel, Policy, ConcurrencyTag> (k))(begin, end);
|
||||
}
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Kernel, class Policy>
|
||||
void hilbert_sort (RandomAccessIterator begin,
|
||||
RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy /*policy*/,
|
||||
typename Kernel::Point_2 *)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::difference_type Diff_t;
|
||||
boost::rand48 random;
|
||||
boost::random_number_generator<boost::rand48, Diff_t> rng(random);
|
||||
CGAL::cpp98::random_shuffle(begin,end, rng);
|
||||
(Hilbert_sort_2<Kernel, Policy, ConcurrencyTag> (k))(begin, end);
|
||||
}
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Kernel, class Policy>
|
||||
void hilbert_sort (RandomAccessIterator begin,
|
||||
RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy /*policy*/,
|
||||
typename Kernel::Point_3 *)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::difference_type Diff_t;
|
||||
boost::rand48 random;
|
||||
boost::random_number_generator<boost::rand48, Diff_t> rng(random);
|
||||
CGAL::cpp98::random_shuffle(begin,end, rng);
|
||||
(Hilbert_sort_3<Kernel, Policy, ConcurrencyTag> (k))(begin, end);
|
||||
}
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Kernel, class Policy>
|
||||
void hilbert_sort (RandomAccessIterator begin,
|
||||
RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy /*policy*/,
|
||||
typename Kernel::Point_d *)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::difference_type Diff_t;
|
||||
boost::rand48 random;
|
||||
boost::random_number_generator<boost::rand48, Diff_t> rng(random);
|
||||
CGAL::cpp98::random_shuffle(begin,end, rng);
|
||||
(Hilbert_sort_d<Kernel, Policy> (k))(begin, end);
|
||||
}
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Kernel, class Policy>
|
||||
void hilbert_sort (RandomAccessIterator begin,
|
||||
RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy /*policy*/,
|
||||
typename Kernel::Point_d *)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::difference_type Diff_t;
|
||||
boost::rand48 random;
|
||||
boost::random_number_generator<boost::rand48, Diff_t> rng(random);
|
||||
CGAL::cpp98::random_shuffle(begin,end, rng);
|
||||
(Hilbert_sort_d<Kernel, Policy> (k))(begin, end);
|
||||
}
|
||||
} // namespace internal
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator>
|
||||
void hilbert_sort (RandomAccessIterator begin, RandomAccessIterator end)
|
||||
{
|
||||
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
|
||||
internal::hilbert_sort<ConcurrencyTag>(begin, end, Kernel(), Hilbert_sort_median_policy(),
|
||||
static_cast<value_type *> (0));
|
||||
internal::hilbert_sort<ConcurrencyTag>(begin, end, Kernel(), Hilbert_sort_median_policy(),
|
||||
static_cast<value_type *> (0));
|
||||
|
||||
}
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Kernel>
|
||||
void hilbert_sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
const Kernel &k)
|
||||
const Kernel &k)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
|
||||
internal::hilbert_sort<ConcurrencyTag>(begin, end, k, Hilbert_sort_median_policy(),
|
||||
static_cast<value_type *> (0));
|
||||
internal::hilbert_sort<ConcurrencyTag>(begin, end, k, Hilbert_sort_median_policy(),
|
||||
static_cast<value_type *> (0));
|
||||
}
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator>
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator>
|
||||
void hilbert_sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
Hilbert_sort_median_policy policy)
|
||||
Hilbert_sort_median_policy policy)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
|
||||
internal::hilbert_sort<ConcurrencyTag>(begin, end, Kernel(), policy,
|
||||
static_cast<value_type *> (0));
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
|
||||
internal::hilbert_sort<ConcurrencyTag>(begin, end, Kernel(), policy,
|
||||
static_cast<value_type *> (0));
|
||||
}
|
||||
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator>
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator>
|
||||
void hilbert_sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
Hilbert_sort_middle_policy policy)
|
||||
Hilbert_sort_middle_policy policy)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
|
||||
internal::hilbert_sort<ConcurrencyTag>(begin, end, Kernel(), policy,
|
||||
static_cast<value_type *> (0));
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
|
||||
internal::hilbert_sort<ConcurrencyTag>(begin, end, Kernel(), policy,
|
||||
static_cast<value_type *> (0));
|
||||
}
|
||||
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Kernel, class Policy>
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Kernel, class Policy>
|
||||
void hilbert_sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
const Kernel &k, Policy policy)
|
||||
const Kernel &k, Policy policy)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
|
||||
internal::hilbert_sort<ConcurrencyTag>(begin, end,
|
||||
k, policy, static_cast<value_type *> (0));
|
||||
internal::hilbert_sort<ConcurrencyTag>(begin, end,
|
||||
k, policy, static_cast<value_type *> (0));
|
||||
}
|
||||
|
||||
} // namespace CGAL
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ namespace internal {
|
|||
|
||||
template <class RandomAccessIterator, class Kernel, class Policy>
|
||||
void hilbert_sort_on_sphere (RandomAccessIterator begin,
|
||||
RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy,
|
||||
typename Kernel::Point_3 *,
|
||||
double sq_r,
|
||||
const typename Kernel::Point_3 &p)
|
||||
RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy,
|
||||
typename Kernel::Point_3 *,
|
||||
double sq_r,
|
||||
const typename Kernel::Point_3 &p)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::difference_type Diff_t;
|
||||
|
|
@ -41,62 +41,63 @@ void hilbert_sort_on_sphere (RandomAccessIterator begin,
|
|||
|
||||
template <class RandomAccessIterator>
|
||||
void hilbert_sort_on_sphere (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
double sq_r = 1.0,
|
||||
const typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3 &p =
|
||||
typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3(0,0,0))
|
||||
double sq_r = 1.0,
|
||||
const typename CGAL::Kernel_traits<
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3 &p =
|
||||
typename CGAL::Kernel_traits<
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3(0,0,0))
|
||||
{
|
||||
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
|
||||
internal::hilbert_sort_on_sphere(begin, end, Kernel(), Hilbert_sort_median_policy(),
|
||||
static_cast<value_type *> (0), sq_r, p);
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
|
||||
internal::hilbert_sort_on_sphere(begin, end, Kernel(), Hilbert_sort_median_policy(), static_cast<value_type *> (0), sq_r, p);
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void hilbert_sort_on_sphere (RandomAccessIterator begin, RandomAccessIterator end, Hilbert_sort_median_policy policy,
|
||||
double sq_r = 1.0,
|
||||
const typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3 &p =
|
||||
typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3(0,0,0))
|
||||
double sq_r = 1.0,
|
||||
const typename CGAL::Kernel_traits<
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3 &p =
|
||||
typename CGAL::Kernel_traits<
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3(0,0,0))
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
|
||||
internal::hilbert_sort_on_sphere(begin, end, Kernel(), policy,
|
||||
static_cast<value_type *> (0), sq_r, p);
|
||||
internal::hilbert_sort_on_sphere(begin, end, Kernel(), policy, static_cast<value_type *> (0), sq_r, p);
|
||||
}
|
||||
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void hilbert_sort_on_sphere (RandomAccessIterator begin, RandomAccessIterator end, Hilbert_sort_middle_policy policy,
|
||||
double sq_r = 1.0,
|
||||
const typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3 &p =
|
||||
typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3(0,0,0))
|
||||
double sq_r = 1.0,
|
||||
const typename CGAL::Kernel_traits<
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3 &p =
|
||||
typename CGAL::Kernel_traits<
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3(0,0,0))
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
|
||||
internal::hilbert_sort_on_sphere(begin, end, Kernel(), policy,
|
||||
static_cast<value_type *> (0), sq_r, p);
|
||||
internal::hilbert_sort_on_sphere(begin, end, Kernel(), policy, static_cast<value_type *> (0), sq_r, p);
|
||||
}
|
||||
|
||||
|
||||
template <class RandomAccessIterator, class Kernel, class Policy>
|
||||
void hilbert_sort_on_sphere (RandomAccessIterator begin, RandomAccessIterator end, const Kernel &k, Policy policy,
|
||||
double sq_r = 1.0, const typename Kernel::Point_3 &p = typename Kernel::Point_3(0,0,0))
|
||||
void hilbert_sort_on_sphere (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
const Kernel &k, Policy policy,
|
||||
double sq_r = 1.0,
|
||||
const typename Kernel::Point_3 &p = typename Kernel::Point_3(0,0,0))
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
|
||||
internal::hilbert_sort_on_sphere(begin, end,
|
||||
k, policy, static_cast<value_type *> (0), sq_r, p);
|
||||
internal::hilbert_sort_on_sphere(begin, end, k, policy, static_cast<value_type *> (0), sq_r, p);
|
||||
}
|
||||
|
||||
} // end of namespace CGAL
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@
|
|||
#ifndef CGAL_INTERNAL_SCALE_COORDINATES_ADAPTOR_TRAITS_3_H
|
||||
#define CGAL_INTERNAL_SCALE_COORDINATES_ADAPTOR_TRAITS_3_H
|
||||
|
||||
namespace CGAL {
|
||||
namespace CGAL {
|
||||
|
||||
namespace internal {
|
||||
|
||||
|
||||
template <int x, int y, int z, int ord>
|
||||
struct Transform_constant_struct;
|
||||
|
||||
|
|
@ -52,162 +52,162 @@ struct Coordinate_value_adaptor;
|
|||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,0> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.y();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.y();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,1> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.y();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.y();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,2> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.y();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.y();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,3> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.y();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.y();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,4> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.x();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.x();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,5> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.x();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.x();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,6> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.x();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.x();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,7> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.x();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.x();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,8> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.z();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.z();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,9> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.z();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.z();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,10> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.z();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.z();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,11> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.z();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.x();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.z();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,12> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.x();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.x();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,13> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.x();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.x();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,14> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.x();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.x();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,15> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.x();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.x();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,16> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.z();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.z();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,17> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.z();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.z();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,18> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.z();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.z();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,19> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.z();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.y();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.z();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,20> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.y();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.y();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,21> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.y();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return p.y();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,22> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.y();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.y();}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
struct Coordinate_value_adaptor<R,23> {
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.y();}
|
||||
static typename R::FT x(const typename R::Point_3& p) {return -p.z();}
|
||||
static typename R::FT y(const typename R::Point_3& p) {return -p.y();}
|
||||
};
|
||||
|
||||
template <class R, int opt>
|
||||
class Compute_x_2
|
||||
{
|
||||
public:
|
||||
typedef typename R::Point_3 Point;
|
||||
typedef typename R::Point_3 Point;
|
||||
typename R::FT x(const Point &p) const { return Coordinate_value_adaptor<R,opt>::x(p); }
|
||||
typename R::FT operator()(const Point& p) const { return x(p); }
|
||||
};
|
||||
|
||||
template <class R, int opt>
|
||||
class Compute_y_2
|
||||
class Compute_y_2
|
||||
{
|
||||
public:
|
||||
typedef typename R::Point_3 Point;
|
||||
typedef typename R::Point_3 Point;
|
||||
typename R::FT y(const Point &p) const { return Coordinate_value_adaptor<R,opt>::y(p); }
|
||||
typename R::FT operator()(const Point& p) const { return y(p); }
|
||||
};
|
||||
|
|
@ -216,7 +216,7 @@ template <class R, int opt>
|
|||
class Less_x_2
|
||||
{
|
||||
public:
|
||||
typedef typename R::Point_3 Point;
|
||||
typedef typename R::Point_3 Point;
|
||||
typename R::FT x(const Point &p) const { return Coordinate_value_adaptor<R,opt>::x(p); }
|
||||
bool operator()(const Point& p, const Point& q) const { return x(p) < x(q); }
|
||||
};
|
||||
|
|
@ -225,34 +225,33 @@ template <class R, int opt>
|
|||
class Less_y_2
|
||||
{
|
||||
public:
|
||||
typedef typename R::Point_3 Point;
|
||||
typedef typename R::Point_3 Point;
|
||||
typename R::FT y(const Point &p) const { return Coordinate_value_adaptor<R,opt>::y(p); }
|
||||
bool operator()(const Point& p, const Point& q) const { return y(p) < y(q); }
|
||||
};
|
||||
|
||||
template <class R, int x, int y, int z, int ord>
|
||||
struct Transform_coordinates_traits_3 {
|
||||
private:
|
||||
enum {opt = Transform_constant_struct<x,y,z,ord>::value};
|
||||
|
||||
public:
|
||||
typedef Transform_coordinates_traits_3<R,x,y,z,ord> Traits;
|
||||
typedef R Rp;
|
||||
typedef typename Rp::Point_3 Point_2;
|
||||
typedef Less_x_2<R,opt> Less_x;
|
||||
typedef Less_y_2<R,opt> Less_y;
|
||||
typedef Compute_x_2<R,opt> Compute_x;
|
||||
typedef Compute_y_2<R,opt> Compute_y;
|
||||
|
||||
Transform_coordinates_traits_3(){}
|
||||
Transform_coordinates_traits_3(const Transform_coordinates_traits_3&){}
|
||||
|
||||
Less_x less_x_2_object() const { return Less_x(); }
|
||||
Less_y less_y_2_object() const { return Less_y(); }
|
||||
Compute_x compute_x_2_object() const { return Compute_x(); }
|
||||
Compute_y compute_y_2_object() const { return Compute_y(); }
|
||||
private:
|
||||
enum {opt = Transform_constant_struct<x,y,z,ord>::value};
|
||||
|
||||
public:
|
||||
typedef Transform_coordinates_traits_3<R,x,y,z,ord> Traits;
|
||||
typedef R Rp;
|
||||
typedef typename Rp::Point_3 Point_2;
|
||||
typedef Less_x_2<R,opt> Less_x;
|
||||
typedef Less_y_2<R,opt> Less_y;
|
||||
typedef Compute_x_2<R,opt> Compute_x;
|
||||
typedef Compute_y_2<R,opt> Compute_y;
|
||||
|
||||
Transform_coordinates_traits_3(){}
|
||||
Transform_coordinates_traits_3(const Transform_coordinates_traits_3&){}
|
||||
|
||||
Less_x less_x_2_object() const { return Less_x(); }
|
||||
Less_y less_y_2_object() const { return Less_y(); }
|
||||
Compute_x compute_x_2_object() const { return Compute_x(); }
|
||||
Compute_y compute_y_2_object() const { return Compute_y(); }
|
||||
};
|
||||
|
||||
|
||||
} } //namespace CGAL::internal
|
||||
|
||||
|
|
|
|||
|
|
@ -29,153 +29,146 @@ namespace CGAL {
|
|||
|
||||
namespace internal {
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Policy, class Kernel>
|
||||
void spatial_sort (
|
||||
RandomAccessIterator begin, RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy /*policy*/,
|
||||
typename Kernel::Point_2 *,
|
||||
std::ptrdiff_t threshold_hilbert,
|
||||
std::ptrdiff_t threshold_multiscale,
|
||||
double ratio)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> Iterator_traits;
|
||||
typedef typename Iterator_traits::difference_type Diff_t;
|
||||
typedef Hilbert_sort_2<Kernel, Policy, ConcurrencyTag> Sort;
|
||||
boost::rand48 random;
|
||||
boost::random_number_generator<boost::rand48, Diff_t> rng(random);
|
||||
CGAL::cpp98::random_shuffle(begin,end,rng);
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Policy, class Kernel>
|
||||
void spatial_sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy /*policy*/,
|
||||
typename Kernel::Point_2 *,
|
||||
std::ptrdiff_t threshold_hilbert,
|
||||
std::ptrdiff_t threshold_multiscale,
|
||||
double ratio)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> Iterator_traits;
|
||||
typedef typename Iterator_traits::difference_type Diff_t;
|
||||
typedef Hilbert_sort_2<Kernel, Policy, ConcurrencyTag> Sort;
|
||||
boost::rand48 random;
|
||||
boost::random_number_generator<boost::rand48, Diff_t> rng(random);
|
||||
CGAL::cpp98::random_shuffle(begin,end,rng);
|
||||
|
||||
if (threshold_hilbert==0) threshold_hilbert=4;
|
||||
if (threshold_multiscale==0) threshold_multiscale=16;
|
||||
if (ratio==0.0) ratio=0.25;
|
||||
|
||||
(Multiscale_sort<Sort> (Sort (k, threshold_hilbert),
|
||||
threshold_multiscale, ratio)) (begin, end);
|
||||
}
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Policy, class Kernel>
|
||||
void spatial_sort (
|
||||
RandomAccessIterator begin, RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy /*policy*/,
|
||||
typename Kernel::Point_3 *,
|
||||
std::ptrdiff_t threshold_hilbert,
|
||||
std::ptrdiff_t threshold_multiscale,
|
||||
double ratio)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> Iterator_traits;
|
||||
typedef typename Iterator_traits::difference_type Diff_t;
|
||||
typedef Hilbert_sort_3<Kernel, Policy, ConcurrencyTag> Sort;
|
||||
boost::rand48 random;
|
||||
boost::random_number_generator<boost::rand48, Diff_t> rng(random);
|
||||
CGAL::cpp98::random_shuffle(begin,end, rng);
|
||||
|
||||
if (threshold_hilbert==0) threshold_hilbert=8;
|
||||
if (threshold_multiscale==0) threshold_multiscale=64;
|
||||
if (ratio==0.0) ratio=0.125;
|
||||
|
||||
(Multiscale_sort<Sort> (Sort (k, threshold_hilbert),
|
||||
threshold_multiscale, ratio)) (begin, end);
|
||||
}
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Policy, class Kernel>
|
||||
void spatial_sort (
|
||||
RandomAccessIterator begin, RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy /*policy*/,
|
||||
typename Kernel::Point_d *,
|
||||
std::ptrdiff_t threshold_hilbert,
|
||||
std::ptrdiff_t threshold_multiscale,
|
||||
double ratio)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> Iterator_traits;
|
||||
typedef typename Iterator_traits::difference_type Diff_t;
|
||||
typedef Hilbert_sort_d<Kernel, Policy> Sort;
|
||||
boost::rand48 random;
|
||||
boost::random_number_generator<boost::rand48, Diff_t> rng(random);
|
||||
CGAL::cpp98::random_shuffle(begin,end, rng);
|
||||
|
||||
if (threshold_hilbert==0) threshold_hilbert=10;
|
||||
if (threshold_multiscale==0) threshold_multiscale=500;
|
||||
if (ratio==0.0) ratio=0.05;
|
||||
|
||||
(Multiscale_sort<Sort> (Sort (k, threshold_hilbert),
|
||||
threshold_multiscale, ratio)) (begin, end);
|
||||
}
|
||||
|
||||
} //namespace internal
|
||||
if (threshold_hilbert==0) threshold_hilbert=4;
|
||||
if (threshold_multiscale==0) threshold_multiscale=16;
|
||||
if (ratio==0.0) ratio=0.25;
|
||||
|
||||
(Multiscale_sort<Sort> (Sort (k, threshold_hilbert), threshold_multiscale, ratio)) (begin, end);
|
||||
}
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Policy, class Kernel>
|
||||
void spatial_sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy policy,
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
Policy /*policy*/,
|
||||
typename Kernel::Point_3 *,
|
||||
std::ptrdiff_t threshold_hilbert,
|
||||
std::ptrdiff_t threshold_multiscale,
|
||||
double ratio)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef std::iterator_traits<RandomAccessIterator> Iterator_traits;
|
||||
typedef typename Iterator_traits::difference_type Diff_t;
|
||||
typedef Hilbert_sort_3<Kernel, Policy, ConcurrencyTag> Sort;
|
||||
boost::rand48 random;
|
||||
boost::random_number_generator<boost::rand48, Diff_t> rng(random);
|
||||
CGAL::cpp98::random_shuffle(begin,end, rng);
|
||||
|
||||
internal::spatial_sort<ConcurrencyTag>(begin, end, k, policy, static_cast<value_type *> (0),
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
if (threshold_hilbert==0) threshold_hilbert=8;
|
||||
if (threshold_multiscale==0) threshold_multiscale=64;
|
||||
if (ratio==0.0) ratio=0.125;
|
||||
|
||||
(Multiscale_sort<Sort> (Sort (k, threshold_hilbert), threshold_multiscale, ratio)) (begin, end);
|
||||
}
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Policy, class Kernel>
|
||||
void spatial_sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy /*policy*/,
|
||||
typename Kernel::Point_d *,
|
||||
std::ptrdiff_t threshold_hilbert,
|
||||
std::ptrdiff_t threshold_multiscale,
|
||||
double ratio)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> Iterator_traits;
|
||||
typedef typename Iterator_traits::difference_type Diff_t;
|
||||
typedef Hilbert_sort_d<Kernel, Policy> Sort;
|
||||
boost::rand48 random;
|
||||
boost::random_number_generator<boost::rand48, Diff_t> rng(random);
|
||||
CGAL::cpp98::random_shuffle(begin,end, rng);
|
||||
|
||||
if (threshold_hilbert==0) threshold_hilbert=10;
|
||||
if (threshold_multiscale==0) threshold_multiscale=500;
|
||||
if (ratio==0.0) ratio=0.05;
|
||||
|
||||
(Multiscale_sort<Sort> (Sort (k, threshold_hilbert), threshold_multiscale, ratio)) (begin, end);
|
||||
}
|
||||
|
||||
} //namespace internal
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Policy, class Kernel>
|
||||
void spatial_sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy policy,
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
|
||||
internal::spatial_sort<ConcurrencyTag>(begin, end, k, policy, static_cast<value_type *> (0),
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
}
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator>
|
||||
void spatial_sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
Hilbert_sort_median_policy policy,
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
Hilbert_sort_median_policy policy,
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
|
||||
spatial_sort<ConcurrencyTag> (begin, end, Kernel(), policy,
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
spatial_sort<ConcurrencyTag> (begin, end, Kernel(), policy,
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
}
|
||||
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator>
|
||||
void spatial_sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
Hilbert_sort_middle_policy policy,
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
Hilbert_sort_middle_policy policy,
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
|
||||
spatial_sort<ConcurrencyTag> (begin, end, Kernel(), policy,
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
spatial_sort<ConcurrencyTag> (begin, end, Kernel(), policy,
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
}
|
||||
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator, class Kernel>
|
||||
void spatial_sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
{
|
||||
spatial_sort<ConcurrencyTag> (begin, end, k,
|
||||
Hilbert_sort_median_policy(),
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
spatial_sort<ConcurrencyTag> (begin, end, k,
|
||||
Hilbert_sort_median_policy(),
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
}
|
||||
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator>
|
||||
template <class ConcurrencyTag = Sequential_tag, class RandomAccessIterator>
|
||||
void spatial_sort (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
{
|
||||
spatial_sort<ConcurrencyTag> (begin, end,
|
||||
Hilbert_sort_median_policy(),
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
Hilbert_sort_median_policy(),
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
}
|
||||
|
||||
} // namespace CGAL
|
||||
|
|
|
|||
|
|
@ -22,116 +22,115 @@ namespace CGAL {
|
|||
namespace internal {
|
||||
|
||||
template <class RandomAccessIterator, class Policy, class Kernel>
|
||||
void spatial_sort_on_sphere (
|
||||
RandomAccessIterator begin, RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy /*policy*/,
|
||||
typename Kernel::Point_3 *,
|
||||
double sq_r,
|
||||
const typename Kernel::Point_3 &p,
|
||||
std::ptrdiff_t threshold_hilbert,
|
||||
std::ptrdiff_t threshold_multiscale,
|
||||
double ratio)
|
||||
void spatial_sort_on_sphere (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy /*policy*/,
|
||||
typename Kernel::Point_3 *,
|
||||
double sq_r,
|
||||
const typename Kernel::Point_3 &p,
|
||||
std::ptrdiff_t threshold_hilbert,
|
||||
std::ptrdiff_t threshold_multiscale,
|
||||
double ratio)
|
||||
{
|
||||
typedef Hilbert_sort_on_sphere_3<Kernel, Policy> Sort;
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::difference_type Diff_t;
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::difference_type Diff_t;
|
||||
|
||||
boost::rand48 random;
|
||||
boost::random_number_generator<boost::rand48, Diff_t> rng(random);
|
||||
CGAL::cpp98::random_shuffle(begin,end, rng);
|
||||
boost::rand48 random;
|
||||
boost::random_number_generator<boost::rand48, Diff_t> rng(random);
|
||||
CGAL::cpp98::random_shuffle(begin,end, rng);
|
||||
|
||||
if (threshold_hilbert==0) threshold_hilbert=4;
|
||||
if (threshold_multiscale==0) threshold_multiscale=16;
|
||||
if (ratio==0.0) ratio=0.25;
|
||||
if (threshold_hilbert==0) threshold_hilbert=4;
|
||||
if (threshold_multiscale==0) threshold_multiscale=16;
|
||||
if (ratio==0.0) ratio=0.25;
|
||||
|
||||
(Multiscale_sort<Sort> (Sort (k, sq_r, p, threshold_hilbert),
|
||||
threshold_multiscale, ratio)) (begin, end);
|
||||
(Multiscale_sort<Sort> (Sort (k, sq_r, p, threshold_hilbert),
|
||||
threshold_multiscale, ratio)) (begin, end);
|
||||
}
|
||||
|
||||
} // end of namespace internal
|
||||
|
||||
template <class RandomAccessIterator, class Policy, class Kernel>
|
||||
void spatial_sort_on_sphere (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
Policy policy,
|
||||
double sq_r=1.0,
|
||||
const typename Kernel::Point_3 &p = typename Kernel::Point_3(0,0,0),
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
const Kernel &k,
|
||||
Policy policy,
|
||||
double sq_r=1.0,
|
||||
const typename Kernel::Point_3 &p = typename Kernel::Point_3(0,0,0),
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
|
||||
internal::spatial_sort_on_sphere(begin, end, k, policy, static_cast<value_type *> (0),
|
||||
sq_r,p, threshold_hilbert,threshold_multiscale,ratio);
|
||||
internal::spatial_sort_on_sphere(begin, end, k, policy, static_cast<value_type *> (0),
|
||||
sq_r,p, threshold_hilbert,threshold_multiscale,ratio);
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void spatial_sort_on_sphere (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
Hilbert_sort_median_policy policy,
|
||||
double sq_r=1.0,
|
||||
const typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3 &p =
|
||||
typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3(0,0,0),
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
Hilbert_sort_median_policy policy,
|
||||
double sq_r=1.0,
|
||||
const typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3 &p =
|
||||
typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3(0,0,0),
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
|
||||
spatial_sort_on_sphere (begin, end, Kernel(), policy, sq_r, p,
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
spatial_sort_on_sphere (begin, end, Kernel(), policy, sq_r, p,
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
}
|
||||
template <class RandomAccessIterator>
|
||||
void spatial_sort_on_sphere (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
Hilbert_sort_middle_policy policy,
|
||||
double sq_r=1.0,
|
||||
const typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3 &p =
|
||||
typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3(0,0,0),
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
Hilbert_sort_middle_policy policy,
|
||||
double sq_r=1.0,
|
||||
const typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3 &p =
|
||||
typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3(0,0,0),
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
{
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
typedef std::iterator_traits<RandomAccessIterator> ITraits;
|
||||
typedef typename ITraits::value_type value_type;
|
||||
typedef CGAL::Kernel_traits<value_type> KTraits;
|
||||
typedef typename KTraits::Kernel Kernel;
|
||||
|
||||
spatial_sort_on_sphere (begin, end, Kernel(), policy, sq_r,p,
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
spatial_sort_on_sphere (begin, end, Kernel(), policy, sq_r,p,
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
}
|
||||
|
||||
|
||||
template <class RandomAccessIterator, class Kernel>
|
||||
void spatial_sort_on_sphere (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
const Kernel &k,
|
||||
double sq_r = 1.0,
|
||||
const typename Kernel::Point_3 &p = typename Kernel::Point_3(0,0,0),
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
const Kernel &k,
|
||||
double sq_r = 1.0,
|
||||
const typename Kernel::Point_3 &p = typename Kernel::Point_3(0,0,0),
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
{
|
||||
spatial_sort_on_sphere (begin, end, k,
|
||||
Hilbert_sort_median_policy(), sq_r, p,
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
spatial_sort_on_sphere (begin, end, k,
|
||||
Hilbert_sort_median_policy(), sq_r, p,
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
}
|
||||
|
||||
template <class RandomAccessIterator>
|
||||
void spatial_sort_on_sphere (RandomAccessIterator begin, RandomAccessIterator end,
|
||||
double sq_r = 1.0,
|
||||
const typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3 &p =
|
||||
typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3(0,0,0),
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
double sq_r = 1.0,
|
||||
const typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3 &p =
|
||||
typename CGAL::Kernel_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::Kernel::Point_3(0,0,0),
|
||||
std::ptrdiff_t threshold_hilbert=0,
|
||||
std::ptrdiff_t threshold_multiscale=0,
|
||||
double ratio=0.0)
|
||||
{
|
||||
spatial_sort_on_sphere (begin, end,
|
||||
Hilbert_sort_median_policy(), sq_r,p,
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
spatial_sort_on_sphere (begin, end,
|
||||
Hilbert_sort_median_policy(), sq_r,p,
|
||||
threshold_hilbert,threshold_multiscale,ratio);
|
||||
}
|
||||
|
||||
} // end of namespace CGAL
|
||||
|
|
|
|||
Loading…
Reference in New Issue