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


Python Arrange.centerFirst方法代码示例

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


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

示例1: test_bestSpot_rectangular_build_plate

# 需要导入模块: from cura.Arranging.Arrange import Arrange [as 别名]
# 或者: from cura.Arranging.Arrange.Arrange import centerFirst [as 别名]
def test_bestSpot_rectangular_build_plate():
    ar = Arrange(16, 40, 8, 20, scale = 1)
    ar.centerFirst()

    shape_arr = gimmeShapeArray()
    best_spot = ar.bestSpot(shape_arr)
    ar.place(best_spot.x, best_spot.y, shape_arr)
    assert best_spot.x == 0
    assert best_spot.y == 0

    # Place object a second time
    best_spot2 = ar.bestSpot(shape_arr)
    assert best_spot2.x is not None  # we found a location
    assert best_spot2.x != 0 or best_spot2.y != 0  # it can't be on the same location
    ar.place(best_spot2.x, best_spot2.y, shape_arr)

    # Place object a 3rd time
    best_spot3 = ar.bestSpot(shape_arr)
    assert best_spot3.x is not None  # we found a location
    assert best_spot3.x != best_spot.x or best_spot3.y != best_spot.y  # it can't be on the same location
    assert best_spot3.x != best_spot2.x or best_spot3.y != best_spot2.y  # it can't be on the same location
    ar.place(best_spot3.x, best_spot3.y, shape_arr)

    best_spot_x = ar.bestSpot(shape_arr)
    ar.place(best_spot_x.x, best_spot_x.y, shape_arr)

    best_spot_x = ar.bestSpot(shape_arr)
    ar.place(best_spot_x.x, best_spot_x.y, shape_arr)

    best_spot_x = ar.bestSpot(shape_arr)
    ar.place(best_spot_x.x, best_spot_x.y, shape_arr)

    print(ar._occupied)  # For debugging
开发者ID:Twosilly,项目名称:Cura,代码行数:35,代码来源:TestArrange.py

示例2: test_bestSpot_scale_rectangular

# 需要导入模块: from cura.Arranging.Arrange import Arrange [as 别名]
# 或者: from cura.Arranging.Arrange.Arrange import centerFirst [as 别名]
def test_bestSpot_scale_rectangular():
    scale = 0.5
    ar = Arrange(16, 40, 8, 20, scale = scale)
    ar.centerFirst()

    shape_arr = gimmeShapeArray(scale)

    shape_arr_square = gimmeShapeArraySquare(scale)
    best_spot = ar.bestSpot(shape_arr_square)
    assert best_spot.x == 0
    assert best_spot.y == 0
    ar.place(best_spot.x, best_spot.y, shape_arr_square)

    print(ar._occupied)

    # Place object a second time
    best_spot = ar.bestSpot(shape_arr)
    assert best_spot.x is not None  # we found a location
    assert best_spot.x != 0 or best_spot.y != 0  # it can't be on the same location
    ar.place(best_spot.x, best_spot.y, shape_arr)

    best_spot = ar.bestSpot(shape_arr_square)
    ar.place(best_spot.x, best_spot.y, shape_arr_square)

    print(ar._occupied)  # For debugging
开发者ID:Twosilly,项目名称:Cura,代码行数:27,代码来源:TestArrange.py

示例3: test_smoke_place_objects

# 需要导入模块: from cura.Arranging.Arrange import Arrange [as 别名]
# 或者: from cura.Arranging.Arrange.Arrange import centerFirst [as 别名]
def test_smoke_place_objects():
    ar = Arrange(20, 20, 10, 10, scale = 1)
    ar.centerFirst()
    shape_arr = gimmeShapeArray()

    for i in range(5):
        best_spot_x, best_spot_y, score, prio = ar.bestSpot(shape_arr)
        ar.place(best_spot_x, best_spot_y, shape_arr)
开发者ID:Twosilly,项目名称:Cura,代码行数:10,代码来源:TestArrange.py

示例4: test_ShapeArray_scaling2

