From e9d3b9767eb30b943ae65c960c2a7715457fca0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 28 May 2018 15:43:45 +0200 Subject: [PATCH 1/3] Fixed taking a reference to a temporary (when using EPECK) --- Triangulation_2/include/CGAL/Regular_triangulation_2.h | 3 ++- Triangulation_3/include/CGAL/Regular_triangulation_3.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Triangulation_2/include/CGAL/Regular_triangulation_2.h b/Triangulation_2/include/CGAL/Regular_triangulation_2.h index 6d376be5f32..df801732320 100644 --- a/Triangulation_2/include/CGAL/Regular_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Regular_triangulation_2.h @@ -434,7 +434,8 @@ private: template struct Index_to_Bare_point { - const Bare_point& operator()(const std::size_t& i) const + typename boost::result_of::type + operator()(const std::size_t& i) const { return cp(c[i]); } diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_3.h index bdb6d561bba..130ea6f73e2 100644 --- a/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -425,7 +425,8 @@ namespace CGAL { template struct Index_to_Bare_point { - const Bare_point& operator()(const std::size_t& i) const + typename boost::result_of::type + operator()(const std::size_t& i) const { return cp(c[i]); } From 8fb3f1a7821ef1f531d50c54fe47537d5866ab8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 28 May 2018 15:45:02 +0200 Subject: [PATCH 2/3] Improved RT3's tests of "insertion with info" types of functions --- .../test_regular_insert_range_with_info.cpp | 354 ++++++++++-------- 1 file changed, 196 insertions(+), 158 deletions(-) diff --git a/Triangulation_3/test/Triangulation_3/test_regular_insert_range_with_info.cpp b/Triangulation_3/test/Triangulation_3/test_regular_insert_range_with_info.cpp index 8d4e95022f5..69c612696b5 100644 --- a/Triangulation_3/test/Triangulation_3/test_regular_insert_range_with_info.cpp +++ b/Triangulation_3/test/Triangulation_3/test_regular_insert_range_with_info.cpp @@ -1,184 +1,222 @@ - #include "test_dependencies.h" + #include +#include + #include #include + #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef K Traits; -typedef CGAL::Regular_triangulation_vertex_base_3 Vbb; -typedef CGAL::Triangulation_vertex_base_with_info_3 Vb; -typedef CGAL::Triangulation_data_structure_3 > Tds; -typedef CGAL::Regular_triangulation_3 Regular; -typedef K::Weighted_point_3 Weighted_point; -typedef K::Point_3 Point; +typedef CGAL::Exact_predicates_exact_constructions_kernel K; + +template +struct Tester +{ + typedef K Traits; + typedef CGAL::Regular_triangulation_vertex_base_3 Vbb; + typedef CGAL::Triangulation_vertex_base_with_info_3 Vb; + typedef CGAL::Regular_triangulation_cell_base_3 Cb; + typedef CGAL::Triangulation_data_structure_3 Tds; + + typedef CGAL::Regular_triangulation_3 RT; + typedef typename RT::Bare_point Bare_point; + typedef typename RT::Weighted_point Weighted_point; #ifdef CGAL_LINKED_WITH_TBB -typedef CGAL::Spatial_lock_grid_3 Lock_ds; -typedef CGAL::Triangulation_data_structure_3, CGAL::Parallel_tag> Tds_parallel; -typedef CGAL::Regular_triangulation_3 RT_parallel; + typedef CGAL::Spatial_lock_grid_3 Lock_ds; + typedef CGAL::Triangulation_data_structure_3 Tds_parallel; + typedef CGAL::Regular_triangulation_3 RT_parallel; #endif -template -void test_iterator_on_pair(){ - typedef std::vector< std::pair > Container; - typedef typename boost::mpl::if_< boost::mpl::bool_,boost::add_const::type,Container >::type Cast_type; - Container points; - - - points.push_back( std::make_pair( Weighted_point(Point(0,0,0),1),0 ) ); - points.push_back( std::make_pair( Weighted_point(Point(1,0,0),2),1 ) ); - points.push_back( std::make_pair( Weighted_point(Point(0,1,0),3),2 ) ); - points.push_back( std::make_pair( Weighted_point(Point(0,0,1),4),3 ) ); - points.push_back( std::make_pair( Weighted_point(Point(2,2,2),5),4 ) ); - points.push_back( std::make_pair( Weighted_point(Point(-1,0,1),6),5 ) ); - - - Regular R( static_cast(points).begin(),static_cast(points).end() ); - - assert( R.number_of_vertices() == 6 ); - - // check that the info was correctly set. - Regular::Finite_vertices_iterator vit; - for (vit = R.finite_vertices_begin(); vit != R.finite_vertices_end(); ++vit) - assert(points[vit->info()].first == vit->point()); - -#ifdef CGAL_LINKED_WITH_TBB + template + void test_iterator_on_pair() const { - // Construct the locking data-structure, using the bounding-box of the points - typename RT_parallel::Lock_data_structure locking_ds( - CGAL::Bbox_3(-1., 0., 0., 2, 2, 2), 50); - // Contruct the triangulation in parallel - RT_parallel R( - static_cast(points).begin(), - static_cast(points).end(), - &locking_ds); + typedef std::vector > Container; + typedef typename boost::mpl::if_, + typename boost::add_const::type, + Container>::type Cast_type; - assert(R.number_of_vertices() == 6); + Container points; + points.push_back(std::make_pair(Weighted_point(Bare_point(0.160385, 0.599679, 0.374932), -0.118572), 0)); + points.push_back(std::make_pair(Weighted_point(Bare_point(0.17093, 0.82228, 0.51697), -0.0226131), 1)); + points.push_back(std::make_pair(Weighted_point(Bare_point(0.15773, 0.66293, 0.458541), -0.0753074), 2)); + points.push_back(std::make_pair(Weighted_point(Bare_point(0.388417, 0.685989, 0.401349), -0.0616195), 3)); + points.push_back(std::make_pair(Weighted_point(Bare_point(0.380061, 0.852124, 0.538984), -0.0145638), 4)); + points.push_back(std::make_pair(Weighted_point(Bare_point(0.0402467, 0.519724, 0.417205), -0.0698374), 5)); + points.push_back(std::make_pair(Weighted_point(Bare_point(0.0270472, 0.360373, 0.358776), -0.0109982), 6)); + points.push_back(std::make_pair(Weighted_point(Bare_point(0.257734, 0.383432, 0.301584), -0.0601458), 7)); + points.push_back(std::make_pair(Weighted_point(Bare_point(0.142091, 0.643406, 0.61943), -0.251061), 8)); - // check that the info was correctly set. - RT_parallel::Finite_vertices_iterator vit; - for (vit = R.finite_vertices_begin(); vit != R.finite_vertices_end(); ++vit) - assert(points[vit->info()].first == vit->point()); - } + RT R(static_cast(points).begin(), static_cast(points).end()); + assert(R.number_of_vertices() == 9); + + R.clear(); + R.insert(static_cast(points).begin(), static_cast(points).end()); + assert(R.number_of_vertices() == 9); + + // check that the info was correctly set. + typename RT::Finite_vertices_iterator vit; + for(vit = R.finite_vertices_begin(); vit != R.finite_vertices_end(); ++vit) + assert(points[vit->info()].first == vit->point()); + + #ifdef CGAL_LINKED_WITH_TBB + { + // Construct the locking data-structure, using the bounding-box of the points + typename RT_parallel::Lock_data_structure locking_ds(CGAL::Bbox_3(-1., 0., 0., 2, 2, 2), 50); + + // Contruct the triangulation in parallel + RT_parallel R(static_cast(points).begin(), static_cast(points).end(), &locking_ds); + assert(R.number_of_vertices() == 9); + + R.clear(); + R.insert(static_cast(points).begin(), static_cast(points).end(), &locking_ds); + assert(R.number_of_vertices() == 9); + + // check that the info was correctly set. + typename RT_parallel::Finite_vertices_iterator vit; + for(vit = R.finite_vertices_begin(); vit != R.finite_vertices_end(); ++vit) { + assert(points[vit->info()].first == vit->point()); + } + } #endif -} + } -void toto(int){} - -template -void test_zip_iterator(){ - typedef std::vector< Weighted_point > Container; - Container points; - typedef typename boost::mpl::if_< boost::mpl::bool_,boost::add_const::type,Container >::type Cast_type; - - points.push_back( Weighted_point(Point(0,0,0),1) ); - points.push_back( Weighted_point(Point(1,0,0),2) ); - points.push_back( Weighted_point(Point(0,1,0),3) ); - points.push_back( Weighted_point(Point(0,0,1),4) ); - points.push_back( Weighted_point(Point(2,2,2),5) ); - points.push_back( Weighted_point(Point(-1,0,1),6) ); - - std::vector indices; - indices.push_back(0); - indices.push_back(1); - indices.push_back(2); - indices.push_back(3); - indices.push_back(4); - indices.push_back(5); - - Regular R( boost::make_zip_iterator(boost::make_tuple( static_cast(points).begin(),indices.begin() )), - boost::make_zip_iterator(boost::make_tuple( static_cast(points).end(),indices.end() ) ) ); - assert( R.number_of_vertices() == 6 ); - - // check that the info was correctly set. - Regular::Finite_vertices_iterator vit; - for (vit = R.finite_vertices_begin(); vit != R.finite_vertices_end(); ++vit) - assert( points[ vit->info() ] == vit->point() ); - -#ifdef CGAL_LINKED_WITH_TBB + template + void test_zip_iterator() const { - // Construct the locking data-structure, using the bounding-box of the points - typename RT_parallel::Lock_data_structure locking_ds( - CGAL::Bbox_3(-1., 0., 0., 2, 2, 2), 50); - // Contruct the triangulation in parallel - RT_parallel R( - boost::make_zip_iterator(boost::make_tuple(static_cast(points).begin(), indices.begin())), - boost::make_zip_iterator(boost::make_tuple(static_cast(points).end(), indices.end())), - &locking_ds); + typedef std::vector Container; + typedef typename boost::mpl::if_, + typename boost::add_const::type, + Container >::type Cast_type; - assert(R.number_of_vertices() == 6); + Container points; + points.push_back(Weighted_point(Bare_point(0,0,0),1)); + points.push_back(Weighted_point(Bare_point(1,0,0),2)); + points.push_back(Weighted_point(Bare_point(0,1,0),3)); + points.push_back(Weighted_point(Bare_point(0,0,1),4)); + points.push_back(Weighted_point(Bare_point(2,2,2),5)); + points.push_back(Weighted_point(Bare_point(-1,0,1),6)); - // check that the info was correctly set. - RT_parallel::Finite_vertices_iterator vit; - for (vit = R.finite_vertices_begin(); vit != R.finite_vertices_end(); ++vit) - assert(points[vit->info()] == vit->point()); - } + std::vector indices; + indices.push_back(0); + indices.push_back(1); + indices.push_back(2); + indices.push_back(3); + indices.push_back(4); + indices.push_back(5); + + RT R(boost::make_zip_iterator(boost::make_tuple(static_cast(points).begin(), indices.begin())), + boost::make_zip_iterator(boost::make_tuple(static_cast(points).end(), indices.end()))); + assert(R.number_of_vertices() == 6); + + // check that the info was correctly set. + typename RT::Finite_vertices_iterator vit; + for(vit = R.finite_vertices_begin(); vit != R.finite_vertices_end(); ++vit) + assert(points[ vit->info() ] == vit->point()); + +#ifdef CGAL_LINKED_WITH_TBB + { + // Construct the locking data-structure, using the bounding-box of the points + typename RT_parallel::Lock_data_structure locking_ds(CGAL::Bbox_3(-1., 0., 0., 2, 2, 2), 50); + + // Contruct the triangulation in parallel + RT_parallel R(boost::make_zip_iterator(boost::make_tuple(static_cast(points).begin(), indices.begin())), + boost::make_zip_iterator(boost::make_tuple(static_cast(points).end(), indices.end())), + &locking_ds); + assert(R.number_of_vertices() == 6); + + // check that the info was correctly set. + typename RT_parallel::Finite_vertices_iterator vit; + for(vit = R.finite_vertices_begin(); vit != R.finite_vertices_end(); ++vit) { + assert(points[vit->info()] == vit->point()); + } + } #endif -} + } -struct Auto_count : public std::unary_function >{ - mutable unsigned i; - Auto_count() : i(0){} - std::pair operator()(const Weighted_point& p) const { - return std::make_pair(p,i++); + struct Auto_count + : public std::unary_function > + { + mutable unsigned i; + Auto_count() : i(0){} + std::pair operator()(const Weighted_point& p) const + { + return std::make_pair(p,i++); + } + }; + + template + void test_transform_iterator() const + { + typedef std::vector< Weighted_point > Container; + typedef typename boost::mpl::if_, + typename boost::add_const::type, + Container >::type Cast_type; + + Container points; + points.push_back(Weighted_point(Bare_point(0,0,0),1)); + points.push_back(Weighted_point(Bare_point(1,0,0),2)); + points.push_back(Weighted_point(Bare_point(0,1,0),3)); + points.push_back(Weighted_point(Bare_point(0,0,1),4)); + points.push_back(Weighted_point(Bare_point(2,2,2),5)); + points.push_back(Weighted_point(Bare_point(-1,0,1),6)); + + RT R(boost::make_transform_iterator(static_cast(points).begin(), Auto_count()), + boost::make_transform_iterator(static_cast(points).end(), Auto_count())); + + assert(R.number_of_vertices() == 6); + + // check that the info was correctly set. + typename RT::Finite_vertices_iterator vit; + for(vit = R.finite_vertices_begin(); vit != R.finite_vertices_end(); ++vit) + assert(points[ vit->info() ] == vit->point()); + +#ifdef CGAL_LINKED_WITH_TBB + { + // Construct the locking data-structure, using the bounding-box of the points + typename RT_parallel::Lock_data_structure locking_ds(CGAL::Bbox_3(-1., 0., 0., 2, 2, 2), 50); + + // Contruct the triangulation in parallel + RT_parallel R(boost::make_transform_iterator(static_cast(points).begin(), Auto_count()), + boost::make_transform_iterator(static_cast(points).end(), Auto_count()), + &locking_ds); + assert(R.number_of_vertices() == 6); + + // check that the info was correctly set. + typename RT_parallel::Finite_vertices_iterator vit; + for(vit = R.finite_vertices_begin(); vit != R.finite_vertices_end(); ++vit) { + assert(points[vit->info()] == vit->point()); + } + } +#endif + } + + void operator()() const + { + test_iterator_on_pair(); + test_iterator_on_pair(); + test_zip_iterator(); + test_zip_iterator(); + test_transform_iterator(); + test_transform_iterator(); } }; -template -void test_transform_iterator(){ - typedef std::vector< Weighted_point > Container; - Container points; - typedef typename boost::mpl::if_< boost::mpl::bool_,boost::add_const::type,Container >::type Cast_type; - - points.push_back( Weighted_point(Point(0,0,0),1) ); - points.push_back( Weighted_point(Point(1,0,0),2) ); - points.push_back( Weighted_point(Point(0,1,0),3) ); - points.push_back( Weighted_point(Point(0,0,1),4) ); - points.push_back( Weighted_point(Point(2,2,2),5) ); - points.push_back( Weighted_point(Point(-1,0,1),6) ); - - Regular R( boost::make_transform_iterator(static_cast(points).begin(),Auto_count()), - boost::make_transform_iterator(static_cast(points).end(), Auto_count() ) ); - - assert( R.number_of_vertices() == 6 ); - - // check that the info was correctly set. - Regular::Finite_vertices_iterator vit; - for (vit = R.finite_vertices_begin(); vit != R.finite_vertices_end(); ++vit) - assert( points[ vit->info() ] == vit->point() ); - -#ifdef CGAL_LINKED_WITH_TBB - { - // Construct the locking data-structure, using the bounding-box of the points - typename RT_parallel::Lock_data_structure locking_ds( - CGAL::Bbox_3(-1., 0., 0., 2, 2, 2), 50); - // Contruct the triangulation in parallel - RT_parallel R( - boost::make_transform_iterator(static_cast(points).begin(), Auto_count()), - boost::make_transform_iterator(static_cast(points).end(), Auto_count()), - &locking_ds); - - assert(R.number_of_vertices() == 6); - - // check that the info was correctly set. - RT_parallel::Finite_vertices_iterator vit; - for (vit = R.finite_vertices_begin(); vit != R.finite_vertices_end(); ++vit) - assert(points[vit->info()] == vit->point()); - } -#endif -} - int main() { - test_iterator_on_pair(); - test_iterator_on_pair(); - test_zip_iterator(); - test_zip_iterator(); - test_transform_iterator(); - test_transform_iterator(); - return 0; -} + typedef CGAL::Exact_predicates_inexact_constructions_kernel Epick; + typedef CGAL::Exact_predicates_exact_constructions_kernel Epeck; + std::cerr << "TESTING WITH Exact_predicates_inexact_constructions_kernel...\n"; + Tester test_epic; + test_epic(); + + std::cerr << "TESTING WITH Exact_predicates_exact_constructions_kernel...\n"; + Tester test_epec; + test_epec(); + + return EXIT_SUCCESS; +} From 8ac412cb8a7c38c0b8f77d700c861e7de8a0cc9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 29 May 2018 15:29:19 +0200 Subject: [PATCH 3/3] Fixed missing includes --- .../Triangulation_3/test_regular_insert_range_with_info.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Triangulation_3/test/Triangulation_3/test_regular_insert_range_with_info.cpp b/Triangulation_3/test/Triangulation_3/test_regular_insert_range_with_info.cpp index 69c612696b5..02c3ea1ae34 100644 --- a/Triangulation_3/test/Triangulation_3/test_regular_insert_range_with_info.cpp +++ b/Triangulation_3/test/Triangulation_3/test_regular_insert_range_with_info.cpp @@ -6,6 +6,9 @@ #include #include +#include +#include +#include #include typedef CGAL::Exact_predicates_exact_constructions_kernel K;