代码拉取完成,页面将自动刷新
同步操作将从 zzthfut/CAM 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from LinkPoint import LinkPoint
from Polyline import Polyline
class LinkSegs_dlook:
def __init__(self, segs):
self.segs = segs
self.contours = []
self.polys = []
self.dic = {}
self.link()
def createLpDic(self):
dic = {}
for seg in self.segs:
lp1, lp2 = LinkPoint(seg.A), LinkPoint(seg.B)
lp1.other, lp2.other = lp2, lp1
l1 = (lp1.x, lp1.y)
l2 = (lp2.x, lp2.y)
if l1 not in dic.keys():
dic[l1] = []
dic[l1].append(lp1)
if l2 not in dic.keys():
dic[l2] = []
dic[l2].append(lp2)
self.dic = dic
return dic
def findUnusedPnt(self, dic=None):
if dic is None:
dic = self.dic
for pnts in dic.values():
for pnt in pnts:
if not pnt.used:
return pnt
return None
def findNextPnt(self, p, dic=None):
if dic is None:
dic = self.dic
other = p.other
pnts = dic[(other.x, other.y)]
for pnt in pnts:
if pnt is not other:
return pnt
return None
def link(self):
self.createLpDic()
while True:
p = self.findUnusedPnt()
if p is None:
break
poly = Polyline()
while True:
poly.addPoint(p.toPoint3D())
p.used, p.other.used = True, True
p = self.findNextPnt(p)
if poly.isClosed():
self.contours.append(poly)
break
if p is None:
self.polys.append(poly)
break
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。