1 Star 0 Fork 2

chenyp401/CAM

forked from zzthfut/CAM 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
SliceModel.py 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
zzthfut 提交于 2023-07-24 15:04 . 5-2
import SliceAlgo
from VtkAdaptor import VtkAdaptor
class SliceModel:
def __init__(self, stlModel, layerThk, sliceAlgo="brutal"):
self.stlModel = stlModel
self.layerThk = layerThk
if sliceAlgo == "brutal":
self.slice_brutal()
elif sliceAlgo == "optimal":
self.slice_optimal()
def slice_brutal(self):
self.layers = SliceAlgo.intersectStl_brutal(self.stlModel, self.layerThk)
for layer in self.layers:
layer.contours = SliceAlgo.linkSegs_brutal(layer.segments)
SliceAlgo.adjustPolygonDirs(layer.contours)
def slice_optimal(self):
pass
def writeSlcFile(self, path):
SliceAlgo.writeSlcFile(self.layers, path)
def readSlcFile(self, path):
SliceAlgo.readSlcFile(path)
def drawLayerContours(
self,
va: VtkAdaptor,
start=0,
stop=0xFFFF,
step=1,
clr=(0.5, 0.5, 0.5),
lineWidth=1,
):
for i in range(max(0, start), min(stop, len(self.layers)), step):
layer = self.layers[i]
for contour in layer.contours:
contourActor = va.drawPolyline(contour)
contourActor.GetProperty().SetColor(clr)
contourActor.GetProperty().SetLineWidth(lineWidth)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/chenyp401/cam.git
git@gitee.com:chenyp401/cam.git
chenyp401
cam
CAM
master

搜索帮助