Refactored basic painting algorithm to generate FlatCAMRtreeStorage.
This commit is contained in:
@@ -742,7 +742,7 @@ class App(QtCore.QObject):
|
|||||||
else: # No: add a number!
|
else: # No: add a number!
|
||||||
name += "_1"
|
name += "_1"
|
||||||
|
|
||||||
# Create object
|
## Create object
|
||||||
classdict = {
|
classdict = {
|
||||||
"gerber": FlatCAMGerber,
|
"gerber": FlatCAMGerber,
|
||||||
"excellon": FlatCAMExcellon,
|
"excellon": FlatCAMExcellon,
|
||||||
@@ -771,11 +771,12 @@ class App(QtCore.QObject):
|
|||||||
self.log.debug("%f seconds executing initialize()." % (t2 - t1))
|
self.log.debug("%f seconds executing initialize()." % (t2 - t1))
|
||||||
|
|
||||||
# Check units and convert if necessary
|
# Check units and convert if necessary
|
||||||
|
# This condition CAN be true because initialize() can change obj.units
|
||||||
if self.options["units"].upper() != obj.units.upper():
|
if self.options["units"].upper() != obj.units.upper():
|
||||||
self.inform.emit("Converting units to " + self.options["units"] + ".")
|
self.inform.emit("Converting units to " + self.options["units"] + ".")
|
||||||
obj.convert_units(self.options["units"])
|
obj.convert_units(self.options["units"])
|
||||||
t3 = time.time()
|
t3 = time.time()
|
||||||
self.log.debug("%f seconds converting units." % (t3 - t2))
|
self.log.debug("%f seconds converting units." % (t3 - t2))
|
||||||
|
|
||||||
FlatCAMApp.App.log.debug("Moving new object back to main thread.")
|
FlatCAMApp.App.log.debug("Moving new object back to main thread.")
|
||||||
|
|
||||||
|
|||||||
28
camlib.py
28
camlib.py
@@ -316,7 +316,8 @@ class Geometry(object):
|
|||||||
boundary = self.solid_geometry.envelope
|
boundary = self.solid_geometry.envelope
|
||||||
return boundary.difference(self.solid_geometry)
|
return boundary.difference(self.solid_geometry)
|
||||||
|
|
||||||
def clear_polygon(self, polygon, tooldia, overlap=0.15):
|
@staticmethod
|
||||||
|
def clear_polygon(polygon, tooldia, overlap=0.15):
|
||||||
"""
|
"""
|
||||||
Creates geometry inside a polygon for a tool to cover
|
Creates geometry inside a polygon for a tool to cover
|
||||||
the whole area.
|
the whole area.
|
||||||
@@ -329,14 +330,29 @@ class Geometry(object):
|
|||||||
:param overlap: Overlap of toolpasses.
|
:param overlap: Overlap of toolpasses.
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
poly_cuts = [polygon.buffer(-tooldia / 2.0)]
|
|
||||||
|
## The toolpaths
|
||||||
|
# Index first and last points in paths
|
||||||
|
def get_pts(o):
|
||||||
|
return [o.coords[0], o.coords[-1]]
|
||||||
|
geoms = FlatCAMRTreeStorage()
|
||||||
|
geoms.get_points = get_pts
|
||||||
|
|
||||||
|
current = polygon.buffer(-tooldia / 2.0)
|
||||||
|
|
||||||
|
geoms.insert(current.exterior)
|
||||||
|
for i in current.interiors:
|
||||||
|
geoms.insert(i)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
polygon = poly_cuts[-1].buffer(-tooldia * (1 - overlap))
|
current = current.buffer(-tooldia * (1 - overlap))
|
||||||
if polygon.area > 0:
|
if current.area > 0:
|
||||||
poly_cuts.append(polygon)
|
geoms.insert(current.exterior)
|
||||||
|
for i in current.interiors:
|
||||||
|
geoms.insert(i)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
return poly_cuts
|
return geoms
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def clear_polygon2(polygon, tooldia, seedpoint=None, overlap=0.15):
|
def clear_polygon2(polygon, tooldia, seedpoint=None, overlap=0.15):
|
||||||
|
|||||||
Reference in New Issue
Block a user