def _slicer_task_4b(layer, ewidth, iwidth, conf, top_masks, bot_masks, perims): # Solid Mask outmask = [] for mask in top_masks: outmask = geom.union(outmask, geom.close_paths(mask)) for mask in bot_masks: outmask = geom.union(outmask, geom.close_paths(mask)) solid_mask = geom.clip(outmask, perims[-1]) bounds = geom.paths_bounds(outmask) # Solid Infill solid_infill = [] base_ang = 45 if layer % 2 == 0 else -45 solid_mask = geom.offset(solid_mask, conf['infill_overlap'] - ewidth) lines = geom.make_infill_lines(bounds, base_ang, 1.0, ewidth) for line in lines: lines = [line] lines = geom.clip(lines, solid_mask, subj_closed=False) solid_infill.extend(lines) # Sparse Infill sparse_infill = [] infill_type = conf['infill_type'] density = conf['infill_density'] / 100.0 if density > 0.0: if density >= 0.99: infill_type = "Lines" mask = geom.offset(perims[-1], conf['infill_overlap'] - iwidth) mask = geom.diff(mask, solid_mask) if infill_type == "Lines": base_ang = 90 * (layer % 2) + 45 lines = geom.make_infill_lines(bounds, base_ang, density, iwidth) elif infill_type == "Triangles": base_ang = 60 * (layer % 3) lines = geom.make_infill_triangles(bounds, base_ang, density, iwidth) elif infill_type == "Grid": base_ang = 90 * (layer % 2) + 45 lines = geom.make_infill_grid(bounds, base_ang, density, iwidth) elif infill_type == "Hexagons": base_ang = 120 * (layer % 3) lines = geom.make_infill_hexagons(bounds, base_ang, density, iwidth) else: lines = [] for line in lines: lines = [line] lines = geom.clip(lines, mask, subj_closed=False) sparse_infill.extend(lines) return solid_infill, sparse_infill
def _slicer_task_3b(layer, conf, ewidth, overhangs): # Support outline = [] infill = [] density = conf['support_density'] / 100.0 if density > 0.0: outline = geom.offset(overhangs, -ewidth / 2.0) outline = geom.close_paths(outline) mask = geom.offset(outline, conf['infill_overlap'] - ewidth) bounds = geom.paths_bounds(mask) lines = geom.make_infill_lines(bounds, 0, density, ewidth) infill = geom.clip(lines, mask, subj_closed=False) return outline, infill
def _slicer_task_4a(ewidth, conf, layer_paths, supp_outline): # Raft raft_outline = [] raft_infill = [] if conf['adhesion_type'] == "Raft": rings = math.ceil(conf['brim_width'] / ewidth) outset = min(conf['skirt_outset'] + ewidth * conf['skirt_loops'], conf['raft_outset']) paths = geom.union(layer_paths, supp_outline) raft_outline = geom.offset(paths, outset) bounds = geom.paths_bounds(raft_outline) mask = geom.offset(raft_outline, conf['infill_overlap'] - ewidth) lines = geom.make_infill_lines(bounds, 0, 0.75, ewidth) raft_infill.append(geom.clip(lines, mask, subj_closed=False)) for layer in range(conf['raft_layers'] - 1): base_ang = 90 * ((layer + 1) % 2) lines = geom.make_infill_lines(bounds, base_ang, 1.0, ewidth) raft_infill.append( geom.clip(lines, raft_outline, subj_closed=False)) # Brim brim = [] adhesion = conf['adhesion_type'] brim_w = conf['brim_width'] if adhesion == "Brim": rings = math.ceil(brim_w / ewidth) for i in range(rings): brim.append(geom.offset(layer_paths, (i + 0.5) * ewidth)) # Skirt skirt = [] priming = [] skirt_w = conf['skirt_outset'] minloops = conf['skirt_loops'] minlen = conf['skirt_min_len'] skirt = geom.offset(layer_paths, brim_w + skirt_w + ewidth / 2.0) plen = sum( sum([ math.hypot(p2[0] - p1[0], p2[1] - p1[1]) for p1, p2 in zip(path, path[1:] + path[0:1]) ]) for path in skirt) loops = minloops if adhesion != "Raft": loops = max(loops, math.ceil(minlen / plen)) for i in range(loops - 1): priming.append(geom.offset(skirt, (i + 1) * ewidth)) return (geom.close_paths(raft_outline), raft_infill, geom.close_paths(brim), geom.close_paths(skirt), geom.close_paths(priming))
def _slicer_task_2a(conf, overhangs, layer_paths): # Overhang Drops outset = conf['support_outset'] supp_type = conf['support_type'] if supp_type == 'None': return [] layer_drops = [] drop_paths = [] for layer in reversed(range(len(overhangs))): drop_paths = geom.union(drop_paths, overhangs[layer]) layer_mask = geom.offset(layer_paths[layer], outset) layer_drops.insert(0, geom.diff(drop_paths, layer_mask)) if supp_type == 'External': return layer_drops out_paths = [] mask_paths = [] for layer, drop_paths in enumerate(layer_drops): layer_mask = geom.offset(layer_paths[layer], outset) mask_paths = geom.union(mask_paths, layer_mask) drop_paths = geom.diff(drop_paths, mask_paths) out_paths.append(drop_paths) return out_paths
def _slicer_task_1(z, ewidth, suppwidth, layer_h, conf, model): # Layer Slicing paths = model.slice_at_z(z - layer_h / 2, layer_h) paths = geom.orient_paths(paths) paths = geom.union(paths, []) # Overhang Masks supp_ang = conf['overhang_angle'] tris = model.get_overhang_footprint_triangles(ang=supp_ang, z=z) overhangs = geom.diff(geom.union(tris, []), paths) # Perimeters perims = [] for i in range(conf['shell_count']): shell = geom.offset(paths, -(i + 0.5) * ewidth) shell = geom.close_paths(shell) perims.append(shell) return paths, overhangs, perims