Exemplo n.º 1
0
/** Get the lines and boundaries from the map and load them in an array
*/
void load_lines(struct Map_info *map, struct Point **points, int *num_points,
		struct Line **lines, int *num_lines)
{
    int index_line = 0;
    int index_point = 0;
    struct line_pnts *sites;
    struct line_cats *cats;
    int cat = 0;
    int type;

    sites = Vect_new_line_struct();
    cats = Vect_new_cats_struct();

    while ((type = Vect_read_next_line(map, sites, cats)) > -1) {

	if (type != GV_LINE && type != GV_BOUNDARY && type != GV_POINT)
	    continue;

	if (type == GV_LINE)
	    process_line(sites, points, &index_point, lines, &index_line, -1);
	else if (type == GV_BOUNDARY)
	    process_boundary(sites, points, &index_point, lines, &index_line,
			     cat++);
	else if (type == GV_POINT)
	    process_point(sites, points, &index_point, -1);

    }

    *num_points = index_point;
    *num_lines = index_line;

    Vect_destroy_line_struct(sites);
    Vect_destroy_cats_struct(cats);
}
Exemplo n.º 2
0
bool dev::sixense::process_event(app::event *E)
{
    switch (E->get_type())
    {
    case E_POINT:
        if (process_point (E)) return true;
        else break;
    case E_AXIS:
        if (process_axis  (E)) return true;
        else break;
    case E_BUTTON:
        if (process_button(E)) return true;
        else break;
    case E_TICK:
        if (process_tick  (E)) return true;
        else break;
    }
    return dev::input::process_event(E);
}
Exemplo n.º 3
0
void generate_voronoi(struct point *p_array, int num){
    init_voronoi();
    //  printf("init memory succed\n");
    X0=0;
    Y0=0;
    X1=2000;
    Y1=2000;

    if(num >= POINT_POOL_SIZE){
        v_error("the number of points is out of bound");
        return;
    }

    int i;
    for (i=0; i<num; i++){
        push_point(p_array[i]);
        //   printf("%f, %f\n", p_array[i].x,  p_array[i].y);
        if(p_array[i].x < X0) X0 = p_array[i].x;
        if(p_array[i].y < Y0) Y0 = p_array[i].y;
        if(p_array[i].x > X1) X1 = p_array[i].x;
        if(p_array[i].y > Y1) Y1 = p_array[i].y;

    }
    add_virtual_obstacles();
    points_quicksort();

    /* X0=0; */
    /* Y0=0; */
    /* X1=2500; */
    /* Y1=2500; */
    //   printf("quicksort finished \n");
    //   printf("%f, %f, %f, %f\n\n\n", X0, Y0, X1,Y1);

    //add 20% margins to the bounding box
    /* double dx = (X1-X0+1)/5.0; */
    /* double dy = (Y1-Y0+1)/5.0; */
    /* X0 -= dx; */
    /* X1 += dx; */
    /* Y0 -= dy; */
    /* Y1 += dy; */
    // printf("%f, %f, %f, %f\n\n\n", X0, Y0, X1,Y1);

    while (!is_pp_empty()){
        if(!is_ep_empty()){
             event_t * top_e = top_event();
             point_t top_p = top_point();
             if(top_e->x <= top_p.x){
                 process_event();
             }else{
                 process_point();
             }

        }else{
            process_point();
        }

    }

    //   print_arc_list();
    while(!is_ep_empty()){
        process_event();
    }
    finish_edges();
    rebuild_seg_list(&seg_list);
    int k;
    char *buf=malloc(sizeof(char)*1024);
    int pcount=0;
    for(k=0;k<seg_list.segs_count;k++){
        pcount+=sprintf(&buf[pcount],"%d;%d;%d;%d",k,seg_list.segs[k]->start.x,seg_list.segs[k]->start.y,seg_list.segs[k]->end.x,seg_list.segs[k]->end.y);
    }
    send_raw_eth_chn(34,buf,603);
}