1 Star 0 Fork 2

chenyp401/CAM

forked from zzthfut/CAM 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Test_clipper.py 815 Bytes
一键复制 编辑 原始数据 按行查看 历史
zzthfut 提交于 2023-08-08 21:17 . 8-6
from GeomBase import Point3D
import pyclipper
from VtkAdaptor import VtkAdaptor
from pyclipper import Pyclipper
from Polyline import Polyline
def tuplesToPoly(tuples):
poly = Polyline()
for pt in tuples:
poly.addPoint(Point3D(pt[0], pt[1], 0))
poly.addPoint(poly.startPoint())
return poly
if __name__ == "__main__":
subject = [(0, 0), (100, 0), (100, 70), (0, 70)]
clip = [(30, 50), (70, 50), (70, 100), (30, 100)]
clipper = Pyclipper()
clipper.AddPath(subject, pyclipper.PT_SUBJECT, True)
clipper.AddPath(clip, pyclipper.PT_CLIP, True)
sln = clipper.Execute(pyclipper.CT_UNION)
vtkAdaptor = VtkAdaptor()
for tuples in sln:
poly = tuplesToPoly(tuples)
vtkAdaptor.drawPolyline(poly).GetProperty().SetColor(0, 0, 0)
vtkAdaptor.display()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/chenyp401/cam.git
git@gitee.com:chenyp401/cam.git
chenyp401
cam
CAM
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385