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

- cascaded_union() method will be deprecated in Shapely 1.8 in favor of unary_union; replaced the usage of cascaded_union with unary_union in all the app

Marius Stanciu 5 лет назад
Родитель
Сommit
66a3e36701

+ 1 - 0
CHANGELOG.md

@@ -18,6 +18,7 @@ CHANGELOG for FlatCAM beta
 - fixed crash on using shortcut for creating a new Document Object
 - fixed Cutout Tool to work with the endxy parameter
 - added the exclusion parameters for Drilling Tool to the Preferences area
+- cascaded_union() method will be deprecated in Shapely 1.8 in favor of unary_union; replaced the usage of cascaded_union with unary_union in all the app
 
 20.10.2020
 

+ 3 - 3
appEditors/AppGeoEditor.py

@@ -21,7 +21,7 @@ from appGUI.GUIElements import OptionalInputSection, FCCheckBox, FCEntry, FCComb
 from appParsers.ParseFont import *
 
 from shapely.geometry import LineString, LinearRing, MultiLineString, Polygon, MultiPolygon
-from shapely.ops import cascaded_union, unary_union, linemerge
+from shapely.ops import unary_union, linemerge
 import shapely.affinity as affinity
 from shapely.geometry.polygon import orient
 
@@ -3147,7 +3147,7 @@ class FCEraser(FCShapeTool):
             temp_shape = eraser_shape.buffer(0.0000001)
             temp_shape = Polygon(temp_shape.exterior)
             eraser_sel_shapes.append(temp_shape)
-        eraser_sel_shapes = cascaded_union(eraser_sel_shapes)
+        eraser_sel_shapes = unary_union(eraser_sel_shapes)
 
         for obj_shape in self.storage.get_objects():
             try:
@@ -5134,7 +5134,7 @@ class AppGeoEditor(QtCore.QObject):
                     return
 
                 # add the result to the results list
-                results.append(cascaded_union(local_results))
+                results.append(unary_union(local_results))
 
         # This is a dirty patch:
         for r in results:

+ 3 - 3
appEditors/AppGerberEditor.py

@@ -9,7 +9,7 @@ from PyQt5 import QtGui, QtCore, QtWidgets
 from PyQt5.QtCore import Qt, QSettings
 
 from shapely.geometry import LineString, LinearRing, MultiLineString, Point, Polygon, MultiPolygon, box
-from shapely.ops import cascaded_union
+from shapely.ops import unary_union
 import shapely.affinity as affinity
 
 from vispy.geometry import Rect
@@ -2235,7 +2235,7 @@ class FCEraser(FCShapeTool):
             temp_shape = eraser_shape['solid'].buffer(0.0000001)
             temp_shape = Polygon(temp_shape.exterior)
             eraser_sel_shapes.append(temp_shape)
-        eraser_sel_shapes = cascaded_union(eraser_sel_shapes)
+        eraser_sel_shapes = unary_union(eraser_sel_shapes)
 
         for storage in self.draw_app.storage_dict:
             try:
@@ -4968,7 +4968,7 @@ class AppGerberEditor(QtCore.QObject):
                 if 'solid' in actual_geo:
                     edit_geo.append(actual_geo['solid'])
 
-        all_geo = cascaded_union(edit_geo)
+        all_geo = unary_union(edit_geo)
 
         # calculate the bounds values for the edited Gerber object
         xmin, ymin, xmax, ymax = all_geo.bounds

+ 1 - 1
appObjects/FlatCAMCNCJob.py

@@ -2568,7 +2568,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
                 #         g['geom'] = affinity.scale(g['geom'], factor, factor, origin=(0, 0))
                 #
                 #     tool_dia_copy['gcode_parsed'] = deepcopy(dia_value)
