Index: trunk/src/libgrbs/route_common.c =================================================================== --- trunk/src/libgrbs/route_common.c (revision 1328) +++ trunk/src/libgrbs/route_common.c (revision 1329) @@ -90,6 +90,40 @@ return best_arc; } +/* Checks if convex-below-concave does not cross a concave arc. Returns 0 if + the concave arc 'from' is valid or non-zero on crossing */ +static int convex_below_concave_validate(grbs_t *grbs, grbs_2net_t *tn, grbs_addr_t *from, double new_da) +{ + int cnc_segi; + + for(cnc_segi = 0; cnc_segi < GRBS_MAX_SEG; cnc_segi++) { + grbs_arc_t *cnc_sentinel = gdl_first(&from->obj.arc->parent_pt->arcs[1][cnc_segi]); + double enda; + + if (cnc_sentinel == NULL) continue; + + printf("sent: %f %f convex: %f %f\n", cnc_sentinel->sa, cnc_sentinel->da, from->obj.arc->new_sa, new_da); + + if (grbs_angle_in_arc(cnc_sentinel->sa, cnc_sentinel->da, from->obj.arc->new_sa, 0)) { + coll_report_arc(grbs, tn, cnc_sentinel->link_point.next); + tprintf("convex_below_concave_validate: start angle\n"); + return 1; + } + + enda = from->obj.arc->new_sa + new_da; + if (enda > 2*M_PI) enda -= 2*M_PI; + if (enda < 0) enda += 2*M_PI; + + if (grbs_angle_in_arc(cnc_sentinel->sa, cnc_sentinel->da, enda, 0)) { + coll_report_arc(grbs, tn, cnc_sentinel->link_point.next); + tprintf("convex_below_concave_validate: end angle\n"); + return 1; + } + } + return 0; +} + + /* "from" is an existing arc with a start angle where the current route entered the orbit in its sector; "end_a" is where it should exit (the direction is known from "from"). This function checks wether this enter-exit @@ -111,6 +145,10 @@ return -1; } + if (!from_conc && convex_below_concave_validate(grbs, tn, from, nda)) + return -1; + + from->obj.arc->new_da = nda; is_new_seg = ((from->obj.arc->link_point.next == NULL) && (from->obj.arc->link_point.prev == NULL) && !from->obj.arc->in_use);