Пример #1
0
def _shapely_pol_to_nest2d_item(product_pol: Polygon):
    points = []
    holes = []
    product_pol = product_pol.buffer(10).convex_hull

    # First exterior
    polx, poly = product_pol.exterior.coords.xy
    points += [Point(x, y) for x, y in zip(polx, poly)]

    # Then interiors
    for interior in product_pol.interiors:
        polx, poly = interior.coords.xy
        holes.append([Point(x, y) for x, y in zip(polx, poly)])

    # Return item representing the shape of the shapely polygon
    return Item(points, holes)
Пример #2
0
def add_shape1(n, items):
    for i in range(n):
        item = Item([
            Point(-5.0, 8.95405),
            Point(5.0, 8.954050),
            Point(5.000000, -0.045949),
            Point(4.972609, -0.568550),
            Point(3.500000, -8.954050),
            Point(-3.500000, -8.954050),
            Point(-4.972609, -0.568550),
            Point(-5.000000, -0.045949),
            Point(-5.000000, 8.954050)
        ])
        items.append(item)
Пример #3
0
def add_shape2(n, items):
    for i in range(n):
        item = Item([
            Point(-11.750000, 13.057900),
            Point(-9.807860, 15.000000),
            Point(4.392139, 24.000000),
            Point(11.750000, 24.000000),
            Point(11.750000, -24.000000),
            Point(4.392139, -24.000000),
            Point(-9.807860, -15.000000),
            Point(-11.750000, -13.057900),
            Point(-11.750000, 13.057900)
        ])
        items.append(item)
Пример #4
0
def test_item():
    i1 = Item([
        Point(-5000000, 8954050),
        Point(5000000, 8954050),
        Point(5000000, -45949),
        Point(4972609, -568550),
        Point(3500000, -8954050),
        Point(-3500000, -8954050),
        Point(-4972609, -568550),
        Point(-5000000, -45949),
        Point(-5000000, 8954050)
    ])
    assert repr(i1) == 'Item(area: 166258748205509, bin_id: -1, vertices: 9)'
    assert Item.__doc__ == 'An item to be placed on a bin.'
Пример #5
0
def add_shape1(n, items):
    for i in range(n):
        item = Item([
            Point(-5000000, 8954050),
            Point(5000000, 8954050),
            Point(5000000, -45949),
            Point(4972609, -568550),
            Point(3500000, -8954050),
            Point(-3500000, -8954050),
            Point(-4972609, -568550),
            Point(-5000000, -45949),
            Point(-5000000, 8954050)
        ])
        items.append(item)
Пример #6
0
def add_shape2(n, items):
    for i in range(n):
        item = Item([
            Point(-11750000, 13057900),
            Point(-9807860, 15000000),
            Point(4392139, 24000000),
            Point(11750000, 24000000),
            Point(11750000, -24000000),
            Point(4392139, -24000000),
            Point(-9807860, -15000000),
            Point(-11750000, -13057900),
            Point(-11750000, 13057900)
        ])
        items.append(item)
 def irregular_containerize(self, objects, bins, params):
     item_list = []
     for k, obj in enumerate(objects):
         mask = obj[3]
         cnt, h = cv2.findContours(mask.astype(np.uint8), cv2.RETR_LIST,
                                   cv2.CHAIN_APPROX_SIMPLE)
         cv2.imwrite("/tmp/k.png", mask)
         #print(len(cnt),cnt[0].shape)
         ps = []
         for p in cnt[0].reshape(-1, 2):
             ps.append(Point(p[0] * 1000, p[1] * 1000))
         item_list.append(Item(ps))
     package = nest(item_list, Box(bins[0] * 1000, bins[1] * 1000))
     print(package)
     self.sw.write_packgroup(package)
     self.sw.save()
Пример #8
0
def test_point():
    p = Point(-5000000, 8954050)
    assert repr(p) == 'Point(-5000000, 8954050)'
    assert Point.__doc__ == '2D Point'
    assert p.x == -5000000
    assert p.y == 8954050