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


Python Polygon.set_points方法代码示例

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


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

示例1: generate_new_poly

# 需要导入模块: from polygon import Polygon [as 别名]
# 或者: from polygon.Polygon import set_points [as 别名]
 def generate_new_poly(self, ev):
     points = get_random_polygon()
     self.set_points(points)
     poly = Polygon()
     poly.set_points(points)
     self.canvas.delete("all")
     self.draw_polygon_points(poly)
     self.set_result(0)
开发者ID:vrublevskiyvitaliy,项目名称:Coursework,代码行数:10,代码来源:gui.py

示例2: create_linked_list

# 需要导入模块: from polygon import Polygon [as 别名]
# 或者: from polygon.Polygon import set_points [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

示例3: main

# 需要导入模块: from polygon import Polygon [as 别名]
# 或者: from polygon.Polygon import set_points [as 别名]
def main():
    interface = GUI()

    points = ioclass.read_from_file(filename)

    interface.set_points(points)

    poly = Polygon()
    poly.set_points(points)

    ear_art_gallery_problem.art_gallery_problem(interface)
    #seidel_art_gallery_color.art_gallery_problem(interface)
    #ear_triang_segment_tree.ear_segment_art_gallery_problem(interface)
    interface.draw_polygon_points(poly)
    root = interface.get_root()
    root.mainloop()
开发者ID:vrublevskiyvitaliy,项目名称:Coursework,代码行数:18,代码来源:main.py

示例4: art_gallery_problem

# 需要导入模块: from polygon import Polygon [as 别名]
# 或者: from polygon.Polygon import set_points [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

示例5: change_solution_method

# 需要导入模块: from polygon import Polygon [as 别名]
# 或者: from polygon.Polygon import set_points [as 别名]
 def change_solution_method(self, ev):
     # 0 - ear - coloring
     # 1 - ear - segment - tree
     self.canvas.delete("all")
     points = self.points
     poly = Polygon()
     poly.set_points(points)
     self.draw_polygon_points(poly)
     show_decomposition = self.show_decomposition_checkbox.var.get() == 1
     mode = self.method_combo.current()
     if mode == 0:
         ear_art_gallery_problem.art_gallery_problem(interface=self, points=points,
                                                     show_decomposition=show_decomposition)
     elif mode == 1:
         ear_triang_segment_tree.ear_segment_art_gallery_problem(interface=self, points=points,
                                                                 show_decomposition=show_decomposition)
     elif mode == 2:
         seidel_art_gallery_segment.seidel_segment_art_gallery_problem(interface=self, points=points,
                                                                       show_decomposition=show_decomposition)
     elif mode == 3:
         seidel_art_gallery_color.art_gallery_problem(interface=self, points=points,
                                                      show_decomposition=show_decomposition)
开发者ID:vrublevskiyvitaliy,项目名称:Coursework,代码行数:24,代码来源:gui.py

示例6: art_gallery_problem

# 需要导入模块: from polygon import Polygon [as 别名]
# 或者: from polygon.Polygon import set_points [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)

    size = len(points)

    list_points = []
    for p in points:
        list_points.append([p.x, p.y])

    seidel_triangalator = seidel.Triangulator(list_points)
    triangles1 = seidel_triangalator.triangles()

    # 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,代码行数:39,代码来源:seidel_art_gallery_color.py

示例7: seidel_segment_art_gallery_problem

# 需要导入模块: from polygon import Polygon [as 别名]
# 或者: from polygon.Polygon import set_points [as 别名]
def seidel_segment_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)
    size = len(points)

    list_points = []
    for p in points:
        list_points.append([p.x, p.y])

    #test = [[0, 0], [1, 0], [1, 1], [0, 1]]
    seidel_triangalator = seidel.Triangulator(list_points)

    triangles1 = seidel_triangalator.triangles()

    if show_decomposition:
        interface.draw_triangles(triangles1)

    triangles_per_point = dict()
    segment_tree = SegmentTree(0, size - 1)

    for triangle in triangles1:
        p1, p2, p3 = triangle[0], triangle[1], triangle[2]

        if p1 not in triangles_per_point.keys():
            triangles_per_point[p1] = list()
        if p2 not in triangles_per_point.keys():
            triangles_per_point[p2] = list()
        if p3 not in triangles_per_point.keys():
            triangles_per_point[p3] = list()

        triangles_per_point[p1].append([p1, p2, p3])
        triangles_per_point[p2].append([p1, p2, p3])
        triangles_per_point[p3].append([p1, p2, p3])

    for point in triangles_per_point:

        segment_tree.add(int(point), int(point), len(triangles_per_point[point]))

    current_max = size
    start = 0
    end = size - 1
    current_max = segment_tree.query_max(start, end)
    current_max_index = segment_tree.query_max_index(start, end)
    res = []
    while current_max > 0:
        res.append(points[current_max_index])
        for triangle in triangles_per_point[current_max_index]:
            p1, p2, p3 = triangle[0], triangle[1], triangle[2]

            p1 = int(p1)
            p2 = int(p2)
            p3 = int(p3)

            segment_tree.add(p1, p1, -1)
            segment_tree.add(p2, p2, -1)
            segment_tree.add(p3, p3, -1)

        current_max = segment_tree.query_max(start, end)
        current_max_index = segment_tree.query_max_index(start, end)

    interface.draw_result_points(res)
    interface.set_result(len(res))

#test = [[0, 0], [1, 0], [1, 1], [0, 1]]
#seidel_1 = seidel.Triangulator(test)

#triangles = seidel_1.triangles()
开发者ID:vrublevskiyvitaliy,项目名称:Coursework,代码行数:71,代码来源:seidel_art_gallery_segment.py


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