Correct handle of rules area (Fix #51)

This commit is contained in:
Jean-Samuel Reynaud
2023-01-23 11:39:18 +01:00
parent a019d9bf5c
commit f9ead29ac2

View File

@ -278,11 +278,13 @@ STEP = '-'
area_layer = area.GetLayer() area_layer = area.GetLayer()
area_clearance = area.GetLocalClearance() area_clearance = area.GetLocalClearance()
area_priority = area.GetPriority() area_priority = area.GetPriority()
is_keepout_area = False # area.GetIsKeepout() is_rules_area = area.GetIsRuleArea()
is_rule_exclude_via_area = area.GetIsRuleArea() and area.GetDoNotAllowVias()
is_target_net = (area.GetNetname() == self.netname) # (area.GetNetname().upper() == self.netname) is_target_net = (area.GetNetname() == self.netname) # (area.GetNetname().upper() == self.netname)
# wx.LogMessage(area.GetNetname()) #wx.LogMessage(area.GetNetname().upper()) # wx.LogMessage(area.GetNetname()) #wx.LogMessage(area.GetNetname().upper())
if (not is_target_net): # Only process areas that are not in the target net if (not is_target_net or is_rule_exclude_via_area): # Only process areas that are not in the target net or is a rule area that could exlude vias
# print("Process...")
# Offset is half the size of the via plus the clearance of the via or the area # Offset is half the size of the via plus the clearance of the via or the area
offset = max(self.clearance, area_clearance) + self.size / 2 offset = max(self.clearance, area_clearance) + self.size / 2
for dx in [-offset, offset]: for dx in [-offset, offset]:
@ -293,19 +295,21 @@ STEP = '-'
hit_test_area = area.HitTestFilledArea(area.GetLayer(), point_to_test) # Collides with a filled area hit_test_area = area.HitTestFilledArea(area.GetLayer(), point_to_test) # Collides with a filled area
hit_test_edge = area.HitTestForEdge(point_to_test, 1) # Collides with an edge/corner hit_test_edge = area.HitTestForEdge(point_to_test, 1) # Collides with an edge/corner
try: try:
hit_test_zone = area.HitTestInsideZone(point_to_test) # Is inside a zone (e.g. KeepOut) hit_test_zone = area.HitTestInsideZone(point_to_test) # Is inside a zone (e.g. KeepOut/Rules)
except: except:
hit_test_zone = False hit_test_zone = False
wxPrint('exception: missing HitTestInsideZone: To Be Fixed') wxPrint('exception: missing HitTestInsideZone: To Be Fixed')
# hit_test_zone = area.HitTest(point_to_test) # Is inside a zone (e.g. KeepOut) kicad nightly 5.99 # hit_test_zone = area.HitTest(point_to_test)
if is_keepout_area and (hit_test_area or hit_test_edge or hit_test_zone):
return self.REASON_KEEPOUT # Collides with keepout
elif (hit_test_area or hit_test_edge): # Is inside a zone (e.g. KeepOut/Rules with via exlusion) kicad
# Collides with another signal (e.g. on another layer) if is_rule_exclude_via_area and (hit_test_area or hit_test_edge or hit_test_zone):
return self.REASON_KEEPOUT # Collides with keepout/rules
elif (hit_test_area or hit_test_edge) and not is_rules_area:
# Collides with another signal (e.g. on another layer) but not a rule zone
return self.REASON_OTHER_SIGNAL return self.REASON_OTHER_SIGNAL
elif hit_test_zone: elif hit_test_zone and not is_rules_area:
# Check if the zone is higher priority than other zones of the target net in the same point # Check if the zone is higher priority than other zones of the target net in the same point
# target_areas_on_same_layer = filter(lambda x: ((x.GetPriority() > area_priority) and (x.GetLayer() == area_layer) and (x.GetNetname().upper() == self.netname)), all_areas) # target_areas_on_same_layer = filter(lambda x: ((x.GetPriority() > area_priority) and (x.GetLayer() == area_layer) and (x.GetNetname().upper() == self.netname)), all_areas)
target_areas_on_same_layer = filter(lambda x: ((x.GetPriority() > area_priority) and ( target_areas_on_same_layer = filter(lambda x: ((x.GetPriority() > area_priority) and (