Exemplo n.º 1
0
def embedded_torus(nw, nh, stop=None, coord_gen=None):
    assert nw > 2 and nh > 2

    # Build dcel
    mD, t1, b1 = embedded_cylinder(nw, nh, coord_gen=coord_gen)

    if stop is None:
        dcel.glue_boundary(mD, b1, t1)
    else:
        t1stop = t1.boundary_forward(stop)
        dcel.glue_boundary(mD, t1, b1, t1stop)

    # return:
    # DCEL (mD, t1: starting edge)
    return mD, t1
Exemplo n.º 2
0
def embedded_torus(nw, nh, stop=None, coord_gen=None):
    assert nw > 2 and nh > 2

    # Build dcel
    mD, t1, b1 = embedded_cylinder(nw, nh, coord_gen=coord_gen)

    if stop is None:
        dcel.glue_boundary(mD, b1, t1)
    else:
        t1stop = t1.boundary_forward(stop)
        dcel.glue_boundary(mD, t1, b1, t1stop)

    # return:
    # DCEL (mD, t1: starting edge)
    return mD, t1
Exemplo n.º 3
0
def cylinder(w,h):
    """Generate DCEL for a triangulated cylinder of height h and circumference w"""
    tops = []
    bottoms = []
    D = dcel.DCEL()

    # Create h separate rings of height 1
    for i in range(h):
        RD,t,b = ring(w)
        tops.append(t)
        bottoms.append(b)
        D |= RD

    # Glue the rings top-to-bottom
    for i in range(h-1):
        dcel.glue_boundary(D, bottoms[i], tops[i + 1])

    return D,tops[0],bottoms[-1]
Exemplo n.º 4
0
def embedded_cylinder(nw, nh, coord_gen):
    """Generate DCEL for a triangulated cylinder of height h and circumference w"""
    tops = []
    bottoms = []
    D = dcel.DCEL()

    # Create h separate rings of height 1
    for i in range(nh):
        RD, t, b = embedded_ring(nw, i, coord_gen=coord_gen)
        tops.append(t)
        bottoms.append(b)
        D |= RD

    # Glue the rings top-to-bottom
    for i in range(nh - 1):
        dcel.glue_boundary(D, bottoms[i], tops[i + 1])

    return D, tops[0], bottoms[-1]
Exemplo n.º 5
0
def embedded_cylinder(nw, nh, coord_gen):
    """Generate DCEL for a triangulated cylinder of height h and circumference w"""
    tops = []
    bottoms = []
    D = dcel.DCEL()

    # Create h separate rings of height 1
    for i in range(nh):
        RD,t,b = embedded_ring(nw, i, coord_gen=coord_gen)
        tops.append(t)
        bottoms.append(b)
        D |= RD

    # Glue the rings top-to-bottom
    for i in range(nh-1):
        dcel.glue_boundary(D, bottoms[i], tops[i + 1])

    return D,tops[0],bottoms[-1]
Exemplo n.º 6
0
    #   \-D2-/            \-D5-/

    
    D1,T1,B1 = cylinder(5,10)
    D2,T2,B2 = cylinder(5,10)

    D3,T3,B3 = cylinder(4,10)

    D4,T4,B4 = cylinder(5,10)
    D5,T5,B5 = cylinder(5,10)

    D = D1 | D2 | D3 | D4 | D5
    new_bdry_edge_12 = B1.boundary_forward(3)     
    new_bdry_edge_45 = B4.boundary_forward(3)     

    dcel.glue_boundary(D, B1, T2, new_bdry_edge_12)  # a  -> D1,D2 form pair of pants
    dcel.glue_boundary(D, T1, B2)                   # b  -> Now punctured torus

    dcel.glue_boundary(D, B4, T5, new_bdry_edge_45)  # c  -> D4,D5 form pair of pants
    dcel.glue_boundary(D, T4, B5)                   # d  -> Now punctured torus

    # Join the two punctured tori along cylinder D3
    dcel.glue_boundary(D, new_bdry_edge_12, T3)     # e
    dcel.glue_boundary(D, B3, new_bdry_edge_45)     # f

    print('verts',len(D.V))
    print('hedges',len(D.E))
    print('faces',len(D.F))

    topo = dcel.oriented_manifold_type(D)
    for k in topo:
Exemplo n.º 7
0
            return np.real(M)

    def hol_around_vertices(self, X):
        return [self.hol_around_vertex(X, v) for v in self.V]


if __name__ == "__main__":
    """Find a KAT point for a one-holed torus with mirror boundary"""
    import triangulations
    import lsons
    from collections import defaultdict
    np.set_printoptions(suppress=True)

    D, t, b = triangulations.cylinder(5, 5)
    t2 = t.boundary_forward(2)
    dcel.glue_boundary(D, t, b, t2)

    chain_down = [t]
    while True:
        e = chain_down[-1]
        a = e.tri_cw
        b = a.vert_ccw
        c = b.vert_ccw
        chain_down += [a, b, c]
        if c == t:
            break

    chain_right = [t]
    while True:
        e = chain_right[-1]
        a = e.vert_ccw
Exemplo n.º 8
0
            return np.real(M)
        
    def hol_around_vertices(self,X):
        return [ self.hol_around_vertex(X,v) for v in self.V ]


if __name__=="__main__":
    """Find a KAT point for a one-holed torus with mirror boundary"""
    import triangulations
    import lsons
    from collections import defaultdict
    np.set_printoptions(suppress=True)

    D,t,b = triangulations.cylinder(5,5)
    t2 = t.boundary_forward(2)
    dcel.glue_boundary(D, t, b, t2)

    chain_down = [t]
    while True:
        e = chain_down[-1]
        a = e.tri_cw
        b = a.vert_ccw
        c = b.vert_ccw
        chain_down += [a,b,c]
        if c == t:
            break        

    chain_right = [t]
    while True:
        e = chain_right[-1]
        a = e.vert_ccw