Просмотр исходного кода

- Cutout Tool - made sure that all the paths generated by this tool are contiguous which means that two lines that meet at one end will become onle line therefore reducing unnecessary Z moves

Marius Stanciu 5 лет назад
Родитель
Сommit
7be4d98172
2 измененных файлов с 11 добавлено и 1 удалено
  1. 1 0
      CHANGELOG.md
  2. 10 1
      appTools/ToolCutOut.py

+ 1 - 0
CHANGELOG.md

@@ -14,6 +14,7 @@ CHANGELOG for FlatCAM beta
 - updated Cutout Tool UI
 - updated Cutout Tool UI
 - Cutout Tool - in manual gap adding there is now an option to automatically turn on the big cursor which could help
 - Cutout Tool - in manual gap adding there is now an option to automatically turn on the big cursor which could help
 - Cutout Tool - fixed errors when trying to add a manual gap without having a geometry object selected in the combobox
 - Cutout Tool - fixed errors when trying to add a manual gap without having a geometry object selected in the combobox
+- Cutout Tool - made sure that all the paths generated by this tool are contiguous which means that two lines that meet at one end will become onle line therefore reducing unnecessary Z moves
 
 
 17.06.2020
 17.06.2020
 
 

+ 10 - 1
appTools/ToolCutOut.py

@@ -10,7 +10,7 @@ from appTool import AppTool
 from appGUI.GUIElements import FCDoubleSpinner, FCCheckBox, RadioSet, FCComboBox, OptionalInputSection, FCButton
 from appGUI.GUIElements import FCDoubleSpinner, FCCheckBox, RadioSet, FCComboBox, OptionalInputSection, FCButton
 
 
 from shapely.geometry import box, MultiPolygon, Polygon, LineString, LinearRing, MultiLineString
 from shapely.geometry import box, MultiPolygon, Polygon, LineString, LinearRing, MultiLineString
-from shapely.ops import cascaded_union, unary_union
+from shapely.ops import cascaded_union, unary_union, linemerge
 import shapely.affinity as affinity
 import shapely.affinity as affinity
 
 
 from matplotlib.backend_bases import KeyEvent as mpl_key_event
 from matplotlib.backend_bases import KeyEvent as mpl_key_event
@@ -403,6 +403,8 @@ class CutOut(AppTool):
             if not solid_geo:
             if not solid_geo:
                 app_obj.inform.emit('[ERROR_NOTCL] %s' % _("Failed."))
                 app_obj.inform.emit('[ERROR_NOTCL] %s' % _("Failed."))
                 return "fail"
                 return "fail"
+
+            solid_geo = linemerge(solid_geo)
             geo_obj.solid_geometry = deepcopy(solid_geo)
             geo_obj.solid_geometry = deepcopy(solid_geo)
 
 
             xmin, ymin, xmax, ymax = CutOut.recursive_bounds(geo_obj.solid_geometry)
             xmin, ymin, xmax, ymax = CutOut.recursive_bounds(geo_obj.solid_geometry)
@@ -613,6 +615,12 @@ class CutOut(AppTool):
             geo_obj.options['cutz'] = self.ui.cutz_entry.get_value()
             geo_obj.options['cutz'] = self.ui.cutz_entry.get_value()
             geo_obj.options['multidepth'] = self.ui.mpass_cb.get_value()
             geo_obj.options['multidepth'] = self.ui.mpass_cb.get_value()
             geo_obj.options['depthperpass'] = self.ui.maxdepth_entry.get_value()
             geo_obj.options['depthperpass'] = self.ui.maxdepth_entry.get_value()
+
+            if not solid_geo:
+                app_obj.inform.emit('[ERROR_NOTCL] %s' % _("Failed."))
+                return "fail"
+
+            solid_geo = linemerge(solid_geo)
             geo_obj.solid_geometry = deepcopy(solid_geo)
             geo_obj.solid_geometry = deepcopy(solid_geo)
 
 
             geo_obj.tools.update({
             geo_obj.tools.update({
@@ -717,6 +725,7 @@ class CutOut(AppTool):
 
 
         # first subtract geometry for the total solid_geometry
         # first subtract geometry for the total solid_geometry
         new_solid_geometry = CutOut.subtract_polygon(self.man_cutout_obj.solid_geometry, cut_poly)
         new_solid_geometry = CutOut.subtract_polygon(self.man_cutout_obj.solid_geometry, cut_poly)
+        new_solid_geometry = linemerge(new_solid_geometry)
         self.man_cutout_obj.solid_geometry = new_solid_geometry
         self.man_cutout_obj.solid_geometry = new_solid_geometry
 
 
         # then do it or each tool in the manual cutout Geometry object
         # then do it or each tool in the manual cutout Geometry object