pull/4/head
Reenforcements 2018-11-17 13:06:26 -05:00
rodzic 2ce3225f7a
commit 28e9f96c60
6 zmienionych plików z 178 dodań i 70 usunięć

Wyświetl plik

@ -3,11 +3,9 @@
<component name="ChangeListManager">
<list default="true" id="0b5af789-e47c-4138-bdb9-8fa765481e1e" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/PES_Emb_mathutils.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/PES_Emb_mathutils.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/learning/complexPath.svg" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/learning/simplePath.svg" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/LOG.md" beforeDir="false" afterPath="$PROJECT_DIR$/LOG.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/PES.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/PES.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/svgFunctions.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/svgFunctions.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@ -17,23 +15,24 @@
</component>
<component name="CoverageDataManager">
<SUITE FILE_PATH="coverage/PES_Embroidery$svgImport.coverage" NAME="svgImport Coverage Results" MODIFIED="1541478220694" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/src/learning" />
<SUITE FILE_PATH="coverage/PES_Embroidery$main.coverage" NAME="main Coverage Results" MODIFIED="1542406581596" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/src" />
<SUITE FILE_PATH="coverage/PES_Embroidery$main.coverage" NAME="main Coverage Results" MODIFIED="1542424584074" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/src" />
</component>
<component name="FUSProjectUsageTrigger">
<session id="-1920598427">
<usages-collector id="statistics.lifecycle.project">
<counts>
<entry key="project.closed" value="5" />
<entry key="project.closed" value="6" />
<entry key="project.open.time.2" value="1" />
<entry key="project.open.time.5" value="1" />
<entry key="project.open.time.6" value="4" />
<entry key="project.opened" value="6" />
<entry key="project.open.time.8" value="1" />
<entry key="project.opened" value="7" />
</counts>
</usages-collector>
<usages-collector id="statistics.vcs.git.usages" />
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="Python" value="6102" />
<entry key="Python" value="7859" />
</counts>
</usages-collector>
<usages-collector id="statistics.js.language.service.starts" />
@ -51,18 +50,18 @@
</usages-collector>
<usages-collector id="statistics.file.extensions.edit">
<counts>
<entry key="py" value="6102" />
<entry key="py" value="7859" />
</counts>
</usages-collector>
</session>
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="405">
<caret line="27" column="43" lean-forward="true" selection-start-line="27" selection-start-column="43" selection-end-line="27" selection-end-column="43" />
<state relative-caret-position="420">
<caret line="28" column="12" selection-start-line="28" selection-start-column="12" selection-end-line="28" selection-end-column="12" />
<folding>
<element signature="e#0#15#0" expanded="true" />
</folding>
@ -70,26 +69,18 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/utilities.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="11" lean-forward="true" selection-start-line="11" selection-end-line="11" />
<folding>
<marker date="1542406580742" expanded="true" signature="66:395" ph="..." />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/PES.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" column="55" lean-forward="true" selection-start-line="6" selection-start-column="55" selection-end-line="6" selection-end-column="55" />
<state relative-caret-position="147">
<caret line="71" column="78" selection-start-line="71" selection-start-column="78" selection-end-line="71" selection-end-column="78" />
<folding>
<marker date="1541543300298" expanded="true" signature="156:195" ph="..." />
<marker date="1541543300298" expanded="true" signature="209:214" ph="..." />
<marker date="1542477978192" expanded="true" signature="91:168" ph="..." />
<marker date="1542477978192" expanded="true" signature="345:385" ph="..." />
<marker date="1542477978192" expanded="true" signature="1480:1934" ph="..." />
<marker date="1542477978192" expanded="true" signature="2112:2190" ph="..." />
<marker date="1542477978192" expanded="true" signature="2204:2243" ph="..." />
<marker date="1542477978192" expanded="true" signature="2256:2261" ph="..." />
</folding>
</state>
</provider>
@ -98,8 +89,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/svgFunctions.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="300">
<caret line="20" column="25" lean-forward="true" selection-start-line="20" selection-start-column="25" selection-end-line="20" selection-end-column="25" />
<state relative-caret-position="255">
<caret line="20" column="25" selection-start-line="20" selection-start-column="25" selection-end-line="20" selection-end-column="25" />
<folding>
<element signature="e#0#19#0" expanded="true" />
<marker date="1541813377581" expanded="true" signature="343:344" ph="..." />
@ -126,6 +117,15 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/utilities.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="11" selection-start-line="11" selection-end-line="11" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
@ -145,12 +145,12 @@
<option value="$PROJECT_DIR$/src/learning/svgImport.py" />
<option value="$PROJECT_DIR$/src/svgImport.py" />
<option value="$PROJECT_DIR$/src/svg.py" />
<option value="$PROJECT_DIR$/src/PES.py" />
<option value="$PROJECT_DIR$/src/PES-Emb-mathutils.py" />
<option value="$PROJECT_DIR$/src/PES_Emb_mathutils.py" />
<option value="$PROJECT_DIR$/src/svgFunctions.py" />
<option value="$PROJECT_DIR$/src/main.py" />
<option value="$PROJECT_DIR$/src/utilities.py" />
<option value="$PROJECT_DIR$/src/main.py" />
<option value="$PROJECT_DIR$/src/PES.py" />
</list>
</option>
</component>
@ -292,7 +292,7 @@
<frame x="0" y="23" width="1680" height="1027" extended-state="0" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.26495728" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.26800978" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
@ -343,6 +343,18 @@
<entry file="file://$PROJECT_DIR$/src/svgImport.py" />
<entry file="file://$PROJECT_DIR$/src/svg.py" />
<entry file="file://$PROJECT_DIR$/src/PES-Emb-mathutils.py" />
<entry file="file://$PROJECT_DIR$/src/svgFunctions.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="20" column="25" selection-start-line="20" selection-start-column="25" selection-end-line="20" selection-end-column="25" />
<folding>
<element signature="e#0#19#0" expanded="true" />
<marker date="1541813377581" expanded="true" signature="343:344" ph="..." />
<marker date="1541813377581" expanded="true" signature="343:348" ph="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/PES_Emb_mathutils.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
@ -358,48 +370,37 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/PES.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" column="55" lean-forward="true" selection-start-line="6" selection-start-column="55" selection-end-line="6" selection-end-column="55" />
<folding>
<marker date="1541543300298" expanded="true" signature="156:195" ph="..." />
<marker date="1541543300298" expanded="true" signature="209:214" ph="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/svgFunctions.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="300">
<caret line="20" column="25" lean-forward="true" selection-start-line="20" selection-start-column="25" selection-end-line="20" selection-end-column="25" />
<folding>
<element signature="e#0#19#0" expanded="true" />
<marker date="1541813377581" expanded="true" signature="343:344" ph="..." />
<marker date="1541813377581" expanded="true" signature="343:348" ph="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/utilities.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="11" lean-forward="true" selection-start-line="11" selection-end-line="11" />
<folding>
<marker date="1542406580742" expanded="true" signature="66:395" ph="..." />
</folding>
<caret line="11" selection-start-line="11" selection-end-line="11" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="405">
<caret line="27" column="43" lean-forward="true" selection-start-line="27" selection-start-column="43" selection-end-line="27" selection-end-column="43" />
<state relative-caret-position="420">
<caret line="28" column="12" selection-start-line="28" selection-start-column="12" selection-end-line="28" selection-end-column="12" />
<folding>
<element signature="e#0#15#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/PES.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="147">
<caret line="71" column="78" selection-start-line="71" selection-start-column="78" selection-end-line="71" selection-end-column="78" />
<folding>
<marker date="1542477978192" expanded="true" signature="91:168" ph="..." />
<marker date="1542477978192" expanded="true" signature="345:385" ph="..." />
<marker date="1542477978192" expanded="true" signature="1480:1934" ph="..." />
<marker date="1542477978192" expanded="true" signature="2112:2190" ph="..." />
<marker date="1542477978192" expanded="true" signature="2204:2243" ph="..." />
<marker date="1542477978192" expanded="true" signature="2256:2261" ph="..." />
</folding>
</state>
</provider>
</entry>
</component>
</project>

