From 2b6b2b429376d05931b67cd2009dd5aa93cc841f Mon Sep 17 00:00:00 2001 From: bozokopic Date: Thu, 12 Apr 2018 14:14:39 +0200 Subject: main.py --- playground/calculate/.gitignore | 2 ++ playground/calculate/params.yaml | 12 +++++++++++ playground/calculate/run.sh | 4 ++++ playground/csp/.gitignore | 1 - playground/csp/main.py | 43 ---------------------------------------- 5 files changed, 18 insertions(+), 44 deletions(-) create mode 100644 playground/calculate/.gitignore create mode 100644 playground/calculate/params.yaml create mode 100755 playground/calculate/run.sh delete mode 100644 playground/csp/.gitignore delete mode 100644 playground/csp/main.py (limited to 'playground') diff --git a/playground/calculate/.gitignore b/playground/calculate/.gitignore new file mode 100644 index 0000000..7f98a9c --- /dev/null +++ b/playground/calculate/.gitignore @@ -0,0 +1,2 @@ +/result.yaml +/output.pdf diff --git a/playground/calculate/params.yaml b/playground/calculate/params.yaml new file mode 100644 index 0000000..605acec --- /dev/null +++ b/playground/calculate/params.yaml @@ -0,0 +1,12 @@ +--- +cut_width: 1 +panels: + p1: + width: 50 + height: 50 +items: + i1: + width: 5 + height: 5 + can_rotate: true +... diff --git a/playground/calculate/run.sh b/playground/calculate/run.sh new file mode 100755 index 0000000..b62fc9e --- /dev/null +++ b/playground/calculate/run.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +export PYTHONPATH=../../src_py +python -m opcut.main calculate --params params.yaml --result result.yaml --output-pdf output.pdf $* diff --git a/playground/csp/.gitignore b/playground/csp/.gitignore deleted file mode 100644 index 61d48f9..0000000 --- a/playground/csp/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/output.pdf diff --git a/playground/csp/main.py b/playground/csp/main.py deleted file mode 100644 index 8aed531..0000000 --- a/playground/csp/main.py +++ /dev/null @@ -1,43 +0,0 @@ -import sys -sys.path += ['../../src_py'] - -from opcut import common -from opcut import csp -from opcut import output - - -def main(): - panels = [ - common.Panel(id='p1', width=100, height=65) - ] - items = [ - common.Item(id='i1', width=10, height=10, can_rotate=True), - common.Item(id='i2', width=10, height=9, can_rotate=True), - common.Item(id='i3', width=20, height=8, can_rotate=True), - common.Item(id='i4', width=10, height=20, can_rotate=True), - common.Item(id='i5', width=30, height=19, can_rotate=True), - common.Item(id='i6', width=10, height=18, can_rotate=False), - common.Item(id='i7', width=10, height=17, can_rotate=True), - common.Item(id='i8', width=20, height=16, can_rotate=True), - common.Item(id='i9', width=10, height=15, can_rotate=True), - common.Item(id='i10', width=30, height=14, can_rotate=True), - common.Item(id='i11', width=10, height=20, can_rotate=True), - common.Item(id='i12', width=19, height=30, can_rotate=False), - common.Item(id='i13', width=10, height=18, can_rotate=True), - common.Item(id='i14', width=10, height=17, can_rotate=True), - common.Item(id='i15', width=20, height=16, can_rotate=True), - common.Item(id='i16', width=10, height=15, can_rotate=True), - common.Item(id='i17', width=30, height=14, can_rotate=True), - common.Item(id='i18', width=10, height=20, can_rotate=True), - common.Item(id='i19', width=30, height=19, can_rotate=True), - ] - cut_width = 0.4 - method = common.Method.FORWARD_GREEDY - result = csp.calculate(panels, items, cut_width, method) - pdf_bytes = output.generate_pdf(result) - with open('output.pdf', 'wb') as f: - f.write(pdf_bytes) - - -if __name__ == '__main__': - sys.exit(main()) -- cgit v1.2.3-70-g09d2