# 需要导入模块: from cura.Arranging.Arrange import Arrange [as 别名]
# 或者: from cura.Arranging.Arrange.Arrange import centerFirst [as 别名]
def test_ShapeArray_scaling2():
    scale = 0.5
    ar = Arrange(16, 16, 8, 8, scale = scale)
    ar.centerFirst()

    shape_arr = gimmeShapeArray(scale)
    count = len(numpy.where(shape_arr.arr == 1)[0])
    assert count >= 1  # should approach 3, but it can be inaccurate due to pixel rounding
开发者ID:TinkerGnome,项目名称:Cura,代码行数:10,代码来源:TestArrange.py

示例5: test_ShapeArray_scaling

# 需要导入模块: from cura.Arranging.Arrange import Arrange [as 别名]
# 或者: from cura.Arranging.Arrange.Arrange import centerFirst [as 别名]
def test_ShapeArray_scaling():
    scale = 2
    ar = Arrange(16, 16, 8, 8, scale = scale)
    ar.centerFirst()

    shape_arr = gimmeShapeArray(scale)
    count = len(numpy.where(shape_arr.arr == 1)[0])
    assert count >= 40  # should approach 2*2*12 = 48
开发者ID:TinkerGnome,项目名称:Cura,代码行数:10,代码来源:TestArrange.py

示例6: test_centerFirst_rectangular

# 需要导入模块: from cura.Arranging.Arrange import Arrange [as 别名]
# 或者: from cura.Arranging.Arrange.Arrange import centerFirst [as 别名]
def test_centerFirst_rectangular():
    ar = Arrange(400, 300, 200, 150, scale = 1)
    ar.centerFirst()
    assert ar._priority[150][200] < ar._priority[150][220]
    assert ar._priority[150][200] < ar._priority[170][200]
    assert ar._priority[150][200] < ar._priority[170][220]
    assert ar._priority[150][200] < ar._priority[180][150]
    assert ar._priority[150][200] < ar._priority[130][200]
    assert ar._priority[150][200] < ar._priority[130][180]
开发者ID:Twosilly,项目名称:Cura,代码行数:11,代码来源:TestArrange.py

示例7: test_centerFirst

# 需要导入模块: from cura.Arranging.Arrange import Arrange [as 别名]
# 或者: from cura.Arranging.Arrange.Arrange import centerFirst [as 别名]
def test_centerFirst():
    ar = Arrange(300, 300, 150, 150, scale = 1)
    ar.centerFirst()
    assert ar._priority[150][150] < ar._priority[170][150]
    assert ar._priority[150][150] < ar._priority[150][170]
    assert ar._priority[150][150] < ar._priority[170][170]
    assert ar._priority[150][150] < ar._priority[130][150]
    assert ar._priority[150][150] < ar._priority[150][130]
    assert ar._priority[150][150] < ar._priority[130][130]
开发者ID:Twosilly,项目名称:Cura,代码行数:11,代码来源:TestArrange.py

示例8: test_smoke_place

# 需要导入模块: from cura.Arranging.Arrange import Arrange [as 别名]
# 或者: from cura.Arranging.Arrange.Arrange import centerFirst [as 别名]
def test_smoke_place():
    ar = Arrange(30, 30, 15, 15)
    ar.centerFirst()

    shape_arr = gimmeShapeArray()

    assert not numpy.any(ar._occupied)
    ar.place(0, 0, shape_arr)
    assert numpy.any(ar._occupied)
开发者ID:Twosilly,项目名称:Cura,代码行数:11,代码来源:TestArrange.py

示例9: test_ShapeArray

# 需要导入模块: from cura.Arranging.Arrange import Arrange [as 别名]
# 或者: from cura.Arranging.Arrange.Arrange import centerFirst [as 别名]
def test_ShapeArray():
    scale = 1
    ar = Arrange(16, 16, 8, 8, scale = scale)
    ar.centerFirst()

    shape_arr = gimmeShapeArray(scale)
    print(shape_arr.arr)
    count = len(numpy.where(shape_arr.arr == 1)[0])
    print(count)
    assert count >= 10  # should approach 12
开发者ID:Twosilly,项目名称:Cura,代码行数:12,代码来源:TestArrange.py

示例10: test_checkShape_place

