diff --git a/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h b/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h index bf45a49f793..24b205a4cac 100644 --- a/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h @@ -503,8 +503,11 @@ private: } else { *(pit.first)++ = fn; int j = fn->index(fh); - stack.push(std::make_pair(fn,ccw(j))); + + // In the non-recursive version, we walk via 'ccw(j)' first. Here, we are filling the stack + // and the order is thus the opposite (we want the top element of the stack to be 'ccw(j)') stack.push(std::make_pair(fn,cw(j))); + stack.push(std::make_pair(fn,ccw(j))); } } return pit; diff --git a/Triangulation_2/test/Triangulation_2/data/layers.xy b/Triangulation_2/test/Triangulation_2/data/layers.xy new file mode 100644 index 00000000000..1207d7eeb95 --- /dev/null +++ b/Triangulation_2/test/Triangulation_2/data/layers.xy @@ -0,0 +1,502 @@ +10 0 +10 0.01 +10 0.02 +10 0.029999999999999999 +10 0.040000000000000001 +10 0.050000000000000003 +10 0.059999999999999998 +10 0.070000000000000007 +10 0.080000000000000002 +10 0.089999999999999997 +10 0.10000000000000001 +10 0.11 +10 0.12 +10 0.13 +10 0.14000000000000001 +10 0.14999999999999999 +10 0.16 +10 0.17000000000000001 +10 0.17999999999999999 +10 0.19 +10 0.20000000000000001 +10 0.20999999999999999 +10 0.22 +10 0.23000000000000001 +10 0.23999999999999999 +10 0.25 +10 0.26000000000000001 +10 0.27000000000000002 +10 0.28000000000000003 +10 0.28999999999999998 +10 0.29999999999999999 +10 0.31 +10 0.32000000000000001 +10 0.33000000000000002 +10 0.34000000000000002 +10 0.34999999999999998 +10 0.35999999999999999 +10 0.37 +10 0.38 +10 0.39000000000000001 +10 0.40000000000000002 +10 0.40999999999999998 +10 0.41999999999999998 +10 0.42999999999999999 +10 0.44 +10 0.45000000000000001 +10 0.46000000000000002 +10 0.46999999999999997 +10 0.47999999999999998 +10 0.48999999999999999 +10 0.5 +10 0.51000000000000001 +10 0.52000000000000002 +10 0.53000000000000003 +10 0.54000000000000004 +10 0.55000000000000004 +10 0.56000000000000005 +10 0.56999999999999995 +10 0.57999999999999996 +10 0.58999999999999997 +10 0.59999999999999998 +10 0.60999999999999999 +10 0.62 +10 0.63 +10 0.64000000000000001 +10 0.65000000000000002 +10 0.66000000000000003 +10 0.67000000000000004 +10 0.68000000000000005 +10 0.68999999999999995 +10 0.69999999999999996 +10 0.70999999999999996 +10 0.71999999999999997 +10 0.72999999999999998 +10 0.73999999999999999 +10 0.75 +10 0.76000000000000001 +10 0.77000000000000002 +10 0.78000000000000003 +10 0.79000000000000004 +10 0.80000000000000004 +10 0.81000000000000005 +10 0.81999999999999995 +10 0.82999999999999996 +10 0.83999999999999997 +10 0.84999999999999998 +10 0.85999999999999999 +10 0.87 +10 0.88 +10 0.89000000000000001 +10 0.90000000000000002 +10 0.91000000000000003 +10 0.92000000000000004 +10 0.93000000000000005 +10 0.93999999999999995 +10 0.94999999999999996 +10 0.95999999999999996 +10 0.96999999999999997 +10 0.97999999999999998 +10 0.98999999999999999 +10 1 +10 1.01 +10 1.02 +10 1.03 +10 1.04 +10 1.05 +10 1.0600000000000001 +10 1.0700000000000001 +10 1.0800000000000001 +10 1.0900000000000001 +10 1.1000000000000001 +10 1.1100000000000001 +10 1.1200000000000001 +10 1.1299999999999999 +10 1.1399999999999999 +10 1.1499999999999999 +10 1.1599999999999999 +10 1.1699999999999999 +10 1.1799999999999999 +10 1.1899999999999999 +10 1.2 +10 1.21 +10 1.22 +10 1.23 +10 1.24 +10 1.25 +10 1.26 +10 1.27 +10 1.28 +10 1.29 +10 1.3 +10 1.3100000000000001 +10 1.3200000000000001 +10 1.3300000000000001 +10 1.3400000000000001 +10 1.3500000000000001 +10 1.3600000000000001 +10 1.3700000000000001 +10 1.3799999999999999 +10 1.3899999999999999 +10 1.3999999999999999 +10 1.4099999999999999 +10 1.4199999999999999 +10 1.4299999999999999 +10 1.4399999999999999 +10 1.45 +10 1.46 +10 1.47 +10 1.48 +10 1.49 +10 1.5 +10 1.51 +10 1.52 +10 1.53 +10 1.54 +10 1.55 +10 1.5600000000000001 +10 1.5700000000000001 +10 1.5800000000000001 +10 1.5900000000000001 +10 1.6000000000000001 +10 1.6100000000000001 +10 1.6200000000000001 +10 1.6299999999999999 +10 1.6399999999999999 +10 1.6499999999999999 +10 1.6599999999999999 +10 1.6699999999999999 +10 1.6799999999999999 +10 1.6899999999999999 +10 1.7 +10 1.71 +10 1.72 +10 1.73 +10 1.74 +10 1.75 +10 1.76 +10 1.77 +10 1.78 +10 1.79 +10 1.8 +10 1.8100000000000001 +10 1.8200000000000001 +10 1.8300000000000001 +10 1.8400000000000001 +10 1.8500000000000001 +10 1.8600000000000001 +10 1.8700000000000001 +10 1.8799999999999999 +10 1.8899999999999999 +10 1.8999999999999999 +10 1.9099999999999999 +10 1.9199999999999999 +10 1.9299999999999999 +10 1.9399999999999999 +10 1.95 +10 1.96 +10 1.97 +10 1.98 +10 1.99 +10 2 +10 2.0099999999999998 +10 2.02 +10 2.0299999999999998 +10 2.04 +10 2.0499999999999998 +10 2.0600000000000001 +10 2.0699999999999998 +10 2.0800000000000001 +10 2.0899999999999999 +10 2.1000000000000001 +10 2.1099999999999999 +10 2.1200000000000001 +10 2.1299999999999999 +10 2.1400000000000001 +10 2.1499999999999999 +10 2.1600000000000001 +10 2.1699999999999999 +10 2.1800000000000002 +10 2.1899999999999999 +10 2.2000000000000002 +10 2.21 +10 2.2200000000000002 +10 2.23 +10 2.2400000000000002 +10 2.25 +10 2.2599999999999998 +10 2.27 +10 2.2799999999999998 +10 2.29 +10 2.2999999999999998 +10 2.3100000000000001 +10 2.3199999999999998 +10 2.3300000000000001 +10 2.3399999999999999 +10 2.3500000000000001 +10 2.3599999999999999 +10 2.3700000000000001 +10 2.3799999999999999 +10 2.3900000000000001 +10 2.3999999999999999 +10 2.4100000000000001 +10 2.4199999999999999 +10 2.4300000000000002 +10 2.4399999999999999 +10 2.4500000000000002 +10 2.46 +10 2.4700000000000002 +10 2.48 +10 2.4900000000000002 +10 2.5 +20 0 +20 0.01 +20 0.02 +20 0.029999999999999999 +20 0.040000000000000001 +20 0.050000000000000003 +20 0.059999999999999998 +20 0.070000000000000007 +20 0.080000000000000002 +20 0.089999999999999997 +20 0.10000000000000001 +20 0.11 +20 0.12 +20 0.13 +20 0.14000000000000001 +20 0.14999999999999999 +20 0.16 +20 0.17000000000000001 +20 0.17999999999999999 +20 0.19 +20 0.20000000000000001 +20 0.20999999999999999 +20 0.22 +20 0.23000000000000001 +20 0.23999999999999999 +20 0.25 +20 0.26000000000000001 +20 0.27000000000000002 +20 0.28000000000000003 +20 0.28999999999999998 +20 0.29999999999999999 +20 0.31 +20 0.32000000000000001 +20 0.33000000000000002 +20 0.34000000000000002 +20 0.34999999999999998 +20 0.35999999999999999 +20 0.37 +20 0.38 +20 0.39000000000000001 +20 0.40000000000000002 +20 0.40999999999999998 +20 0.41999999999999998 +20 0.42999999999999999 +20 0.44 +20 0.45000000000000001 +20 0.46000000000000002 +20 0.46999999999999997 +20 0.47999999999999998 +20 0.48999999999999999 +20 0.5 +20 0.51000000000000001 +20 0.52000000000000002 +20 0.53000000000000003 +20 0.54000000000000004 +20 0.55000000000000004 +20 0.56000000000000005 +20 0.56999999999999995 +20 0.57999999999999996 +20 0.58999999999999997 +20 0.59999999999999998 +20 0.60999999999999999 +20 0.62 +20 0.63 +20 0.64000000000000001 +20 0.65000000000000002 +20 0.66000000000000003 +20 0.67000000000000004 +20 0.68000000000000005 +20 0.68999999999999995 +20 0.69999999999999996 +20 0.70999999999999996 +20 0.71999999999999997 +20 0.72999999999999998 +20 0.73999999999999999 +20 0.75 +20 0.76000000000000001 +20 0.77000000000000002 +20 0.78000000000000003 +20 0.79000000000000004 +20 0.80000000000000004 +20 0.81000000000000005 +20 0.81999999999999995 +20 0.82999999999999996 +20 0.83999999999999997 +20 0.84999999999999998 +20 0.85999999999999999 +20 0.87 +20 0.88 +20 0.89000000000000001 +20 0.90000000000000002 +20 0.91000000000000003 +20 0.92000000000000004 +20 0.93000000000000005 +20 0.93999999999999995 +20 0.94999999999999996 +20 0.95999999999999996 +20 0.96999999999999997 +20 0.97999999999999998 +20 0.98999999999999999 +20 1 +20 1.01 +20 1.02 +20 1.03 +20 1.04 +20 1.05 +20 1.0600000000000001 +20 1.0700000000000001 +20 1.0800000000000001 +20 1.0900000000000001 +20 1.1000000000000001 +20 1.1100000000000001 +20 1.1200000000000001 +20 1.1299999999999999 +20 1.1399999999999999 +20 1.1499999999999999 +20 1.1599999999999999 +20 1.1699999999999999 +20 1.1799999999999999 +20 1.1899999999999999 +20 1.2 +20 1.21 +20 1.22 +20 1.23 +20 1.24 +20 1.25 +20 1.26 +20 1.27 +20 1.28 +20 1.29 +20 1.3 +20 1.3100000000000001 +20 1.3200000000000001 +20 1.3300000000000001 +20 1.3400000000000001 +20 1.3500000000000001 +20 1.3600000000000001 +20 1.3700000000000001 +20 1.3799999999999999 +20 1.3899999999999999 +20 1.3999999999999999 +20 1.4099999999999999 +20 1.4199999999999999 +20 1.4299999999999999 +20 1.4399999999999999 +20 1.45 +20 1.46 +20 1.47 +20 1.48 +20 1.49 +20 1.5 +20 1.51 +20 1.52 +20 1.53 +20 1.54 +20 1.55 +20 1.5600000000000001 +20 1.5700000000000001 +20 1.5800000000000001 +20 1.5900000000000001 +20 1.6000000000000001 +20 1.6100000000000001 +20 1.6200000000000001 +20 1.6299999999999999 +20 1.6399999999999999 +20 1.6499999999999999 +20 1.6599999999999999 +20 1.6699999999999999 +20 1.6799999999999999 +20 1.6899999999999999 +20 1.7 +20 1.71 +20 1.72 +20 1.73 +20 1.74 +20 1.75 +20 1.76 +20 1.77 +20 1.78 +20 1.79 +20 1.8 +20 1.8100000000000001 +20 1.8200000000000001 +20 1.8300000000000001 +20 1.8400000000000001 +20 1.8500000000000001 +20 1.8600000000000001 +20 1.8700000000000001 +20 1.8799999999999999 +20 1.8899999999999999 +20 1.8999999999999999 +20 1.9099999999999999 +20 1.9199999999999999 +20 1.9299999999999999 +20 1.9399999999999999 +20 1.95 +20 1.96 +20 1.97 +20 1.98 +20 1.99 +20 2 +20 2.0099999999999998 +20 2.02 +20 2.0299999999999998 +20 2.04 +20 2.0499999999999998 +20 2.0600000000000001 +20 2.0699999999999998 +20 2.0800000000000001 +20 2.0899999999999999 +20 2.1000000000000001 +20 2.1099999999999999 +20 2.1200000000000001 +20 2.1299999999999999 +20 2.1400000000000001 +20 2.1499999999999999 +20 2.1600000000000001 +20 2.1699999999999999 +20 2.1800000000000002 +20 2.1899999999999999 +20 2.2000000000000002 +20 2.21 +20 2.2200000000000002 +20 2.23 +20 2.2400000000000002 +20 2.25 +20 2.2599999999999998 +20 2.27 +20 2.2799999999999998 +20 2.29 +20 2.2999999999999998 +20 2.3100000000000001 +20 2.3199999999999998 +20 2.3300000000000001 +20 2.3399999999999999 +20 2.3500000000000001 +20 2.3599999999999999 +20 2.3700000000000001 +20 2.3799999999999999 +20 2.3900000000000001 +20 2.3999999999999999 +20 2.4100000000000001 +20 2.4199999999999999 +20 2.4300000000000002 +20 2.4399999999999999 +20 2.4500000000000002 +20 2.46 +20 2.4700000000000002 +20 2.48 +20 2.4900000000000002 +20 2.5 diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h index 97419a8cc71..2204331cfe8 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h @@ -20,20 +20,21 @@ // coordinator : INRIA Sophia-Antipolis // ============================================================================ -#include -#include -//#include #include +#include +#include +#include +#include +#include #include -using std::rand; +using std::rand; template void _test_delaunay_duality( const Del &T ); - template void _test_cls_delaunay_triangulation_2( const Del & ) @@ -136,14 +137,58 @@ _test_cls_delaunay_triangulation_2( const Del & ) // test insertion through get_conflicts + star_hole conflicts.clear(); hole_bd.clear(); - T2.get_conflicts_and_boundary(Point(1,1,2), - std::back_inserter(conflicts), - std::back_inserter(hole_bd)); + Point query(1,1,2); + T2.get_conflicts_and_boundary(query, + std::back_inserter(conflicts), + std::back_inserter(hole_bd)); + + // check the sanity of the boundary (faces are not in conflict && edges are ccw ordered) + typename std::list::iterator curr = hole_bd.begin(), last = --(hole_bd.end()); + Vertex_handle prev_vh = last->first->vertex(T2.ccw(last->second)); + do + { + assert(curr->first->vertex(T2.cw(curr->second)) == prev_vh); + assert(!T2.test_conflict(query, curr->first)); + prev_vh = curr->first->vertex(T2.ccw(curr->second)); + ++curr; + } + while(curr != hole_bd.end()); + T2.star_hole (Point(1,1,2), hole_bd.begin(), hole_bd.end(), conflicts.begin(), conflicts.end() ); assert(T2.is_valid()); - + + // check get_conflict for a large enough point set (to use the non-recursive function) + double x, y; + std::vector layer_pts; + + std::ifstream in("data/layers.xy"); + assert(in); + while(in >> x >> y) + layer_pts.push_back(Point(x, y)); + + Del T2b(layer_pts.begin(), layer_pts.end()); + + conflicts.clear(); + hole_bd.clear(); + + query = Point(12.25, 0.031250); + T2b.get_conflicts_and_boundary(query, + std::back_inserter(conflicts), + std::back_inserter(hole_bd)); + + // check the sanity of the boundary (faces are not in conflict && edges are ccw ordered) + curr = hole_bd.begin(), last = --(hole_bd.end()); + prev_vh = last->first->vertex(T2b.ccw(last->second)); + do + { + assert(curr->first->vertex(T2b.cw(curr->second)) == prev_vh); + assert(!T2b.test_conflict(query, curr->first)); + prev_vh = curr->first->vertex(T2b.ccw(curr->second)); + ++curr; + } + while(curr != hole_bd.end()); /********************/ /***** Duality ******/