Temporary fix/workaround for bug #83. Checking for empty list before running cascaded_union.

This commit is contained in:
jpcaram
2014-12-14 19:03:04 -05:00
parent 4eb69a9f07
commit c1b606feb4
2 changed files with 11 additions and 11 deletions

View File

@@ -1289,7 +1289,7 @@ class Gerber (Geometry):
if quadrant_mode == 'MULTI': if quadrant_mode == 'MULTI':
center = [i + current_x, j + current_y] center = [i + current_x, j + current_y]
radius = sqrt(i**2 + j**2) radius = sqrt(i ** 2 + j ** 2)
start = arctan2(-j, -i) # Start angle start = arctan2(-j, -i) # Start angle
# Numerical errors might prevent start == stop therefore # Numerical errors might prevent start == stop therefore
# we check ahead of time. This should result in a # we check ahead of time. This should result in a
@@ -1363,8 +1363,6 @@ class Gerber (Geometry):
else: else:
log.warning("Invalid arc in line %d." % line_num) log.warning("Invalid arc in line %d." % line_num)
### Operation code alone ### Operation code alone
# Operation code alone, usually just D03 (Flash) # Operation code alone, usually just D03 (Flash)
# self.opcode_re = re.compile(r'^D0?([123])\*$') # self.opcode_re = re.compile(r'^D0?([123])\*$')
@@ -1479,26 +1477,28 @@ class Gerber (Geometry):
print "RE:", self.lpol_re.pattern print "RE:", self.lpol_re.pattern
print "MATCH:", self.lpol_re.search(gline) print "MATCH:", self.lpol_re.search(gline)
match = self.lpol_re.search(gline) match = self.lpol_re.search(gline)
if match: if match:
if len(path) > 1 and current_polarity != match.group(1): if len(path) > 1 and current_polarity != match.group(1):
# --- Buffered ---- # --- Buffered ----
width = self.apertures[last_path_aperture]["size"] width = self.apertures[last_path_aperture]["size"]
geo = LineString(path).buffer(width/2) geo = LineString(path).buffer(width / 2)
poly_buffer.append(geo) poly_buffer.append(geo)
path = [path[-1]] path = [path[-1]]
# --- Apply buffer --- # --- Apply buffer ---
print "current_polarity:", current_polarity print "current_polarity:", current_polarity
if current_polarity == 'D': # If added for testing of bug #83
print "Union with Cascaded Union of:", poly_buffer # TODO: Remove when bug fixed
self.solid_geometry = self.solid_geometry.union(cascaded_union(poly_buffer)) if len(poly_buffer) > 0:
else: if current_polarity == 'D':
self.solid_geometry = self.solid_geometry.difference(cascaded_union(poly_buffer)) print "Union with Cascaded Union of:", poly_buffer
poly_buffer = [] self.solid_geometry = self.solid_geometry.union(cascaded_union(poly_buffer))
else:
self.solid_geometry = self.solid_geometry.difference(cascaded_union(poly_buffer))
poly_buffer = []
current_polarity = match.group(1) current_polarity = match.group(1)
continue continue

0
setup_ubuntu.sh Normal file → Executable file
View File