-                #     tool_dia_copy['solid_geometry'] = cascaded_union([geo['geom'] for geo in dia_value])
+                #     tool_dia_copy['solid_geometry'] = unary_union([geo['geom'] for geo in dia_value])
 
             temp_tools_dict.update({
                 tooluid_key: deepcopy(tool_dia_copy)

+ 2 - 2
appObjects/FlatCAMGeometry.py

@@ -2052,7 +2052,7 @@ class GeometryObject(FlatCAMObj, Geometry):
                 # TODO this serve for bounding box creation only; should be optimized
                 # commented this; there is no need for the actual GCode geometry - the original one will serve as well
                 # for bounding box values
-                # dia_cnc_dict['solid_geometry'] = cascaded_union([geo['geom'] for geo in dia_cnc_dict['gcode_parsed']])
+                # dia_cnc_dict['solid_geometry'] = unary_union([geo['geom'] for geo in dia_cnc_dict['gcode_parsed']])
                 try:
                     dia_cnc_dict['solid_geometry'] = tool_solid_geometry
                     self.app.inform.emit('[success] %s...' % _("Finished G-Code processing"))
@@ -2202,7 +2202,7 @@ class GeometryObject(FlatCAMObj, Geometry):
                 # TODO this serve for bounding box creation only; should be optimized
                 # commented this; there is no need for the actual GCode geometry - the original one will serve as well
                 # for bounding box values
-                # geo_for_bound_values = cascaded_union([
+                # geo_for_bound_values = unary_union([
                 #     geo['geom'] for geo in dia_cnc_dict['gcode_parsed'] if geo['geom'].is_valid is True
                 # ])
                 try:

+ 3 - 3
appObjects/FlatCAMGerber.py

@@ -12,7 +12,7 @@
 
 
 from shapely.geometry import Point, Polygon, MultiPolygon, MultiLineString, LineString, LinearRing
-from shapely.ops import cascaded_union
+from shapely.ops import unary_union
 
 from appParsers.ParseGerber import Gerber
 from appObjects.FlatCAMObj import *
@@ -386,7 +386,7 @@ class GerberObject(FlatCAMObj, Gerber):
                 try:
                     self.solid_geometry = MultiPolygon(self.solid_geometry)
                 except Exception:
-                    self.solid_geometry = cascaded_union(self.solid_geometry)
+                    self.solid_geometry = unary_union(self.solid_geometry)
 
             bounding_box = self.solid_geometry.envelope.buffer(float(self.options["noncoppermargin"]))
             if not self.options["noncopperrounded"]:
@@ -412,7 +412,7 @@ class GerberObject(FlatCAMObj, Gerber):
                 try:
                     self.solid_geometry = MultiPolygon(self.solid_geometry)
                 except Exception:
-                    self.solid_geometry = cascaded_union(self.solid_geometry)
+                    self.solid_geometry = unary_union(self.solid_geometry)
 
             # Bounding box with rounded corners
             bounding_box = self.solid_geometry.envelope.buffer(float(self.options["bboxmargin"]))

+ 2 - 2
appParsers/ParseGerber.py

@@ -374,7 +374,7 @@ class Gerber(Geometry):
         geo_f = None
 
         # Polygons are stored here until there is a change in polarity.
-        # Only then they are combined via cascaded_union and added or
+        # Only then they are combined via unary_union and added or
         # subtracted from solid_geometry. This is ~100 times faster than
         # applying a union for every new polygon.
         poly_buffer = []
@@ -1680,7 +1680,7 @@ class Gerber(Geometry):
         #
         # self.do_flashes()
         #
-        # self.solid_geometry = cascaded_union(self.buffered_paths +
+        # self.solid_geometry = unary_union(self.buffered_paths +
         #                                      [poly['polygon'] for poly in self.regions] +
         #                                      self.flash_geometry)
 

+ 7 - 7
appTools/ToolCopperThieving.py

@@ -12,7 +12,7 @@ from appTool import AppTool
 from appGUI.GUIElements import FCDoubleSpinner, RadioSet, FCEntry, FCComboBox
 
 import shapely.geometry.base as base
-from shapely.ops import cascaded_union, unary_union
+from shapely.ops import unary_union
 from shapely.geometry import Polygon, MultiPolygon, Point, LineString
 from shapely.geometry import box as box
 import shapely.affinity as affinity
@@ -428,7 +428,7 @@ class ToolCopperThieving(AppTool):
             if len(self.sel_rect) == 0:
                 return
 
-            self.sel_rect = cascaded_union(self.sel_rect)
+            self.sel_rect = unary_union(self.sel_rect)
 
             if not isinstance(self.sel_rect, Iterable):
                 self.sel_rect = [self.sel_rect]
@@ -606,9 +606,9 @@ class ToolCopperThieving(AppTool):
                             env_obj = geo_n.convex_hull
                         elif (isinstance(geo_n, MultiPolygon) and len(geo_n) == 1) or \
                                 (isinstance(geo_n, list) and len(geo_n) == 1) and isinstance(geo_n[0], Polygon):
-                            env_obj = cascaded_union(geo_n)
+                            env_obj = unary_union(geo_n)
                         else:
-                            env_obj = cascaded_union(geo_n)
+                            env_obj = unary_union(geo_n)
                             env_obj = env_obj.convex_hull
                         bounding_box = env_obj.buffer(distance=margin, join_style=base.JOIN_STYLE.mitre)
                     else:
@@ -660,10 +660,10 @@ class ToolCopperThieving(AppTool):
                             raise grace
                         geo_buff_list.append(poly.buffer(distance=margin, join_style=base.JOIN_STYLE.mitre))
 
-                    bounding_box = cascaded_union(geo_buff_list)
+                    bounding_box = unary_union(geo_buff_list)
                 elif working_obj.kind == 'gerber':
-                    geo_n = cascaded_union(geo_n).convex_hull
-                    bounding_box = cascaded_union(thieving_obj.solid_geometry).convex_hull.intersection(geo_n)
+                    geo_n = unary_union(geo_n).convex_hull
+                    bounding_box = unary_union(thieving_obj.solid_geometry).convex_hull.intersection(geo_n)
                     bounding_box = bounding_box.buffer(distance=margin, join_style=base.JOIN_STYLE.mitre)
                 else:
                     app_obj.app.inform.emit('[ERROR_NOTCL] %s' % _("The reference object type is not supported."))

+ 3 - 3
appTools/ToolCutOut.py

@@ -11,7 +11,7 @@ from appGUI.GUIElements import FCDoubleSpinner, FCCheckBox, RadioSet, FCComboBox
     FCLabel
 
 from shapely.geometry import box, MultiPolygon, Polygon, LineString, LinearRing, MultiLineString
-from shapely.ops import cascaded_union, unary_union, linemerge
+from shapely.ops import unary_union, linemerge
 import shapely.affinity as affinity
 
 from matplotlib.backend_bases import KeyEvent as mpl_key_event
@@ -1834,7 +1834,7 @@ class CutOut(AppTool):
         log.debug("%d paths" % len(flat_geometry))
 
         polygon = Polygon(points)
-        toolgeo = cascaded_union(polygon)
+        toolgeo = unary_union(polygon)
         diffs = []
         for target in flat_geometry:
             if type(target) == LineString or type(target) == LinearRing:
@@ -1908,7 +1908,7 @@ class CutOut(AppTool):
 
         :param target_geo:      geometry from which to subtract
         :param subtractor:      a list of Points, a LinearRing or a Polygon that will be subtracted from target_geo
-        :return:                a cascaded union of the resulting geometry
+        :return:                a unary_union of the resulting geometry
         """
 
         if target_geo is None:

+ 3 - 3
appTools/ToolDistanceMin.py

@@ -11,7 +11,7 @@ from appGUI.GUIElements import FCEntry
 
 from shapely.ops import nearest_points
 from shapely.geometry import Point, MultiPolygon
-from shapely.ops import cascaded_union
+from shapely.ops import unary_union
 
 import math
 import logging
@@ -113,12 +113,12 @@ class DistanceMin(AppTool):
                     try:
                         selected_objs[0].solid_geometry = MultiPolygon(selected_objs[0].solid_geometry)
                     except Exception:
-                        selected_objs[0].solid_geometry = cascaded_union(selected_objs[0].solid_geometry)
+                        selected_objs[0].solid_geometry = unary_union(selected_objs[0].solid_geometry)
 
                     try:
                         selected_objs[1].solid_geometry = MultiPolygon(selected_objs[1].solid_geometry)
                     except Exception:
-                        selected_objs[1].solid_geometry = cascaded_union(selected_objs[1].solid_geometry)
+                        selected_objs[1].solid_geometry = unary_union(selected_objs[1].solid_geometry)
 
                 first_pos, last_pos = nearest_points(selected_objs[0].solid_geometry, selected_objs[1].solid_geometry)
 

+ 7 - 7
appTools/ToolIsolation.py

@@ -19,7 +19,7 @@ import numpy as np
 import simplejson as json
 import sys
 
-from shapely.ops import cascaded_union, nearest_points
+from shapely.ops import unary_union, nearest_points
 from shapely.geometry import MultiPolygon, Polygon, MultiLineString, LineString, LinearRing, Point
 
 from matplotlib.backend_bases import KeyEvent as mpl_key_event
@@ -1474,8 +1474,8 @@ class ToolIsolation(AppTool, Gerber):
 
         elif selection == _("Reference Object"):
             ref_obj = self.app.collection.get_by_name(self.ui.reference_combo.get_value())
-            ref_geo = cascaded_union(ref_obj.solid_geometry)
-            use_geo = cascaded_union(isolated_obj.solid_geometry).difference(ref_geo)
+            ref_geo = unary_union(ref_obj.solid_geometry)
+            use_geo = unary_union(isolated_obj.solid_geometry).difference(ref_geo)
             self.isolate(isolated_obj=isolated_obj, geometry=use_geo)
 
     def isolate(self, isolated_obj, geometry=None, limited_area=None, negative_dia=None, plot=True):
@@ -2048,11 +2048,11 @@ class ToolIsolation(AppTool, Gerber):
         target_geo = geo
 
         if subtraction_geo:
-            sub_union = cascaded_union(subtraction_geo)
+            sub_union = unary_union(subtraction_geo)
         else:
             name = self.ui.exc_obj_combo.currentText()
             subtractor_obj = self.app.collection.get_by_name(name)
-            sub_union = cascaded_union(subtractor_obj.solid_geometry)
+            sub_union = unary_union(subtractor_obj.solid_geometry)
 
         try:
             for geo_elem in target_geo:
@@ -2106,7 +2106,7 @@ class ToolIsolation(AppTool, Gerber):
         new_geometry = []
         target_geo = geo
 
-        intersect_union = cascaded_union(intersection_geo)
+        intersect_union = unary_union(intersection_geo)
 
         try:
             for geo_elem in target_geo:
@@ -2427,7 +2427,7 @@ class ToolIsolation(AppTool, Gerber):
             if len(self.sel_rect) == 0:
                 return
 
-            self.sel_rect = cascaded_union(self.sel_rect)
+            self.sel_rect = unary_union(self.sel_rect)
             self.isolate(isolated_obj=self.grb_obj, limited_area=self.sel_rect, plot=True)
             self.sel_rect = []
 

+ 1 - 1
appTools/ToolMilling.py

@@ -17,7 +17,7 @@ from copy import deepcopy
 # import numpy as np
 # import math
 
-# from shapely.ops import cascaded_union
+# from shapely.ops import unary_union
 from shapely.geometry import Point, LineString
 
 from matplotlib.backend_bases import KeyEvent as mpl_key_event

+ 24 - 24
appTools/ToolNCC.py

@@ -18,7 +18,7 @@ from copy import deepcopy
 
 import numpy as np
 from shapely.geometry import base
-from shapely.ops import cascaded_union, nearest_points
+from shapely.ops import unary_union, nearest_points
 from shapely.geometry import MultiPolygon, Polygon, MultiLineString, LineString, LinearRing
 
 from matplotlib.backend_bases import KeyEvent as mpl_key_event
@@ -1461,7 +1461,7 @@ class NonCopperClear(AppTool, Gerber):
             if len(self.sel_rect) == 0:
                 return
 
-            self.sel_rect = cascaded_union(self.sel_rect)
+            self.sel_rect = unary_union(self.sel_rect)
 
             self.clear_copper(ncc_obj=self.ncc_obj, sel_obj=self.bound_obj, ncctooldia=self.ncc_dia_list,
                               isotooldia=self.iso_dia_list, outname=self.o_name)
@@ -1623,16 +1623,16 @@ class NonCopperClear(AppTool, Gerber):
                     env_obj = geo_n.convex_hull
                 elif (isinstance(geo_n, MultiPolygon) and len(geo_n) == 1) or \
                         (isinstance(geo_n, list) and len(geo_n) == 1) and isinstance(geo_n[0], Polygon):
-                    env_obj = cascaded_union(geo_n)
+                    env_obj = unary_union(geo_n)
                 else:
-                    env_obj = cascaded_union(geo_n)
+                    env_obj = unary_union(geo_n)
                     env_obj = env_obj.convex_hull
             except Exception as e:
                 log.debug("NonCopperClear.calculate_bounding_box() 'itself'  --> %s" % str(e))
                 self.app.inform.emit('[ERROR_NOTCL] %s' % _("No object available."))
                 return None
         elif ncc_select == _("Area Selection"):
-            env_obj = cascaded_union(self.sel_rect)
+            env_obj = unary_union(self.sel_rect)
             try:
                 __ = iter(env_obj)
             except Exception:
@@ -1650,8 +1650,8 @@ class NonCopperClear(AppTool, Gerber):
                     env_obj = [box_geo]
 
             elif box_kind == 'gerber':
-                box_geo = cascaded_union(box_obj.solid_geometry).convex_hull
-                ncc_geo = cascaded_union(ncc_obj.solid_geometry).convex_hull
+                box_geo = unary_union(box_obj.solid_geometry).convex_hull
+                ncc_geo = unary_union(ncc_obj.solid_geometry).convex_hull
                 env_obj = ncc_geo.intersection(box_geo)
             else:
                 self.app.inform.emit('[ERROR_NOTCL] %s' % _("The reference object type is not supported."))
@@ -1693,7 +1693,7 @@ class NonCopperClear(AppTool, Gerber):
                     # graceful abort requested by the user
                     raise grace
                 geo_buff_list.append(poly.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre))
-            new_bounding_box = cascaded_union(geo_buff_list)
+            new_bounding_box = unary_union(geo_buff_list)
         elif ncc_select == _("Reference Object"):
             if box_kind == 'geometry':
                 geo_buff_list = []
@@ -1703,7 +1703,7 @@ class NonCopperClear(AppTool, Gerber):
                         raise grace
                     geo_buff_list.append(poly.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre))
 
-                new_bounding_box = cascaded_union(geo_buff_list)
+                new_bounding_box = unary_union(geo_buff_list)
             elif box_kind == 'gerber':
                 new_bounding_box = bbox.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre)
             else:
@@ -1874,7 +1874,7 @@ class NonCopperClear(AppTool, Gerber):
                         geo_obj.tools[current_uid] = dict(tools_storage[current_uid])
                         break
 
-            sol_geo = cascaded_union(isolated_geo)
+            sol_geo = unary_union(isolated_geo)
             if has_offset is True:
                 self.app.inform.emit('[WARNING_NOTCL] %s ...' % _("Buffering"))
                 sol_geo = sol_geo.buffer(distance=ncc_offset)
@@ -1887,7 +1887,7 @@ class NonCopperClear(AppTool, Gerber):
                 return 'fail'
 
         elif ncc_obj.kind == 'geometry':
-            sol_geo = cascaded_union(ncc_obj.solid_geometry)
+            sol_geo = unary_union(ncc_obj.solid_geometry)
             if has_offset is True:
                 self.app.inform.emit('[WARNING_NOTCL] %s ...' % _("Buffering"))
                 sol_geo = sol_geo.buffer(distance=ncc_offset)
@@ -2431,7 +2431,7 @@ class NonCopperClear(AppTool, Gerber):
                             log.debug("There are no geometries in the cleared polygon.")
 
                 # Area to clear next
-                buffered_cleared = cascaded_union(cleared_geo).buffer(tool / 2.0)
+                buffered_cleared = unary_union(cleared_geo).buffer(tool / 2.0)
                 area = area.difference(buffered_cleared)
 
                 if not area or area.is_empty:
@@ -2443,7 +2443,7 @@ class NonCopperClear(AppTool, Gerber):
                 #     new_area = [p.buffer(buff_distance) for p in area if not p.is_empty]
                 # except TypeError:
                 #     new_area = [area.buffer(tool * ncc_overlap)]
-                # area = cascaded_union(area)
+                # area = unary_union(area)
 
             geo_obj.multigeo = True
             geo_obj.options["cnctooldia"] = '0.0'
@@ -2616,9 +2616,9 @@ class NonCopperClear(AppTool, Gerber):
                     env_obj = geo_n.convex_hull
                 elif (isinstance(geo_n, MultiPolygon) and len(geo_n) == 1) or \
                         (isinstance(geo_n, list) and len(geo_n) == 1) and isinstance(geo_n[0], Polygon):
-                    env_obj = cascaded_union(geo_n)
+                    env_obj = unary_union(geo_n)
                 else:
-                    env_obj = cascaded_union(geo_n)
+                    env_obj = unary_union(geo_n)
                     env_obj = env_obj.convex_hull
 
                 bounding_box = env_obj.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre)
@@ -2628,7 +2628,7 @@ class NonCopperClear(AppTool, Gerber):
                 return 'fail'
 
         elif ncc_select == 'area':
-            geo_n = cascaded_union(self.sel_rect)
+            geo_n = unary_union(self.sel_rect)
             try:
                 __ = iter(geo_n)
             except Exception as e:
@@ -2642,7 +2642,7 @@ class NonCopperClear(AppTool, Gerber):
                     raise grace
                 geo_buff_list.append(poly.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre))
 
-            bounding_box = cascaded_union(geo_buff_list)
+            bounding_box = unary_union(geo_buff_list)
 
         elif ncc_select == _("Reference Object"):
             geo_n = ncc_sel_obj.solid_geometry
@@ -2660,10 +2660,10 @@ class NonCopperClear(AppTool, Gerber):
                         raise grace
                     geo_buff_list.append(poly.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre))
 
-                bounding_box = cascaded_union(geo_buff_list)
+                bounding_box = unary_union(geo_buff_list)
             elif ncc_sel_obj.kind == 'gerber':
-                geo_n = cascaded_union(geo_n).convex_hull
-                bounding_box = cascaded_union(self.ncc_obj.solid_geometry).convex_hull.intersection(geo_n)
+                geo_n = unary_union(geo_n).convex_hull
+                bounding_box = unary_union(self.ncc_obj.solid_geometry).convex_hull.intersection(geo_n)
                 bounding_box = bounding_box.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre)
             else:
                 self.app.inform.emit('[ERROR_NOTCL] %s' % _("The reference object type is not supported."))
@@ -2838,7 +2838,7 @@ class NonCopperClear(AppTool, Gerber):
                                 break
                         geo_obj.tools[current_uid] = dict(tools_storage[current_uid])
 
-                sol_geo = cascaded_union(isolated_geo)
+                sol_geo = unary_union(isolated_geo)
                 if has_offset is True:
                     app_obj.inform.emit('[WARNING_NOTCL] %s ...' % _("Buffering"))
                     sol_geo = sol_geo.buffer(distance=ncc_offset)
@@ -2853,7 +2853,7 @@ class NonCopperClear(AppTool, Gerber):
                     return 'fail'
 
             elif ncc_obj.kind == 'geometry':
-                sol_geo = cascaded_union(ncc_obj.solid_geometry)
+                sol_geo = unary_union(ncc_obj.solid_geometry)
                 if has_offset is True:
                     app_obj.inform.emit('[WARNING_NOTCL] %s ...' % _("Buffering"))
                     sol_geo = sol_geo.buffer(distance=ncc_offset)
@@ -3220,7 +3220,7 @@ class NonCopperClear(AppTool, Gerber):
                                 break
                         geo_obj.tools[current_uid] = dict(tools_storage[current_uid])
 
-                sol_geo = cascaded_union(isolated_geo)
+                sol_geo = unary_union(isolated_geo)
                 if has_offset is True:
                     app_obj.inform.emit('[WARNING_NOTCL] %s ...' % _("Buffering"))
                     sol_geo = sol_geo.buffer(distance=ncc_offset)
@@ -3235,7 +3235,7 @@ class NonCopperClear(AppTool, Gerber):
                     return 'fail'
 
             elif ncc_obj.kind == 'geometry':
-                sol_geo = cascaded_union(ncc_obj.solid_geometry)
+                sol_geo = unary_union(ncc_obj.solid_geometry)
                 if has_offset is True:
                     app_obj.inform.emit('[WARNING_NOTCL] %s ...' % _("Buffering"))
                     sol_geo = sol_geo.buffer(distance=ncc_offset)

+ 10 - 10
appTools/ToolPaint.py

@@ -17,7 +17,7 @@ from appGUI.GUIElements import FCTable, FCDoubleSpinner, FCCheckBox, FCInputDial
     FCLabel
 
 from shapely.geometry import base, Polygon, MultiPolygon, LinearRing, Point
-from shapely.ops import cascaded_union, unary_union, linemerge
+from shapely.ops import unary_union, linemerge
 
 from matplotlib.backend_bases import KeyEvent as mpl_key_event
 
@@ -1294,7 +1294,7 @@ class ToolPaint(AppTool, Gerber):
             if len(self.sel_rect) == 0:
                 return
 
-            self.sel_rect = cascaded_union(self.sel_rect)
+            self.sel_rect = unary_union(self.sel_rect)
             self.paint_poly_area(obj=self.paint_obj, tooldia=self.tooldia_list, sel_obj=self.sel_rect,
                                  outname=self.o_name)
 
@@ -1881,7 +1881,7 @@ class ToolPaint(AppTool, Gerber):
             geo_obj.tools.clear()
             geo_obj.tools = dict(tools_storage)
 
-            geo_obj.solid_geometry = cascaded_union(final_solid_geometry)
+            geo_obj.solid_geometry = unary_union(final_solid_geometry)
 
             try:
                 if isinstance(geo_obj.solid_geometry, list):
@@ -1935,7 +1935,7 @@ class ToolPaint(AppTool, Gerber):
                     except TypeError:
                         poly_buf.append(buffered_pol)
 
-            poly_buf = cascaded_union(poly_buf)
+            poly_buf = unary_union(poly_buf)
 
             if not poly_buf:
                 self.app.inform.emit('[WARNING_NOTCL] %s' % _("Margin parameter too big. Tool is not used"))
@@ -2001,7 +2001,7 @@ class ToolPaint(AppTool, Gerber):
                                                                 prog_plot=prog_plot)
                             geo_elems = list(geo_res.get_objects())
                             # See if the polygon was completely cleared
-                            pp_cleared = cascaded_union(geo_elems).buffer(tool_dia / 2.0)
+                            pp_cleared = unary_union(geo_elems).buffer(tool_dia / 2.0)
                             rest = pp.difference(pp_cleared)
                             if rest and not rest.is_empty:
                                 try:
@@ -2041,7 +2041,7 @@ class ToolPaint(AppTool, Gerber):
                         geo_elems = list(geo_res.get_objects())
 
                         # See if the polygon was completely cleared
-                        pp_cleared = cascaded_union(geo_elems).buffer(tool_dia / 2.0)
+                        pp_cleared = unary_union(geo_elems).buffer(tool_dia / 2.0)
                         rest = poly_buf.difference(pp_cleared)
                         if rest and not rest.is_empty:
                             try:
@@ -2095,7 +2095,7 @@ class ToolPaint(AppTool, Gerber):
 
                 poly_buf = MultiPolygon(tmp)
                 if not poly_buf.is_valid:
-                    poly_buf = cascaded_union(tmp)
+                    poly_buf = unary_union(tmp)
 
                 if not poly_buf or poly_buf.is_empty or not poly_buf.is_valid:
                     log.debug("Rest geometry empty. Breaking.")
@@ -2135,7 +2135,7 @@ class ToolPaint(AppTool, Gerber):
                           "Change the painting parameters and try again.")
                     )
                     return "fail"
-                geo_obj.solid_geometry = cascaded_union(final_solid_geometry)
+                geo_obj.solid_geometry = unary_union(final_solid_geometry)
             else:
                 return 'fail'
             try:
@@ -2447,9 +2447,9 @@ class ToolPaint(AppTool, Gerber):
                 env_obj = geo.convex_hull
             elif (isinstance(geo, MultiPolygon) and len(geo) == 1) or \
                     (isinstance(geo, list) and len(geo) == 1) and isinstance(geo[0], Polygon):
-                env_obj = cascaded_union(self.bound_obj.solid_geometry)
+                env_obj = unary_union(self.bound_obj.solid_geometry)
             else:
-                env_obj = cascaded_union(self.bound_obj.solid_geometry)
+                env_obj = unary_union(self.bound_obj.solid_geometry)
                 env_obj = env_obj.convex_hull
             sel_rect = env_obj.buffer(distance=0.0000001, join_style=base.JOIN_STYLE.mitre)
         except Exception as e:

+ 2 - 2
appTools/ToolPanelize.py

@@ -589,8 +589,8 @@ class Panelize(AppTool):
                         obj_fin.source_file = self.app.export_dxf(obj_name=self.outname, filename=None,
                                                                      local_use=obj_fin, use_thread=False)
 
-                    # obj_fin.solid_geometry = cascaded_union(obj_fin.solid_geometry)
-                    # app_obj.log.debug("Finished creating a cascaded union for the panel.")
+                    # obj_fin.solid_geometry = unary_union(obj_fin.solid_geometry)
+                    # app_obj.log.debug("Finished creating a unary_union for the panel.")
                     app_obj.proc_container.update_view_text('')
 
                 self.app.inform.emit('%s: %d' % (_("Generating panel... Spawning copies"), (int(rows * columns))))

+ 7 - 7
appTools/ToolProperties.py

@@ -10,7 +10,7 @@ from appTool import AppTool
 from appGUI.GUIElements import FCTree
 
 from shapely.geometry import MultiPolygon, Polygon
-from shapely.ops import cascaded_union
+from shapely.ops import unary_union
 
 from copy import deepcopy
 import math
@@ -237,7 +237,7 @@ class Properties(AppTool):
                 if obj_prop.kind.lower() == 'cncjob':
                     try:
                         for tool_k in obj_prop.exc_cnc_tools:
-                            x0, y0, x1, y1 = cascaded_union(obj_prop.exc_cnc_tools[tool_k]['solid_geometry']).bounds
+                            x0, y0, x1, y1 = unary_union(obj_prop.exc_cnc_tools[tool_k]['solid_geometry']).bounds
                             xmin.append(x0)
                             ymin.append(y0)
                             xmax.append(x1)
@@ -247,7 +247,7 @@ class Properties(AppTool):
 
                     try:
                         for tool_k in obj_prop.cnc_tools:
-                            x0, y0, x1, y1 = cascaded_union(obj_prop.cnc_tools[tool_k]['solid_geometry']).bounds
+                            x0, y0, x1, y1 = unary_union(obj_prop.cnc_tools[tool_k]['solid_geometry']).bounds
                             xmin.append(x0)
                             ymin.append(y0)
                             xmax.append(x1)
@@ -257,7 +257,7 @@ class Properties(AppTool):
                 else:
                     try:
                         for tool_k in obj_prop.tools:
-                            x0, y0, x1, y1 = cascaded_union(obj_prop.tools[tool_k]['solid_geometry']).bounds
+                            x0, y0, x1, y1 = unary_union(obj_prop.tools[tool_k]['solid_geometry']).bounds
                             xmin.append(x0)
                             ymin.append(y0)
                             xmax.append(x1)
@@ -308,10 +308,10 @@ class Properties(AppTool):
                             env_obj = geo.convex_hull
                         elif (isinstance(geo, MultiPolygon) and len(geo) == 1) or \
                                 (isinstance(geo, list) and len(geo) == 1) and isinstance(geo[0], Polygon):
-                            env_obj = cascaded_union(geo)
+                            env_obj = unary_union(geo)
                             env_obj = env_obj.convex_hull
                         else:
-                            env_obj = cascaded_union(geo)
+                            env_obj = unary_union(geo)
                             env_obj = env_obj.convex_hull
 
                         area_chull = env_obj.area
@@ -321,7 +321,7 @@ class Properties(AppTool):
                     try:
                         area_chull = []
                         for tool_k in obj_prop.tools:
-                            area_el = cascaded_union(obj_prop.tools[tool_k]['solid_geometry']).convex_hull
+                            area_el = unary_union(obj_prop.tools[tool_k]['solid_geometry']).convex_hull
                             area_chull.append(area_el.area)
                         area_chull = max(area_chull)
                     except Exception as er:

+ 2 - 2
appTools/ToolSolderPaste.py

@@ -19,7 +19,7 @@ from copy import deepcopy
 from datetime import datetime
 
 from shapely.geometry import Polygon, LineString
-from shapely.ops import cascaded_union
+from shapely.ops import unary_union
 
 import traceback
 from io import StringIO
@@ -941,7 +941,7 @@ class SolderPaste(AppTool):
                 tool_cnc_dict['gcode_parsed'] = job_obj.gcode_parse()
 
                 # TODO this serve for bounding box creation only; should be optimized
-                tool_cnc_dict['solid_geometry'] = cascaded_union([geo['geom'] for geo in tool_cnc_dict['gcode_parsed']])
+                tool_cnc_dict['solid_geometry'] = unary_union([geo['geom'] for geo in tool_cnc_dict['gcode_parsed']])
 
                 # tell gcode_parse from which point to start drawing the lines depending on what kind of
                 # object is the source of gcode

+ 3 - 3
appTools/ToolSub.py

@@ -11,7 +11,7 @@ from appTool import AppTool
 from appGUI.GUIElements import FCCheckBox, FCButton, FCComboBox
 
 from shapely.geometry import Polygon, MultiPolygon, MultiLineString, LineString
-from shapely.ops import cascaded_union
+from shapely.ops import unary_union
 
 import traceback
 from copy import deepcopy
@@ -396,7 +396,7 @@ class ToolSub(AppTool):
         else:
             self.promises.append("single")
 
-        self.sub_union = cascaded_union(self.sub_geo_obj.solid_geometry)
+        self.sub_union = unary_union(self.sub_geo_obj.solid_geometry)
 
         # start the QTimer to check for promises with 0.5 second period check
         self.periodic_check(500, reset=True)
@@ -421,7 +421,7 @@ class ToolSub(AppTool):
         with self.app.proc_container.new(text):
             # resulting paths are closed resulting into Polygons
             if self.ui.close_paths_cb.isChecked():
-                new_geo = (cascaded_union(geo)).difference(self.sub_union)
+                new_geo = (unary_union(geo)).difference(self.sub_union)
                 if new_geo:
                     if not new_geo.is_empty:
                         new_geometry.append(new_geo)

+ 20 - 20
camlib.py

@@ -25,7 +25,7 @@ from lxml import etree as ET
 from shapely.geometry import Polygon, Point, LinearRing
 
 from shapely.geometry import box as shply_box
-from shapely.ops import cascaded_union, unary_union, substring, linemerge
+from shapely.ops import unary_union, substring, linemerge
 import shapely.affinity as affinity
 from shapely.wkt import loads as sloads
 from shapely.wkt import dumps as sdumps
@@ -413,13 +413,13 @@ class ApertureMacro:
             if r <= 0:
                 break
             ring = Point((x, y)).buffer(r).exterior.buffer(thickness / 2.0)
-            result = cascaded_union([result, ring])
+            result = unary_union([result, ring])
             i += 1
 
         # ## Crosshair
         hor = LineString([(x - cross_len, y), (x + cross_len, y)]).buffer(cross_th / 2.0, cap_style=2)
         ver = LineString([(x, y - cross_len), (x, y + cross_len)]).buffer(cross_th / 2.0, cap_style=2)
-        result = cascaded_union([result, hor, ver])
+        result = unary_union([result, hor, ver])
 
         return {"pol": 1, "geometry": result}
 
@@ -726,7 +726,7 @@ class Geometry(object):
             polygon = Polygon(points)
         else:
             polygon = points
-        toolgeo = cascaded_union(polygon)
+        toolgeo = unary_union(polygon)
         diffs = []
         for target in flat_geometry:
             if isinstance(target, LineString) or isinstance(target, LineString) or isinstance(target, MultiLineString):
@@ -838,7 +838,7 @@ class Geometry(object):
         #         if len(self.solid_geometry) == 0:
         #             log.debug('solid_geometry is empty []')
         #             return 0, 0, 0, 0
-        #         return cascaded_union(flatten(self.solid_geometry)).bounds
+        #         return unary_union(flatten(self.solid_geometry)).bounds
         #     else:
         #         return self.solid_geometry.bounds
         # except Exception as e:
@@ -853,7 +853,7 @@ class Geometry(object):
         #     if len(self.solid_geometry) == 0:
         #         log.debug('solid_geometry is empty []')
         #         return 0, 0, 0, 0
-        #     return cascaded_union(self.solid_geometry).bounds
+        #     return unary_union(self.solid_geometry).bounds
         # else:
         #     return self.solid_geometry.bounds
 
@@ -1376,7 +1376,7 @@ class Geometry(object):
             self.solid_geometry = []
 
         if type(self.solid_geometry) is list:
-            # self.solid_geometry.append(cascaded_union(geos))
+            # self.solid_geometry.append(unary_union(geos))
             if type(geos) is list:
                 self.solid_geometry += geos
             else:
@@ -1386,7 +1386,7 @@ class Geometry(object):
 
         # flatten the self.solid_geometry list for import_svg() to import SVG as Gerber
         self.solid_geometry = list(self.flatten_list(self.solid_geometry))
-        self.solid_geometry = cascaded_union(self.solid_geometry)
+        self.solid_geometry = unary_union(self.solid_geometry)
 
         # self.solid_geometry = MultiPolygon(self.solid_geometry)
         # self.solid_geometry = self.solid_geometry.buffer(0.00000001)
@@ -2262,12 +2262,12 @@ class Geometry(object):
 
     def union(self):
         """
-        Runs a cascaded union on the list of objects in
+        Runs a unary_union on the list of objects in
         solid_geometry.
 
         :return: None
         """
-        self.solid_geometry = [cascaded_union(self.solid_geometry)]
+        self.solid_geometry = [unary_union(self.solid_geometry)]
 
     def export_svg(self, scale_stroke_factor=0.00,
                    scale_factor_x=None, scale_factor_y=None,
@@ -2286,11 +2286,11 @@ class Geometry(object):
             if self.multigeo:
                 for tool in self.tools:
                     flat_geo += self.flatten(self.tools[tool]['solid_geometry'])
-                geom_svg = cascaded_union(flat_geo)
+                geom_svg = unary_union(flat_geo)
             else:
-                geom_svg = cascaded_union(self.flatten())
+                geom_svg = unary_union(self.flatten())
         else:
-            geom_svg = cascaded_union(self.flatten())
+            geom_svg = unary_union(self.flatten())
 
         skew_ref = 'center'
         if skew_reference != 'center':
@@ -6869,7 +6869,7 @@ class CNCjob(Geometry):
         # This takes forever. Too much data?
         # self.app.inform.emit('%s: %s' % (_("Unifying Geometry from parsed Geometry segments"),
         #                                  str(len(self.gcode_parsed))))
-        # self.solid_geometry = cascaded_union([geo['geom'] for geo in self.gcode_parsed])
+        # self.solid_geometry = unary_union([geo['geom'] for geo in self.gcode_parsed])
 
         # This is much faster but not so nice to look at as you can see different segments of the geometry
         self.solid_geometry = [geo['geom'] for geo in self.gcode_parsed]
@@ -7475,18 +7475,18 @@ class CNCjob(Geometry):
                 travels.append(g)
 
         # Used to determine the overall board size
-        self.solid_geometry = cascaded_union([geo['geom'] for geo in self.gcode_parsed])
+        self.solid_geometry = unary_union([geo['geom'] for geo in self.gcode_parsed])
 
         # Convert the cuts and travels into single geometry objects we can render as svg xml
         if travels:
-            travelsgeom = cascaded_union([geo['geom'] for geo in travels])
+            travelsgeom = unary_union([geo['geom'] for geo in travels])
 
         if self.app.abort_flag:
             # graceful abort requested by the user
             raise grace
 
         if cuts:
-            cutsgeom = cascaded_union([geo['geom'] for geo in cuts])
+            cutsgeom = unary_union([geo['geom'] for geo in cuts])
 
         # Render the SVG Xml
         # The scale factor affects the size of the lines, and the stroke color adds different formatting for each set
@@ -7753,7 +7753,7 @@ class CNCjob(Geometry):
                         self.app.proc_container.update_view_text(' %d%%' % disp_number)
                         self.old_disp_number = disp_number
 
-                v['solid_geometry'] = cascaded_union([geo['geom'] for geo in v['gcode_parsed']])
+                v['solid_geometry'] = unary_union([geo['geom'] for geo in v['gcode_parsed']])
         self.create_geometry()
         self.app.proc_container.new_text = ''
 
@@ -7862,7 +7862,7 @@ class CNCjob(Geometry):
                         self.old_disp_number = disp_number
 
                 # for the bounding box
-                v['solid_geometry'] = cascaded_union([geo['geom'] for geo in v['gcode_parsed']])
+                v['solid_geometry'] = unary_union([geo['geom'] for geo in v['gcode_parsed']])
 
         self.app.proc_container.new_text = ''
 
@@ -8234,7 +8234,7 @@ def dict2obj(d):
 #
 #     m = MultiLineString(edge_points)
 #     triangles = list(polygonize(m))
-#     return cascaded_union(triangles), edge_points
+#     return unary_union(triangles), edge_points
 
 # def voronoi(P):
 #     """

+ 2 - 2
tclCommands/TclCommandBbox.py

@@ -1,7 +1,7 @@
 import collections
 from tclCommands.TclCommand import TclCommand
 
-from shapely.ops import cascaded_union
+from shapely.ops import unary_union
 
 import gettext
 import appTranslation as fcTranslate
@@ -94,7 +94,7 @@ class TclCommandBbox(TclCommand):
                 # assert geo_obj.kind == 'geometry'
 
                 # Bounding box with rounded corners
-                geo = cascaded_union(obj.solid_geometry)
+                geo = unary_union(obj.solid_geometry)
                 bounding_box = geo.envelope.buffer(float(margin))
                 if not rounded:  # Remove rounded corners
                     bounding_box = bounding_box.envelope

+ 2 - 2
tclCommands/TclCommandCutout.py

@@ -3,7 +3,7 @@ from tclCommands.TclCommand import TclCommand
 import collections
 import logging
 
-from shapely.ops import cascaded_union
+from shapely.ops import unary_union
 from shapely.geometry import LineString
 
 log = logging.getLogger('base')
@@ -134,7 +134,7 @@ class TclCommandCutout(TclCommand):
                            [pts[6], pts[7], pts[8]],
                            [pts[9], pts[10], pts[11]]]}
             cuts = cases[gaps_par]
