Skip to content

Commit

Permalink
Merge pull request #471 from eyal0/cutter_sort
Browse files Browse the repository at this point in the history
Sort outline cuts from shortest to longest instead of using TSP
  • Loading branch information
eyal0 committed Jul 15, 2020
2 parents 29d960a + d648791 commit 1ccdffc
Show file tree
Hide file tree
Showing 4 changed files with 2,830 additions and 2,820 deletions.
16 changes: 13 additions & 3 deletions surface_vectorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,20 @@ multi_linestring_type_fp Surface_vectorial::post_process_toolpath(
for (const auto& ls_and_allow_reversal : toolpath1) {
combined_toolpath.push_back(ls_and_allow_reversal.first);
}
if (tsp_2opt) {
tsp_solver::tsp_2opt(combined_toolpath, point_type_fp(0, 0));
if (dynamic_pointer_cast<Isolator>(mill) != nullptr) {
if (tsp_2opt) {
tsp_solver::tsp_2opt(combined_toolpath, point_type_fp(0, 0));
} else {
tsp_solver::nearest_neighbour(combined_toolpath, point_type_fp(0, 0));
}
} else {
tsp_solver::nearest_neighbour(combined_toolpath, point_type_fp(0, 0));
// It's a cutter so do the cuts from shortest to longest. This
// makes it very likely that the inside cuts will happen before
// the perimeter cut, which is best for stability of the PCB.
std::sort(combined_toolpath.begin(), combined_toolpath.end(),
[](const linestring_type_fp& lhs, const linestring_type_fp rhs) {
return bg::length(lhs) < bg::length(rhs);
});
}

if (mill->optimise) {
Expand Down
22 changes: 11 additions & 11 deletions testing/gerbv_example/edge-cuts-inside-cuts/expected/outline.ngc
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@ G04 P1.00000 (Wait for spindle to get up to speed)
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G00 Z0.08000 ( retract )

G00 X4.35000 Y-4.35000 ( rapid move to begin. )
G01 Z-0.00512 F50.00000 ( plunge. )
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G01 F100.00000
G01 X4.35000 Y-3.80000
G01 X5.05000 Y-3.80000
G01 X5.05000 Y-4.35000
G01 X4.35000 Y-4.35000
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G00 Z0.08000 ( retract )

G00 X4.55000 Y-4.25000 ( rapid move to begin. )
G01 Z-0.00512 F50.00000 ( plunge. )
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
Expand Down Expand Up @@ -85,6 +74,17 @@ G01 X4.61910 Y-3.89122
G01 X4.60865 Y-3.90933
G01 X4.60219 Y-3.92921
G01 X4.60000 Y-3.95000
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G00 Z0.08000 ( retract )

G00 X4.35000 Y-4.35000 ( rapid move to begin. )
G01 Z-0.00512 F50.00000 ( plunge. )
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G01 F100.00000
G01 X4.35000 Y-3.80000
G01 X5.05000 Y-3.80000
G01 X5.05000 Y-4.35000
G01 X4.35000 Y-4.35000

G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G00 Z1.000000 ( retract )
Expand Down
Loading

0 comments on commit 1ccdffc

Please sign in to comment.