void delaunay_stack_point(long pt_x, long pt_y) { long tri_idx,cor_idx; long dst_tri_idx,dst_cor_idx; long tri_id2, i; NAVIDBG(19,"Starting"); //_DK_delaunay_stack_point(pt_x, pt_y); return; tri_idx = triangle_find8(pt_x << 8, pt_y << 8); if (tri_idx == -1) { NAVIDBG(19,"Tri not found"); return; } delaunay_add_triangle(tri_idx); for (cor_idx=0; cor_idx < 3; cor_idx++) { tri_id2 = Triangles[tri_idx].tags[cor_idx]; if (tri_id2 != -1) { delaunay_add_triangle(tri_id2); } } if (point_find(pt_x, pt_y, &dst_tri_idx, &dst_cor_idx)) { tri_idx = dst_tri_idx; cor_idx = dst_cor_idx; unsigned long k; k = 0; do { tri_id2 = Triangles[tri_idx].tags[cor_idx]; if (tri_id2 == -1) { NAVIDBG(19,"Tag not found"); break; } i = link_find(tri_id2, tri_idx); if (i == -1) { NAVIDBG(19,"Link not found"); break; } cor_idx = MOD3[i+1]; tri_idx = tri_id2; delaunay_add_triangle(tri_idx); k++; if (k >= TRIANLGLES_COUNT) { ERRORDBG(9,"Infinite loop detected"); break; } } while (tri_idx != dst_tri_idx); } NAVIDBG(19,"Done"); }
long optimise_heuristic(long tri_id1, long tri_id2) { //return _DK_optimise_heuristic(tri_id1, tri_id2); struct Triangle *tri1; struct Triangle *tri3; struct Point *pt; long tri_id3,tri_lnk; long Ax,Ay,Bx,By,Cx,Cy,Dx,Dy; tri1 = get_triangle(tri_id1); tri_id3 = tri1->tags[tri_id2]; if (tri_id3 == -1) return 0; tri3 = get_triangle(tri_id3); if (get_triangle_tree_alt(tri_id3) != get_triangle_tree_alt(tri_id1)) { return 0; } tri_lnk = link_find(tri_id3, tri_id1); if (( (tri1->field_D & (1 << tri_id2)) == 0) || ( (tri3->field_D & (1 << tri_lnk)) == 0)) { return 0; } pt = get_triangle_point(tri_id3, MOD3[tri_lnk+2]); Ax = pt->x; Ay = pt->y; pt = get_triangle_point(tri_id1, MOD3[tri_id2+2]); Bx = pt->x; By = pt->y; pt = get_triangle_point(tri_id1, MOD3[tri_id2+1]); Cx = pt->x; Cy = pt->y; pt = get_triangle_point(tri_id1, MOD3[tri_id2]); Dx = pt->x; Dy = pt->y; if (LbCompareMultiplications(Ay-By, Dx-Bx, Ax-Bx, Dy-By) >= 0) return 0; if (LbCompareMultiplications(Ay-By, Cx-Bx, Ax-Bx, Cy-By) <= 0) return 0; return ((Bx-Ax) * (Bx-Ax)) + ((By-Ay) * (By-Ay)) < ((Dy-Ay) - (Cy-Ay)) * ((Dy-Ay) - (Cy-Ay)) + ((Dx-Ax) - (Cx-Ax)) * ((Dx-Ax) - (Cx-Ax)); }
void * map_val(t_map map, const char *key){ struct mapnode * next; link_find(t_map, map, next, strcmp(key, next->key)==0); return next != NULL ? next->data : NULL; }
struct mapnode * map_get(t_map map, const char *key){ struct mapnode * next; link_find(t_map, map, next, strcmp(key, next->key)==0); return next!=map?next:NULL; }