- Gerber Editor: some more changes in processing LPC polygons
This commit is contained in:
parent
0fdd2e4f7c
commit
4100e98ebe
|
@ -3183,10 +3183,10 @@ class Gerber (Geometry):
|
||||||
temp_geo = []
|
temp_geo = []
|
||||||
for apid in self.apertures:
|
for apid in self.apertures:
|
||||||
if 'clear_geometry' in self.apertures[apid]:
|
if 'clear_geometry' in self.apertures[apid]:
|
||||||
clear_geo = cascaded_union(self.apertures[apid]['clear_geometry'])
|
clear_geo = MultiPolygon(self.apertures[apid]['clear_geometry'])
|
||||||
for solid_geo in self.apertures[apid]['solid_geometry']:
|
for solid_geo in self.apertures[apid]['solid_geometry']:
|
||||||
if clear_geo.intersects(solid_geo):
|
if clear_geo.intersects(solid_geo):
|
||||||
res_geo = clear_geo.symmetric_difference(solid_geo)
|
res_geo = solid_geo.difference(clear_geo)
|
||||||
temp_geo.append(res_geo)
|
temp_geo.append(res_geo)
|
||||||
else:
|
else:
|
||||||
temp_geo.append(solid_geo)
|
temp_geo.append(solid_geo)
|
||||||
|
|
|
@ -1292,6 +1292,9 @@ class FlatCAMGrbEditor(QtCore.QObject):
|
||||||
# this var will store the state of the toolbar before starting the editor
|
# this var will store the state of the toolbar before starting the editor
|
||||||
self.toolbar_old_state = False
|
self.toolbar_old_state = False
|
||||||
|
|
||||||
|
# holds flattened geometry
|
||||||
|
self.flat_geometry = []
|
||||||
|
|
||||||
# Init GUI
|
# Init GUI
|
||||||
self.apdim_lbl.hide()
|
self.apdim_lbl.hide()
|
||||||
self.apdim_entry.hide()
|
self.apdim_entry.hide()
|
||||||
|
@ -1927,6 +1930,37 @@ class FlatCAMGrbEditor(QtCore.QObject):
|
||||||
self.shapes.clear(update=True)
|
self.shapes.clear(update=True)
|
||||||
self.tool_shape.clear(update=True)
|
self.tool_shape.clear(update=True)
|
||||||
|
|
||||||
|
def flatten(self, geometry=None, reset=True, pathonly=False):
|
||||||
|
"""
|
||||||
|
Creates a list of non-iterable linear geometry objects.
|
||||||
|
Polygons are expanded into its exterior pathonly param if specified.
|
||||||
|
|
||||||
|
Results are placed in flat_geometry
|
||||||
|
|
||||||
|
:param geometry: Shapely type or list or list of list of such.
|
||||||
|
:param reset: Clears the contents of self.flat_geometry.
|
||||||
|
:param pathonly: Expands polygons into linear elements from the exterior attribute.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if reset:
|
||||||
|
self.flat_geometry = []
|
||||||
|
## If iterable, expand recursively.
|
||||||
|
try:
|
||||||
|
for geo in geometry:
|
||||||
|
if geo is not None:
|
||||||
|
self.flatten(geometry=geo, reset=False, pathonly=pathonly)
|
||||||
|
|
||||||
|
## Not iterable, do the actual indexing and add.
|
||||||
|
except TypeError:
|
||||||
|
if pathonly and type(geometry) == Polygon:
|
||||||
|
self.flat_geometry.append(geometry.exterior)
|
||||||
|
self.flatten(geometry=geometry.interiors,
|
||||||
|
reset=False,
|
||||||
|
pathonly=True)
|
||||||
|
else:
|
||||||
|
self.flat_geometry.append(geometry)
|
||||||
|
return self.flat_geometry
|
||||||
|
|
||||||
def edit_fcgerber(self, orig_grb_obj):
|
def edit_fcgerber(self, orig_grb_obj):
|
||||||
"""
|
"""
|
||||||
Imports the geometry found in self.apertures from the given FlatCAM Gerber object
|
Imports the geometry found in self.apertures from the given FlatCAM Gerber object
|
||||||
|
|
Loading…
Reference in New Issue