Fixed the test suite so that it can function also when GMP is not installed.

This commit is contained in:
Ron Wein 2006-03-12 10:41:39 +00:00
parent dcbb71487c
commit a56b61093b
5 changed files with 131 additions and 117 deletions

View File

@ -42,14 +42,16 @@ CGAL_BEGIN_NAMESPACE
* to creates the set of landmarks on the grid.
* the size of the grid is determined by the number of landmarks.
*/
template <class Arrangement_>
template <class Arrangement_, class NT_>
class Arr_grid_landmarks_generator
: public Arr_observer <Arrangement_>
{
public:
typedef Arrangement_ Arrangement_2;
typedef NT_ NT;
typedef Arr_grid_landmarks_generator<Arrangement_2, NT> Self;
typedef typename Arrangement_2::Traits_2 Traits_2;
typedef Arr_grid_landmarks_generator<Arrangement_2> Self;
typedef typename Arrangement_2::Vertex_const_iterator Vertex_const_iterator;
typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle;
typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle;
@ -62,13 +64,6 @@ public:
typedef typename Traits_2::Approximate_number_type ANT;
#ifdef SEGMENTS
typedef typename Traits_2::Kernel::FT FT;
#elif defined (CONICS)
typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Algebraic FT;
#endif
typedef typename Traits_2::Point_2 Point_2;
typedef std::vector<Point_2> Points_set;
@ -90,7 +85,7 @@ protected:
//bounding box of the arrangement
ANT x_min, x_max, y_min, y_max;
FT step_x, step_y;
NT step_x, step_y;
int sqrt_n;
private:
@ -271,8 +266,8 @@ protected:
//calculate the step size
sqrt_n = static_cast<int> (std::sqrt(static_cast<double> (n)) + 0.99999);
FT delta_x = right.x() - left.x();
FT delta_y = top.y() - bottom.y();
NT delta_x = right.x() - left.x();
NT delta_y = top.y() - bottom.y();
step_x = delta_x / (sqrt_n-1);
step_y = delta_y / (sqrt_n-1);

View File

@ -171,7 +171,7 @@ compile_and_run_trapped_test()
test_segment_traits()
{
# function executable number type kernel traits
compile_test test_traits $CGAL_GMPQ_NT $CARTESIAN_KERNEL $SEGMENT_TRAITS
compile_test test_traits $QUOTIENT_MP_FLOAT_NT $CARTESIAN_KERNEL $SEGMENT_TRAITS
if [ ${res} -eq 0 ] ; then
echo " ERROR: not executed test_traits" >> $ERRORFILE
else
@ -193,7 +193,7 @@ test_segment_traits()
test_non_caching_segment_traits()
{
# function executable number type kernel traits
compile_test test_traits $CGAL_GMPQ_NT $CARTESIAN_KERNEL $NON_CACHING_SEGMENT_TRAITS
compile_test test_traits $QUOTIENT_MP_FLOAT_NT $CARTESIAN_KERNEL $NON_CACHING_SEGMENT_TRAITS
if [ ${res} -eq 0 ] ; then
echo " ERROR: not executed test_traits" >> $ERRORFILE
else
@ -215,7 +215,7 @@ test_non_caching_segment_traits()
test_polyline_traits()
{
# function executable number type kernel traits
compile_test test_traits $CGAL_GMPQ_NT $CARTESIAN_KERNEL $POLYLINE_TRAITS
compile_test test_traits $QUOTIENT_MP_FLOAT_NT $CARTESIAN_KERNEL $POLYLINE_TRAITS
if [ ${res} -eq 0 ] ; then
echo " ERROR: not executed test_traits" >> $ERRORFILE
else
@ -237,7 +237,7 @@ test_polyline_traits()
test_non_caching_polyline_traits()
{
# function executable number type kernel traits
compile_test test_traits $CGAL_GMPQ_NT $CARTESIAN_KERNEL $NON_CACHING_POLYLINE_TRAITS
compile_test test_traits $QUOTIENT_MP_FLOAT_NT $CARTESIAN_KERNEL $NON_CACHING_POLYLINE_TRAITS
if [ ${res} -eq 0 ] ; then
echo " ERROR: not executed test_traits" >> $ERRORFILE
else

View File

@ -1,28 +1,26 @@
#include <CGAL/basic.h>
//#define CONICS
#define SEGMENTS
//#define SEGMENTS_IN_DOUBLE
#ifdef CGAL_USE_GMP
#include <CGAL/Gmpq.h>
typedef CGAL::Gmpq Number_type;
#else
#include <CGAL/MP_Float.h>
#include <CGAL/Quotient.h>
typedef CGAL::Quotient<CGAL::MP_Float> Number_type;
#endif
#include <CGAL/Cartesian.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Timer.h>
#include <cstdlib>
#ifdef SEGMENTS
#include <CGAL/Gmpq.h>
#include <CGAL/Arr_segment_traits_2.h>
#elif defined (CONICS)
#include <CGAL/CORE_algebraic_number_traits.h>
#include <CGAL/Arr_conic_traits_2.h>
#endif
#ifdef SEGMENTS_IN_DOUBLE
#include "Segment_reader_double.h"
#elif defined (SEGMENTS)
#include "Segment_reader.h"
#elif defined (CONICS)
#include "Conic_reader.h"
#endif
#include <CGAL/Arr_naive_point_location.h>
#include <CGAL/Arr_walk_along_line_point_location.h>
@ -32,31 +30,12 @@
#include <CGAL/Arr_point_location/Arr_lm_grid_generator.h>
#include <CGAL/Arr_point_location/Arr_lm_halton_generator.h>
#ifdef SEGMENTS
//#include <CGAL/Arr_triangulation_point_location.h>
#include <CGAL/Arr_point_location/Arr_lm_middle_edges_generator.h>
#endif
#ifdef SEGMENTS
typedef CGAL::Gmpq Number_type;
typedef CGAL::Cartesian<Number_type> Kernel;
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
#elif defined (CONICS)
typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Rational Number_type;
typedef Nt_traits::Algebraic Algebraic;
typedef CGAL::Cartesian<Rational> Rat_kernel;
typedef Rat_kernel::Point_2 Rat_point_2;
typedef Rat_kernel::Segment_2 Rat_segment_2;
typedef Rat_kernel::Circle_2 Rat_circle_2;
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
typedef CGAL::Arr_conic_traits_2<Rat_kernel,
Alg_kernel,
Nt_traits> Traits_2;
#endif
typedef Traits_2::Point_2 Point_2;
typedef Traits_2::Curve_2 Curve_2;
typedef Traits_2::X_monotone_curve_2 Segment_2;
@ -77,7 +56,7 @@ typedef CGAL::Arr_random_landmarks_generator<Arrangement_2>
Random_lm_generator;
typedef CGAL::Arr_landmarks_point_location<Arrangement_2, Random_lm_generator>
Lm_random_point_location;
typedef CGAL::Arr_grid_landmarks_generator<Arrangement_2>
typedef CGAL::Arr_grid_landmarks_generator<Arrangement_2, Number_type>
Grid_lm_generator;
typedef CGAL::Arr_landmarks_point_location<Arrangement_2, Grid_lm_generator>
Lm_grid_point_location;
@ -85,14 +64,13 @@ typedef CGAL::Arr_halton_landmarks_generator<Arrangement_2>
Halton_lm_generator;
typedef CGAL::Arr_landmarks_point_location<Arrangement_2, Halton_lm_generator>
Lm_halton_point_location;
#ifdef SEGMENTS
typedef CGAL::Arr_middle_edges_landmarks_generator<Arrangement_2>
Mide_lm_generator;
typedef CGAL::Arr_landmarks_point_location<Arrangement_2, Mide_lm_generator>
Lm_mide_point_location;
//typedef CGAL::Arr_triangulation_point_location<Arrangement_2>
// Trg_point_location;
#endif
// ===> Add new point location type here <===
typedef std::list<Point_2> Points_list;
@ -103,11 +81,7 @@ typedef Objects_vector::iterator Object_iterator;
// ===> Change the number of point-location startegies
// when a new point location is added. <===
#ifdef SEGMENTS
#define NUM_OF_POINT_LOCATION_STRATEGIES 8
#else
#define NUM_OF_POINT_LOCATION_STRATEGIES 7
#endif
/*! */
int check_point_location (Arrangement_2 &arr, Points_list &plist)
@ -158,7 +132,6 @@ int check_point_location (Arrangement_2 &arr, Points_list &plist)
std::cout << "Halton lm construction took " << timer.time() <<std::endl;
//std::cout << ' ' << timer.time() ;
#ifdef SEGMENTS
timer.reset(); timer.start();
Mide_lm_generator mide_g(arr);
Lm_mide_point_location mide_lm_pl (arr, &mide_g); // 7
@ -169,7 +142,6 @@ int check_point_location (Arrangement_2 &arr, Points_list &plist)
//Trg_point_location trg_pl(arr); // 8
//timer.stop();
//std::cout << "Trg construction took " << timer.time() <<std::endl;
#endif
std::cout<< std::endl;
// ===> Add new point location instance here. <===
@ -271,9 +243,7 @@ int check_point_location (Arrangement_2 &arr, Points_list &plist)
}
timer.stop(); ///END
std::cout << "Halton LM location took " << timer.time() <<std::endl;
// std::cout << ' ' << timer.time() ;
#ifdef SEGMENTS
std::cout << "Middle edges LM" ;
timer.reset();
timer.start(); //START
@ -297,7 +267,6 @@ int check_point_location (Arrangement_2 &arr, Points_list &plist)
//}
//timer.stop(); ///END
//std::cout << " location took " << timer.time() <<std::endl;
#endif
std::cout << std::endl;
// ===> Add a call to operate the the new point location. <===
@ -434,11 +403,7 @@ int read_points(const char * points_filename, Points_list &plist)
bool test(const char* curves_filename, const char* points_filename)
{
//read curves and insert them into the arrangement
#ifdef SEGMENTS
Segment_reader<Traits_2> reader;
#elif defined (CONICS)
Conic_reader<Traits_2> reader;
#endif
CGAL::Bbox_2 bbox;
Curve_list curve_list;

View File

@ -42,7 +42,7 @@
#endif
#if !defined(TEST_NT)
#define TEST_NT LEDA_RAT_NT
#define TEST_NT QUOTIENT_MP_FLOAT_NT
#endif
#if !defined(TEST_TRAITS)

View File

@ -1,10 +1,20 @@
#include <CGAL/basic.h>
#ifdef CGAL_USE_GMP
#include <CGAL/Gmpq.h>
typedef CGAL::Gmpq Number_type;
#else
#include <CGAL/MP_Float.h>
#include <CGAL/Quotient.h>
typedef CGAL::Quotient<CGAL::MP_Float> Number_type;
#endif
#include <CGAL/Simple_cartesian.h>
#include <CGAL/MP_Float.h>
#include <CGAL/Quotient.h>
#include <CGAL/Gmpq.h>
#include <CGAL/Arr_segment_traits_2.h>
#include<CGAL/Arr_curve_data_traits_2.h>
#include <CGAL/Arrangement_2.h>
@ -45,12 +55,15 @@ public:
};
template <class Arrangement>
bool are_same_results(Arrangement& arr,
bool are_same_results
(Arrangement& arr,
unsigned int n_v,
unsigned int n_e,
unsigned int n_f,
const std::vector<typename Arrangement::Point_2> &pts_from_file,
const std::vector<typename Arrangement::X_monotone_curve_2>& subcurves_from_file)
const std::vector<typename Arrangement::Point_2>&
pts_from_file,
const std::vector<typename Arrangement::X_monotone_curve_2>&
subcurves_from_file)
{
typedef typename Arrangement::Traits_2 Traits_2;
typedef typename Arrangement::Point_2 Point_2;
@ -92,13 +105,13 @@ bool are_same_results(Arrangement& arr,
std::sort(curves_res.begin(), curves_res.end(), Curve_compare<Traits_2>());
Curve_equal<Traits_2> curve_eq;
if(!std::equal(curves_res.begin(), curves_res.end(), subcurves_from_file.begin(), curve_eq))
if (! std::equal (curves_res.begin(), curves_res.end(),
subcurves_from_file.begin(), curve_eq))
return false;
return true;
}
typedef CGAL::Gmpq Number_type;
typedef CGAL::Simple_cartesian<Number_type> Kernel;
typedef CGAL::Arr_segment_traits_2<Kernel> Base_traits_2;
typedef Base_traits_2::Curve_2 Base_curve_2;
@ -165,33 +178,41 @@ bool test_one_file(std::ifstream& in_file)
{
CGAL::insert_curve(arr, curves[i]);
}
if(!are_same_results(arr, n_vertices, n_edges, n_faces, pts_from_file, subcurves_from_file) ||
!CGAL::is_valid(arr))
if (! are_same_results (arr,
n_vertices, n_edges, n_faces,
pts_from_file, subcurves_from_file) ||
! CGAL::is_valid(arr))
{
std::cout<<"ERROR : insert_curve failed\n";
return false;
}
arr.clear();
arr.clear();
////////////////////////////////////////////////////////////
// test aggregate construction
CGAL::insert_curves(arr, curves.begin(), curves.end());
if(!are_same_results(arr, n_vertices, n_edges, n_faces, pts_from_file, subcurves_from_file) ||
!CGAL::is_valid(arr))
if (! are_same_results (arr,
n_vertices, n_edges, n_faces,
pts_from_file, subcurves_from_file) ||
! CGAL::is_valid(arr))
{
std::cout<<"ERROR : insert_curves failed\n";
return false;
}
arr.clear();
/////////////////////////////////////////////////////////////
// insert half of the curves aggregatley and than insert the rest aggregatley
//(test the addition visitor)
// insert half of the curves aggregatley and than insert the rest
// aggregatley (test the addition visitor)
CGAL::insert_curves(arr, curves.begin(), curves.begin() + (num_of_curves/2));
CGAL::insert_curves(arr, curves.begin() + (num_of_curves/2), curves.end());
if(!are_same_results(arr, n_vertices, n_edges, n_faces, pts_from_file, subcurves_from_file) ||
!CGAL::is_valid(arr))
if (! are_same_results (arr,
n_vertices, n_edges, n_faces,
pts_from_file, subcurves_from_file) ||
! CGAL::is_valid(arr))
{
std::cout<<"ERROR : insert_curves (addition) failed\n";
return false;
@ -210,8 +231,10 @@ bool test_one_file(std::ifstream& in_file)
CGAL::insert_point(arr, iso_verts[i]);
}
if(!are_same_results(arr, n_vertices, n_edges, n_faces, pts_from_file, subcurves_from_file) ||
!CGAL::is_valid(arr))
if (! are_same_results (arr,
n_vertices, n_edges, n_faces,
pts_from_file, subcurves_from_file) ||
! CGAL::is_valid(arr))
{
std::cout<<"ERROR : insert_x_monotone_curve failed\n";
return false;
@ -219,13 +242,17 @@ bool test_one_file(std::ifstream& in_file)
arr.clear();
/////////////////////////////////////////////////////////////////////
// insert the disjoint subcurves aggregatley with insert_x_monotone_curves
CGAL::insert_x_monotone_curves(arr, subcurves_from_file.begin(), subcurves_from_file.end());
CGAL::insert_x_monotone_curves (arr,
subcurves_from_file.begin(),
subcurves_from_file.end());
for(i=0; i<iso_verts.size(); ++i)
{
CGAL::insert_point(arr, iso_verts[i]);
}
if(!are_same_results(arr, n_vertices, n_edges, n_faces, pts_from_file, subcurves_from_file) ||
!CGAL::is_valid(arr))
if (! are_same_results (arr,
n_vertices, n_edges, n_faces,
pts_from_file, subcurves_from_file) ||
! CGAL::is_valid(arr))
{
std::cout<<"ERROR : insert_x_monotone_curves failed\n";
return false;
@ -234,16 +261,23 @@ bool test_one_file(std::ifstream& in_file)
/////////////////////////////////////////////////////////////////////
// insert half of the disjoint subcurves aggregatley and than insert the rest aggregatley
//with insert_x_monotone_curves(test the addition visitor)
CGAL::insert_x_monotone_curves(arr, subcurves_from_file.begin(), subcurves_from_file.begin() + (n_edges/2));
CGAL::insert_x_monotone_curves(arr, subcurves_from_file.begin() + (n_edges/2), subcurves_from_file.end());
// insert half of the disjoint subcurves aggregatley and than insert the
// rest aggregatley with insert_x_monotone_curves(test the addition visitor)
CGAL::insert_x_monotone_curves (arr,
subcurves_from_file.begin(),
subcurves_from_file.begin() + (n_edges/2));
CGAL::insert_x_monotone_curves (arr,
subcurves_from_file.begin() + (n_edges/2),
subcurves_from_file.end());
for(i=0; i<iso_verts.size(); ++i)
{
CGAL::insert_point(arr, iso_verts[i]);
}
if(!are_same_results(arr, n_vertices, n_edges, n_faces, pts_from_file, subcurves_from_file) ||
!CGAL::is_valid(arr))
if (! are_same_results (arr,
n_vertices, n_edges, n_faces,
pts_from_file, subcurves_from_file) ||
! CGAL::is_valid(arr))
{
std::cout<<"ERROR : insert_x_monotone_curves (addition) failed\n";
return false;
@ -251,7 +285,8 @@ bool test_one_file(std::ifstream& in_file)
arr.clear();
/////////////////////////////////////////////////////////////////////
//insert the disjoint subcurves incrementally with insert_non_intersecting_curve
// insert the disjoint subcurves incrementally with
// insert_non_intersecting_curve
for(i=0; i<n_edges; ++i)
{
CGAL::insert_non_intersecting_curve(arr, subcurves_from_file[i]);
@ -260,8 +295,11 @@ bool test_one_file(std::ifstream& in_file)
{
CGAL::insert_point(arr, iso_verts[i]);
}
if(!are_same_results(arr, n_vertices, n_edges, n_faces, pts_from_file, subcurves_from_file) ||
!CGAL::is_valid(arr))
if (! are_same_results (arr,
n_vertices, n_edges, n_faces,
pts_from_file, subcurves_from_file) ||
! CGAL::is_valid(arr))
{
std::cout<<"ERROR : insert_non_intersecting_curve failed\n";
return false;
@ -269,14 +307,20 @@ bool test_one_file(std::ifstream& in_file)
arr.clear();
/////////////////////////////////////////////////////////////////////
// insert the disjoint subcurves aggregatley with insert_non_intersecting_curves
CGAL::insert_non_intersecting_curves(arr, subcurves_from_file.begin(), subcurves_from_file.end());
// insert the disjoint subcurves aggregatley with
// insert_non_intersecting_curves
CGAL::insert_non_intersecting_curves (arr,
subcurves_from_file.begin(),
subcurves_from_file.end());
for(i=0; i<iso_verts.size(); ++i)
{
CGAL::insert_point(arr, iso_verts[i]);
}
if(!are_same_results(arr, n_vertices, n_edges, n_faces, pts_from_file, subcurves_from_file) ||
!CGAL::is_valid(arr))
if (! are_same_results (arr,
n_vertices, n_edges, n_faces,
pts_from_file, subcurves_from_file) ||
! CGAL::is_valid(arr))
{
std::cout<<"ERROR : insert_non_intersecting_curves failed\n";
return false;
@ -285,23 +329,34 @@ bool test_one_file(std::ifstream& in_file)
// insert half of the disjoint subcurves aggregatley and than insert the rest aggregatley
//with insert_non_intersecting_curves(test the addition visitor)
CGAL::insert_non_intersecting_curves(arr, subcurves_from_file.begin(), subcurves_from_file.begin() + (n_edges/2));
CGAL::insert_non_intersecting_curves(arr, subcurves_from_file.begin() + (n_edges/2), subcurves_from_file.end());
// insert half of the disjoint subcurves aggregatley and than insert the
// rest aggregatley with insert_non_intersecting_curves (test the addition
// visitor)
CGAL::insert_non_intersecting_curves
(arr,
subcurves_from_file.begin(),
subcurves_from_file.begin() + (n_edges/2));
CGAL::insert_non_intersecting_curves
(arr,
subcurves_from_file.begin() + (n_edges/2),
subcurves_from_file.end());
for(i=0; i<iso_verts.size(); ++i)
{
CGAL::insert_point(arr, iso_verts[i]);
}
if(!are_same_results(arr, n_vertices, n_edges, n_faces, pts_from_file, subcurves_from_file) ||
!CGAL::is_valid(arr))
if (! are_same_results (arr,
n_vertices, n_edges, n_faces,
pts_from_file, subcurves_from_file) ||
! CGAL::is_valid(arr))
{
std::cout<<"ERROR : insert_non_intersecting_curves (addition) failed\n";
return false;
}
arr.clear();
return true;
}
@ -356,4 +411,3 @@ int main(int argc, char **argv)
return success;
}