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


Python Polygon.get_linked_list方法代码示例

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


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

示例1: create_linked_list

# 需要导入模块: from polygon import Polygon [as 别名]
# 或者: from polygon.Polygon import get_linked_list [as 别名]
def create_linked_list(filename='input.txt'):
    
    points = read_from_file(filename)

    poly = Polygon()
    poly.set_points(points)

    points = poly.get_linked_list()
        
    return points[0], len(points)
开发者ID:vrublevskiyvitaliy,项目名称:Coursework,代码行数:12,代码来源:ioclass.py

示例2: art_gallery_problem

# 需要导入模块: from polygon import Polygon [as 别名]
# 或者: from polygon.Polygon import get_linked_list [as 别名]
def art_gallery_problem(interface, points=None, show_decomposition=True):
    if points is None:
        points = ioclass.read_from_file(filename)
    poly = Polygon()

    poly.set_points(points)

    linked_list = poly.get_linked_list()
    headnode = linked_list[0]
    size = len(points)

    # Check if the file reading was successful or if there were inconsistencies:
    if not headnode or size < 3:
        print("No triangulations to output")
        return

    # Create a Triangulation object from the linked list:
    t1 = EarTriangulation(headnode, size)

    # Do the triangulation. The return value is a list of 3-tuples, which
    # represent the vertices of each triangle.

    triangles1 = t1.triangulate()

    # Now for the GUI. Both the polygon and its triangulation have been scaled,
    # as specified above. Now we need to draw them on a Tkinter Canvas.
    # Setup and init a canvas:
    if show_decomposition:
        interface.draw_triangles(triangles1)

    # The last step is to output the triangulation of the original, non-scaled
    # polygon to the console:
    ioclass.print_triangles_to_console(triangles1)

    art_gallery_coloring = Coloring()
    art_gallery_coloring.set_triangulation(points, triangles1)
    points_str, res = art_gallery_coloring.colorize()

    list_res = []
    for p in points_str:
        p = p.name
        list_res.append([points[int(p)].x, points[int(p)].y])

    interface.draw_result(list_res)
    interface.set_result(res)
开发者ID:vrublevskiyvitaliy,项目名称:Coursework,代码行数:47,代码来源:ear_art_gallery_problem.py


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