From 4d5287ce1224e6fcfa9292eeb00b05c48f8229f0 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 5 Jul 2023 16:22:49 +0300 Subject: [PATCH] - Gerber Parser: fixed a bug where a region is a MultiPolygon and failed because of changes in Shapely starting with version 2.0 --- CHANGELOG.md | 1 + appGUI/VisPyCanvas.py | 2 +- appParsers/ParseGerber.py | 49 +++++++++++---------------------------- 3 files changed, 16 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36d26fb5..a04f75a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ CHANGELOG for FlatCAM Evo beta - Excellon Editor: fixed crash when editing hole diameters in the Tool Table - Isolation Plugin: fixed some possible issues when using rest machining - Drag and Drop files works now only in the Notebook and in the Plot Tab +- Gerber Parser: fixed a bug where a region is a MultiPolygon and failed because of changes in Shapely starting with version 2.0 4.07.2023 diff --git a/appGUI/VisPyCanvas.py b/appGUI/VisPyCanvas.py index a80d2fd2..8637a52b 100644 --- a/appGUI/VisPyCanvas.py +++ b/appGUI/VisPyCanvas.py @@ -34,7 +34,7 @@ class VisPyCanvas(scene.SceneCanvas): if settings.contains("axis_font_size"): a_fsize = settings.value('axis_font_size', type=int) else: - a_fsize = 8 + a_fsize = 6 if settings.contains("theme"): theme = settings.value('theme', type=str) diff --git a/appParsers/ParseGerber.py b/appParsers/ParseGerber.py index bb26dc76..d06c1768 100644 --- a/appParsers/ParseGerber.py +++ b/appParsers/ParseGerber.py @@ -998,53 +998,32 @@ class Gerber(Geometry): self.app.log.warning( "Found invalid Gerber geometry at line: %s. Fixing..." % str(line_num)) region_s = region_s.buffer(0.0000001, int(self.steps_per_circle)) + region_s = flatten_shapely_geometry(region_s) - if not region_s.is_valid: + if not region_s: self.app.log.warning( "Failed to fix the invalid Geometry found at line: %s" % str(line_num)) else: - try: - for pol in region_s: - # is it possible that simplification creates an Empty Geometry ????? - if self.app.options['gerber_simplification']: - pol = pol.simplify(s_tol) - - prepare(pol) - pol_f = pol.exterior - prepare(pol_f) - if not pol_f.is_empty: - follow_buffer.append(pol_f) - geo_dict['follow'] = pol - - poly_buffer.append(pol) - - if self.is_lpc is True: - geo_dict['clear'] = pol - else: - geo_dict['solid'] = pol - - if not pol.is_empty: - self.tools[0]['geometry'].append(geo_dict) - except TypeError: + for pol in region_s: # is it possible that simplification creates an Empty Geometry ????? if self.app.options['gerber_simplification']: - region_s = region_s.simplify(s_tol) + pol = pol.simplify(s_tol) - region_f = region_s.exterior - if not region_f.is_empty: - prepare(region_f) - follow_buffer.append(region_f) - geo_dict['follow'] = region_f + prepare(pol) + pol_f = pol.exterior + prepare(pol_f) + if not pol_f.is_empty: + follow_buffer.append(pol_f) + geo_dict['follow'] = pol - prepare(region_s) - poly_buffer.append(region_s) + poly_buffer.append(pol) if self.is_lpc is True: - geo_dict['clear'] = region_s + geo_dict['clear'] = pol else: - geo_dict['solid'] = region_s + geo_dict['solid'] = pol - if not region_s.is_empty: + if not pol.is_empty: self.tools[0]['geometry'].append(geo_dict) else: # is it possible that simplification creates an Empty Geometry ?????