- NCC Plugin - fixed a minor bug that crashed the NCC Tcl Command; reported by @Aldin Halilovic on bitbucket
This commit is contained in:
@@ -11,6 +11,7 @@ CHANGELOG for FlatCAM Evo beta
|
|||||||
|
|
||||||
- Gerber Parser: minor changes, cleaning up the KiCAD junk lines if the Gerber file is made by KiCAD
|
- Gerber Parser: minor changes, cleaning up the KiCAD junk lines if the Gerber file is made by KiCAD
|
||||||
- Allowed the opening of certain types of damaged Gerber files (apertures not defines but used) but WARNINGS
|
- Allowed the opening of certain types of damaged Gerber files (apertures not defines but used) but WARNINGS
|
||||||
|
- NCC Plugin - fixed a minor bug that crashed the NCC Tcl Command; reported by @Aldin Halilovic on bitbucket
|
||||||
|
|
||||||
7.06.2023
|
7.06.2023
|
||||||
|
|
||||||
|
|||||||
@@ -3228,85 +3228,87 @@ class NonCopperClear(AppTool, Gerber):
|
|||||||
old_disp_number = 0
|
old_disp_number = 0
|
||||||
self.app.log.warning("Total number of polygons to be cleared. %s" % str(geo_len))
|
self.app.log.warning("Total number of polygons to be cleared. %s" % str(geo_len))
|
||||||
|
|
||||||
if area.geoms:
|
if not area:
|
||||||
pol_nr = 0
|
continue
|
||||||
for p in area:
|
|
||||||
# provide the app with a way to process the GUI events when in a blocking loop
|
|
||||||
QtWidgets.QApplication.processEvents()
|
|
||||||
|
|
||||||
if self.app.abort_flag:
|
pol_nr = 0
|
||||||
# graceful abort requested by the user
|
for p in area:
|
||||||
raise grace
|
# provide the app with a way to process the GUI events when in a blocking loop
|
||||||
|
QtWidgets.QApplication.processEvents()
|
||||||
|
|
||||||
# clean the polygon
|
if self.app.abort_flag:
|
||||||
p = p.buffer(0)
|
# graceful abort requested by the user
|
||||||
|
raise grace
|
||||||
|
|
||||||
if p and p.is_valid:
|
# clean the polygon
|
||||||
poly_processed = []
|
p = p.buffer(0)
|
||||||
if isinstance(p, Polygon):
|
|
||||||
if ncc_method == 0: # standard
|
if p and p.is_valid:
|
||||||
cp = self.clear_polygon(p, tool, self.circle_steps,
|
poly_processed = []
|
||||||
overlap=overlap, contour=contour, connect=connect,
|
if isinstance(p, Polygon):
|
||||||
prog_plot=False)
|
if ncc_method == 0: # standard
|
||||||
elif ncc_method == 1: # seed
|
cp = self.clear_polygon(p, tool, self.circle_steps,
|
||||||
cp = self.clear_polygon2(p, tool, self.circle_steps,
|
overlap=overlap, contour=contour, connect=connect,
|
||||||
overlap=overlap, contour=contour, connect=connect,
|
prog_plot=False)
|
||||||
prog_plot=False)
|
elif ncc_method == 1: # seed
|
||||||
else:
|
cp = self.clear_polygon2(p, tool, self.circle_steps,
|
||||||
cp = self.clear_polygon3(p, tool, self.circle_steps,
|
overlap=overlap, contour=contour, connect=connect,
|
||||||
overlap=overlap, contour=contour, connect=connect,
|
prog_plot=False)
|
||||||
prog_plot=False)
|
|
||||||
if cp:
|
|
||||||
cleared_geo += list(cp.get_objects())
|
|
||||||
poly_processed.append(True)
|
|
||||||
else:
|
|
||||||
poly_processed.append(False)
|
|
||||||
self.app.log.warning("Polygon can not be cleared.")
|
|
||||||
else:
|
else:
|
||||||
self.app.log.warning("Geo can not be cleared because it is: %s" % str(type(p)))
|
cp = self.clear_polygon3(p, tool, self.circle_steps,
|
||||||
|
overlap=overlap, contour=contour, connect=connect,
|
||||||
|
prog_plot=False)
|
||||||
|
if cp:
|
||||||
|
cleared_geo += list(cp.get_objects())
|
||||||
|
poly_processed.append(True)
|
||||||
|
else:
|
||||||
|
poly_processed.append(False)
|
||||||
|
self.app.log.warning("Polygon can not be cleared.")
|
||||||
|
else:
|
||||||
|
self.app.log.warning("Geo can not be cleared because it is: %s" % str(type(p)))
|
||||||
|
|
||||||
p_cleared = poly_processed.count(True)
|
p_cleared = poly_processed.count(True)
|
||||||
p_not_cleared = poly_processed.count(False)
|
p_not_cleared = poly_processed.count(False)
|
||||||
|
|
||||||
if p_not_cleared:
|
if p_not_cleared:
|
||||||
app_obj.poly_not_cleared = True
|
app_obj.poly_not_cleared = True
|
||||||
|
|
||||||
if p_cleared == 0:
|
if p_cleared == 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
pol_nr += 1
|
pol_nr += 1
|
||||||
disp_number = int(np.interp(pol_nr, [0, geo_len], [0, 100]))
|
disp_number = int(np.interp(pol_nr, [0, geo_len], [0, 100]))
|
||||||
# log.debug("Polygons cleared: %d" % pol_nr)
|
# log.debug("Polygons cleared: %d" % pol_nr)
|
||||||
|
|
||||||
if old_disp_number < disp_number <= 100:
|
if old_disp_number < disp_number <= 100:
|
||||||
self.app.proc_container.update_view_text(' %d%%' % disp_number)
|
self.app.proc_container.update_view_text(' %d%%' % disp_number)
|
||||||
old_disp_number = disp_number
|
old_disp_number = disp_number
|
||||||
# log.debug("Polygons cleared: %d. Percentage done: %d%%" % (pol_nr, disp_number))
|
# log.debug("Polygons cleared: %d. Percentage done: %d%%" % (pol_nr, disp_number))
|
||||||
|
|
||||||
# check if there is a geometry at all in the cleared geometry
|
# check if there is a geometry at all in the cleared geometry
|
||||||
if cleared_geo:
|
if cleared_geo:
|
||||||
# Overall cleared area
|
# Overall cleared area
|
||||||
cleared = empty.buffer(-offset_a * (1 + overlap)).buffer(-tool / 1.999999).buffer(
|
cleared = empty.buffer(-offset_a * (1 + overlap)).buffer(-tool / 1.999999).buffer(
|
||||||
tool / 1.999999)
|
tool / 1.999999)
|
||||||
|
|
||||||
# clean-up cleared geo
|
# clean-up cleared geo
|
||||||
cleared = cleared.buffer(0)
|
cleared = cleared.buffer(0)
|
||||||
|
|
||||||
# find the tooluid associated with the current tool_dia so we know where to add the tool
|
# find the tooluid associated with the current tool_dia so we know where to add the tool
|
||||||
# solid_geometry
|
# solid_geometry
|
||||||
for k, v in tools_storage.items():
|
for k, v in tools_storage.items():
|
||||||
if float('%.*f' % (self.decimals, v['tooldia'])) == float('%.*f' % (self.decimals,
|
if float('%.*f' % (self.decimals, v['tooldia'])) == float('%.*f' % (self.decimals,
|
||||||
tool)):
|
tool)):
|
||||||
current_uid = int(k)
|
current_uid = int(k)
|
||||||
|
|
||||||
# add the solid_geometry to the current too in self.paint_tools dictionary
|
# add the solid_geometry to the current too in self.paint_tools dictionary
|
||||||
# and then reset the temporary list that stored that solid_geometry
|
# and then reset the temporary list that stored that solid_geometry
|
||||||
v['solid_geometry'] = flatten_shapely_geometry(cleared_geo)
|
v['solid_geometry'] = flatten_shapely_geometry(cleared_geo)
|
||||||
v['data']['name'] = name
|
v['data']['name'] = name
|
||||||
break
|
break
|
||||||
geo_obj.tools[current_uid] = dict(tools_storage[current_uid])
|
geo_obj.tools[current_uid] = dict(tools_storage[current_uid])
|
||||||
else:
|
else:
|
||||||
app_obj.log.debug("There are no geometries in the cleared polygon.")
|
app_obj.log.debug("There are no geometries in the cleared polygon.")
|
||||||
|
|
||||||
# delete tools with empty geometry
|
# delete tools with empty geometry
|
||||||
# look for keys in the tools_storage dict that have 'solid_geometry' values empty
|
# look for keys in the tools_storage dict that have 'solid_geometry' values empty
|
||||||
|
|||||||
Reference in New Issue
Block a user