Exemplo n.º 1
0
def recur(arealist, a1, stepover, from_center):
    # this makes arealist by recursively offsetting a1 inwards

    if a1.num_curves() == 0:
        return

    if from_center:
        arealist.insert(0, a1)
    else:
        arealist.append(a1)

    a_offset = area.Area(a1)
    a_offset.Offset(stepover)

    # split curves into new areas
    if area.holes_linked():
        for curve in a_offset.getCurves():
            a2 = area.Area()
            a2.append(curve)
            recur(arealist, a2, stepover, from_center)

    else:
        # split curves into new areas
        a_offset.Reorder()
        a2 = None

        for curve in a_offset.getCurves():
            if curve.IsClockwise():
                if a2 != None:
                    a2.append(curve)
            else:
                if a2 != None:
                    recur(arealist, a2, stepover, from_center)
                a2 = area.Area()
                a2.append(curve)

        if a2 != None:
            recur(arealist, a2, stepover, from_center)
Exemplo n.º 2
0
def recur(arealist, a1, stepover, from_center):
    # this makes arealist by recursively offsetting a1 inwards

    if a1.num_curves() == 0:
        return

    if from_center:
        arealist.insert(0, a1)
    else:
        arealist.append(a1)

    a_offset = area.Area(a1)
    a_offset.Offset(stepover)

    # split curves into new areas
    if area.holes_linked():
        for curve in a_offset.getCurves():
            a2 = area.Area()
            a2.append(curve)
            recur(arealist, a2, stepover, from_center)

    else:
        # split curves into new areas
        a_offset.Reorder()
        a2 = None

        for curve in a_offset.getCurves():
            if curve.IsClockwise():
                if a2 != None:
                    a2.append(curve)
            else:
                if a2 != None:
                    recur(arealist, a2, stepover, from_center)
                a2 = area.Area()
                a2.append(curve)

        if a2 != None:
            recur(arealist, a2, stepover, from_center)
Exemplo n.º 3
0
def pocket(a,
           tool_radius,
           extra_offset,
           stepover,
           depthparams,
           from_center,
           keep_tool_down_if_poss,
           use_zig_zag,
           zig_angle,
           zig_unidirectional=False,
           start_point=None,
           cut_mode='conventional',
           entry_style='plunge'):
    global tool_radius_for_pocket
    global area_for_feed_possible

    #if len(a.getCurves()) > 1:
    #    for crv in a.getCurves():
    #        ar = area.Area()
    #        ar.append(crv)
    #        pocket(ar, tool_radius, extra_offset, rapid_safety_space, start_depth, final_depth, stepover, stepdown, clearance_height, from_center, keep_tool_down_if_poss, use_zig_zag, zig_angle, zig_unidirectional)
    #    return

    tool_radius_for_pocket = tool_radius

    if keep_tool_down_if_poss:
        area_for_feed_possible = area.Area(a)
        area_for_feed_possible.Offset(extra_offset - 0.01)

    use_internal_function = (
        area.holes_linked() == False
    )  # use internal function, if area module is the Clipper library

    if use_internal_function:
        curve_list = a.MakePocketToolpath(tool_radius, extra_offset, stepover,
                                          from_center, use_zig_zag, zig_angle)

    else:
        global sin_angle_for_zigs
        global cos_angle_for_zigs
        global sin_minus_angle_for_zigs
        global cos_minus_angle_for_zigs
        radians_angle = zig_angle * math.pi / 180
        sin_angle_for_zigs = math.sin(-radians_angle)
        cos_angle_for_zigs = math.cos(-radians_angle)
        sin_minus_angle_for_zigs = math.sin(radians_angle)
        cos_minus_angle_for_zigs = math.cos(radians_angle)

        arealist = list()

        a_offset = area.Area(a)
        current_offset = tool_radius + extra_offset
        a_offset.Offset(current_offset)

        do_recursive = True

        if use_zig_zag:
            zigzag(a_offset, stepover, zig_unidirectional)
            curve_list = curve_list_for_zigs
        else:
            if do_recursive:
                recur(arealist, a_offset, stepover, from_center)
            else:
                while (a_offset.num_curves() > 0):
                    if from_center:
                        arealist.insert(0, a_offset)
                    else:
                        arealist.append(a_offset)
                    current_offset = current_offset + stepover
                    a_offset = area.Area(a)
                    a_offset.Offset(current_offset)
            curve_list = get_curve_list(arealist, cut_mode == 'climb')

    depths = depthparams.get_depths()

    current_start_depth = depthparams.start_depth

    if start_point == None:
        for depth in depths:
            cut_curvelist1(curve_list, depthparams.rapid_safety_space,
                           current_start_depth, depth,
                           depthparams.clearance_height,
                           keep_tool_down_if_poss, entry_style)
            current_start_depth = depth

    else:
        for depth in depths:
            cut_curvelist2(curve_list, depthparams.rapid_safety_space,
                           current_start_depth, depth,
                           depthparams.clearance_height,
                           keep_tool_down_if_poss, start_point)
            current_start_depth = depth
