代码拉取完成,页面将自动刷新
同步操作将从 zzthfut/CAM 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from GenHatch import genHatches
from GeomAlgo import rotatePolygons
import numpy as np
from Polyline import Polyline
from SpiltRegion import splitRegion
class GenDpPath:
def __init__(self, polygons, interval, angle):
self.polygons = polygons
self.interval = interval
self.angle = angle
self.splitPolys = []
def genScanYs(self, polygons):
yMin, yMax = float("inf"), float("-inf")
for poly in polygons:
for pt in poly.points:
yMin, yMax = min(pt.y, yMin), max(pt.y, yMax)
ys = [round(y, 7) for y in np.arange(yMin + self.interval, yMax, self.interval)]
# print(ys)
return ys
def linkLocalHatches(self, segs):
poly = Polyline()
for i, seg in enumerate(segs):
poly.addPoint(seg.A if (i % 2 == 0) else seg.B)
poly.addPoint(seg.B if (i % 2 == 0) else seg.A)
return poly
def generate(self):
rotPolys = rotatePolygons(self.polygons, -self.angle)
ys = self.genScanYs(rotPolys)
self.splitPolys = splitRegion(rotPolys)
paths = []
for poly in self.splitPolys:
segs = genHatches([poly], ys)
if len(segs) > 0:
path = self.linkLocalHatches(segs)
paths.append(path)
return rotatePolygons(paths, self.angle)
def genDpPath(polygons, interval, angle):
return GenDpPath(polygons, interval, angle).generate()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。