当前位置: 首页>>代码示例>>Python>>正文


Python LinkedList.load方法代码示例

本文整理汇总了Python中LinkedList.LinkedList.load方法的典型用法代码示例。如果您正苦于以下问题:Python LinkedList.load方法的具体用法?Python LinkedList.load怎么用?Python LinkedList.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LinkedList.LinkedList的用法示例。


在下文中一共展示了LinkedList.load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: extendWithIntersectionPoints

# 需要导入模块: from LinkedList import LinkedList [as 别名]
# 或者: from LinkedList.LinkedList import load [as 别名]
    def extendWithIntersectionPoints(self, other):
        """
        Update current points list,
        extended with intersection points
        """
        debugResult = []
        first = True
        result = []

        linkedPoints = LinkedList()
        linkedPoints.load(self.points)
        linkedOtherPoints = LinkedList()
        linkedOtherPoints.load((other.points))

        node = linkedPoints[0]
        while node.hasNext():
            candidates = []
            if first:
                candidates.append(node.data)
                first = False
            nextNode = node.next
            seg = (node.data, nextNode.data)

            otherNode = linkedOtherPoints[0]
            while otherNode.hasNext():
                nextOtherNode = otherNode.next
                otherSeg = (otherNode.data, nextOtherNode.data)

                intersection, info = segmentIntersection(seg, otherSeg)
                kind = None
                if intersection:
                    kind = Kind.incoming if info['sign'] < 0 else Kind.outgoing
                    tpl = (intersection, kind)
                    #print("seg, otherseg, tpl: ",seg, otherSeg, tpl)

                    #node.insertAfter((intersection, kind))
                    #otherNode.insertAfter((intersection, kind))
                    candidates.append(tpl)
                    #print("{} : {}  x  {}".format(info['sign'], seg, otherSeg))
                #this is for debugging
                debugResult.append((intersection, seg, otherSeg, kind))
                #print("{0} :: {1} :: {2}".format(intersection, seg, otherSeg))
                otherNode = otherNode.next  # !!!!
            node = node.next  # !!!

            sorted = lolsort(candidates, node.data)
            result += sorted

            result.append(node.data)

        GlobalQueue.queue.insert(debugResult)

        return filterDuplicates(result)

        return result
        return linkedPoints.toList(), linkedOtherPoints.toList()
开发者ID:Rast1234,项目名称:graphics,代码行数:58,代码来源:Clipping.py

示例2: __sub__

# 需要导入模块: from LinkedList import LinkedList [as 别名]
# 或者: from LinkedList.LinkedList import load [as 别名]
    def __sub__(self, other):
        """
        Subtraction of polygons
        """
        sequence = []

        # get raw points lists without duplication first-last
        points = [dict([["point",p], ["kind",k], ["visited", False]]) for p, k in self.points[:-1]]
        otherPoints = [dict([["point",p], ["kind",k], ["visited", False]]) for p, k in other.points[:-1]]


        tmp = [BravePoint(p,k) for p, k in self.points[:-1]]
        tmp2 = [BravePoint(p,k) for p, k in other.points[:-1]]
        tmp2.reverse()  # useful
        points = LinkedList()
        points.load(tmp)
        points.setEndless(True)

        otherPoints = LinkedList()
        otherPoints.load(tmp2)
        otherPoints.setEndless(True)

        #pprint(tmp)
        #pprint(tmp2)
        p = points.first
        firstStep = True
        while p is not points.first or firstStep:
            firstStep = False
            d = p.data
            if d.kind != Kind.outgoing or d.visited:
                p = p.next
                continue
            # brave new polygon!
            newbies = getPointsUntilExit(points, otherPoints, p.data)
            #print("newbies= ", newbies)
            sequence.append(newbies)
        #print "sequence= ", sequence

        points.setEndless(False)
        otherPoints.setEndless(False)
        #pprint({'points': points.toList(), 'otherPoints': otherPoints.toList()})

        result = []
        for lol in sequence:
            tmp = [bp.point for bp in lol]
            kinds = [Kind.neutral]*len(tmp)
            poly = Poly(points=zip(tmp, kinds))
            result.append(poly)
        return result
开发者ID:Rast1234,项目名称:graphics,代码行数:51,代码来源:Clipping.py


注:本文中的LinkedList.LinkedList.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。