compas-dev / compas_slicer

Slicing package for FDM 3D Printing with COMPAS.
https://compas.dev/compas_slicer/
MIT License
30 stars 16 forks source link

Bug in unify_paths_orientation: points are deleted and paths not always unified well #148

Open joburger opened 3 years ago

joburger commented 3 years ago

It seems like 'unify paths orientation' is not always giving the intended behaviour. I found this out by investigating the behaviour of close_paths(self) in the Base Slicer. I thought it was strange that after slicing a geometry with CGAL, it is still necessary for the script to add extra points to close the paths. This is strange, because if a path is closed according to CGAL Slicing, it must already have the same first as the same last point (path.points[0] == path.points[-1]). So what currently happens:

I think the result of 'unify paths orientation' should already be a closed path, without the need of additionally closing the path in a next step right? I.e.: ideally we don't need the 'close_paths' function to ever trigger.

Img1: Slicing result with unify path orientation and close paths commented out:

image

Img2: Slicing result with close paths commented out (and unify paths orientation on):

image

Additonally, I think unify paths orientation does not always unify the direction correctly, and sometimes it can even mess up the orientation of paths that were perfectly fine after just the slicing result. This should be investigated more.

Code used (very simple): Model I can still share if necessary but it should be the same for all models.


MODEL = 'start_stop_fix_test_geo.stl'

    compas_mesh = Mesh.from_stl(os.path.join(DATA, MODEL))

    slicer = PlanarSlicer(compas_mesh, slicer_type="cgal", layer_height=20.00)
    slicer.slice_model()

    simplify_paths_rdp_igl(slicer, threshold=0.9)
    seams_align(slicer, "next_path")

    slicer.printout_info()

    save_to_json(slicer.to_data(), OUTPUT_DIR, 'slicer_data.json')

    print_organizer = PlanarPrintOrganizer(slicer)
    print_organizer.create_printpoints()

    set_extruder_toggle(print_organizer, slicer)
    add_safety_printpoints(print_organizer, z_hop=60.0)
    set_linear_velocity_constant(print_organizer, v=100.0)
    set_blend_radius(print_organizer, d_fillet=10.0)

    print_organizer.printout_info()

    printpoints_data = print_organizer.output_printpoints_dict()
    utils.save_to_json(printpoints_data, OUTPUT_DIR, 'out_printpoints.json')