- in import SVG and import DXF methods made sure that any polygons that are imported as polygons will survive and only the lines are optimized (changed the behavior of the above made modification)

This commit is contained in:
Marius Stanciu 2020-07-23 01:01:40 +03:00
parent b8fb64a143
commit 5142b51590
2 changed files with 27 additions and 4 deletions

View File

@ -16,6 +16,7 @@ CHANGELOG for FlatCAM beta
- made sure that optimizations of lines when importing SVG or DXF as lines will not encounter polygons but only LinesStrings or LinearRings, otherwise having crashes
- fixed the import SVG and import DXF, when importing as Geometry to be imported as multigeo tool
- fixed the import SVG and import DXF, the source files will be saved as loaded into the source_file attribute of the resulting object (be it Geometry or Gerber)
- in import SVG and import DXF methods made sure that any polygons that are imported as polygons will survive and only the lines are optimized (changed the behavior of the above made modification)
21.07.2020

View File

@ -1058,8 +1058,19 @@ class Geometry(object):
geos = [translate(scale(g, 1.0, -1.0, origin=(0, 0)), yoff=h) for g in geos]
# trying to optimize the resulting geometry by merging contiguous lines
geos = self.flatten(geos, reset=True, pathonly=True)
geos = linemerge(geos)
geos = list(self.flatten_list(geos))
geos_polys = []
geos_lines = []
for g in geos:
if isinstance(g, Polygon):
geos_polys.append(g)
else:
geos_lines.append(g)
merged_lines = linemerge(geos_lines)
geos = geos_polys
for l in merged_lines:
geos.append(l)
# Add to object
if self.solid_geometry is None:
@ -1123,8 +1134,19 @@ class Geometry(object):
geos = getdxfgeo(dxf)
# trying to optimize the resulting geometry by merging contiguous lines
geos = self.flatten(geos, reset=True, pathonly=True)
geos = linemerge(geos)
geos = list(self.flatten_list(geos))
geos_polys = []
geos_lines = []
for g in geos:
if isinstance(g, Polygon):
geos_polys.append(g)
else:
geos_lines.append(g)
merged_lines = linemerge(geos_lines)
geos = geos_polys
for l in merged_lines:
geos.append(l)
# Add to object
if self.solid_geometry is None: