- fixed the offseting feature in the Isolation Plugin such that the interiors of the isolated polygons are offset correctly
This commit is contained in:
@@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta
|
|||||||
|
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
|
27.10.2021
|
||||||
|
|
||||||
|
- fixed the offseting feature in the Isolation Plugin such that the interiors of the isolated polygons are offset correctly
|
||||||
|
|
||||||
25.10.2021
|
25.10.2021
|
||||||
|
|
||||||
- updated the PlotCanvas3d
|
- updated the PlotCanvas3d
|
||||||
|
|||||||
59
camlib.py
59
camlib.py
@@ -977,6 +977,37 @@ class Geometry(object):
|
|||||||
|
|
||||||
return self.flat_geometry
|
return self.flat_geometry
|
||||||
|
|
||||||
|
def flatten_exterior_interiors(self, geometry=None):
|
||||||
|
"""
|
||||||
|
Creates a list of non-iterable linear geometry objects.
|
||||||
|
Polygons are expanded into its exterior and interiors.
|
||||||
|
|
||||||
|
|
||||||
|
:param geometry: Shapely type or list or list of list of such.
|
||||||
|
"""
|
||||||
|
|
||||||
|
flat_geo_ext = []
|
||||||
|
flat_geo_ints = []
|
||||||
|
|
||||||
|
if geometry is None:
|
||||||
|
geometry = self.solid_geometry
|
||||||
|
# ## If iterable, expand recursively.
|
||||||
|
try:
|
||||||
|
for geo in geometry:
|
||||||
|
if geo is not None:
|
||||||
|
ext, ints = self.flatten_exterior_interiors(geo)
|
||||||
|
flat_geo_ext += ext
|
||||||
|
flat_geo_ints += ints
|
||||||
|
# ## Not iterable, do the actual indexing and add.
|
||||||
|
except TypeError:
|
||||||
|
if type(geometry) == Polygon:
|
||||||
|
flat_geo_ext.append(geometry.exterior)
|
||||||
|
flat_geo_ints += geometry.interiors
|
||||||
|
elif isinstance(geometry, (LineString, LinearRing)):
|
||||||
|
flat_geo_ext.append(geometry)
|
||||||
|
|
||||||
|
return flat_geo_ext, flat_geo_ints
|
||||||
|
|
||||||
# def make2Dstorage(self):
|
# def make2Dstorage(self):
|
||||||
#
|
#
|
||||||
# self.flatten()
|
# self.flatten()
|
||||||
@@ -3545,15 +3576,10 @@ class CNCjob(Geometry):
|
|||||||
|
|
||||||
# The Geometry from which we create GCode
|
# The Geometry from which we create GCode
|
||||||
geometry = tools[tool]['solid_geometry']
|
geometry = tools[tool]['solid_geometry']
|
||||||
# ## Flatten the geometry. Only linear elements (no polygons) remain.
|
|
||||||
flat_geometry = self.flatten(geometry, reset=True, pathonly=True)
|
|
||||||
log.debug("%d paths" % len(flat_geometry))
|
|
||||||
|
|
||||||
# #########################################################################################################
|
|
||||||
# #########################################################################################################
|
# #########################################################################################################
|
||||||
# ############# PARAMETERS used in PREPROCESSORS so they need to be updated ###############################
|
# ############# PARAMETERS used in PREPROCESSORS so they need to be updated ###############################
|
||||||
# #########################################################################################################
|
# #########################################################################################################
|
||||||
# #########################################################################################################
|
|
||||||
self.tool = str(tool)
|
self.tool = str(tool)
|
||||||
tool_dict = tools[tool]['data']
|
tool_dict = tools[tool]['data']
|
||||||
# this is the tool diameter, it is used as such to accommodate the preprocessor who need the tool diameter
|
# this is the tool diameter, it is used as such to accommodate the preprocessor who need the tool diameter
|
||||||
@@ -3593,13 +3619,34 @@ class CNCjob(Geometry):
|
|||||||
else:
|
else:
|
||||||
tool_offset = 0.0
|
tool_offset = 0.0
|
||||||
|
|
||||||
|
# #############################################################################################################
|
||||||
|
# ## Flatten the geometry. Only linear elements (no polygons) remain.
|
||||||
|
# #############################################################################################################
|
||||||
|
flat_ext_geo, flat_ints_geo = self.flatten_exterior_interiors(geometry)
|
||||||
|
flat_geometry = flat_ext_geo + flat_ints_geo
|
||||||
|
# flat_geometry = self.flatten(geometry, reset=True, pathonly=True)
|
||||||
|
log.debug("%d paths" % len(flat_geometry))
|
||||||
if tool_offset != 0.0:
|
if tool_offset != 0.0:
|
||||||
for it in flat_geometry:
|
# for it in flat_geometry:
|
||||||
|
# # if the geometry is a closed shape then create a Polygon out of it
|
||||||
|
# if isinstance(it, LineString):
|
||||||
|
# if it.is_ring:
|
||||||
|
# it = Polygon(it)
|
||||||
|
# temp_solid_geometry.append(it.buffer(tool_offset, join_style=2))
|
||||||
|
for it in flat_ext_geo:
|
||||||
# if the geometry is a closed shape then create a Polygon out of it
|
# if the geometry is a closed shape then create a Polygon out of it
|
||||||
if isinstance(it, LineString):
|
if isinstance(it, LineString):
|
||||||
if it.is_ring:
|
if it.is_ring:
|
||||||
it = Polygon(it)
|
it = Polygon(it)
|
||||||
temp_solid_geometry.append(it.buffer(tool_offset, join_style=2))
|
temp_solid_geometry.append(it.buffer(tool_offset, join_style=2))
|
||||||
|
|
||||||
|
for it in flat_ints_geo:
|
||||||
|
# if the geometry is a closed shape then create a Polygon out of it
|
||||||
|
if isinstance(it, (LineString, LinearRing)):
|
||||||
|
if it.is_ring:
|
||||||
|
it = Polygon(it)
|
||||||
|
temp_solid_geometry.append(it.buffer(-tool_offset, join_style=2))
|
||||||
|
|
||||||
temp_solid_geometry = self.flatten(temp_solid_geometry, reset=True, pathonly=True)
|
temp_solid_geometry = self.flatten(temp_solid_geometry, reset=True, pathonly=True)
|
||||||
else:
|
else:
|
||||||
temp_solid_geometry = flat_geometry
|
temp_solid_geometry = flat_geometry
|
||||||
|
|||||||
Reference in New Issue
Block a user