mirror of https://github.com/CGAL/cgal
Improve CH2 tests
This commit is contained in:
parent
e4e52c8391
commit
2e330b1342
|
|
@ -15,14 +15,14 @@
|
|||
|
||||
#include <CGAL/license/Convex_hull_2.h>
|
||||
|
||||
|
||||
#ifndef CGAL_CH_NO_POSTCONDITIONS
|
||||
#include <CGAL/convexity_check_2.h>
|
||||
#endif // CGAL_CH_NO_POSTCONDITIONS
|
||||
|
||||
#include <CGAL/Convex_hull_2/ch_assertions.h>
|
||||
#include <queue>
|
||||
#include <iterator>
|
||||
|
||||
#include <algorithm>
|
||||
#include <deque>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
#include <iostream>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/convex_hull_2.h>
|
||||
#include <CGAL/convex_hull_traits_2.h>
|
||||
|
||||
#include <CGAL/boost/iterator/counting_iterator.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef K::Point_2 Point_2;
|
||||
|
||||
|
||||
template <class F, class Point>
|
||||
struct Forward_bool_functor
|
||||
: public F
|
||||
|
|
@ -128,5 +131,5 @@ int main()
|
|||
|
||||
assert( result.size() == 3 );
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/convex_hull_2.h>
|
||||
#include <CGAL/Projection_traits_xy_3.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
|
|
@ -8,18 +10,20 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
|||
typedef CGAL::Projection_traits_xy_3<Kernel> Traits;
|
||||
typedef Traits::Point_2 Point_2;
|
||||
|
||||
int main(){
|
||||
int main()
|
||||
{
|
||||
std::vector<Point_2> points;
|
||||
std::ifstream input("data/CD500");
|
||||
|
||||
double x,y;
|
||||
while (input >> x >> y){
|
||||
while(input >> x >> y)
|
||||
{
|
||||
points.push_back(Point_2(x,y,3.));
|
||||
}
|
||||
|
||||
std::vector<Point_2> ch2;
|
||||
|
||||
CGAL::convex_hull_2(points.begin(),points.end(),std::back_inserter(ch2),Traits());
|
||||
|
||||
std::cout << ch2.size() << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,33 +1,9 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// Copyright (c) 1999 The CGAL Consortium
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// file : ch_test_CH.C
|
||||
// revision : $Id$
|
||||
// revision_date : $Date$
|
||||
// author(s) : Stefan Schirra
|
||||
//
|
||||
// coordinator : MPI, Saarbruecken
|
||||
// ============================================================================
|
||||
#include <CGAL/_test_fct_ch_I_2.h>
|
||||
|
||||
#include <CGAL/Homogeneous.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/convex_hull_traits_2.h>
|
||||
|
||||
#include <CGAL/convex_hull_constructive_traits_2.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#ifdef CGAL_USE_LEDA
|
||||
#include <CGAL/leda_integer.h>
|
||||
#include <CGAL/leda_rational.h>
|
||||
|
|
@ -37,28 +13,23 @@
|
|||
#include <CGAL/Gmpz.h>
|
||||
#endif
|
||||
|
||||
#include <CGAL/_test_fct_ch_I_2.h>
|
||||
|
||||
int
|
||||
main()
|
||||
int main()
|
||||
{
|
||||
#ifdef CGAL_USE_LEDA
|
||||
CGAL::Convex_hull_constructive_traits_2< CGAL::Homogeneous<leda_integer> >
|
||||
cch_H_integer;
|
||||
std::cout << "Homogeneous<integer>: C ";
|
||||
CGAL::ch__batch_test( cch_H_integer );
|
||||
CGAL::Convex_hull_constructive_traits_2< CGAL::Homogeneous<leda_integer> > cch_H_integer;
|
||||
std::cout << "Homogeneous<integer>:" << std::endl;
|
||||
CGAL::ch__batch_test(cch_H_integer);
|
||||
#endif
|
||||
|
||||
#ifdef CGAL_USE_GMP
|
||||
CGAL::Convex_hull_constructive_traits_2< CGAL::Homogeneous<CGAL::Gmpz> >
|
||||
cch_H_gmp;
|
||||
std::cout << "Homogeneous<gmp>: C ";
|
||||
CGAL::ch__batch_test( cch_H_gmp );
|
||||
CGAL::Convex_hull_constructive_traits_2< CGAL::Homogeneous<CGAL::Gmpz> > cch_H_gmp;
|
||||
std::cout << "Homogeneous<gmp>:" << std::endl;
|
||||
CGAL::ch__batch_test(cch_H_gmp);
|
||||
#endif
|
||||
|
||||
CGAL::Convex_hull_constructive_traits_2< CGAL::Homogeneous<double> >
|
||||
cch_H_double;
|
||||
std::cout << "Homogeneous<double>: C ";
|
||||
CGAL::ch__batch_test( cch_H_double );
|
||||
return 0;
|
||||
CGAL::Convex_hull_constructive_traits_2< CGAL::Homogeneous<double> > cch_H_double;
|
||||
std::cout << "Homogeneous<double>:" << std::endl;
|
||||
CGAL::ch__batch_test(cch_H_double);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +1,6 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// Copyright (c) 1999 The CGAL Consortium
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// file : ch_test_SC.C
|
||||
// revision : $Id$
|
||||
// revision_date : $Date$
|
||||
// author(s) : Stefan Schirra
|
||||
//
|
||||
// coordinator : MPI, Saarbruecken
|
||||
// ============================================================================
|
||||
#include <CGAL/_test_fct_ch_I_2.h>
|
||||
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/convex_hull_traits_2.h>
|
||||
#include <CGAL/convex_hull_constructive_traits_2.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#ifdef CGAL_USE_LEDA
|
||||
#include <CGAL/leda_integer.h>
|
||||
|
|
@ -36,25 +11,23 @@
|
|||
#include <CGAL/Gmpz.h>
|
||||
#endif
|
||||
|
||||
#include <CGAL/_test_fct_ch_I_2.h>
|
||||
|
||||
int
|
||||
main()
|
||||
int main()
|
||||
{
|
||||
#ifdef CGAL_USE_LEDA
|
||||
CGAL::Cartesian<leda_rational> ch_C_rational;
|
||||
std::cout << "Cartesian<rational>: ";
|
||||
CGAL::ch__batch_test( ch_C_rational );
|
||||
CGAL::Cartesian<leda_rational> ch_C_rational;
|
||||
std::cout << "Cartesian<rational>:" << std::endl;
|
||||
CGAL::ch__batch_test(ch_C_rational);
|
||||
#endif
|
||||
|
||||
#ifdef CGAL_USE_GMP
|
||||
CGAL::Cartesian<CGAL::Quotient<CGAL::Gmpz> > ch_C_Qgmp;
|
||||
std::cout << "Cartesian<Quotient<Gmpz> > >: ";
|
||||
CGAL::ch__batch_test( ch_C_Qgmp );
|
||||
CGAL::Cartesian<CGAL::Quotient<CGAL::Gmpz> > ch_C_Qgmp;
|
||||
std::cout << "Cartesian<Quotient<Gmpz> > >:" << std::endl;
|
||||
CGAL::ch__batch_test(ch_C_Qgmp);
|
||||
#endif
|
||||
|
||||
CGAL::Cartesian<double> ch_C_double;
|
||||
std::cout << "Cartesian<double>: ";
|
||||
CGAL::ch__batch_test( ch_C_double );
|
||||
return 0;
|
||||
CGAL::Cartesian<double> ch_C_double;
|
||||
std::cout << "Cartesian<double>:" << std::endl;
|
||||
CGAL::ch__batch_test(ch_C_double);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +1,6 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// Copyright (c) 1999 The CGAL Consortium
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// file : ch_test_SH.C
|
||||
// revision : $Id$
|
||||
// revision_date : $Date$
|
||||
// author(s) : Stefan Schirra
|
||||
//
|
||||
// coordinator : MPI, Saarbruecken
|
||||
// ============================================================================
|
||||
#include <CGAL/_test_fct_ch_I_2.h>
|
||||
|
||||
#include <CGAL/Homogeneous.h>
|
||||
#include <CGAL/convex_hull_traits_2.h>
|
||||
#include <CGAL/convex_hull_constructive_traits_2.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#ifdef CGAL_USE_LEDA
|
||||
#include <CGAL/leda_integer.h>
|
||||
|
|
@ -35,25 +10,24 @@
|
|||
#ifdef CGAL_USE_GMP
|
||||
#include <CGAL/Gmpz.h>
|
||||
#endif
|
||||
#include <CGAL/_test_fct_ch_I_2.h>
|
||||
|
||||
int
|
||||
main()
|
||||
int main()
|
||||
{
|
||||
#ifdef CGAL_USE_LEDA
|
||||
CGAL::Homogeneous<leda_integer> ch_H_integer;
|
||||
std::cout << "Homogeneous<integer>: ";
|
||||
CGAL::Homogeneous<leda_integer> ch_H_integer;
|
||||
std::cout << "Homogeneous<integer>:" << std::endl;
|
||||
CGAL::ch__batch_test( ch_H_integer );
|
||||
#endif
|
||||
|
||||
#ifdef CGAL_USE_GMP
|
||||
CGAL::Homogeneous<CGAL::Gmpz> ch_H_gmp;
|
||||
std::cout << "Homogeneous<gmp>: ";
|
||||
CGAL::Homogeneous<CGAL::Gmpz> ch_H_gmp;
|
||||
std::cout << "Homogeneous<gmp>:" << std::endl;
|
||||
CGAL::ch__batch_test( ch_H_gmp );
|
||||
#endif
|
||||
|
||||
CGAL::Homogeneous<double> ch_H_double;
|
||||
std::cout << "Homogeneous<double>: ";
|
||||
CGAL::Homogeneous<double> ch_H_double;
|
||||
std::cout << "Homogeneous<double>:" << std::endl;
|
||||
CGAL::ch__batch_test( ch_H_double );
|
||||
return 0;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,32 +1,6 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// Copyright (c) 1999 The CGAL Consortium
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// file : ch_test_SS.C
|
||||
// revision : $Id$
|
||||
// revision_date : $Date$
|
||||
// author(s) : Stefan Schirra
|
||||
//
|
||||
// coordinator : MPI, Saarbruecken
|
||||
// ============================================================================
|
||||
|
||||
#include <CGAL/_test_fct_ch_I_2.h>
|
||||
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/convex_hull_traits_2.h>
|
||||
#include <CGAL/convex_hull_constructive_traits_2.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#ifdef CGAL_USE_LEDA
|
||||
#include <CGAL/leda_integer.h>
|
||||
|
|
@ -36,25 +10,24 @@
|
|||
#ifdef CGAL_USE_GMP
|
||||
#include <CGAL/Gmpz.h>
|
||||
#endif
|
||||
#include <CGAL/_test_fct_ch_I_2.h>
|
||||
|
||||
int
|
||||
main()
|
||||
int main()
|
||||
{
|
||||
#ifdef CGAL_USE_LEDA
|
||||
CGAL::Simple_cartesian<leda_rational> ch_S_rational;
|
||||
std::cout << "SimpleCartesian<rational>: ";
|
||||
CGAL::Simple_cartesian<leda_rational> ch_S_rational;
|
||||
std::cout << "SimpleCartesian<rational>:" << std::endl;
|
||||
CGAL::ch__batch_test( ch_S_rational );
|
||||
#endif
|
||||
|
||||
#ifdef CGAL_USE_GMP
|
||||
CGAL::Simple_cartesian<CGAL::Quotient<CGAL::Gmpz> > ch_S_Qgmp;
|
||||
std::cout << "SimpleCartesian<Quotient<Gmpz> > >: ";
|
||||
CGAL::Simple_cartesian<CGAL::Quotient<CGAL::Gmpz> > ch_S_Qgmp;
|
||||
std::cout << "SimpleCartesian<Quotient<Gmpz> > >:" << std::endl;
|
||||
CGAL::ch__batch_test( ch_S_Qgmp );
|
||||
#endif
|
||||
|
||||
CGAL::Simple_cartesian<double> ch_S_double;
|
||||
std::cout << "SimpleCartesian<double>: ";
|
||||
CGAL::Simple_cartesian<double> ch_S_double;
|
||||
std::cout << "SimpleCartesian<double>:" << std::endl;
|
||||
CGAL::ch__batch_test( ch_S_double );
|
||||
return 0;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,21 +18,243 @@
|
|||
// coordinator : MPI, Saarbruecken
|
||||
// ============================================================================
|
||||
|
||||
|
||||
#ifndef _TEST_FCT_CH_I_2_H
|
||||
#define _TEST_FCT_CH_I_2_H
|
||||
|
||||
#include <cassert>
|
||||
#include <CGAL/ch__test.h>
|
||||
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template <class Traits>
|
||||
bool
|
||||
ch__batch_test( const Traits& chI );
|
||||
void ch__batch_test_simple(const Traits& chI)
|
||||
{
|
||||
using Point_2 = typename Traits::Point_2;
|
||||
|
||||
} //namespace CGAL
|
||||
std::cout << std::endl << " == Test Simple ==" << std::endl;
|
||||
|
||||
#include <CGAL/_test_fct_ch_I_2_impl.h>
|
||||
std::vector<Point_2> points;
|
||||
points.push_back(Point_2( -10, 0, 1));
|
||||
points.push_back(Point_2( -15, -1, 1));
|
||||
points.push_back(Point_2( -7, -10, 1));
|
||||
points.push_back(Point_2( -9, -20, 1));
|
||||
points.push_back(Point_2( -3, -20, 1));
|
||||
points.push_back(Point_2( 74, 0, 1));
|
||||
points.push_back(Point_2( 1, 1, 1));
|
||||
points.push_back(Point_2( 0, 100, 1));
|
||||
|
||||
assert(ch__test(points.begin(), points.end(), chI));
|
||||
}
|
||||
|
||||
template <class Traits>
|
||||
void ch__batch_test_cocircular(const Traits& chI)
|
||||
{
|
||||
using Point_2 = typename Traits::Point_2;
|
||||
|
||||
std::cout << std::endl << " == Test Cocircular ==" << std::endl;
|
||||
|
||||
std::vector<Point_2> cocircular_points;
|
||||
cocircular_points.push_back(Point_2( 39, 80, 89));
|
||||
cocircular_points.push_back(Point_2( 180, 299, 349));
|
||||
cocircular_points.push_back(Point_2( -3, -4, 5));
|
||||
cocircular_points.push_back(Point_2(-651, 260, 701));
|
||||
cocircular_points.push_back(Point_2( 180, -19, 181));
|
||||
cocircular_points.push_back(Point_2(-153, 104, 185));
|
||||
cocircular_points.push_back(Point_2(-247, -96, 265));
|
||||
cocircular_points.push_back(Point_2( -32, 255, 257));
|
||||
cocircular_points.push_back(Point_2( 45, -28, 53));
|
||||
cocircular_points.push_back(Point_2( -12, -35, 37));
|
||||
|
||||
assert(!ch_brute_force_check_2(cocircular_points.begin(), cocircular_points.end(),
|
||||
cocircular_points.begin(), cocircular_points.end(), chI));
|
||||
assert(ch_brute_force_check_2(cocircular_points.begin(), cocircular_points.begin(),
|
||||
cocircular_points.begin(), cocircular_points.end(), chI));
|
||||
assert(ch__test(cocircular_points.begin(), cocircular_points.end(), chI, ch_ALL, ch_CHECK_CONVEXITY));
|
||||
|
||||
std::vector<Point_2> extreme_points;
|
||||
convex_hull_2(cocircular_points.begin(), cocircular_points.end(),
|
||||
std::back_inserter(extreme_points), chI);
|
||||
|
||||
assert(is_ccw_strongly_convex_2(extreme_points.begin(), extreme_points.begin(), chI));
|
||||
assert(is_cw_strongly_convex_2(extreme_points.rend(), extreme_points.rend(), chI));
|
||||
assert(is_ccw_strongly_convex_2(extreme_points.begin(), extreme_points.begin() + 1, chI));
|
||||
assert(is_cw_strongly_convex_2(extreme_points.begin(), extreme_points.begin() + 1, chI));
|
||||
assert(is_ccw_strongly_convex_2(extreme_points.begin(), extreme_points.end(), chI));
|
||||
assert(is_cw_strongly_convex_2(extreme_points.rbegin(), extreme_points.rend(), chI));
|
||||
}
|
||||
|
||||
template <class Traits>
|
||||
void ch__batch_test_cocircular_ordered(const Traits& chI)
|
||||
{
|
||||
using Point_2 = typename Traits::Point_2;
|
||||
|
||||
std::cout << std::endl << " == Test Cocircular (ordered) ==" << std::endl;
|
||||
|
||||
std::vector<Point_2> cocircular_points;
|
||||
cocircular_points.push_back(Point_2( 180, -19, 181));
|
||||
cocircular_points.push_back(Point_2( 45, -28, 53));
|
||||
cocircular_points.push_back(Point_2( -12, -35, 37));
|
||||
cocircular_points.push_back(Point_2( -3, -4, 5));
|
||||
cocircular_points.push_back(Point_2(-247, -96, 265));
|
||||
cocircular_points.push_back(Point_2(-651, 260, 701));
|
||||
cocircular_points.push_back(Point_2(-153, 104, 185));
|
||||
cocircular_points.push_back(Point_2( -32, 255, 257));
|
||||
cocircular_points.push_back(Point_2( 39, 80, 89));
|
||||
cocircular_points.push_back(Point_2( 180, 299, 349));
|
||||
|
||||
assert(!ch_brute_force_check_2(cocircular_points.begin(), cocircular_points.end(),
|
||||
cocircular_points.begin(), cocircular_points.end(), chI));
|
||||
assert(ch_brute_force_check_2(cocircular_points.begin(), cocircular_points.begin(),
|
||||
cocircular_points.begin(), cocircular_points.end(), chI));
|
||||
assert(ch__test(cocircular_points.begin(), cocircular_points.end(), chI, ch_ALL, ch_CHECK_CONVEXITY));
|
||||
|
||||
std::vector<Point_2> extreme_points;
|
||||
convex_hull_2(cocircular_points.begin(), cocircular_points.end(),
|
||||
std::back_inserter(extreme_points), chI);
|
||||
|
||||
assert(is_ccw_strongly_convex_2(extreme_points.begin(), extreme_points.begin(), chI));
|
||||
assert(is_cw_strongly_convex_2(extreme_points.rend(), extreme_points.rend(), chI));
|
||||
assert(is_ccw_strongly_convex_2(extreme_points.begin(), extreme_points.begin() + 1, chI));
|
||||
assert(is_cw_strongly_convex_2(extreme_points.begin(), extreme_points.begin() + 1, chI));
|
||||
assert(is_ccw_strongly_convex_2(extreme_points.begin(), extreme_points.end(), chI));
|
||||
assert(is_cw_strongly_convex_2(extreme_points.rbegin(), extreme_points.rend(), chI));
|
||||
}
|
||||
|
||||
template <class Traits>
|
||||
void ch__batch_test_collinear(const Traits& chI)
|
||||
{
|
||||
using Point_2 = typename Traits::Point_2;
|
||||
|
||||
std::cout << std::endl << " == Test Collinear ==" << std::endl;
|
||||
|
||||
std::vector<Point_2> collinear_points;
|
||||
collinear_points.push_back(Point_2( 16, 20, 1));
|
||||
collinear_points.push_back(Point_2( 46, 40, 1));
|
||||
collinear_points.push_back(Point_2( 76, 60, 1));
|
||||
collinear_points.push_back(Point_2(106, 80, 1));
|
||||
collinear_points.push_back(Point_2(-14, 0, 1));
|
||||
collinear_points.push_back(Point_2(136, 100, 1));
|
||||
|
||||
assert(ch__test(collinear_points.begin(), collinear_points.end(), chI));
|
||||
}
|
||||
|
||||
template <class Traits>
|
||||
void ch__batch_test_multiple(const Traits& chI)
|
||||
{
|
||||
using Point_2 = typename Traits::Point_2;
|
||||
|
||||
std::cout << std::endl << " == Test Multiple ==" << std::endl;
|
||||
|
||||
std::vector<Point_2> multiple_points;
|
||||
multiple_points.push_back(Point_2(17, 80, 1));
|
||||
multiple_points.push_back(Point_2(17, 80, 1));
|
||||
multiple_points.push_back(Point_2(17, 80, 1));
|
||||
multiple_points.push_back(Point_2(17, 80, 1));
|
||||
|
||||
assert(ch_brute_force_check_2(multiple_points.begin(), multiple_points.end(),
|
||||
multiple_points.begin(), multiple_points.begin() + 1, chI));
|
||||
assert(is_ccw_strongly_convex_2(multiple_points.begin(), multiple_points.begin(), chI));
|
||||
|
||||
assert(ch__test(multiple_points.begin(), multiple_points.end(), chI));
|
||||
assert(ch__test(multiple_points.begin() + 2, multiple_points.begin() + 3, chI));
|
||||
}
|
||||
|
||||
template <class Traits>
|
||||
void ch__batch_test_iso_rectangle(const Traits& chI)
|
||||
{
|
||||
using Point_2 = typename Traits::Point_2;
|
||||
|
||||
std::cout << std::endl << " == Test Iso Rectangle ==" << std::endl;
|
||||
|
||||
std::vector<Point_2> iso_rectangle_points;
|
||||
iso_rectangle_points.push_back(Point_2( 15, 0, 1));
|
||||
iso_rectangle_points.push_back(Point_2( 45, 0, 1));
|
||||
iso_rectangle_points.push_back(Point_2( 70, 0, 10));
|
||||
iso_rectangle_points.push_back(Point_2( 12, 0, 1));
|
||||
iso_rectangle_points.push_back(Point_2( 56, 118, 1));
|
||||
iso_rectangle_points.push_back(Point_2( 27, 118, 1));
|
||||
iso_rectangle_points.push_back(Point_2( 56, 118, 1));
|
||||
iso_rectangle_points.push_back(Point_2(112, 118, 1));
|
||||
iso_rectangle_points.push_back(Point_2( 0, 9, 1));
|
||||
iso_rectangle_points.push_back(Point_2( 0, 78, 1));
|
||||
iso_rectangle_points.push_back(Point_2( 0, 16, 1));
|
||||
iso_rectangle_points.push_back(Point_2( 0, 77, 1));
|
||||
iso_rectangle_points.push_back(Point_2(150, 56, 1));
|
||||
iso_rectangle_points.push_back(Point_2(150, 57, 1));
|
||||
iso_rectangle_points.push_back(Point_2(150, 58, 1));
|
||||
iso_rectangle_points.push_back(Point_2(150, 58, 1));
|
||||
|
||||
assert(ch__test(iso_rectangle_points.begin(), iso_rectangle_points.end(), chI));
|
||||
assert(ch__test(iso_rectangle_points.begin(), iso_rectangle_points.begin()+3, chI));
|
||||
assert(ch__test(iso_rectangle_points.begin()+4, iso_rectangle_points.begin()+7, chI));
|
||||
assert(ch__test(iso_rectangle_points.begin()+5, iso_rectangle_points.begin()+5, chI));
|
||||
}
|
||||
|
||||
// https://github.com/CGAL/cgal/issues/6723
|
||||
template <class Traits>
|
||||
void ch__batch_test_issue_6723(const Traits& chI)
|
||||
{
|
||||
using Point_2 = typename Traits::Point_2;
|
||||
|
||||
std::cout << std::endl << " == Test issue_6723 ==" << std::endl;
|
||||
|
||||
std::vector<Point_2> points = { Point_2( 4, 2, 1),
|
||||
Point_2( 0, 0, 1),
|
||||
Point_2(10, 0, 1),
|
||||
Point_2( 3, 1, 1),
|
||||
Point_2( 3,-1, 1),
|
||||
Point_2( 2, 2, 1),
|
||||
Point_2( 5, 2, 1),
|
||||
Point_2( 9, 2, 1),
|
||||
Point_2( 3, 2, 1) };
|
||||
|
||||
assert(ch__test(points.begin(), points.end(), chI));
|
||||
}
|
||||
|
||||
template <class Traits>
|
||||
void ch__batch_test_random(const Traits& chI)
|
||||
{
|
||||
using Point_2 = typename Traits::Point_2;
|
||||
|
||||
std::cout << std::endl << " == Test Random ==" << std::endl;
|
||||
|
||||
CGAL::Random rnd;
|
||||
std::cout << "Random seed = " << rnd.get_seed() << std::endl;
|
||||
|
||||
std::vector<Point_2> points;
|
||||
|
||||
const int h = rnd.get_int(1, 100);
|
||||
for(int i=0; i<10; ++i)
|
||||
{
|
||||
const int x = rnd.get_int(-100, 100);
|
||||
const int y = rnd.get_int(-100, 100);
|
||||
points.emplace_back(x, y, h);
|
||||
}
|
||||
|
||||
assert(ch__test(points.begin(), points.end(), chI));
|
||||
}
|
||||
|
||||
template <class Traits>
|
||||
bool ch__batch_test(const Traits& chI)
|
||||
{
|
||||
std::cout << "Testing Convex Hulls" << std::endl;;
|
||||
|
||||
ch__batch_test_simple(chI);
|
||||
ch__batch_test_cocircular(chI);
|
||||
ch__batch_test_cocircular_ordered(chI); // so melkman gets called
|
||||
ch__batch_test_collinear(chI);
|
||||
ch__batch_test_multiple(chI);
|
||||
ch__batch_test_iso_rectangle(chI);
|
||||
ch__batch_test_issue_6723(chI);
|
||||
ch__batch_test_random(chI);
|
||||
|
||||
std::cout << "done" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // _TEST_FCT_CH_I_2_H
|
||||
|
|
|
|||
|
|
@ -1,137 +0,0 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// Copyright (c) 1999 The CGAL Consortium
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// file : _test_fct_ch_I_2.C
|
||||
// revision : $Id$
|
||||
// revision_date : $Date$
|
||||
// author(s) : Stefan Schirra
|
||||
//
|
||||
// coordinator : MPI, Saarbruecken
|
||||
// ============================================================================
|
||||
|
||||
|
||||
#ifndef _TEST_FCT_CH_I_2_IMPL_H
|
||||
#define _TEST_FCT_CH_I_2_IMPL_H
|
||||
|
||||
#include <CGAL/_test_fct_ch_I_2.h>
|
||||
#include <cassert>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template <class Traits>
|
||||
bool
|
||||
ch__batch_test( const Traits& chI )
|
||||
{
|
||||
typedef typename Traits::Point_2 Point_2;
|
||||
|
||||
std::cout << "Testing ch";
|
||||
std::vector< Point_2 > Cocircular_points;
|
||||
Cocircular_points.push_back( Point_2( 39, 80, 89 ));
|
||||
Cocircular_points.push_back( Point_2( 180, 299, 349 ));
|
||||
Cocircular_points.push_back( Point_2( -3, -4, 5 ));
|
||||
Cocircular_points.push_back( Point_2( -651, 260, 701 ));
|
||||
Cocircular_points.push_back( Point_2( 180, -19, 181 ));
|
||||
Cocircular_points.push_back( Point_2( -153, 104, 185 ));
|
||||
Cocircular_points.push_back( Point_2( -247, -96, 265 ));
|
||||
Cocircular_points.push_back( Point_2( -32, 255, 257 ));
|
||||
Cocircular_points.push_back( Point_2( 45, -28, 53 ));
|
||||
Cocircular_points.push_back( Point_2( -12, -35, 37 ));
|
||||
assert( ! ch_brute_force_check_2( \
|
||||
Cocircular_points.begin(), Cocircular_points.end(), \
|
||||
Cocircular_points.begin(), Cocircular_points.end(), chI ));
|
||||
assert( ch_brute_force_check_2( \
|
||||
Cocircular_points.begin(), Cocircular_points.begin(), \
|
||||
Cocircular_points.begin(), Cocircular_points.end(), chI ));
|
||||
assert( ch__test( Cocircular_points.begin(), \
|
||||
Cocircular_points.end(), \
|
||||
chI, ch_ALL, ch_CHECK_CONVEXITY ));
|
||||
std::vector< Point_2 > extreme_points;
|
||||
convex_hull_2(Cocircular_points.begin(), Cocircular_points.end(),
|
||||
std::back_inserter(extreme_points), chI );
|
||||
assert( is_ccw_strongly_convex_2( extreme_points.begin(), \
|
||||
extreme_points.begin(), \
|
||||
chI ));
|
||||
assert( is_cw_strongly_convex_2( extreme_points.rend(),
|
||||
extreme_points.rend(), \
|
||||
chI ));
|
||||
assert( is_ccw_strongly_convex_2( extreme_points.begin(), \
|
||||
extreme_points.begin() + 1, chI ));
|
||||
assert( is_cw_strongly_convex_2( extreme_points.begin(), \
|
||||
extreme_points.begin() + 1, chI ));
|
||||
assert( is_ccw_strongly_convex_2( extreme_points.begin(), \
|
||||
extreme_points.end(), \
|
||||
chI ));
|
||||
assert( is_cw_strongly_convex_2( extreme_points.rbegin(),
|
||||
extreme_points.rend(), \
|
||||
chI ));
|
||||
|
||||
std::cout << '.';
|
||||
std::vector< Point_2 > Collinear_points;
|
||||
Collinear_points.push_back( Point_2( 16, 20, 1 ));
|
||||
Collinear_points.push_back( Point_2( 46, 40, 1 ));
|
||||
Collinear_points.push_back( Point_2( 76, 60, 1 ));
|
||||
Collinear_points.push_back( Point_2( 106, 80, 1 ));
|
||||
Collinear_points.push_back( Point_2( -14, 0 , 1));
|
||||
Collinear_points.push_back( Point_2( 136, 100, 1 ));
|
||||
assert( ch__test( Collinear_points.begin(), \
|
||||
Collinear_points.end(), chI ));
|
||||
|
||||
std::cout << '.';
|
||||
std::vector< Point_2 > Multiple_points;
|
||||
Multiple_points.push_back( Point_2( 17, 80, 1 ));
|
||||
Multiple_points.push_back( Point_2( 17, 80, 1 ));
|
||||
Multiple_points.push_back( Point_2( 17, 80, 1 ));
|
||||
Multiple_points.push_back( Point_2( 17, 80, 1 ));
|
||||
assert( ch_brute_force_check_2( \
|
||||
Multiple_points.begin(), Multiple_points.end(),\
|
||||
Multiple_points.begin(), Multiple_points.begin() + 1, chI ));
|
||||
assert( is_ccw_strongly_convex_2(Multiple_points.begin(), \
|
||||
Multiple_points.begin(), chI ));
|
||||
assert( ch__test( Multiple_points.begin(), \
|
||||
Multiple_points.end(), chI ));
|
||||
assert( ch__test( Multiple_points.begin() + 2, \
|
||||
Multiple_points.begin() + 3, chI ));
|
||||
|
||||
std::cout << '.';
|
||||
std::vector< Point_2 > Iso_rectangle_points;
|
||||
Iso_rectangle_points.push_back( Point_2( 15, 0, 1 ));
|
||||
Iso_rectangle_points.push_back( Point_2( 45, 0, 1 ));
|
||||
Iso_rectangle_points.push_back( Point_2( 70, 0, 10 ));
|
||||
Iso_rectangle_points.push_back( Point_2( 12, 0, 1 ));
|
||||
Iso_rectangle_points.push_back( Point_2( 56, 118, 1 ));
|
||||
Iso_rectangle_points.push_back( Point_2( 27, 118, 1 ));
|
||||
Iso_rectangle_points.push_back( Point_2( 56, 118, 1 ));
|
||||
Iso_rectangle_points.push_back( Point_2( 112, 118, 1));
|
||||
Iso_rectangle_points.push_back( Point_2( 0, 9, 1));
|
||||
Iso_rectangle_points.push_back( Point_2( 0, 78, 1));
|
||||
Iso_rectangle_points.push_back( Point_2( 0, 16, 1));
|
||||
Iso_rectangle_points.push_back( Point_2( 0, 77, 1));
|
||||
Iso_rectangle_points.push_back( Point_2( 150, 56, 1));
|
||||
Iso_rectangle_points.push_back( Point_2( 150, 57, 1));
|
||||
Iso_rectangle_points.push_back( Point_2( 150, 58, 1));
|
||||
Iso_rectangle_points.push_back( Point_2( 150, 58, 1));
|
||||
assert( ch__test( Iso_rectangle_points.begin(), \
|
||||
Iso_rectangle_points.end(), chI ));
|
||||
assert( ch__test( Iso_rectangle_points.begin(), \
|
||||
Iso_rectangle_points.begin()+3, chI ));
|
||||
assert( ch__test( Iso_rectangle_points.begin()+4, \
|
||||
Iso_rectangle_points.begin()+7, chI ));
|
||||
assert( ch__test( Iso_rectangle_points.begin()+5, \
|
||||
Iso_rectangle_points.begin()+5, chI ));
|
||||
|
||||
std::cout << "done" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
#endif // _TEST_FCT_CH_I_2_IMPL_H
|
||||
|
|
@ -29,46 +29,210 @@
|
|||
#include <CGAL/ch_eddy.h>
|
||||
#include <CGAL/ch_bykat.h>
|
||||
#include <CGAL/ch_jarvis.h>
|
||||
#include <CGAL/ch_melkman.h>
|
||||
|
||||
#include <CGAL/Polygon_2_algorithms.h>
|
||||
|
||||
#include <array>
|
||||
#include <iterator>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
enum ch_Algorithm{ ch_JARVIS,
|
||||
ch_GRAHAM_ANDREW,
|
||||
ch_EDDY,
|
||||
ch_BYKAT,
|
||||
ch_BYKAT_WITH_THRESHOLD,
|
||||
ch_LOWER_UPPER,
|
||||
ch_AKL_TOUSSAINT,
|
||||
ch_ALL,
|
||||
ch_DEFAULT };
|
||||
enum ch_Algorithm
|
||||
{
|
||||
ch_AKL_TOUSSAINT = 0,
|
||||
ch_BYKAT,
|
||||
ch_BYKAT_WITH_THRESHOLD,
|
||||
ch_EDDY,
|
||||
ch_JARVIS,
|
||||
ch_GRAHAM_ANDREW,
|
||||
ch_LOWER_UPPER,
|
||||
ch_MELKMAN,
|
||||
ch_ALL,
|
||||
ch_DEFAULT
|
||||
};
|
||||
|
||||
enum ch_Check_status{ ch_CHECK_ALL,
|
||||
ch_CHECK_CONVEXITY,
|
||||
ch_CHECK_CONTAINEMENT,
|
||||
ch_NO_CHECK };
|
||||
static std::array<std::string, 10> algorithm_names = {{ "AKL TOUSSAINT",
|
||||
"BYKAT",
|
||||
"BYKAT WITH THRESHOLD",
|
||||
"EDDY",
|
||||
"JARVIS",
|
||||
"GRAHAM ANDREW",
|
||||
"LOWER UPPER",
|
||||
"MELKMAN",
|
||||
"ALL",
|
||||
"DEFAULT"
|
||||
}};
|
||||
|
||||
enum ch_Check_status
|
||||
{
|
||||
ch_CHECK_ALL,
|
||||
ch_CHECK_CONVEXITY,
|
||||
ch_CHECK_CONTAINEMENT,
|
||||
ch_NO_CHECK
|
||||
};
|
||||
|
||||
// Also compare the results
|
||||
template <typename InputIterator, typename Traits>
|
||||
bool test_all_and_compare(InputIterator first, InputIterator beyond,
|
||||
const Traits& ch_traits,
|
||||
ch_Check_status check_level = ch_CHECK_ALL)
|
||||
{
|
||||
using Point_2 = typename Traits::Point_2;
|
||||
|
||||
bool call_melkman = is_simple_2(first, beyond, ch_traits);
|
||||
|
||||
std::cout << "Input:";
|
||||
InputIterator first_o = first;
|
||||
for(; first_o!=beyond;++first_o)
|
||||
std::cout << " " << first_o->x() << " " << first_o->y() << " 0";
|
||||
std::cout << std::endl;
|
||||
|
||||
if(!ch__test(first, beyond, ch_traits, ch_AKL_TOUSSAINT, check_level))
|
||||
return false;
|
||||
if(!ch__test(first, beyond, ch_traits, ch_BYKAT, check_level))
|
||||
return false;
|
||||
if(!ch__test(first, beyond, ch_traits, ch_BYKAT_WITH_THRESHOLD, check_level))
|
||||
return false;
|
||||
if(!ch__test(first, beyond, ch_traits, ch_EDDY, check_level))
|
||||
return false;
|
||||
if(!ch__test(first, beyond, ch_traits, ch_JARVIS, check_level))
|
||||
return false;
|
||||
if(!ch__test(first, beyond, ch_traits, ch_GRAHAM_ANDREW, check_level))
|
||||
return false;
|
||||
if(!ch__test(first, beyond, ch_traits, ch_LOWER_UPPER, check_level))
|
||||
return false;
|
||||
if(call_melkman)
|
||||
{
|
||||
if(!ch__test(first, beyond, ch_traits, ch_MELKMAN, check_level))
|
||||
return false;
|
||||
}
|
||||
|
||||
std::set<Point_2> V0;
|
||||
ch_akl_toussaint(first, beyond, std::inserter(V0, V0.end()), ch_traits);
|
||||
|
||||
{
|
||||
std::set<Point_2> V0_other;
|
||||
ch_bykat(first, beyond, std::inserter(V0_other, V0_other.end()), ch_traits);
|
||||
assert(V0 == V0_other);
|
||||
}
|
||||
|
||||
{
|
||||
std::set<Point_2> V0_other;
|
||||
ch_bykat_with_threshold(first, beyond, std::inserter(V0_other, V0_other.end()), ch_traits);
|
||||
assert(V0 == V0_other);
|
||||
}
|
||||
|
||||
{
|
||||
std::set<Point_2> V0_other;
|
||||
ch_eddy(first, beyond, std::inserter(V0_other, V0_other.end()), ch_traits);
|
||||
assert(V0 == V0_other);
|
||||
}
|
||||
|
||||
{
|
||||
std::set<Point_2> V0_other;
|
||||
ch_jarvis(first, beyond, std::inserter(V0_other, V0_other.end()), ch_traits);
|
||||
assert(V0 == V0_other);
|
||||
}
|
||||
|
||||
{
|
||||
std::set<Point_2> V0_other;
|
||||
ch_graham_andrew(first, beyond, std::inserter(V0_other, V0_other.end()), ch_traits);
|
||||
assert(V0 == V0_other);
|
||||
}
|
||||
|
||||
{
|
||||
std::set<Point_2> V0_other;
|
||||
lower_hull_points_2(first, beyond, std::inserter(V0_other, V0_other.end()), ch_traits);
|
||||
upper_hull_points_2(first, beyond, std::inserter(V0_other, V0_other.end()), ch_traits);
|
||||
assert(V0 == V0_other);
|
||||
}
|
||||
|
||||
if(call_melkman)
|
||||
{
|
||||
std::cout << "Simple polyline, proceed with melkman check" << std::endl;
|
||||
std::set<Point_2> V0_other;
|
||||
ch_melkman(first, beyond, std::inserter(V0_other, V0_other.end()), ch_traits);
|
||||
|
||||
assert(V0 == V0_other);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Cannot call melkman on non-simple polyline" << std::endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class InputIterator, class Traits>
|
||||
bool
|
||||
ch__test(InputIterator first, InputIterator last,
|
||||
const Traits& ch_traits,
|
||||
ch_Algorithm alg,
|
||||
ch_Check_status check_level);
|
||||
ch__test(InputIterator first, InputIterator beyond,
|
||||
const Traits& ch_traits,
|
||||
ch_Algorithm alg = ch_ALL,
|
||||
ch_Check_status check_level = ch_CHECK_ALL)
|
||||
{
|
||||
using Point_2 = typename Traits::Point_2;
|
||||
std::vector<Point_2> VI(first, beyond);
|
||||
std::vector<Point_2> VO;
|
||||
|
||||
template <class InputIterator, class Traits>
|
||||
bool
|
||||
ch__test(InputIterator first, InputIterator last,
|
||||
const Traits& ch_traits,
|
||||
ch_Algorithm alg);
|
||||
using V_iter = typename std::vector<Point_2>::iterator;
|
||||
V_iter VIfirst = VI.begin();
|
||||
V_iter VIlast = VI.end();
|
||||
|
||||
template <class InputIterator, class Traits>
|
||||
bool
|
||||
ch__test(InputIterator first, InputIterator last,
|
||||
const Traits& ch_traits);
|
||||
std::cout << "Algorithm: " << algorithm_names[std::size_t(alg)] << std::endl;
|
||||
switch(alg)
|
||||
{
|
||||
case ch_AKL_TOUSSAINT:
|
||||
ch_akl_toussaint(first, beyond, std::back_inserter(VO), ch_traits);
|
||||
break;
|
||||
case ch_BYKAT:
|
||||
ch_bykat(first, beyond, std::back_inserter(VO), ch_traits);
|
||||
break;
|
||||
case ch_BYKAT_WITH_THRESHOLD:
|
||||
ch_bykat_with_threshold(first, beyond, std::back_inserter(VO), ch_traits);
|
||||
break;
|
||||
case ch_EDDY:
|
||||
ch_eddy(first, beyond, std::back_inserter(VO), ch_traits);
|
||||
break;
|
||||
case ch_JARVIS:
|
||||
ch_jarvis(first, beyond, std::back_inserter(VO), ch_traits);
|
||||
break;
|
||||
case ch_GRAHAM_ANDREW:
|
||||
ch_graham_andrew(first, beyond, std::back_inserter(VO), ch_traits);
|
||||
break;
|
||||
case ch_LOWER_UPPER:
|
||||
lower_hull_points_2(first, beyond, std::back_inserter(VO), ch_traits);
|
||||
upper_hull_points_2(first, beyond, std::back_inserter(VO), ch_traits);
|
||||
break;
|
||||
case ch_MELKMAN:
|
||||
ch_melkman(first, beyond, std::back_inserter(VO), ch_traits);
|
||||
break;
|
||||
case ch_ALL:
|
||||
return test_all_and_compare(first, beyond, ch_traits, check_level);
|
||||
case ch_DEFAULT:
|
||||
default:
|
||||
convex_hull_2(first, beyond, std::back_inserter(VO), ch_traits);
|
||||
break;
|
||||
}
|
||||
|
||||
switch(check_level)
|
||||
{
|
||||
case ch_CHECK_CONVEXITY:
|
||||
return is_ccw_strongly_convex_2(VO.begin(), VO.end(), ch_traits);
|
||||
case ch_CHECK_CONTAINEMENT:
|
||||
return ch_brute_force_check_2(first, beyond, VO.begin(), VO.end(), ch_traits);
|
||||
case ch_NO_CHECK:
|
||||
return true;
|
||||
case ch_CHECK_ALL:
|
||||
default:
|
||||
return is_ccw_strongly_convex_2(VO.begin(), VO.end(), ch_traits) &&
|
||||
ch_brute_force_check_2(first, beyond, VO.begin(), VO.end(), ch_traits);
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
#include <CGAL/ch__test_impl.h>
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_CH__TEST_H
|
||||
|
|
|
|||
|
|
@ -1,290 +0,0 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// Copyright (c) 1999 The CGAL Consortium
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// file : ch__test.C
|
||||
// revision : $Id$
|
||||
// revision_date : $Date$
|
||||
// author(s) : Stefan Schirra
|
||||
//
|
||||
// coordinator : MPI, Saarbruecken
|
||||
// ============================================================================
|
||||
|
||||
|
||||
#ifndef CGAL_CH__TEST_IMPL_H
|
||||
#define CGAL_CH__TEST_IMPL_H
|
||||
|
||||
#include <CGAL/ch__test.h>
|
||||
|
||||
namespace CGAL {
|
||||
template <class InputIterator, class Traits>
|
||||
bool
|
||||
ch__test(InputIterator first, InputIterator last, const Traits& ch_traits)
|
||||
{
|
||||
ch_Algorithm alg = ch_ALL;
|
||||
ch_Check_status check_level = ch_CHECK_ALL;
|
||||
typedef typename Traits::Point_2 Point_2;
|
||||
std::vector< Point_2 > VI (first, last);
|
||||
std::vector< Point_2 > VO;
|
||||
typedef typename std::vector< Point_2 >::iterator V_iter;
|
||||
V_iter VIfirst = VI.begin();
|
||||
V_iter VIlast = VI.end();
|
||||
switch (alg)
|
||||
{
|
||||
case ch_JARVIS:
|
||||
ch_jarvis(VIfirst, VIlast, std::back_inserter(VO), ch_traits);
|
||||
break;
|
||||
case ch_GRAHAM_ANDREW:
|
||||
ch_graham_andrew(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_EDDY:
|
||||
ch_eddy(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_AKL_TOUSSAINT:
|
||||
ch_akl_toussaint( VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_BYKAT:
|
||||
ch_bykat(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_BYKAT_WITH_THRESHOLD:
|
||||
ch_bykat_with_threshold(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_LOWER_UPPER:
|
||||
lower_hull_points_2(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
upper_hull_points_2(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_ALL:
|
||||
return
|
||||
ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_JARVIS, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_GRAHAM_ANDREW, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_EDDY, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_BYKAT, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_BYKAT_WITH_THRESHOLD, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_LOWER_UPPER, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_AKL_TOUSSAINT, check_level);
|
||||
case ch_DEFAULT:
|
||||
default:
|
||||
convex_hull_2( VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (check_level)
|
||||
{
|
||||
case ch_CHECK_CONVEXITY:
|
||||
return is_ccw_strongly_convex_2( VO.begin(), VO.end(),
|
||||
ch_traits);
|
||||
case ch_CHECK_CONTAINEMENT:
|
||||
return ch_brute_force_check_2( VIfirst, VIlast,
|
||||
VO.begin(), VO.end(),
|
||||
ch_traits);
|
||||
case ch_NO_CHECK:
|
||||
return true;
|
||||
case ch_CHECK_ALL:
|
||||
default:
|
||||
return is_ccw_strongly_convex_2( VO.begin(), VO.end(),
|
||||
ch_traits)
|
||||
&& ch_brute_force_check_2( VIfirst, VIlast,
|
||||
VO.begin(), VO.end(),
|
||||
ch_traits);
|
||||
}
|
||||
}
|
||||
|
||||
template <class InputIterator, class Traits>
|
||||
bool
|
||||
ch__test(InputIterator first, InputIterator last, const Traits& ch_traits,
|
||||
ch_Algorithm alg )
|
||||
{
|
||||
ch_Check_status check_level = ch_CHECK_ALL;
|
||||
typedef typename Traits::Point_2 Point_2;
|
||||
std::vector< Point_2 > VI (first, last);
|
||||
std::vector< Point_2 > VO;
|
||||
typedef typename std::vector< Point_2 >::iterator V_iter;
|
||||
V_iter VIfirst = VI.begin();
|
||||
V_iter VIlast = VI.end();
|
||||
switch (alg)
|
||||
{
|
||||
case ch_JARVIS:
|
||||
ch_jarvis(VIfirst, VIlast, std::back_inserter(VO), ch_traits);
|
||||
break;
|
||||
case ch_GRAHAM_ANDREW:
|
||||
ch_graham_andrew(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_EDDY:
|
||||
ch_eddy(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_AKL_TOUSSAINT:
|
||||
ch_akl_toussaint( VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_BYKAT:
|
||||
ch_bykat(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_BYKAT_WITH_THRESHOLD:
|
||||
ch_bykat_with_threshold(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_LOWER_UPPER:
|
||||
lower_hull_points_2(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
upper_hull_points_2(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_ALL:
|
||||
return
|
||||
ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_JARVIS, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_GRAHAM_ANDREW, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_EDDY, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_BYKAT, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_BYKAT_WITH_THRESHOLD, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_LOWER_UPPER, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_AKL_TOUSSAINT, check_level);
|
||||
case ch_DEFAULT:
|
||||
default:
|
||||
( VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (check_level)
|
||||
{
|
||||
case ch_CHECK_CONVEXITY:
|
||||
return is_ccw_strongly_convex_2( VO.begin(), VO.end(),
|
||||
ch_traits);
|
||||
case ch_CHECK_CONTAINEMENT:
|
||||
return ch_brute_force_check_2( VIfirst, VIlast,
|
||||
VO.begin(), VO.end(),
|
||||
ch_traits);
|
||||
case ch_NO_CHECK:
|
||||
return true;
|
||||
case ch_CHECK_ALL:
|
||||
default:
|
||||
return is_ccw_strongly_convex_2( VO.begin(), VO.end(),
|
||||
ch_traits)
|
||||
&& ch_brute_force_check_2( VIfirst, VIlast,
|
||||
VO.begin(), VO.end(),
|
||||
ch_traits);
|
||||
}
|
||||
}
|
||||
|
||||
template <class InputIterator, class Traits>
|
||||
bool
|
||||
ch__test(InputIterator first, InputIterator last, const Traits& ch_traits,
|
||||
ch_Algorithm alg, ch_Check_status check_level)
|
||||
{
|
||||
typedef typename Traits::Point_2 Point_2;
|
||||
std::vector< Point_2 > VI (first, last);
|
||||
std::vector< Point_2 > VO;
|
||||
typedef typename std::vector< Point_2 >::iterator V_iter;
|
||||
V_iter VIfirst = VI.begin();
|
||||
V_iter VIlast = VI.end();
|
||||
switch (alg)
|
||||
{
|
||||
case ch_JARVIS:
|
||||
ch_jarvis(VIfirst, VIlast, std::back_inserter(VO), ch_traits);
|
||||
break;
|
||||
case ch_GRAHAM_ANDREW:
|
||||
ch_graham_andrew(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_EDDY:
|
||||
ch_eddy(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_AKL_TOUSSAINT:
|
||||
ch_akl_toussaint( VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_BYKAT:
|
||||
ch_bykat(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_BYKAT_WITH_THRESHOLD:
|
||||
ch_bykat_with_threshold(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_LOWER_UPPER:
|
||||
lower_hull_points_2(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
upper_hull_points_2(VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
case ch_ALL:
|
||||
return
|
||||
ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_JARVIS, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_GRAHAM_ANDREW, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_EDDY, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_BYKAT, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_BYKAT_WITH_THRESHOLD, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_LOWER_UPPER, check_level)
|
||||
&& ch__test(VIfirst, VIlast, ch_traits,
|
||||
ch_AKL_TOUSSAINT, check_level);
|
||||
case ch_DEFAULT:
|
||||
default:
|
||||
convex_hull_2( VIfirst, VIlast, std::back_inserter(VO),
|
||||
ch_traits);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (check_level)
|
||||
{
|
||||
case ch_CHECK_CONVEXITY:
|
||||
return is_ccw_strongly_convex_2( VO.begin(), VO.end(),
|
||||
ch_traits);
|
||||
case ch_CHECK_CONTAINEMENT:
|
||||
return ch_brute_force_check_2( VIfirst, VIlast,
|
||||
VO.begin(), VO.end(),
|
||||
ch_traits);
|
||||
case ch_NO_CHECK:
|
||||
return true;
|
||||
case ch_CHECK_ALL:
|
||||
default:
|
||||
return is_ccw_strongly_convex_2( VO.begin(), VO.end(),
|
||||
ch_traits)
|
||||
&& ch_brute_force_check_2( VIfirst, VIlast,
|
||||
VO.begin(), VO.end(),
|
||||
ch_traits);
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
#endif // CGAL_CH__TEST_IMPL_H
|
||||
Loading…
Reference in New Issue