-            geo_obj.solid_geometry = cascaded_union([LineString(segment) for segment in cuts])
+            geo_obj.solid_geometry = unary_union([LineString(segment) for segment in cuts])
 
         try:
             self.app.app_obj.new_object("geometry", outname, geo_init_me, plot=False)

+ 3 - 3
tclCommands/TclCommandGeoCutout.py

@@ -3,7 +3,7 @@ from tclCommands.TclCommand import TclCommandSignaled
 import logging
 import collections
 from copy import deepcopy
-from shapely.ops import cascaded_union
+from shapely.ops import unary_union
 from shapely.geometry import Polygon, LineString, LinearRing
 
 import gettext
@@ -131,14 +131,14 @@ class TclCommandGeoCutout(TclCommandSignaled):
             flat_geometry = flatten(geo, pathonly=True)
 
             polygon = Polygon(pts)
-            toolgeo = cascaded_union(polygon)
+            toolgeo = unary_union(polygon)
             diffs = []
             for target in flat_geometry:
                 if type(target) == LineString or type(target) == LinearRing:
                     diffs.append(target.difference(toolgeo))
                 else:
                     log.warning("Not implemented.")
-            return cascaded_union(diffs)
+            return unary_union(diffs)
 
         if 'name' in args:
             name = args['name']

