From ce4b6a5a85c6fb330dcb084c4065d19b7b74452b Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Thu, 2 Jul 2020 05:53:59 +0300 Subject: [PATCH] - trying to optimize the resulting geometry in DXF import (and in SVG import) by merging contiguous lines; reduced the lines to about one third of the original --- CHANGELOG.md | 4 ++++ camlib.py | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e0e06c4..0b8cf598 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta ================================================= +2.07.2020 + +- trying to optimize the resulting geometry in DXF import (and in SVG import) by merging contiguous lines; reduced the lines to about one third of the original + 30.06.2020 - fixed the SVG parser so the SVG files with no information regarding the 'height' can be opened in FlatCAM; fixed issue #433 diff --git a/camlib.py b/camlib.py index 5bf74406..aa4d314a 100644 --- a/camlib.py +++ b/camlib.py @@ -25,7 +25,7 @@ from lxml import etree as ET from shapely.geometry import Polygon, LineString, Point, LinearRing, MultiLineString, MultiPoint, MultiPolygon from shapely.geometry import box as shply_box -from shapely.ops import cascaded_union, unary_union, substring +from shapely.ops import cascaded_union, unary_union, substring, linemerge import shapely.affinity as affinity from shapely.wkt import loads as sloads from shapely.wkt import dumps as sdumps @@ -1057,6 +1057,9 @@ class Geometry(object): if flip: 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 = linemerge(geos) + # Add to object if self.solid_geometry is None: self.solid_geometry = [] @@ -1098,6 +1101,8 @@ class Geometry(object): # Parse into list of shapely objects dxf = ezdxf.readfile(filename) geos = getdxfgeo(dxf) + # trying to optimize the resulting geometry by merging contiguous lines + geos = linemerge(geos) # Add to object if self.solid_geometry is None: