- more fixes in Rules Check Tool

This commit is contained in:
Marius Stanciu
2019-10-12 05:47:50 +03:00
committed by Marius
parent 53338a2186
commit 0ca078abf2
2 changed files with 95 additions and 35 deletions

View File

@@ -12,7 +12,7 @@ CAD program, and create G-Code for Isolation routing.
12.10.2019 12.10.2019
- fixed the Gerber Parser convert units unnecessary usage. The only units conversion should be done when creating the new object, after the parsing - fixed the Gerber Parser convert units unnecessary usage. The only units conversion should be done when creating the new object, after the parsing
- more fixes in Rules Check Tool
11.10.2019 11.10.2019

View File

@@ -564,6 +564,8 @@ class RulesCheck(FlatCAMTool):
@staticmethod @staticmethod
def check_inside_gerber_clearance(gerber_obj, size, rule): def check_inside_gerber_clearance(gerber_obj, size, rule):
log.debug("RulesCheck.check_inside_gerber_clearance()")
rule_title = rule rule_title = rule
violations = list() violations = list()
@@ -639,6 +641,7 @@ class RulesCheck(FlatCAMTool):
@staticmethod @staticmethod
def check_gerber_clearance(gerber_list, size, rule): def check_gerber_clearance(gerber_list, size, rule):
log.debug("RulesCheck.check_gerber_clearance()")
rule_title = rule rule_title = rule
violations = list() violations = list()
@@ -694,11 +697,13 @@ class RulesCheck(FlatCAMTool):
if isinstance(total_geo_grb_1, Polygon): if isinstance(total_geo_grb_1, Polygon):
len_1 = 1 len_1 = 1
total_geo_grb_1 = [total_geo_grb_1]
else: else:
len_1 = len(total_geo_grb_1) len_1 = len(total_geo_grb_1)
if isinstance(total_geo_grb_3, Polygon): if isinstance(total_geo_grb_3, Polygon):
len_3 = 1 len_3 = 1
total_geo_grb_3 = [total_geo_grb_3]
else: else:
len_3 = len(total_geo_grb_3) len_3 = len(total_geo_grb_3)
@@ -743,6 +748,8 @@ class RulesCheck(FlatCAMTool):
@staticmethod @staticmethod
def check_holes_size(elements, size): def check_holes_size(elements, size):
log.debug("RulesCheck.check_holes_size()")
rule = _("Hole Size") rule = _("Hole Size")
violations = list() violations = list()
@@ -757,7 +764,7 @@ class RulesCheck(FlatCAMTool):
name = elem['name'] name = elem['name']
for tool in elem['tools']: for tool in elem['tools']:
tool_dia = float(elem['tools'][tool]['C']) tool_dia = float('%.*f' % (4, float(elem['tools'][tool]['C'])))
if tool_dia < float(size): if tool_dia < float(size):
dia_list.append(tool_dia) dia_list.append(tool_dia)
obj_violations['name'] = name obj_violations['name'] = name
@@ -768,6 +775,7 @@ class RulesCheck(FlatCAMTool):
@staticmethod @staticmethod
def check_holes_clearance(elements, size): def check_holes_clearance(elements, size):
log.debug("RulesCheck.check_holes_clearance()")
rule = _("Hole to Hole Clearance") rule = _("Hole to Hole Clearance")
violations = list() violations = list()
@@ -822,6 +830,8 @@ class RulesCheck(FlatCAMTool):
@staticmethod @staticmethod
def check_traces_size(elements, size): def check_traces_size(elements, size):
log.debug("RulesCheck.check_traces_size()")
rule = _("Trace Size") rule = _("Trace Size")
violations = list() violations = list()
@@ -934,11 +944,13 @@ class RulesCheck(FlatCAMTool):
if isinstance(total_geo_grb, Polygon): if isinstance(total_geo_grb, Polygon):
len_1 = 1 len_1 = 1
total_geo_grb = [total_geo_grb]
else: else:
len_1 = len(total_geo_grb) len_1 = len(total_geo_grb)
if isinstance(total_geo_exc, Polygon): if isinstance(total_geo_exc, Polygon):
len_2 = 1 len_2 = 1
total_geo_exc = [total_geo_exc]
else: else:
len_2 = len(total_geo_exc) len_2 = len(total_geo_exc)
@@ -946,10 +958,16 @@ class RulesCheck(FlatCAMTool):
log.debug("RulesCheck.check_gerber_annular_ring(). Iterations: %s" % str(iterations)) log.debug("RulesCheck.check_gerber_annular_ring(). Iterations: %s" % str(iterations))
min_dict = dict() min_dict = dict()
dist = None
for geo in total_geo_grb: for geo in total_geo_grb:
for s_geo in total_geo_exc: for s_geo in total_geo_exc:
try:
# minimize the number of distances by not taking into considerations those that are too small # minimize the number of distances by not taking into considerations those that are too small
dist = geo.exterior.distance(s_geo) dist = abs(geo.exterior.distance(s_geo))
except Exception as e:
log.debug("RulesCheck.check_gerber_annular_ring() --> %s" % str(e))
if dist > 0:
if float(dist) < float(size): if float(dist) < float(size):
loc_1, loc_2 = nearest_points(geo.exterior, s_geo) loc_1, loc_2 = nearest_points(geo.exterior, s_geo)
@@ -961,6 +979,11 @@ class RulesCheck(FlatCAMTool):
min_dict[dist].append(loc) min_dict[dist].append(loc)
else: else:
min_dict[dist] = [loc] min_dict[dist] = [loc]
else:
if dist in min_dict:
min_dict[dist].append(s_geo.representative_point())
else:
min_dict[dist] = [s_geo.representative_point()]
points_list = list() points_list = list()
for dist in min_dict.keys(): for dist in min_dict.keys():
@@ -968,19 +991,32 @@ class RulesCheck(FlatCAMTool):
points_list.append(location) points_list.append(location)
name_list = list() name_list = list()
try:
if gerber_obj: if gerber_obj:
name_list.append(gerber_obj['name']) name_list.append(gerber_obj['name'])
except KeyError:
pass
try:
if gerber_extra_obj: if gerber_extra_obj:
name_list.append(gerber_extra_obj['name']) name_list.append(gerber_extra_obj['name'])
except KeyError:
pass
try:
if exc_obj: if exc_obj:
name_list.append(exc_obj['name']) name_list.append(exc_obj['name'])
except KeyError:
pass
try:
if exc_extra_obj: if exc_extra_obj:
name_list.append(exc_extra_obj['name']) name_list.append(exc_extra_obj['name'])
except KeyError:
pass
obj_violations['name'] = name_list obj_violations['name'] = name_list
obj_violations['points'] = points_list obj_violations['points'] = points_list
violations.append(deepcopy(obj_violations)) violations.append(deepcopy(obj_violations))
return rule_title, violations return rule_title, violations
def execute(self): def execute(self):
@@ -1438,6 +1474,7 @@ class RulesCheck(FlatCAMTool):
txt += 'File name: %s<BR>' % str(el[1][0]['name']) txt += 'File name: %s<BR>' % str(el[1][0]['name'])
point_txt = '' point_txt = ''
try:
if el[1][0]['points']: if el[1][0]['points']:
txt += '{title}: <span style="color:{color};">{status}</span>.<BR>'.format(title=_("STATUS"), txt += '{title}: <span style="color:{color};">{status}</span>.<BR>'.format(title=_("STATUS"),
color='red', color='red',
@@ -1454,6 +1491,29 @@ class RulesCheck(FlatCAMTool):
color='green', color='green',
status=_("PASSED")) status=_("PASSED"))
txt += '%s<BR>' % _("Violations: There are no violations for the current rule.") txt += '%s<BR>' % _("Violations: There are no violations for the current rule.")
except KeyError:
pass
try:
if el[1][0]['dia']:
txt += '{title}: <span style="color:{color};">{status}</span>.<BR>'.format(title=_("STATUS"),
color='red',
status=_("FAILED"))
if 'Failed' in el[1][0]['dia']:
point_txt = el[1][0]['dia']
else:
for pt in el[1][0]['dia']:
point_txt += '%.*f' % (self.decimals, float(pt))
point_txt += ', '
txt += 'Violations: %s<BR>' % str(point_txt)
else:
txt += '{title}: <span style="color:{color};">{status}</span>.<BR>'.format(title=_("STATUS"),
color='green',
status=_("PASSED"))
txt += '%s<BR>' % _("Violations: There are no violations for the current rule.")
except KeyError:
pass
txt += '<BR><BR>' txt += '<BR><BR>'
new_obj.source_file = txt new_obj.source_file = txt
new_obj.read_only = True new_obj.read_only = True