def _travel_path(origin_id, start_id):
	path = []
	branch_encounted = False
	head = start_id
	while True:
		path.append(head)
		b = Segment.by_id(head)
		if not b:
			b = Block.by_id(head)
		if origin_id == head:
			break
		if b.has_return():
			break
		if b.branch() and not b.branch().has_return():
			branch_encounted = True
			break
		head = b.passthru().id
	return path, branch_encounted
Exemplo n.º 2
0
def _travel_path(origin_id, start_id):
    path = []
    branch_encounted = False
    head = start_id
    while True:
        path.append(head)
        b = Segment.by_id(head)
        if not b:
            b = Block.by_id(head)
        if origin_id == head:
            break
        if b.has_return():
            break
        if b.branch() and not b.branch().has_return():
            branch_encounted = True
            break
        head = b.passthru().id
    return path, branch_encounted
def _new_segment(segment, segments, included_in, members):
	id = segment.id
	segments.append(segment.id)

	m = []
	if segment.type == Segment.BRANCH:
		m = segment.left[:]
		m.extend(segment.right[:])
	elif segment.type == Segment.LOOP:
		m = segment.body[:]

	sm = []
	for block_id in m:
		if Segment.by_id(block_id):
			if block_id not in included_in: # temporary
				included_in[block_id] = id
			sm.extend(members[block_id])
			sm.remove(block_id) # remove dup
	
	m.append(id)
	m.extend(sm)
	members[id] = m
Exemplo n.º 4
0
def _new_segment(segment, segments, included_in, members):
    id = segment.id
    segments.append(segment.id)

    m = []
    if segment.type == Segment.BRANCH:
        m = segment.left[:]
        m.extend(segment.right[:])
    elif segment.type == Segment.LOOP:
        m = segment.body[:]

    sm = []
    for block_id in m:
        if Segment.by_id(block_id):
            if block_id not in included_in:  # temporary
                included_in[block_id] = id
            sm.extend(members[block_id])
            sm.remove(block_id)  # remove dup

    m.append(id)
    m.extend(sm)
    members[id] = m