소스 검색

- 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)

Marius Stanciu 5 년 전
부모
커밋
5142b51590
2개의 변경된 파일27개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 0
      CHANGELOG.md
  2. 26 4
      camlib.py

+ 1 - 0
CHANGELOG.md

@@ -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
 

+ 26 - 4
camlib.py

@@ -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: