Index: trunk/src_plugins/query/net_len.c =================================================================== --- trunk/src_plugins/query/net_len.c (revision 34953) +++ trunk/src_plugins/query/net_len.c (revision 34954) @@ -203,8 +203,9 @@ } if (conns == 0) { - if (dist == NULL) + if (dist == NULL) { rnd_trace("NSL: junction at: middle of #%ld vs. #%ld\n", new_obj->ID, arrived_from->ID); + } return -2; } if (conns > 1) { @@ -249,7 +250,26 @@ } } +static void add_junction(parent_net_len_t *ctx, pcb_any_obj_t *junct, pcb_any_obj_t *seg_end) +{ + int i = 0; +/* rnd_trace(" junction: obj=#%ld at end #%ld\n", junct->ID, seg_end->ID);*/ + + /* do not add the same thing twice */ + if ((ctx->seglen->junction[0] == junct) || (ctx->seglen->junction[1] == junct)) + return; + + if (ctx->seglen->junction[i] != NULL) i++; + if (ctx->seglen->junction[i] != NULL) { + ctx->seglen->hub = 1; + return; + } + + ctx->seglen->junction[i] = junct; + ctx->seglen->junc_at[i] = seg_end; +} + static int parent_net_len_found_cb(pcb_find_t *fctx, pcb_any_obj_t *new_obj, pcb_any_obj_t *arrived_from, pcb_found_conn_type_t ctype) { parent_net_len_t *ctx = fctx->user_data; @@ -268,6 +288,7 @@ of it is affected*/ remove_offender_from_open(fctx, new_obj); remove_offender_from_closed(fctx, new_obj, arrived_from); + add_junction(ctx, new_obj, arrived_from); } else if (coll == -2) { long n; @@ -300,9 +321,14 @@ vtp0_remove(&ctx->ec->tmplst, n, 1); n--; } + else { + if (o != arrived_from) + add_junction(ctx, arrived_from, o); + else + add_junction(ctx, new_obj, o); + } } } - } return PCB_FIND_DROP_THREAD; } @@ -450,6 +476,11 @@ lg = g; } + /* make sure junctions are ordered the same way as the object array */ + if (ctx.seglen->junc_at[0] != ctx.seglen->objs.array[0]) { + rnd_swap(pcb_any_obj_t *, ctx.seglen->junc_at[0], ctx.seglen->junc_at[1]); + rnd_swap(pcb_any_obj_t *, ctx.seglen->junction[0], ctx.seglen->junction[1]); + } ec->tmplst.used = 0; return ctx.seglen; Index: trunk/src_plugins/query/net_len.h =================================================================== --- trunk/src_plugins/query/net_len.h (revision 34953) +++ trunk/src_plugins/query/net_len.h (revision 34954) @@ -5,7 +5,8 @@ unsigned has_junction:1; unsigned has_nontrace:1; pcb_any_obj_t *junction[2]; /* object with a junction on it before and after the list */ - rnd_coord_t ex[2], ey[2]; /* extend from the first and last object to the junction point */ + pcb_any_obj_t *junc_at[2]; /* our last object (part of the seg) that faces the given junction */ + unsigned hub:1; /* when set, this segment is a junction hub with more than 2 connected segments */ rnd_coord_t len; int num_vias; /* number of functional vias, a.k.a. layer group changes */ } pcb_qry_netseg_len_t;