16
LOG.md
Wyświetl plik

@ -1,3 +1,19 @@
# 11/16
I haven't had the chance to work on this in a while. That's ok, this weekend is partially dedicated to coding this project (among other things.)
I added a debug flag to generate an image based on the exported PES. This will be my first and most basic testing. I'm starting to really understand the format.
Man, the PEC stitch coordinate system is weird.
Okay, it's less weird after finding [this resource](https://edutechwiki.unige.ch/en/Embroidery_format_PEC) which explains it much better. Apparently stitches have a short and long form. I'm going to always use the long form to make things simpler. That way, I won't have to worry about making multiple jumps or not.
I'd like to try to optimize the groups of stitches to minimize jumps and make the jumps optimal if possible.
In version 1 of the .PES format, the PES and PEC sections contain the same data.
I think I'm going to try totally skipping the PES section because it won't be needed for embroidering, which is the purpose of this software.
# 11/6
Trying to make sense of the "d" string in the path object. I need to be able to parse this myself I think to find intersections.

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 69 B

Wyświetl plik

@ -1,17 +1,104 @@
import struct
from struct import pack
def encodeU8(num):
return pack("<B", num)
def encodeU16(num):
return pack("<H", num)
def encodeU32(num):
return pack("<I", num)
'''
The EmbroideryDesign class is used to build
the stitches that will be exported. To actually
export them, the object is converted to a PES
object.
'''
class EmbroideryDesign:
def __init__(self):
None
'''
The PES object and all the objects that follow it
are for easy encoding to the PES format.
'''
class PES:
def __init__(self):
self.version = "#PES0001"
# PEC seek value (4 byte little endian integer)
self.magic = "#PES"
self.version = "0001"
self.sections = []
def encode(self):
b = bytearray()
b.extend(self.magic)
b.extend(self.version)
# Save a spot for the PEC offset that we will
# change later to the actual offset
b.extend("0000")
# Old code for the PES section
# that I decided to try excluding.
# # Assume 100mm x 100mm hoop size
# b.extend(encodeU16(0))
# # Use existing design area (don't know what this does.)
# b.extend(encodeU16(0))
# # Segment block count
# b.extend(encodeU16( len(self.sections) ))
#
# if len(self.sections) is 0:
# # No sections follow
# b.extend("0000")
# b.extend("0000")
# else:
# # Write sections
# for section in self.sections:
# section.encode(b)
return b
class PEC:
def __init__(self):
self.label = "default"
def encode(self, b):
# The label is always 19 bytes
# "LA:" + name + spaces to make it 19 bytes total + carriage return
b.extend("LA:" + self.label[:16].ljust(16))
b.extend("\r")
# Lots of values that aren't understood but probably have to be there.
b.extend([0x20] * 11)
b.extend(0xFF)
b.extend(0x00)
b.extend(0xFF)
class CEmbOne:
def __init__(self):
None
def encode(self, b):
b.extend(encodeU16(7))
b.extend("CEmbOne")
b.extend()
class BlockGeometry:
def __init__(self):
None
def encode(self, b):
None
class CSewSeg:
def __init__(self):
None
class Stitch:
def __init__(self, start, end):
if type(start) != complex:
raise Exception("Stitch - start point not a point object.")

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -3,6 +3,7 @@ import sys
from svgFunctions import *
import pyembroidery
from utilities import *
from PES import *
parser = argparse.ArgumentParser(description="Converts an SVG file into a PES embroidery file.")
@ -24,10 +25,13 @@ for shape in paths:
stitchLines = makeStitchLines(shape)
print(shape)
pes = PES()
pes.encode()
if args.debug:
pes = pyembroidery.read(args.outputFile)
if pes is not None:
loadedPES = pyembroidery.read(args.outputFile)
if loadedPES is not None:
print("Generating debug image.")
pyembroidery.write_png(pes, replaceFilenameAndExtensionFromPath(args.inputFile, "debugPicture", "png"))
pyembroidery.write_png(loadedPES, replaceFilenameAndExtensionFromPath(args.inputFile, "debugPicture", "png"))
else:
print("Couldn't find output file.")