+ 2 - 2
tclCommands/TclCommandNregions.py

@@ -1,6 +1,6 @@
 from tclCommands.TclCommand import TclCommand
 
-from shapely.ops import cascaded_union
+from shapely.ops import unary_union
 
 import collections
 
@@ -92,7 +92,7 @@ class TclCommandNregions(TclCommand):
             def geo_init(geo_obj, app_obj):
                 assert geo_obj.kind == 'geometry'
 
-                geo = cascaded_union(obj.solid_geometry)
+                geo = unary_union(obj.solid_geometry)
                 bounding_box = geo.envelope.buffer(float(margin))
                 if not rounded:
                     bounding_box = bounding_box.envelope

+ 1 - 1
tests/other/test_plotg.py

@@ -1,5 +1,5 @@
 from shapely.geometry import LineString, Polygon
-from shapely.ops import cascaded_union, unary_union
+from shapely.ops import unary_union
 from matplotlib.pyplot import plot, subplot, show, axes
 from matplotlib.axes import *
 from camlib import *

+ 1 - 1
tests/test_paint.py

@@ -1,7 +1,7 @@
 import unittest
 
 from shapely.geometry import LineString, Polygon
-from shapely.ops import cascaded_union, unary_union
+from shapely.ops import unary_union
 from matplotlib.pyplot import plot, subplot, show, cla, clf, xlim, ylim, title
 from matplotlib.axes import *
 from camlib import *

+ 1 - 1
tests/test_pathconnect.py

@@ -1,7 +1,7 @@
 import unittest
 
 from shapely.geometry import LineString, Polygon
-from shapely.ops import cascaded_union, unary_union
+from shapely.ops import unary_union
 from matplotlib.pyplot import plot, subplot, show, cla, clf, xlim, ylim, title
 from camlib import *
 from random import random