Index: map_2nets.c =================================================================== --- map_2nets.c (revision 35010) +++ map_2nets.c (revision 35011) @@ -50,6 +50,8 @@ long n; pcb_2netmap_iseg_t *ns; + if (!map->nonterminals && (obj->term == NULL)) + return; if ((layer != NULL) && (pcb_layer_flags_(layer) & PCB_LYT_COPPER) == 0) return; @@ -61,7 +63,6 @@ if (seg == NULL) return; - ns = calloc(sizeof(pcb_2netmap_iseg_t), 1); if (!seg->has_invalid_hub) { ns->next = map->isegs; @@ -124,6 +125,25 @@ list_obj(ctx, pcb, NULL, (pcb_any_obj_t *)ps); } +static int list_subc_cb(void *ctx, pcb_board_t *pcb, pcb_subc_t *subc, int enter) +{ + pcb_board_t tmp = {0}; + + tmp.Data = subc->data; + pcb_loop_all(&tmp, ctx, + NULL, /* layer */ + list_line_cb, + list_arc_cb, + NULL, /* text */ + list_poly_cb, + NULL, /* gfx */ + list_subc_cb, /* subc */ + list_pstk_cb + ); + return 0; +} + + #include "map_2nets_geo.c" #include "map_2nets_map.c" @@ -140,17 +160,21 @@ htpp_init(&map->o2n, ptrhash, ptrkeyeq); - /* map segments using query's netlen mapper */ - pcb_loop_all(PCB, map, - NULL, /* layer */ - list_line_cb, - list_arc_cb, - NULL, /* text */ - list_poly_cb, - NULL, /* gfx */ - NULL, /* subc */ - list_pstk_cb - ); + /* map segments using query's netlen mapper; first from terminals then + from non-terminals; this way some corner cases can be avoided by + picking out objects forming real nets, starting from terminals */ + for(map->nonterminals = 0; map->nonterminals < 2; map->nonterminals++) { + pcb_loop_all(PCB, map, + NULL, /* layer */ + list_line_cb, + list_arc_cb, + NULL, /* text */ + list_poly_cb, + NULL, /* gfx */ + list_subc_cb, /* subc */ + list_pstk_cb + ); + } /* the result is really a graph because of junctions; search random paths from terminal to terminal (junctions resolved into overlaps) */ Index: map_2nets.h =================================================================== --- map_2nets.h (revision 35010) +++ map_2nets.h (revision 35011) @@ -83,6 +83,7 @@ htpp_t o2n; /* of (pcb_2netmap_iseg_t *); tells the net for an object */ pcb_2netmap_iseg_t *isegs; /* head of a singly linked list */ pcb_qry_exec_t *ec; + unsigned char nonterminals; } pcb_2netmap_t;