コード例 #1
0
ファイル: skansk.py プロジェクト: psavine42/viper-server
def _process_index(node_dict, pts_index, ix, cylinder):
    if ix not in node_dict:
        node_dict[ix] = Node(gutil.tuplify(pts_index[ix]), pt_index=ix)
    other = _other_ix(ix)
    if other not in node_dict:
        node_dict[other] = Node(gutil.tuplify(pts_index[other]), pt_index=other)
    node_dict[ix].connect_to(node_dict[other], is_pipe=True, radius=cylinder.radius)
    return node_dict
コード例 #2
0
ファイル: skansk.py プロジェクト: psavine42/viper-server
def connect_heads2(node):
    neighs = node.neighbors(fwd=True, bkwd=True, edges=True)
    if node.get('has_head') is True:
        return  # node, False

    elif len(neighs) == 1:
        node.write('has_head', True)
        return  # node, True

    elif len(neighs) == 2:
        e1, e2 = neighs
        if _is_pipe(e1) is True and _is_pipe(e2) is False:
            edge, data = e2, e1.tmps
        elif _is_pipe(e1) is False and _is_pipe(e2) is True:
            edge, data = e1, e2.tmps
        else:
            return

        p1, p2 = edge.geom
        center = Point(p1).midpoint_to(Point(p2))
        new_main = edge.source

        new_main.geom = gutil.tuplify(center.numpy)
        new_main.remove_edge(edge)
        new_main.write('has_head', True)

        rem_node = edge.target
        for s in rem_node.successors():
            new_main.connect_to(s, **data)
        rem_node.deref()
        return
コード例 #3
0
ファイル: skansk.py プロジェクト: psavine42/viper-server
def resolve_elbow_edges(node, lim=2/12, **kwargs):
    """
    [inn_edge]   [node]
    =============>+
                  \ [edge]
                  + [tgt]
                  ||
                  || [out_edge]
                  ||
                  +  [new_tgt]
    """
    if node.npred != 1 or node.nsucs != 1:
        return node

    edge, tgt = node.successors(both=True, ix=0)
    if edge.get('is_elbow', None) is True:
        inn_edge = node.predecessors(edges=True, ix=0)
        out_edge, out_node = edge.target.successors(both=True, ix=0)
        bl1 = inn_edge.curve.line
        bl2 = out_edge.curve.line
        inn_line = inn_edge.curve.extend(10, 10).line
        out_line = out_edge.curve.extend(10, 10).line
        pp1 = bl1.points[1].projected_on(out_line)
        pp2 = bl2.points[0].projected_on(inn_line)
        dst = pp1.distance_to(pp2)
        if dst < lim:
            node.geom = gutil.tuplify(pp1.midpoint_to(pp2).numpy)
            node.connect_to(out_node, **out_edge.tmps)
            tgt.deref()
            edge.delete()
            out_edge.delete()
            return node
    return node
コード例 #4
0
ファイル: skansk.py プロジェクト: psavine42/viper-server
def align_vertical(edge, tol=0.01):
    if _is_pipe(edge) is True:
        slope = 1 - np.abs(gutil.slope(edge))
        if slope < tol:
            src = edge.source.as_np
            tgt = edge.target.as_np
            tgt[0:2] = src[0:2]
            edge.target.geom = gutil.tuplify(tgt)
    return edge
コード例 #5
0
ファイル: skansk.py プロジェクト: psavine42/viper-server
def add_ups(node, h=0.1, **kwargs):
    if node.get('has_head', None) is True:
        nd = np.array(list(node.geom))
        nd[-1] += h
        new = Node(gutil.tuplify(nd), is_head=True)
        node.connect_to(new, remove_head=True, tap_edge=True)
        node.write('has_head', False)
        node.write('head_tee', True)
        new.write('$create', '$head')
    return node
コード例 #6
0
ファイル: skansk.py プロジェクト: psavine42/viper-server
def tap_is_other(node_in, tap_node, node_out2, new_pnt):
    node_in.geom = gutil.tuplify(new_pnt.numpy)
    node_in.write('is_tee', True)
    node_in.write('tap_input', True)
    tap_edge, tap_succ = tap_node.successors(both=True)[0]

    if tap_edge.curve.line.length < 1.:
        node_in.connect_to(tap_succ, **tap_edge.tmps, tap_edge=True)
        tap_edge.delete()
    else:
        node_in.connect_to(tap_node, **tap_edge.tmps, tap_edge=True)

    o_edge, o_succ = node_out2.successors(both=True)[0]
    node_in.connect_to(o_succ, **o_edge.tmps)
    o_edge.delete()
    return node_in
コード例 #7
0
ファイル: skansk.py プロジェクト: psavine42/viper-server
def tap_is_input(node_in_tap, node_out1, node_out2, new_pnt):
    tap_edge, pred_node = node_in_tap.predecessors(both=True)[0]
    pt_tuple = gutil.tuplify(new_pnt.numpy)

    if tap_edge.curve.line.length < 1.:
        node_in_tap.geom = pt_tuple
        node_in = node_in_tap
        tap_edge.write('tap_edge', True)
    else:
        node_in = Node(pt_tuple, tee_index=0, tee_mid=True)
        node_in_tap.connect_to(node_in, **tap_edge.tmps, tap_edge=True)

    node_in.write('tap_input', False)
    node_in.write('is_tee', True)
    for n in [node_out1, node_out2]:
        o_edge, o_succ = n.successors(both=True)[0]
        node_in.connect_to(o_succ, **o_edge.tmps)
        o_edge.delete()
    return node_in
コード例 #8
0
ファイル: skansk.py プロジェクト: psavine42/viper-server
def align_tap(edge, TOL=_REVIT_ANGLE):
    """

    :param edge:
    :param TOL:HARDCODED REVIT TOLERANCE. found empirically
     working: [89.22843573127959, 89.91857497862868, 89.22841701199027, 89.93205755597465, 89.2284428900399]
     not working: [88.89186491151713, 88.84667449752507, 88.89179632626258, 88.8919083924853, 88.89182755566546]
    :return:
    """
    if edge.get('tap_edge', None) is not True or edge.source.npred != 1:
        return edge
    egde_in = edge.source.predecessors(edges=True, ix=0)
    angle = math.degrees(egde_in.curve.line.angle_to(edge.curve.line))
    if angle < TOL:
        src = edge.source.as_np
        tgt = edge.target.as_np
        tgt[0:2] = src[0:2]
        edge.target.geom = gutil.tuplify(tgt)
        return edge
    return edge