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