示例#1
0
def zigzag(a, stepover, zig_unidirectional):
    if a.num_curves() == 0:
        return

    global rightward_for_zigs
    global curve_list_for_zigs
    global sin_angle_for_zigs
    global cos_angle_for_zigs
    global sin_minus_angle_for_zigs
    global cos_minus_angle_for_zigs
    global one_over_units

    one_over_units = 1 / area.get_units()

    a = rotated_area(a)

    b = area.Box()
    a.GetBox(b)

    x0 = b.MinX() - 1.0
    x1 = b.MaxX() + 1.0

    height = b.MaxY() - b.MinY()
    num_steps = int(height / stepover + 1)
    y = b.MinY() + 0.1 * one_over_units
    null_point = area.Point(0, 0)
    rightward_for_zigs = True
    curve_list_for_zigs = []

    for i in range(0, num_steps):
        y0 = y
        y = y + stepover
        p0 = area.Point(x0, y0)
        p1 = area.Point(x0, y)
        p2 = area.Point(x1, y)
        p3 = area.Point(x1, y0)
        c = area.Curve()
        c.append(area.Vertex(0, p0, null_point, 0))
        c.append(area.Vertex(0, p1, null_point, 0))
        c.append(area.Vertex(0, p2, null_point, 1))
        c.append(area.Vertex(0, p3, null_point, 0))
        c.append(area.Vertex(0, p0, null_point, 1))
        a2 = area.Area()
        a2.append(c)
        a2.Intersect(a)
        make_zig(a2, y0, y, zig_unidirectional)
        if zig_unidirectional == False:
            rightward_for_zigs = (rightward_for_zigs == False)

    reorder_zigs()
示例#2
0
def zigzag(a, a_firstoffset, stepover):
    if a.num_curves() == 0:
        return

    global rightward_for_zigs
    global curve_list_for_zigs
    global test_count
    global sin_angle_for_zigs
    global cos_angle_for_zigs
    global sin_minus_angle_for_zigs
    global cos_minus_angle_for_zigs

    a = rotated_area(a)

    b = area.Box()
    a.GetBox(b)

    #x0 = b.MinX() - 1.0
    #x1 = b.MaxX() + 1.0
    x1 = b.MinX() - 1.0
    x0 = b.MaxX() + 1.0

    height = b.MaxY() - b.MinY()
    num_steps = int(height / stepover + 1)
    #y = b.MinY() + 0.1
    y = b.MaxY() - 0.1
    null_point = area.Point(0, 0)
    rightward_for_zigs = True
    curve_list_for_zigs = []
    test_count = 0

    for i in range(0, num_steps):
        #collect vertices for a  box shape from X+,Y+ toward the curve
        #then move the tool Y+ and then back toward the X start position
        #   ------->
        #  |
        #   -------<
        test_count = test_count + 1
        y0 = y
        #y = y + stepover
        y = y - stepover
        p0 = area.Point(x0, y0)
        p1 = area.Point(x0, y)
        p2 = area.Point(x1, y)
        p3 = area.Point(x1, y0)
        c = area.Curve()
        c.append(area.Vertex(0, p0, null_point, 0))
        c.append(area.Vertex(0, p1, null_point, 0))
        c.append(area.Vertex(0, p2, null_point, 1))
        c.append(area.Vertex(0, p3, null_point, 0))
        c.append(area.Vertex(0, p0, null_point, 1))

        a2 = area.Area()
        a2.append(c)
        a2.Intersect(a)

        rightward_for_zigs = (rightward_for_zigs == False)

        y10 = y + stepover
        #y = y + stepover
        y2 = y + stepover * 2
        p10 = area.Point(x0, y10)
        p11 = area.Point(x0, y2)
        p12 = area.Point(x1, y2)
        p13 = area.Point(x1, y10)
        c2 = area.Curve()
        c2.append(area.Vertex(0, p10, null_point, 0))
        c2.append(area.Vertex(0, p11, null_point, 0))
        c2.append(area.Vertex(0, p12, null_point, 1))
        c2.append(area.Vertex(0, p13, null_point, 0))
        c2.append(area.Vertex(0, p10, null_point, 1))
        a3 = area.Area()
        a3.append(c2)
        a3.Intersect(a)
        make_zig(a3, y0, y)
        rightward_for_zigs = (rightward_for_zigs == False)

    reorder_zigs()