コード例 #1
0
// comments relate to Sugihara-Iri paper
// this is roughly "algorithm A" from the paper, page 15/50
void VoronoiDiagram::addVertexSite(const Point& p) {
    // only add vertices within the far_radius circle
    assert( p.xyNorm() < far_radius );
    
    // 1) find the closest face and associated generator
    gen_count++;
    HEFace closest_face = fgrid->grid_find_closest_face( p );
    
    // 2) among the vertices on the closest_face
    //    find the seed, which has the lowest detH
    HEVertex v_seed = findSeedVertex(closest_face, p);
    g[v_seed].type = IN;
    VertexVector v0;
    v0.push_back(v_seed); 
    
    // 3) augment the vertex set to be deleted
    //    vertex set must remain a tree
    //    must not delete cycles
    augment_vertex_set_M(v0, p); 
    
    // 4) add new vertices on all edges that connect v0 IN edges to OUT edges
    add_new_voronoi_vertices(v0, p);
    
    // 5) generate new edges that form a loop around the region to be deleted
    HEFace newface = split_faces(p);
    
    // 6) fix the next-pointers in newface, then remove set v0
    remove_vertex_set(v0, newface);
    
    // 7) reset IN/OUT/UNDECIDED for verts, and INCIDENT/NONINCIDENT for faces
    reset_labels();

    assert( vdChecker.isValid(this) );
}
コード例 #2
0
ファイル: voronoidiagram_py.hpp プロジェクト: play113/swer
 // for visualizing the delete-set
 boost::python::list getDeleteSet( Point p ) { // no const here(?)
     boost::python::list out;
     HEFace closest_face = fgrid->grid_find_closest_face( p );
     HEVertex v_seed = findSeedVertex(closest_face, p);
     g[v_seed].type = IN;
     VertexVector v0;
     v0.push_back(v_seed); 
     augment_vertex_set_M(v0, p);
     BOOST_FOREACH( HEVertex v, v0) {
         boost::python::list vert;
         vert.append( g[ v ].position );
         vert.append( g[ v ].type );
         out.append( vert );
     }