diff --git a/HalfedgeDS/test/HalfedgeDS/test_hds_range_based_loops.cpp b/HalfedgeDS/test/HalfedgeDS/test_hds_range_based_loops.cpp index 19adc023f29..455367d6836 100644 --- a/HalfedgeDS/test/HalfedgeDS/test_hds_range_based_loops.cpp +++ b/HalfedgeDS/test/HalfedgeDS/test_hds_range_based_loops.cpp @@ -8,159 +8,192 @@ using Kernel = CGAL::Simple_cartesian; using HDS_list = CGAL::HalfedgeDS_list; using HDS_vector = CGAL::HalfedgeDS_vector; -// void test_vertex_handles_and_points( -// Polyhedron& polyhedron) { +using VL = typename HDS_list::Vertex; +using HL = typename HDS_list::Halfedge; +using FL = typename HDS_list::Face; -// auto pit = polyhedron.points_begin(); -// auto vit = polyhedron.vertices_begin(); -// for (auto vh : polyhedron.vertex_handles()) { -// assert(vh == vit); -// assert(vh->point() == vit->point()); -// assert(vh->point() == *pit); -// ++vit; ++pit; -// } -// assert(pit == polyhedron.points_end()); -// assert(vit == polyhedron.vertices_end()); +using VV = typename HDS_vector::Vertex; +using HV = typename HDS_vector::Halfedge; +using FV = typename HDS_vector::Face; -// pit = polyhedron.points_begin(); -// vit = polyhedron.vertices_begin(); -// for (auto& point : polyhedron.points()) { -// assert(*pit == point); -// assert(vit->point() == point); -// ++vit; ++pit; -// } -// assert(pit == polyhedron.points_end()); -// assert(vit == polyhedron.vertices_end()); -// } +void test_vertex_handles( + HDS_list& hds_list, + HDS_vector& hds_vector) { -// void test_const_vertex_handles_and_points( -// const Polyhedron& polyhedron) { + auto lit = hds_list.vertices_begin(); + assert(hds_list.vertex_handles().size() == 1); + for (auto vh : hds_list.vertex_handles()) { + assert(vh == lit); + assert(vh->point() == lit->point()); + assert(vh->halfedge() == lit->halfedge()); + ++lit; + } + assert(lit == hds_list.vertices_end()); -// auto pit = polyhedron.points_begin(); -// auto vit = polyhedron.vertices_begin(); -// for (const auto vh : polyhedron.vertex_handles()) { -// assert(vh == vit); -// assert(vh->point() == vit->point()); -// assert(vh->point() == *pit); -// ++vit; ++pit; -// } -// assert(pit == polyhedron.points_end()); -// assert(vit == polyhedron.vertices_end()); + auto vit = hds_vector.vertices_begin(); + assert(hds_vector.vertex_handles().size() == 1); + for (auto vh : hds_vector.vertex_handles()) { + assert(vh == vit); + assert(vh->point() == vit->point()); + assert(vh->halfedge() == vit->halfedge()); + ++vit; + } + assert(vit == hds_vector.vertices_end()); +} -// pit = polyhedron.points_begin(); -// vit = polyhedron.vertices_begin(); -// for (const auto& point : polyhedron.points()) { -// assert(*pit == point); -// assert(vit->point() == point); -// ++vit; ++pit; -// } -// assert(pit == polyhedron.points_end()); -// assert(vit == polyhedron.vertices_end()); -// } +void test_const_vertex_handles( + const HDS_list& hds_list, + const HDS_vector& hds_vector) { -// void test_facet_handles_and_planes( -// Polyhedron& polyhedron) { + auto lit = hds_list.vertices_begin(); + assert(hds_list.vertex_handles().size() == 1); + for (const auto vh : hds_list.vertex_handles()) { + assert(vh == lit); + assert(vh->point() == lit->point()); + assert(vh->halfedge() == lit->halfedge()); + ++lit; + } + assert(lit == hds_list.vertices_end()); -// auto pit = polyhedron.planes_begin(); -// auto fit = polyhedron.facets_begin(); -// for (auto fh : polyhedron.facet_handles()) { -// assert(fh == fit); -// assert(fh->plane() == fit->plane()); -// assert(fh->plane() == *pit); -// ++fit; ++pit; -// } -// assert(pit == polyhedron.planes_end()); -// assert(fit == polyhedron.facets_end()); + auto vit = hds_vector.vertices_begin(); + assert(hds_vector.vertex_handles().size() == 1); + for (const auto vh : hds_vector.vertex_handles()) { + assert(vh == vit); + assert(vh->point() == vit->point()); + assert(vh->halfedge() == vit->halfedge()); + ++vit; + } + assert(vit == hds_vector.vertices_end()); +} -// pit = polyhedron.planes_begin(); -// fit = polyhedron.facets_begin(); -// for (auto& plane : polyhedron.planes()) { -// assert(*pit == plane); -// assert(fit->plane() == plane); -// ++fit; ++pit; -// } -// assert(pit == polyhedron.planes_end()); -// assert(fit == polyhedron.facets_end()); -// } +void test_face_handles( + HDS_list& hds_list, + HDS_vector& hds_vector) { -// void test_const_facet_handles_and_planes( -// const Polyhedron& polyhedron) { + auto lit = hds_list.faces_begin(); + assert(hds_list.face_handles().size() == 2); + for (auto fh : hds_list.face_handles()) { + assert(fh == lit); + assert(fh->plane() == lit->plane()); + assert(fh->halfedge() == lit->halfedge()); + ++lit; + } + assert(lit == hds_list.faces_end()); -// auto pit = polyhedron.planes_begin(); -// auto fit = polyhedron.facets_begin(); -// for (const auto fh : polyhedron.facet_handles()) { -// assert(fh == fit); -// assert(fh->plane() == fit->plane()); -// assert(fh->plane() == *pit); -// ++fit; ++pit; -// } -// assert(pit == polyhedron.planes_end()); -// assert(fit == polyhedron.facets_end()); + auto vit = hds_vector.faces_begin(); + assert(hds_vector.face_handles().size() == 2); + for (auto fh : hds_vector.face_handles()) { + assert(fh == vit); + assert(fh->plane() == vit->plane()); + assert(fh->halfedge() == vit->halfedge()); + ++vit; + } + assert(vit == hds_vector.faces_end()); +} -// pit = polyhedron.planes_begin(); -// fit = polyhedron.facets_begin(); -// for (const auto& plane : polyhedron.planes()) { -// assert(*pit == plane); -// assert(fit->plane() == plane); -// ++fit; ++pit; -// } -// assert(pit == polyhedron.planes_end()); -// assert(fit == polyhedron.facets_end()); -// } +void test_const_face_handles( + const HDS_list& hds_list, + const HDS_vector& hds_vector) { -// void test_halfedge_handles_and_edges( -// Polyhedron& polyhedron) { + auto lit = hds_list.faces_begin(); + assert(hds_list.face_handles().size() == 2); + for (const auto fh : hds_list.face_handles()) { + assert(fh == lit); + assert(fh->plane() == lit->plane()); + assert(fh->halfedge() == lit->halfedge()); + ++lit; + } + assert(lit == hds_list.faces_end()); -// auto hit = polyhedron.halfedges_begin(); -// for (auto hh : polyhedron.halfedge_handles()) { -// assert(hh == hit); -// assert(hh->facet() == hit->facet()); -// assert(hh->vertex() == hit->vertex()); -// ++hit; -// } -// assert(hit == polyhedron.halfedges_end()); + auto vit = hds_vector.faces_begin(); + assert(hds_vector.face_handles().size() == 2); + for (const auto fh : hds_vector.face_handles()) { + assert(fh == vit); + assert(fh->plane() == vit->plane()); + assert(fh->halfedge() == vit->halfedge()); + ++vit; + } + assert(vit == hds_vector.faces_end()); +} -// auto eit = polyhedron.edges_begin(); -// for (auto& edge : polyhedron.edges()) { -// assert((*eit).facet() == edge.facet()); -// assert((*eit).vertex() == edge.vertex()); -// ++eit; -// } -// assert(eit == polyhedron.edges_end()); -// } +void test_halfedge_handles( + HDS_list& hds_list, + HDS_vector& hds_vector) { -// void test_const_halfedge_handles_and_edges( -// const Polyhedron& polyhedron) { + auto lit = hds_list.halfedges_begin(); + assert(hds_list.halfedge_handles().size() == 2); + for (auto hh : hds_list.halfedge_handles()) { + assert(hh == lit); + assert(hh->face() == lit->face()); + assert(hh->vertex() == lit->vertex()); + ++lit; + } + assert(lit == hds_list.halfedges_end()); -// auto hit = polyhedron.halfedges_begin(); -// for (const auto hh : polyhedron.halfedge_handles()) { -// assert(hh == hit); -// assert(hh->facet() == hit->facet()); -// assert(hh->vertex() == hit->vertex()); -// ++hit; -// } -// assert(hit == polyhedron.halfedges_end()); + auto vit = hds_vector.halfedges_begin(); + assert(hds_vector.halfedge_handles().size() == 2); + for (auto hh : hds_vector.halfedge_handles()) { + assert(hh == vit); + assert(hh->face() == vit->face()); + assert(hh->vertex() == vit->vertex()); + ++vit; + } + assert(vit == hds_vector.halfedges_end()); +} -// auto eit = polyhedron.edges_begin(); -// for (const auto& edge : polyhedron.edges()) { -// assert((*eit).facet() == edge.facet()); -// assert((*eit).vertex() == edge.vertex()); -// ++eit; -// } -// assert(eit == polyhedron.edges_end()); -// } +void test_const_halfedge_handles( + const HDS_list& hds_list, + const HDS_vector& hds_vector) { + + auto lit = hds_list.halfedges_begin(); + assert(hds_list.halfedge_handles().size() == 2); + for (const auto hh : hds_list.halfedge_handles()) { + assert(hh == lit); + assert(hh->face() == lit->face()); + assert(hh->vertex() == lit->vertex()); + ++lit; + } + assert(lit == hds_list.halfedges_end()); + + auto vit = hds_vector.halfedges_begin(); + assert(hds_vector.halfedge_handles().size() == 2); + for (const auto hh : hds_vector.halfedge_handles()) { + assert(hh == vit); + assert(hh->face() == vit->face()); + assert(hh->vertex() == vit->vertex()); + ++vit; + } + assert(vit == hds_vector.halfedges_end()); +} int main() { HDS_list hds_list(1, 2, 2); - HDS_vector hds_vector(1, 2, 2); + hds_list.vertices_push_back(VL()); + hds_list.edges_push_back(HL(), HL()); + hds_list.faces_push_back(FL()); + hds_list.faces_push_back(FL()); - // test_vertex_handles_and_points(polyhedron); - // test_const_vertex_handles_and_points(polyhedron); - // test_facet_handles_and_planes(polyhedron); - // test_const_facet_handles_and_planes(polyhedron); - // test_halfedge_handles_and_edges(polyhedron); - // test_const_halfedge_handles_and_edges(polyhedron); + HDS_vector hds_vector(1, 2, 2); + hds_vector.vertices_push_back(VV()); + hds_vector.edges_push_back(HV(), HV()); + hds_vector.faces_push_back(FV()); + hds_vector.faces_push_back(FV()); + + assert(hds_list.size_of_vertices() == 1); + assert(hds_list.size_of_halfedges() == 2); + assert(hds_list.size_of_faces() == 2); + + assert(hds_vector.size_of_vertices() == 1); + assert(hds_vector.size_of_halfedges() == 2); + assert(hds_vector.size_of_faces() == 2); + + test_vertex_handles(hds_list, hds_vector); + test_const_vertex_handles(hds_list, hds_vector); + test_face_handles(hds_list, hds_vector); + test_const_face_handles(hds_list, hds_vector); + test_halfedge_handles(hds_list, hds_vector); + test_const_halfedge_handles(hds_list, hds_vector); std::cout << "test_hds_range_based_loops: SUCCESS" << std::endl; return EXIT_SUCCESS;