From ed44248b81a6615c448616e65d873bac5c9cf22d Mon Sep 17 00:00:00 2001 From: Guillaume Damiand Date: Mon, 31 Oct 2011 07:19:05 +0000 Subject: [PATCH] Start of test --- .../Linear_cell_complex_2_test.h | 101 ++++++++++++++++++ .../Linear_cell_complex_test.cpp | 7 ++ 2 files changed, 108 insertions(+) diff --git a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_2_test.h b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_2_test.h index a127d24f51b..12cdef6e3ab 100644 --- a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_2_test.h +++ b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_2_test.h @@ -1 +1,102 @@ #include +#include + +template +bool check_number_of_cells_2(LCC& lcc, unsigned int nbv, unsigned int nbe, + unsigned int nbf, unsigned int nbcc) +{ + std::vector nbc; + nbc=lcc.count_all_cells(); + + if (nbv!=nbc[0] || nbe!=nbc[1] || nbf!=nbc[2] || nbcc!=nbc[3]) + { + std::cout<<"Error: the number of cells is not correct. We must have " + <<" ("< +bool test_LCC_2() +{ + LCC lcc; + + typedef typename LCC::Dart_handle Dart_handle; + typedef typename LCC::Point Point; + typedef typename LCC::Vector Vector; + + // Construction operations + Dart_handle dh1=lcc.make_segment(Point(0,0),Point(1,0)); + Dart_handle dh2=lcc.make_segment(Point(2,0),Point(2,1)); + Dart_handle dh3=lcc.make_segment(Point(2,2),Point(3,1)); + + lcc.template sew<0>(dh2,dh1); + lcc.template sew<1>(dh2,dh3); + + Dart_handle dh5=lcc.make_triangle(Point(5,5),Point(7,5),Point(6,6)); + Dart_handle dh6=lcc.make_triangle(Point(5,4),Point(7,4),Point(6,3)); + + lcc.template sew<2>(dh5,dh6); + + Dart_handle dh7=lcc.template insert_barycenter_in_cell<1>(dh1); + + Dart_handle dh8=lcc.template insert_barycenter_in_cell<2>(dh5); + + Dart_handle dh9=lcc.template insert_point_in_cell<1>(dh2,Point(1,0)); + + Dart_handle dh10=lcc.template insert_point_in_cell<2>(dh6,Point(6,5)); + + Dart_handle dh11=lcc.insert_dangling_cell_1_in_cell_2(dh8,Point(6,5.2)); + + // Removal operations + CGAL::remove_cell(lcc, dh11); + + std::vector toremove; + for ( typename LCC::template Dart_of_cell_range<0,2>::iterator + it=lcc.template darts_of_cell<0,2>(dh10).begin(), + itend=lcc.template darts_of_cell<0,2>(dh10).end(); + it!=itend; ++it ) + { + Dart_handle cur = it; + //toremove.push_back( lcc.dart_handle(it) ); + toremove.push_back( cur ); + } + + for ( typename std::vector::iterator + it=toremove.begin(), itend=toremove.end(); it!=itend; ++it ) + CGAL::remove_cell(lcc, *it); + toremove.clear(); + + CGAL::remove_cell(lcc, dh9); + + /* for (...) TODO with dh8 + remove_cell(it); */ + + CGAL::remove_cell(lcc, dh7); + + lcc.template unsew<2>(dh5); + + CGAL::remove_cell(lcc, dh6); + CGAL::remove_cell(lcc, dh5); + + lcc.template unsew<0>(dh2); + lcc.template unsew<1>(dh2); + + CGAL::remove_cell(lcc, dh1); + CGAL::remove_cell(lcc, dh2); + CGAL::remove_cell(lcc, dh3); + + /* import_from_polyhedron(lcc,ap); + + lcc.clear(); + + import_from_plane_graph(lcc,ais); + + lcc.clear();*/ + + return true; +} diff --git a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_test.cpp b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_test.cpp index cebcbd4c8e7..bb4782a8507 100644 --- a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_test.cpp +++ b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_test.cpp @@ -4,5 +4,12 @@ int main() { + typedef CGAL::Linear_cell_complex<2> LCC1; + if ( !test_LCC_2() ) + { + std::cout<<"ERROR during Test_LCC_2."<