Beispiel #1
0
void test_HalfedgeDS_decorator() {
    // Simple instantiation of the default halfedge data structure.
    typedef CGAL_HALFEDGEDS_DEFAULT<Dummy_traits_2>  HDS;
    typedef CGAL::HalfedgeDS_decorator<HDS>          Decorator;
    typedef HDS::Halfedge_handle                     Halfedge_handle;
    typedef HDS::Face_handle                         Face_handle;
    HDS hds;
    Decorator  decorator(hds);
    // Check create single loop.
    Halfedge_handle h = decorator.create_loop();
    hds.normalize_border();
    assert( hds.size_of_vertices() == 1);
    assert( hds.size_of_halfedges() == 2);
    assert( hds.size_of_faces() == 2);
    assert( decorator.is_valid( false, 4));

    // Restart with open segment.
    hds.clear();
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    h = decorator.create_segment();
    assert( hds.size_of_vertices() == 2);
    assert( hds.size_of_halfedges() == 2);
    assert( hds.size_of_faces() == 1);
    assert( decorator.is_valid( false, 4));

    // Create border edge and check normalization.
    decorator.set_face( h->opposite(), Face_handle());
    hds.normalize_border();
    assert( hds.size_of_border_halfedges() == 1);
    assert( hds.size_of_border_edges() == 1);
    assert( decorator.normalized_border_is_valid());
    decorator.set_face( h->opposite(), h->face());
    hds.normalize_border();
    assert( hds.size_of_border_halfedges() == 0);
    assert( hds.size_of_border_edges() == 0);
    assert( decorator.is_valid( false, 4));

    // Extend edge to two triangles.
    Halfedge_handle g = decorator.split_vertex( h, h);
    assert( decorator.is_valid( false, 4));
    assert( h != g);
    assert( h->next()->next() == g);
    assert( h == g->next()->next());
    assert( h->opposite() == g->next());
    assert( g->opposite() == h->next());
    Halfedge_handle g2 = decorator.split_face(h->opposite(),g->opposite());
    assert( decorator.is_valid( false, 4));
    assert( h->opposite()->next() == g2);
    assert( g2->next() == g);
    decorator.split_vertex( g2, g->opposite());
    assert( decorator.is_valid( false, 4));
    assert( g->next()->next()->next()->next() == g);
    Halfedge_handle g3 = 
        decorator.split_face( g2->next()->opposite(), h);
    assert( decorator.is_valid( false, 4));
    assert( g->next()->next()->next()->next() == g);
    assert( h->next()->next()->next() == h);
    assert( g3->next()->next()->next() == g3);
    assert( g3->next() == g->opposite());
    assert( g3->opposite()->next() == g2->opposite());
    assert( g3->opposite() == h->next());

    // Edge flip within the triangle.
    Halfedge_handle g4 = decorator.flip_edge( g3);
    assert( decorator.is_valid( false, 4));
    assert( g4 == g3);
    assert( g3->next()->next() == g2->opposite());
    assert( g3->opposite()->next() == h);
    assert( g->next()->next()->next()->next() == g);
    assert( h->next()->next()->next() == h);
    assert( g3->next()->next()->next() == g3);

    // Reverse face orientation.
    decorator.inside_out();
    assert( decorator.is_valid( false, 4));
    decorator.inside_out();
    assert( decorator.is_valid( false, 4));

    // Check hole manipulations.
    decorator.make_hole(g);
    hds.normalize_border();
    assert( hds.size_of_border_halfedges() == 4);
    assert( hds.size_of_border_edges() == 4);
    assert( decorator.is_valid( false, 4));

    // Reverse face orientation, deal also with the hole..
    decorator.inside_out();
    assert( decorator.is_valid( false, 3));
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));

    // Check add_face_to_border.
    hds.clear();
    h = decorator.create_loop();
    decorator.make_hole( h->opposite());
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    decorator.add_face_to_border( h->opposite(), h->opposite());
    assert( hds.size_of_halfedges() == 4);
    assert( hds.size_of_faces() == 2);
    assert( decorator.is_valid( false, 3));
}
Beispiel #2
0
void test_HalfedgeDS_decorator2() {
    // Instantiation of the halfedge data structure using vector
    // with max-bases for a polyhedral surface.
    typedef CGAL::HalfedgeDS_vector< Dummy_traits_3,
                                           CGAL::Polyhedron_items_3> HDS;
    typedef CGAL::HalfedgeDS_decorator<HDS> Decorator;
    typedef HDS::Halfedge_handle            Halfedge_handle;
    typedef HDS::Face_handle                Face_handle;
    HDS hds(4,10,3);
    Decorator  decorator(hds);
    // Check create single loop.
    Halfedge_handle h = decorator.create_loop();
    hds.normalize_border();
    assert( hds.size_of_vertices() == 1);
    assert( hds.size_of_halfedges() == 2);
    assert( hds.size_of_faces() == 2);
    assert( decorator.is_valid( false, 4));

    // Restart with open segment.
    hds.clear();
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    h = decorator.create_segment();
    assert( hds.size_of_vertices() == 2);
    assert( hds.size_of_halfedges() == 2);
    assert( hds.size_of_faces() == 1);
    assert( decorator.is_valid( false, 3));
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));

    // Create border edge and check normalization.
    decorator.set_face( h->opposite(), Face_handle());
    hds.normalize_border();
    assert( hds.size_of_border_halfedges() == 1);
    assert( hds.size_of_border_edges() == 1);
    assert( decorator.normalized_border_is_valid());
    decorator.set_face( h->opposite(), h->face());
    hds.normalize_border();
    assert( hds.size_of_border_halfedges() == 0);
    assert( hds.size_of_border_edges() == 0);
    assert( decorator.is_valid( false, 4));

    // Extend edge to two triangles.
    Halfedge_handle g = decorator.split_vertex( h, h);
    assert( decorator.is_valid( false, 3));
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    assert( h != g);
    assert( h->next()->next() == g);
    assert( h == g->next()->next());
    assert( h->opposite() == g->next());
    assert( g->opposite() == h->next());
    Halfedge_handle g2 = decorator.split_face(h->opposite(),g->opposite());
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    assert( h->opposite()->next() == g2);
    assert( g2->next() == g);
    decorator.split_vertex( g2, g->opposite());
    assert( decorator.is_valid( false, 3));
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    assert( g->next()->next()->next()->next() == g);
    Halfedge_handle g3 = 
        decorator.split_face( g2->next()->opposite(), h);
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    assert( g->next()->next()->next()->next() == g);
    assert( h->next()->next()->next() == h);
    assert( g3->next()->next()->next() == g3);
    assert( g3->next() == g->opposite());
    assert( g3->opposite()->next() == g2->opposite());
    assert( g3->opposite() == h->next());

    // Edge flip within the triangle.
    Halfedge_handle g4 = decorator.flip_edge( g3);
    assert( decorator.is_valid( false, 3));
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    assert( g4 == g3);
    assert( g3->next()->next() == g2->opposite());
    assert( g3->opposite()->next() == h);
    assert( g->next()->next()->next()->next() == g);
    assert( h->next()->next()->next() == h);
    assert( g3->next()->next()->next() == g3);

    // Reverse face orientation.
    decorator.inside_out();
    assert( decorator.is_valid( false, 4));
}