Exemplo n.º 4
0
def pocket(a,tool_radius, extra_offset, stepover, depthparams, from_center, keep_tool_down_if_poss, use_zig_zag, zig_angle, zig_unidirectional = False,start_point=None, cut_mode = 'conventional'):
    global tool_radius_for_pocket
    global area_for_feed_possible
    #if len(a.getCurves()) > 1:
    #    for crv in a.getCurves():
    #        ar = area.Area()
    #        ar.append(crv)
    #        pocket(ar, tool_radius, extra_offset, rapid_safety_space, start_depth, final_depth, stepover, stepdown, clearance_height, from_center, keep_tool_down_if_poss, use_zig_zag, zig_angle, zig_unidirectional)
    #    return

    tool_radius_for_pocket = tool_radius

    if keep_tool_down_if_poss:
        area_for_feed_possible = area.Area(a)
        area_for_feed_possible.Offset(extra_offset - 0.01)

    use_internal_function = (area.holes_linked() == False) # use internal function, if area module is the Clipper library

    if use_internal_function:
        curve_list = a.MakePocketToolpath(tool_radius, extra_offset, stepover, from_center, use_zig_zag, zig_angle)

    else:
        global sin_angle_for_zigs
        global cos_angle_for_zigs
        global sin_minus_angle_for_zigs
        global cos_minus_angle_for_zigs
        radians_angle = zig_angle * math.pi / 180
        sin_angle_for_zigs = math.sin(-radians_angle)
        cos_angle_for_zigs = math.cos(-radians_angle)
        sin_minus_angle_for_zigs = math.sin(radians_angle)
        cos_minus_angle_for_zigs = math.cos(radians_angle)

        arealist = list()

        a_offset = area.Area(a)
        current_offset = tool_radius + extra_offset
        a_offset.Offset(current_offset)

        do_recursive = True

        if use_zig_zag:
            zigzag(a_offset, stepover, zig_unidirectional)
            curve_list = curve_list_for_zigs
        else:
            if do_recursive:
                recur(arealist, a_offset, stepover, from_center)
            else:
                while(a_offset.num_curves() > 0):
                    if from_center:
                        arealist.insert(0, a_offset)
                    else:
                        arealist.append(a_offset)
                    current_offset = current_offset + stepover
                    a_offset = area.Area(a)
                    a_offset.Offset(current_offset)
            curve_list = get_curve_list(arealist, cut_mode == 'climb')
            
    depths = depthparams.get_depths()
    current_start_depth = depthparams.start_depth
    if start_point==None:
        for depth in depths:
            cut_curvelist1(curve_list, depthparams.rapid_safety_space, current_start_depth, depth, depthparams.clearance_height, keep_tool_down_if_poss)
            current_start_depth = depth

    else:
        for depth in depths:
            cut_curvelist2(curve_list, depthparams.rapid_safety_space, current_start_depth, depth, depthparams.clearance_height, keep_tool_down_if_poss, start_point)
            current_start_depth = depth
