Beispiel #1
0
def add_track_with_localnames(g, ic, segment, connections, lines):
    """Add tracks to the rr_graph from lines, connections, using local names (from the positions).
    """

    def hlc_name_f(line, pos):
        for npos in line:
            if pos.x == npos.x and pos.y == npos.y:
                names = set(n for n in npos.names if not n.endswith("_x"))
                assert len(names) <= 1, (line, npos)
                if not names:
                    return None
                return names.pop()
        assert False, (line, npos, pos)

    new_lines = []
    for line in lines:
        names = [n for n in line.names if not n.endswith('_x')]
        if len(names) <= 1:
            continue

        for npos in line:
            if len(npos.names) <= 1:
                continue
            fnames = [i for i in npos.names if not i.endswith("_x")]
            if len(fnames) <= 1:
                continue
            logging.debug("temp - %s %s %s", npos, fnames[0], fnames[1:])
            for name in fnames[1:]:
                npos.names.remove(name)
                new_pos = points.NamedPosition(npos.pos, [name])
                new_line = points.StraightSegment(
                    direction=line.direction, positions=[new_pos]
                )
                logging.debug(
                    "npos:%s name:%s new_pos:%s new_line:%s", npos, name,
                    new_pos, new_line
                )
                new_lines.append(new_line)
                connections[npos.pos].append((fnames[0], name))
                assert new_lines[-1], (npos, new_lines)
            assert npos.names, npos
    logging.debug("new_lines: %s", new_lines)
    lines.extend(new_lines)
    add_track_with_lines(g, ic, segment, lines, connections, hlc_name_f)
Beispiel #2
0
def add_tracks(g, ic, all_group_segments, segtype_filter=None):
    """Adding tracks from icebox segment groups."""
    add_dummy_tracks(g, ic)

    for group in sorted(all_group_segments):
        positions = {}
        for x, y, netname in group:
            p = PositionIcebox(x, y)
            if p in positions:
                positions[p].names.append(netname)
            else:
                positions[(x, y)] = points.NamedPosition(p, [netname])
        positions = list(positions.values())

        segtype = group_seg_type(positions)
        if segtype_filter is not None and segtype != segtype_filter:
            continue
        if segtype == "unknown":
            logging.debug("Skipping unknown track group: %s", group)
            continue
        if segtype == "global":
            logging.debug("Skipping global track group: %s", group)
            continue
        segment = g.segments[segtype]

        fpositions = filter_track_names(positions)
        if not fpositions:
            logging.debug("Filtered out track group: %s", positions)
            continue

        connections, lines = points.decompose_into_straight_lines(fpositions)
        logging.info("connections:%s lines:%s", connections, lines)
        hlc_name = group_hlc_name(fpositions)
        if hlc_name:
            add_track_with_globalname(g, ic, segment, connections, lines,
                                      hlc_name)
        else:
            add_track_with_localnames(g, ic, segment, connections, lines)