# 需要导入模块: from cura.Arranging.Arrange import Arrange [as 别名]
# 或者: from cura.Arranging.Arrange.Arrange import centerFirst [as 别名]
def test_checkShape_place():
    ar = Arrange(30, 30, 15, 15)
    ar.centerFirst()

    shape_arr = gimmeShapeArray()
    points = ar.checkShape(3, 6, shape_arr)
    ar.place(3, 6, shape_arr)
    points2 = ar.checkShape(3, 6, shape_arr)

    assert points2 is None
开发者ID:Twosilly,项目名称:Cura,代码行数:12,代码来源:TestArrange.py

示例11: test_checkShape

# 需要导入模块: from cura.Arranging.Arrange import Arrange [as 别名]
# 或者: from cura.Arranging.Arrange.Arrange import centerFirst [as 别名]
def test_checkShape():
    ar = Arrange(30, 30, 15, 15)
    ar.centerFirst()

    shape_arr = gimmeShapeArray()
    points = ar.checkShape(0, 0, shape_arr)
    points2 = ar.checkShape(5, 0, shape_arr)
    points3 = ar.checkShape(0, 5, shape_arr)
    assert points2 > points
    assert points3 > points
开发者ID:Twosilly,项目名称:Cura,代码行数:12,代码来源:TestArrange.py

示例12: test_smoke_bestSpot

# 需要导入模块: from cura.Arranging.Arrange import Arrange [as 别名]
# 或者: from cura.Arranging.Arrange.Arrange import centerFirst [as 别名]
def test_smoke_bestSpot():
    ar = Arrange(30, 30, 15, 15, scale = 1)
    ar.centerFirst()

    shape_arr = gimmeShapeArray()
    best_spot = ar.bestSpot(shape_arr)
    assert hasattr(best_spot, "x")
    assert hasattr(best_spot, "y")
    assert hasattr(best_spot, "penalty_points")
    assert hasattr(best_spot, "priority")
开发者ID:Twosilly,项目名称:Cura,代码行数:12,代码来源:TestArrange.py

示例13: test_checkShape_rectangular

# 需要导入模块: from cura.Arranging.Arrange import Arrange [as 别名]
# 或者: from cura.Arranging.Arrange.Arrange import centerFirst [as 别名]
def test_checkShape_rectangular():
    ar = Arrange(20, 30, 10, 15)
    ar.centerFirst()
    print(ar._priority)

    shape_arr = gimmeShapeArray()
    points = ar.checkShape(0, 0, shape_arr)
    points2 = ar.checkShape(5, 0, shape_arr)
    points3 = ar.checkShape(0, 5, shape_arr)
    assert points2 > points
    assert points3 > points
开发者ID:Twosilly,项目名称:Cura,代码行数:13,代码来源:TestArrange.py

示例14: test_bestSpot

# 需要导入模块: from cura.Arranging.Arrange import Arrange [as 别名]
# 或者: from cura.Arranging.Arrange.Arrange import centerFirst [as 别名]
def test_bestSpot():
    ar = Arrange(16, 16, 8, 8, scale = 1)
    ar.centerFirst()

    shape_arr = gimmeShapeArray()
    best_spot = ar.bestSpot(shape_arr)
    assert best_spot.x == 0
    assert best_spot.y == 0
    ar.place(best_spot.x, best_spot.y, shape_arr)

    # Place object a second time
    best_spot = ar.bestSpot(shape_arr)
    assert best_spot.x is not None  # we found a location
    assert best_spot.x != 0 or best_spot.y != 0  # it can't be on the same location
    ar.place(best_spot.x, best_spot.y, shape_arr)
开发者ID:TinkerGnome,项目名称:Cura,代码行数:17,代码来源:TestArrange.py

示例15: test_compare_occupied_and_priority_tables

# 需要导入模块: from cura.Arranging.Arrange import Arrange [as 别名]
# 或者: from cura.Arranging.Arrange.Arrange import centerFirst [as 别名]
def test_compare_occupied_and_priority_tables():
    ar = Arrange(10, 15, 5, 7)
    ar.centerFirst()
    assert ar._priority.shape == ar._occupied.shape
开发者ID:Twosilly,项目名称:Cura,代码行数:6,代码来源:TestArrange.py


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