代码拉取完成,页面将自动刷新
同步操作将从 zzthfut/CAM 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from layer import Layer
from GeomAlgo import intersectTriangleZPlane
import numpy as np
class SweepPlane:
def __init__(self):
self.triangles = []
self.z = 0
class IntersectStl_sweep:
def __init__(self, stlModel, layerThk):
self.stlModel = stlModel
self.layerThk = layerThk
self.layers = []
self.intersect()
def intersect(self):
triangles = self.stlModel.triangles
triangles.sort(key=lambda t: t.zMinPnt(), reverse=False)
zs = self.genLayerHeights()
k = 0
sweep = SweepPlane()
for z in zs:
for i in range(len(sweep.triangles) - 1, -1, -1):
if z > sweep.triangles[i].zMaxPnt():
del sweep.triangles[i]
for i in range(k, len(triangles)):
tri = triangles[i]
if z >= tri.zMinPnt() and z <= tri.zMaxPnt():
sweep.triangles.append(tri)
elif tri.zMinPnt() > z:
k = i
break
layer = Layer(z)
for triangle in sweep.triangles:
seg = intersectTriangleZPlane(triangle, z)
if seg is not None:
layer.segments.append(seg)
self.layers.append(layer)
def genLayerHeights(self):
xMin, xMax, yMin, yMax, zMin, zMax = self.stlModel.getBounds()
z = zMin + self.layerThk
zs = [i for i in np.arange(z, zMax, step=self.layerThk, dtype="float")]
return zs
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。