Exemplo n.º 5
0
def pocket(
    a,
    tool_radius,
    extra_offset,
    rapid_safety_space,
    start_depth,
    final_depth,
    stepover,
    stepdown,
    clearance_height,
    from_center,
    keep_tool_down_if_poss,
    use_zig_zag,
    zig_angle,
    zig_unidirectional=False,
    start_point=None,
):
    global tool_radius_for_pocket
    global area_for_feed_possible
    tool_radius_for_pocket = tool_radius

    if keep_tool_down_if_poss:
        area_for_feed_possible = area.Area(a)
        area_for_feed_possible.Offset(extra_offset - 0.01)

    if rapid_safety_space > clearance_height:
        rapid_safety_space = clearance_height

    use_internal_function = area.holes_linked() == False  # use internal function, if area module is the Clipper library

    if use_internal_function:
        curve_list = a.MakePocketToolpath(tool_radius, extra_offset, stepover, from_center, use_zig_zag, zig_angle)

    else:
        global sin_angle_for_zigs
        global cos_angle_for_zigs
        global sin_minus_angle_for_zigs
        global cos_minus_angle_for_zigs
        radians_angle = zig_angle * math.pi / 180
        sin_angle_for_zigs = math.sin(-radians_angle)
        cos_angle_for_zigs = math.cos(-radians_angle)
        sin_minus_angle_for_zigs = math.sin(radians_angle)
        cos_minus_angle_for_zigs = math.cos(radians_angle)

        arealist = list()

        a_offset = area.Area(a)
        current_offset = tool_radius + extra_offset
        a_offset.Offset(current_offset)

        do_recursive = True

        if use_zig_zag:
            zigzag(a_offset, stepover, zig_unidirectional)
            curve_list = curve_list_for_zigs
        else:
            if do_recursive:
                recur(arealist, a_offset, stepover, from_center)
            else:
                while a_offset.num_curves() > 0:
                    if from_center:
                        arealist.insert(0, a_offset)
                    else:
                        arealist.append(a_offset)
                    current_offset = current_offset + stepover
                    a_offset = area.Area(a)
                    a_offset.Offset(current_offset)
            curve_list = get_curve_list(arealist)

    layer_count = int((start_depth - final_depth) / stepdown)

    if layer_count * stepdown + 0.00001 < start_depth - final_depth:
        layer_count += 1

    current_start_depth = start_depth

    if start_point == None:

        for i in range(1, layer_count + 1):
            if i == layer_count:
                depth = final_depth
            else:
                depth = start_depth - i * stepdown
            cut_curvelist1(
                curve_list, rapid_safety_space, current_start_depth, depth, clearance_height, keep_tool_down_if_poss
            )
            current_start_depth = depth

    else:
        for i in range(1, layer_count + 1):
            if i == layer_count:
                depth = final_depth
            else:
                depth = start_depth - i * stepdown
            cut_curvelist2(
                curve_list,
                rapid_safety_space,
                current_start_depth,
                depth,
                clearance_height,
                keep_tool_down_if_poss,
                start_point,
            )
            current_start_depth = depth
Exemplo n.º 6
0
def pocket(a,
           tool_radius,
           extra_offset,
           rapid_safety_space,
           start_depth,
           final_depth,
           stepover,
           stepdown,
           clearance_height,
           from_center,
           keep_tool_down_if_poss,
           use_zig_zag,
           zig_angle,
           zig_unidirectional=False,
           start_point=None):
    global tool_radius_for_pocket
    global area_for_feed_possible
    tool_radius_for_pocket = tool_radius

    if keep_tool_down_if_poss:
        area_for_feed_possible = area.Area(a)
        area_for_feed_possible.Offset(extra_offset - 0.01)

    if rapid_safety_space > clearance_height:
        rapid_safety_space = clearance_height

    use_internal_function = (
        area.holes_linked() == False
    )  # use internal function, if area module is the Clipper library

    if use_internal_function:
        curve_list = a.MakePocketToolpath(tool_radius, extra_offset, stepover,
                                          from_center, use_zig_zag, zig_angle)

    else:
        global sin_angle_for_zigs
        global cos_angle_for_zigs
        global sin_minus_angle_for_zigs
        global cos_minus_angle_for_zigs
        radians_angle = zig_angle * math.pi / 180
        sin_angle_for_zigs = math.sin(-radians_angle)
        cos_angle_for_zigs = math.cos(-radians_angle)
        sin_minus_angle_for_zigs = math.sin(radians_angle)
        cos_minus_angle_for_zigs = math.cos(radians_angle)

        arealist = list()

        a_offset = area.Area(a)
        current_offset = tool_radius + extra_offset
        a_offset.Offset(current_offset)

        do_recursive = True

        if use_zig_zag:
            zigzag(a_offset, stepover, zig_unidirectional)
            curve_list = curve_list_for_zigs
        else:
            if do_recursive:
                recur(arealist, a_offset, stepover, from_center)
            else:
                while (a_offset.num_curves() > 0):
                    if from_center:
                        arealist.insert(0, a_offset)
                    else:
                        arealist.append(a_offset)
                    current_offset = current_offset + stepover
                    a_offset = area.Area(a)
                    a_offset.Offset(current_offset)
            curve_list = get_curve_list(arealist)

    layer_count = int((start_depth - final_depth) / stepdown)

    if layer_count * stepdown + 0.00001 < start_depth - final_depth:
        layer_count += 1

    current_start_depth = start_depth

    if start_point == None:

        for i in range(1, layer_count + 1):
            if i == layer_count:
                depth = final_depth
            else:
                depth = start_depth - i * stepdown
            cut_curvelist1(curve_list, rapid_safety_space, current_start_depth,
                           depth, clearance_height, keep_tool_down_if_poss)
            current_start_depth = depth

    else:
        for i in range(1, layer_count + 1):
            if i == layer_count:
                depth = final_depth
            else:
                depth = start_depth - i * stepdown
            cut_curvelist2(curve_list, rapid_safety_space, current_start_depth,
                           depth, clearance_height, keep_tool_down_if_poss,
                           start_point)
            current_start_depth = depth