- fixed the Cutout plugin not working with Geometry objects that are made out of a LineString or LinearRing geometric elements
This commit is contained in:
@@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta
|
|||||||
|
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
|
26.01.2022
|
||||||
|
|
||||||
|
- fixed the Cutout plugin not working with Geometry objects that are made out of a LineString or LinearRing geometric elements
|
||||||
|
|
||||||
25.01.2022
|
25.01.2022
|
||||||
|
|
||||||
- minor changes
|
- minor changes
|
||||||
|
|||||||
@@ -690,7 +690,7 @@ class CutOut(AppTool):
|
|||||||
"Fill in a correct value and retry."))
|
"Fill in a correct value and retry."))
|
||||||
return
|
return
|
||||||
|
|
||||||
def any_cutout_handler(geom, cut_dia, gaps, gapsize, margin):
|
def any_cutout_handler(geom, cut_diameter, gaps, gapsize, margin):
|
||||||
r_temp_geo = []
|
r_temp_geo = []
|
||||||
initial_geo = deepcopy(geom)
|
initial_geo = deepcopy(geom)
|
||||||
|
|
||||||
@@ -705,9 +705,9 @@ class CutOut(AppTool):
|
|||||||
if gaps != 'None':
|
if gaps != 'None':
|
||||||
if gaps == '8' or gaps == '2LR':
|
if gaps == '8' or gaps == '2LR':
|
||||||
points = (
|
points = (
|
||||||
xxmin - (gapsize + cut_dia), # botleft_x
|
xxmin - (gapsize + cut_diameter), # botleft_x
|
||||||
py - (gapsize / 2) + leny / 4, # botleft_y
|
py - (gapsize / 2) + leny / 4, # botleft_y
|
||||||
xxmax + (gapsize + cut_dia), # topright_x
|
xxmax + (gapsize + cut_diameter), # topright_x
|
||||||
py + (gapsize / 2) + leny / 4 # topright_y
|
py + (gapsize / 2) + leny / 4 # topright_y
|
||||||
)
|
)
|
||||||
geom = self.subtract_poly_from_geo(geom, points)
|
geom = self.subtract_poly_from_geo(geom, points)
|
||||||
@@ -716,9 +716,9 @@ class CutOut(AppTool):
|
|||||||
)
|
)
|
||||||
|
|
||||||
points = (
|
points = (
|
||||||
xxmin - (gapsize + cut_dia),
|
xxmin - (gapsize + cut_diameter),
|
||||||
py - (gapsize / 2) - leny / 4,
|
py - (gapsize / 2) - leny / 4,
|
||||||
xxmax + (gapsize + cut_dia),
|
xxmax + (gapsize + cut_diameter),
|
||||||
py + (gapsize / 2) - leny / 4
|
py + (gapsize / 2) - leny / 4
|
||||||
)
|
)
|
||||||
geom = self.subtract_poly_from_geo(geom, points)
|
geom = self.subtract_poly_from_geo(geom, points)
|
||||||
@@ -729,9 +729,9 @@ class CutOut(AppTool):
|
|||||||
if gaps == '8' or gaps == '2TB':
|
if gaps == '8' or gaps == '2TB':
|
||||||
points = (
|
points = (
|
||||||
px - (gapsize / 2) + lenx / 4,
|
px - (gapsize / 2) + lenx / 4,
|
||||||
yymin - (gapsize + cut_dia),
|
yymin - (gapsize + cut_diameter),
|
||||||
px + (gapsize / 2) + lenx / 4,
|
px + (gapsize / 2) + lenx / 4,
|
||||||
yymax + (gapsize + cut_dia)
|
yymax + (gapsize + cut_diameter)
|
||||||
)
|
)
|
||||||
geom = self.subtract_poly_from_geo(geom, points)
|
geom = self.subtract_poly_from_geo(geom, points)
|
||||||
r_temp_geo.append(
|
r_temp_geo.append(
|
||||||
@@ -740,9 +740,9 @@ class CutOut(AppTool):
|
|||||||
|
|
||||||
points = (
|
points = (
|
||||||
px - (gapsize / 2) - lenx / 4,
|
px - (gapsize / 2) - lenx / 4,
|
||||||
yymin - (gapsize + cut_dia),
|
yymin - (gapsize + cut_diameter),
|
||||||
px + (gapsize / 2) - lenx / 4,
|
px + (gapsize / 2) - lenx / 4,
|
||||||
yymax + (gapsize + cut_dia)
|
yymax + (gapsize + cut_diameter)
|
||||||
)
|
)
|
||||||
geom = self.subtract_poly_from_geo(geom, points)
|
geom = self.subtract_poly_from_geo(geom, points)
|
||||||
r_temp_geo.append(
|
r_temp_geo.append(
|
||||||
@@ -751,9 +751,9 @@ class CutOut(AppTool):
|
|||||||
|
|
||||||
if gaps == '4' or gaps == 'LR':
|
if gaps == '4' or gaps == 'LR':
|
||||||
points = (
|
points = (
|
||||||
xxmin - (gapsize + cut_dia),
|
xxmin - (gapsize + cut_diameter),
|
||||||
py - (gapsize / 2),
|
py - (gapsize / 2),
|
||||||
xxmax + (gapsize + cut_dia),
|
xxmax + (gapsize + cut_diameter),
|
||||||
py + (gapsize / 2)
|
py + (gapsize / 2)
|
||||||
)
|
)
|
||||||
geom = self.subtract_poly_from_geo(geom, points)
|
geom = self.subtract_poly_from_geo(geom, points)
|
||||||
@@ -764,9 +764,9 @@ class CutOut(AppTool):
|
|||||||
if gaps == '4' or gaps == 'TB':
|
if gaps == '4' or gaps == 'TB':
|
||||||
points = (
|
points = (
|
||||||
px - (gapsize / 2),
|
px - (gapsize / 2),
|
||||||
yymin - (gapsize + cut_dia),
|
yymin - (gapsize + cut_diameter),
|
||||||
px + (gapsize / 2),
|
px + (gapsize / 2),
|
||||||
yymax + (gapsize + cut_dia)
|
yymax + (gapsize + cut_diameter)
|
||||||
)
|
)
|
||||||
geom = self.subtract_poly_from_geo(geom, points)
|
geom = self.subtract_poly_from_geo(geom, points)
|
||||||
r_temp_geo.append(
|
r_temp_geo.append(
|
||||||
@@ -855,6 +855,8 @@ class CutOut(AppTool):
|
|||||||
if isinstance(object_geo, (MultiPolygon, MultiLineString)):
|
if isinstance(object_geo, (MultiPolygon, MultiLineString)):
|
||||||
x0, y0, x1, y1 = object_geo.bounds
|
x0, y0, x1, y1 = object_geo.bounds
|
||||||
object_geo = box(x0, y0, x1, y1)
|
object_geo = box(x0, y0, x1, y1)
|
||||||
|
if isinstance(object_geo, (LinearRing, LineString)):
|
||||||
|
object_geo = Polygon(object_geo)
|
||||||
geo_buf = object_geo.buffer(0)
|
geo_buf = object_geo.buffer(0)
|
||||||
geo = geo_buf.exterior
|
geo = geo_buf.exterior
|
||||||
|
|
||||||
|
|||||||
@@ -129,14 +129,23 @@ class TclCommandCutout(TclCommand):
|
|||||||
[maxx, midy + hgap],
|
[maxx, midy + hgap],
|
||||||
[maxx, maxy],
|
[maxx, maxy],
|
||||||
[midx + hgap, maxy]]
|
[midx + hgap, maxy]]
|
||||||
cases = {"tb": [[pts[0], pts[1], pts[4], pts[5]],
|
|
||||||
[pts[6], pts[7], pts[10], pts[11]]],
|
cases = {
|
||||||
"lr": [[pts[9], pts[10], pts[1], pts[2]],
|
"tb": [
|
||||||
[pts[3], pts[4], pts[7], pts[8]]],
|
[pts[0], pts[1], pts[4], pts[5]],
|
||||||
"4": [[pts[0], pts[1], pts[2]],
|
[pts[6], pts[7], pts[10], pts[11]]
|
||||||
|
],
|
||||||
|
"lr": [
|
||||||
|
[pts[9], pts[10], pts[1], pts[2]],
|
||||||
|
[pts[3], pts[4], pts[7], pts[8]]
|
||||||
|
],
|
||||||
|
"4": [
|
||||||
|
[pts[0], pts[1], pts[2]],
|
||||||
[pts[3], pts[4], pts[5]],
|
[pts[3], pts[4], pts[5]],
|
||||||
[pts[6], pts[7], pts[8]],
|
[pts[6], pts[7], pts[8]],
|
||||||
[pts[9], pts[10], pts[11]]]}
|
[pts[9], pts[10], pts[11]]
|
||||||
|
]
|
||||||
|
}
|
||||||
cuts = cases[gaps_par]
|
cuts = cases[gaps_par]
|
||||||
geo_obj.solid_geometry = unary_union([LineString(segment) for segment in cuts])
|
geo_obj.solid_geometry = unary_union([LineString(segment) for segment in cuts])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user