fix: support Excellon routing/milling commands (G00, G01, M15, M16, M17)#283
Conversation
Excellon files with routing/milling commands were rendered as a single drill hole instead of milled paths. The drill parser only knew how to create FLASH nets for every X/Y coordinate, regardless of routing mode. Add a routing state machine to the drill parser: - Track route_mode (G00 rapid/G01 linear vs G05 drill) and tool_down state (M15 plunge / M16,M17 retract) in drill_state_t - When routing with tool down, X/Y coordinates produce line segments (APERTURE_STATE_ON + LINEARx1) instead of flash drill holes - When routing with tool up, X/Y coordinates reposition without geometry - Reset routing state on tool change (T-code) and drill mode (G05) The renderer already handles APERTURE_STATE_ON + LINEARx1 for drill layers (proven by G85 slot support), so no draw.c changes are needed. G02/G03 arc routing is not yet implemented and still logs as unsupported. Fixes gerbv#271
|
Thank you for this patch. If this is good enough I apply it else I will leave comments. |
|
Tested on the branch. Build clean, feature works correctly. Code: The two-field state machine ( Before fix: 12 CRITICAL error messages on the test file (G00, G01, M15, M16, M17 all logged as unsupported). Tests: New test One minor note: |
Summary
Fixes #271
Excellon files with routing/milling commands (G00, G01, M15, M16, M17) are rendered as a single drill hole instead of milled paths. These commands are standard Excellon (used by Mentor Graphics, understood by GcPrevue, ViewMate, and Ucamco's online viewer), but gerbv's drill parser creates a
FLASHnet for every X/Y coordinate regardless of routing mode.This PR adds a routing state machine to the drill parser in
drill.c:route_modefield indrill_state_ttracks whether the parser is in drill mode (G05, default), rapid positioning (G00), or linear routing (G01)tool_downfield tracks plunge (M14/M15) vs retract (M16/M17) stateAPERTURE_STATE_ON+LINEARx1) instead of flash drill holes. When tool is up, coordinates reposition without creating geometrydrill_parse_M_code()instead of falling toDRILL_M_UNKNOWNNo changes to
drill.h,draw.c, orgerbv.h— the renderer already handlesAPERTURE_STATE_ON+LINEARx1for drill layers (proven by existing G85 slot support). The existing enums indrill.h(DRILL_G_ROUT,DRILL_G_LINEARMOVE,DRILL_M_ZAXISROUTEPOSITION, etc.) already had the correct values.Before (single drill hole)
After (milled Y-shape paths)
Scope
gerbv_cirseg_t.gerbv.hchanges).Test plan
test-drill-route-milling.exc(exact file from Excellon milling data are rendered as a hole #271) registered intests.listandrun_drill_tests.sh