Exemple #1
0
import decodes as dc
from decodes.core import *
from decodes.extensions import packing
import random
from time import time
import math

import os, cStringIO

path = os.path.expanduser("~") + os.sep + "_decodes_export"
f_prefix = "pack_19_"
random.seed(0)


shape = PGon(packing.rand_points(random.randint(3, 10), random.randint(1, 100)))

min_area = shape.bounds.dim_x * shape.bounds.dim_y
print "Initial shape bounding area: ", min_area


n = 6
m = 10
min_a = 0
max_a = 0.5 * math.pi

trial = shape.rotated_to_min_bounds(n, m)

print trial, trial.bounds.dim_x * trial.bounds.dim_y


"""
import decodes as dc
from decodes.core import *
from decodes.extensions import packing
import random
from time import time
import math

import os,cStringIO
path = os.path.expanduser("~") + os.sep + "_decodes_export"
f_prefix = "pack_21_"
random.seed(0)


# initialize parameters
print packing.rand_points(10,100)

sheet_size = Interval(240,240)
no_rects = 40
no_sheets = 1

# create list of random shapes
shapes = []
for i in range(no_rects):
    shapes.append(PGon(packing.rand_points(random.randint(3,10),random.randint(1,min(sheet_size.a,sheet_size.b)/3))))

# sort, bin and extract the polygons
print "sorting..."
shapes_sorted = packing.sort_polygons(shapes, 'a', reverse_list = True)

print "packing..."
sheets_filled = packing.bin_polygons(shapes_sorted, sheet_size)
Exemple #3
0
import decodes as dc
from decodes.core import *
from decodes.extensions import packing
import random
from time import time
import math

import os,cStringIO
path = os.path.expanduser("~") + os.sep + "_decodes_export"
f_prefix = "pack_19_"
random.seed(0)


shape = PGon(packing.rand_points(random.randint(3,10),random.randint(1, 100)))

min_area = shape.bounds.dim_x * shape.bounds.dim_y
print "Initial shape bounding area: ", min_area


n = 6
m = 10
min_a = 0
max_a = .5 * math.pi

trial = shape.rotated_to_min_bounds(n,m)

print trial, trial.bounds.dim_x * trial.bounds.dim_y


'''
for j in range(m):
i_size = Interval(500,500)


def sheldon_packing(width, shape):
    result = []
    cut = sheldon_cut(w,shape)
    if cut:                 # returns True if cuttable
        result.append(cut[0])
        result.append(sheldon_packing(width, cut[1]))
    else:
        result.append(shape)
    return result


pts = packing.rand_points(4,size)

for i in range(4):
    pts[i] = pts[i] + Vec(i_size.a/2.0,i_size.b/2.0)

shape = PGon(pts)

shape.set_color(Color(0.0))

# send the geometry to an outie
outie = dc.makeOut(dc.Outies.SVG, f_prefix, canvas_dimensions=i_size, flip_y = True)
'''
for x in strips_packed:
    outie.put(x)
'''
outie.put(shape)
i_size = Interval(500, 500)


def sheldon_packing(width, shape):
    result = []
    cut = sheldon_cut(w, shape)
    if cut:  # returns True if cuttable
        result.append(cut[0])
        result.append(sheldon_packing(width, cut[1]))
    else:
        result.append(shape)
    return result


pts = packing.rand_points(4, size)

for i in range(4):
    pts[i] = pts[i] + Vec(i_size.a / 2.0, i_size.b / 2.0)

shape = PGon(pts)

shape.set_color(Color(0.0))

# send the geometry to an outie
outie = dc.makeOut(dc.Outies.SVG,
                   f_prefix,
                   canvas_dimensions=i_size,
                   flip_y=True)
'''
for x in strips_packed:
Exemple #6
0
import decodes as dc
from decodes.core import *
from decodes.extensions import packing
import random
from time import time
import math

import os, cStringIO
path = os.path.expanduser("~") + os.sep + "_decodes_export"
f_prefix = "pack_21_"
random.seed(0)

# initialize parameters
print packing.rand_points(10, 100)

sheet_size = Interval(240, 240)
no_rects = 40
no_sheets = 1

# create list of random shapes
shapes = []
for i in range(no_rects):
    shapes.append(
        PGon(
            packing.rand_points(
                random.randint(3, 10),
                random.randint(1,
                               min(sheet_size.a, sheet_size.b) / 3))))

# sort, bin and extract the polygons
print "sorting..."