Fixes #157.
This commit is contained in:
parent
d1442a4900
commit
eb18b7fd3f
71
camlib.py
71
camlib.py
|
@ -1773,6 +1773,9 @@ class Gerber (Geometry):
|
||||||
|
|
||||||
## --- BUFFERED ---
|
## --- BUFFERED ---
|
||||||
if making_region:
|
if making_region:
|
||||||
|
if follow:
|
||||||
|
geo = Polygon()
|
||||||
|
else:
|
||||||
geo = Polygon(path)
|
geo = Polygon(path)
|
||||||
else:
|
else:
|
||||||
if last_path_aperture is None:
|
if last_path_aperture is None:
|
||||||
|
@ -1783,7 +1786,9 @@ class Gerber (Geometry):
|
||||||
geo = LineString(path)
|
geo = LineString(path)
|
||||||
else:
|
else:
|
||||||
geo = LineString(path).buffer(width / 2)
|
geo = LineString(path).buffer(width / 2)
|
||||||
if not geo.is_empty: poly_buffer.append(geo)
|
|
||||||
|
if not geo.is_empty:
|
||||||
|
poly_buffer.append(geo)
|
||||||
|
|
||||||
path = [[current_x, current_y]] # Start new path
|
path = [[current_x, current_y]] # Start new path
|
||||||
|
|
||||||
|
@ -1795,17 +1800,26 @@ class Gerber (Geometry):
|
||||||
if len(path) > 1:
|
if len(path) > 1:
|
||||||
# --- Buffered ----
|
# --- Buffered ----
|
||||||
width = self.apertures[last_path_aperture]["size"]
|
width = self.apertures[last_path_aperture]["size"]
|
||||||
|
|
||||||
|
if follow:
|
||||||
|
geo = LineString(path)
|
||||||
|
else:
|
||||||
geo = LineString(path).buffer(width / 2)
|
geo = LineString(path).buffer(width / 2)
|
||||||
if not geo.is_empty: poly_buffer.append(geo)
|
|
||||||
|
if not geo.is_empty:
|
||||||
|
poly_buffer.append(geo)
|
||||||
|
|
||||||
# Reset path starting point
|
# Reset path starting point
|
||||||
path = [[current_x, current_y]]
|
path = [[current_x, current_y]]
|
||||||
|
|
||||||
# --- BUFFERED ---
|
# --- BUFFERED ---
|
||||||
# Draw the flash
|
# Draw the flash
|
||||||
|
if follow:
|
||||||
|
continue
|
||||||
flash = Gerber.create_flash_geometry(Point([current_x, current_y]),
|
flash = Gerber.create_flash_geometry(Point([current_x, current_y]),
|
||||||
self.apertures[current_aperture])
|
self.apertures[current_aperture])
|
||||||
if not flash.is_empty: poly_buffer.append(flash)
|
if not flash.is_empty:
|
||||||
|
poly_buffer.append(flash)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -1858,8 +1872,13 @@ class Gerber (Geometry):
|
||||||
|
|
||||||
# --- BUFFERED ---
|
# --- BUFFERED ---
|
||||||
width = self.apertures[last_path_aperture]["size"]
|
width = self.apertures[last_path_aperture]["size"]
|
||||||
|
|
||||||
|
if follow:
|
||||||
|
buffered = LineString(path)
|
||||||
|
else:
|
||||||
buffered = LineString(path).buffer(width / 2)
|
buffered = LineString(path).buffer(width / 2)
|
||||||
if not buffered.is_empty: poly_buffer.append(buffered)
|
if not buffered.is_empty:
|
||||||
|
poly_buffer.append(buffered)
|
||||||
|
|
||||||
current_x = x
|
current_x = x
|
||||||
current_y = y
|
current_y = y
|
||||||
|
@ -1972,9 +1991,12 @@ class Gerber (Geometry):
|
||||||
log.debug("Bare op-code %d." % current_operation_code)
|
log.debug("Bare op-code %d." % current_operation_code)
|
||||||
# flash = Gerber.create_flash_geometry(Point(path[-1]),
|
# flash = Gerber.create_flash_geometry(Point(path[-1]),
|
||||||
# self.apertures[current_aperture])
|
# self.apertures[current_aperture])
|
||||||
|
if follow:
|
||||||
|
continue
|
||||||
flash = Gerber.create_flash_geometry(Point(current_x, current_y),
|
flash = Gerber.create_flash_geometry(Point(current_x, current_y),
|
||||||
self.apertures[current_aperture])
|
self.apertures[current_aperture])
|
||||||
if not flash.is_empty: poly_buffer.append(flash)
|
if not flash.is_empty:
|
||||||
|
poly_buffer.append(flash)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
log.warning("Line %d: %s -> Nothing there to flash!" % (line_num, gline))
|
log.warning("Line %d: %s -> Nothing there to flash!" % (line_num, gline))
|
||||||
|
|
||||||
|
@ -1996,8 +2018,13 @@ class Gerber (Geometry):
|
||||||
|
|
||||||
## --- Buffered ---
|
## --- Buffered ---
|
||||||
width = self.apertures[last_path_aperture]["size"]
|
width = self.apertures[last_path_aperture]["size"]
|
||||||
|
|
||||||
|
if follow:
|
||||||
|
geo = LineString(path)
|
||||||
|
else:
|
||||||
geo = LineString(path).buffer(width/2)
|
geo = LineString(path).buffer(width/2)
|
||||||
if not geo.is_empty: poly_buffer.append(geo)
|
if not geo.is_empty:
|
||||||
|
poly_buffer.append(geo)
|
||||||
|
|
||||||
path = [path[-1]]
|
path = [path[-1]]
|
||||||
|
|
||||||
|
@ -2024,10 +2051,15 @@ class Gerber (Geometry):
|
||||||
# "aperture": last_path_aperture})
|
# "aperture": last_path_aperture})
|
||||||
|
|
||||||
# --- Buffered ---
|
# --- Buffered ---
|
||||||
|
if follow:
|
||||||
|
region = Polygon()
|
||||||
|
else:
|
||||||
region = Polygon(path)
|
region = Polygon(path)
|
||||||
if not region.is_valid:
|
if not region.is_valid:
|
||||||
|
if not follow:
|
||||||
region = region.buffer(0)
|
region = region.buffer(0)
|
||||||
if not region.is_empty: poly_buffer.append(region)
|
if not region.is_empty:
|
||||||
|
poly_buffer.append(region)
|
||||||
|
|
||||||
path = [[current_x, current_y]] # Start new path
|
path = [[current_x, current_y]] # Start new path
|
||||||
continue
|
continue
|
||||||
|
@ -2060,8 +2092,14 @@ class Gerber (Geometry):
|
||||||
if len(path) > 1:
|
if len(path) > 1:
|
||||||
# --- Buffered ----
|
# --- Buffered ----
|
||||||
width = self.apertures[last_path_aperture]["size"]
|
width = self.apertures[last_path_aperture]["size"]
|
||||||
|
|
||||||
|
if follow:
|
||||||
|
geo = LineString(path)
|
||||||
|
else:
|
||||||
geo = LineString(path).buffer(width / 2)
|
geo = LineString(path).buffer(width / 2)
|
||||||
if not geo.is_empty: poly_buffer.append(geo)
|
if not geo.is_empty:
|
||||||
|
poly_buffer.append(geo)
|
||||||
|
|
||||||
path = [path[-1]]
|
path = [path[-1]]
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
@ -2076,8 +2114,13 @@ class Gerber (Geometry):
|
||||||
|
|
||||||
# --- Buffered ----
|
# --- Buffered ----
|
||||||
width = self.apertures[last_path_aperture]["size"]
|
width = self.apertures[last_path_aperture]["size"]
|
||||||
|
|
||||||
|
if follow:
|
||||||
|
geo = LineString(path)
|
||||||
|
else:
|
||||||
geo = LineString(path).buffer(width / 2)
|
geo = LineString(path).buffer(width / 2)
|
||||||
if not geo.is_empty: poly_buffer.append(geo)
|
if not geo.is_empty:
|
||||||
|
poly_buffer.append(geo)
|
||||||
|
|
||||||
path = [path[-1]]
|
path = [path[-1]]
|
||||||
|
|
||||||
|
@ -2148,10 +2191,18 @@ class Gerber (Geometry):
|
||||||
|
|
||||||
## --- Buffered ---
|
## --- Buffered ---
|
||||||
width = self.apertures[last_path_aperture]["size"]
|
width = self.apertures[last_path_aperture]["size"]
|
||||||
|
if follow:
|
||||||
|
geo = LineString(path)
|
||||||
|
else:
|
||||||
geo = LineString(path).buffer(width / 2)
|
geo = LineString(path).buffer(width / 2)
|
||||||
if not geo.is_empty: poly_buffer.append(geo)
|
if not geo.is_empty:
|
||||||
|
poly_buffer.append(geo)
|
||||||
|
|
||||||
# --- Apply buffer ---
|
# --- Apply buffer ---
|
||||||
|
if follow:
|
||||||
|
self.solid_geometry = poly_buffer
|
||||||
|
return
|
||||||
|
|
||||||
log.warn("Joining %d polygons." % len(poly_buffer))
|
log.warn("Joining %d polygons." % len(poly_buffer))
|
||||||
if self.use_buffer_for_union:
|
if self.use_buffer_for_union:
|
||||||
log.debug("Union by buffer...")
|
log.debug("Union by buffer...")
|
||||||
|
|
Loading…
Reference in New Issue