當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。