Added another mode that produces straighter stitches instead of zigags

pull/4/head
Reenforcements 2018-12-04 22:27:53 -05:00
rodzic d0a925f8a9
commit 2622593e5b
8 zmienionych plików z 171 dodań i 69 usunięć

Wyświetl plik

@ -2,10 +2,7 @@
<project version="4">
<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$/TestOutput/simple.PES" beforeDir="false" afterPath="$PROJECT_DIR$/TestOutput/simple.PES" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Tests/debugPicture.png" beforeDir="false" afterPath="$PROJECT_DIR$/Tests/debugPicture.png" 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>
@ -18,8 +15,8 @@
<component name="CoverageDataManager">
<SUITE FILE_PATH="coverage/PES_Embroidery$PESDump.coverage" NAME="PESDump Coverage Results" MODIFIED="1543957085304" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/PESDump" />
<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="1543977993215" 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$PECRender_main.coverage" NAME="PECRender-main Coverage Results" MODIFIED="1543961582133" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/PECRender" />
<SUITE FILE_PATH="coverage/PES_Embroidery$main.coverage" NAME="main Coverage Results" MODIFIED="1543980289433" 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$PECRender_main.coverage" NAME="PECRender-main Coverage Results" MODIFIED="1543980402090" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/PECRender" />
<SUITE FILE_PATH="coverage/PES_Embroidery$getColors.coverage" NAME="getColors Coverage Results" MODIFIED="1542917684965" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/Colors" />
<SUITE FILE_PATH="coverage/PES_Embroidery$main__1_.coverage" NAME="PESDump Coverage Results" MODIFIED="1543893622615" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/PESDump" />
</component>
@ -39,7 +36,7 @@
<usages-collector id="statistics.vcs.git.usages" />
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="Python" value="43982" />
<entry key="Python" value="44400" />
</counts>
</usages-collector>
<usages-collector id="statistics.js.language.service.starts" />
@ -57,18 +54,18 @@
</usages-collector>
<usages-collector id="statistics.file.extensions.edit">
<counts>
<entry key="py" value="43982" />
<entry key="py" value="44400" />
</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="187">
<caret line="53" lean-forward="true" selection-start-line="53" selection-end-line="53" />
<state relative-caret-position="11">
<caret line="35" column="33" lean-forward="true" selection-start-line="35" selection-start-column="33" selection-end-line="35" selection-end-column="33" />
<folding>
<element signature="e#0#15#0" expanded="true" />
</folding>
@ -79,13 +76,13 @@
<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="351">
<caret line="227" column="47" selection-start-line="227" selection-start-column="47" selection-end-line="227" selection-end-column="47" />
<state relative-caret-position="225">
<caret line="360" column="55" selection-start-line="360" selection-start-column="55" selection-end-line="360" selection-end-column="55" />
<folding>
<element signature="e#0#19#0" expanded="true" />
<marker date="1543977959007" expanded="true" signature="143:2224" ph="..." />
<marker date="1543977959007" expanded="true" signature="8439:8962" ph="..." />
<marker date="1543977959007" expanded="true" signature="8991:8996" ph="..." />
<marker date="1543979114206" expanded="true" signature="143:2224" ph="..." />
<marker date="1543979114206" expanded="true" signature="8439:8962" ph="..." />
<marker date="1543979114206" expanded="true" signature="8991:8996" ph="..." />
</folding>
</state>
</provider>
@ -94,7 +91,7 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/PES.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="305">
<state relative-caret-position="299">
<caret line="238" column="32" lean-forward="true" selection-start-line="238" selection-start-column="32" selection-end-line="238" selection-end-column="32" />
<folding>
<element signature="e#0#23#0" expanded="true" />
@ -111,8 +108,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/PES_Emb_mathutils.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="209">
<caret line="92" column="49" lean-forward="true" selection-start-line="92" selection-start-column="49" selection-end-line="92" selection-end-column="49" />
<state relative-caret-position="75">
<caret line="5" column="35" selection-start-line="5" selection-start-column="35" selection-end-line="5" selection-end-column="35" />
<folding>
<element signature="e#0#29#0" expanded="true" />
<marker date="1543625107768" expanded="true" signature="139:2608" ph="..." />
@ -144,11 +141,11 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/PECRender/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="600">
<caret line="40" column="45" lean-forward="true" selection-start-line="40" selection-start-column="45" selection-end-line="40" selection-end-column="45" />
<state relative-caret-position="225">
<caret line="15" column="76" lean-forward="true" selection-start-line="15" selection-start-column="76" selection-end-line="15" selection-end-column="76" />
<folding>
<element signature="e#0#10#0" expanded="true" />
</folding>
@ -167,9 +164,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>color cha</find>
<find>default</find>
<find>ColorChange</find>
<find>getClosest</find>
<find>image</find>
<find>fe</find>
@ -194,9 +188,12 @@
<find>encode</find>
<find>prepe</find>
<find>maxStitchDistance</find>
<find>print</find>
<find>subshapeLineGroups</find>
<find>prepend</find>
<find>createSubshapeLineGroups</find>
<find>inver</find>
<find>print</find>
<find>closest</find>
<find>subshapeLineGroups</find>
</findStrings>
</component>
<component name="Git.Settings">
@ -215,10 +212,10 @@
<option value="$PROJECT_DIR$/src/PES_Emb_mathutils.py" />
<option value="$PROJECT_DIR$/src/PES_render_utils.py" />
<option value="$PROJECT_DIR$/PESDump/main.py" />
<option value="$PROJECT_DIR$/PECRender/main.py" />
<option value="$PROJECT_DIR$/src/PES.py" />
<option value="$PROJECT_DIR$/src/svgFunctions.py" />
<option value="$PROJECT_DIR$/src/main.py" />
<option value="$PROJECT_DIR$/PECRender/main.py" />
</list>
</option>
</component>
@ -304,7 +301,7 @@
</list>
</option>
</component>
<component name="RunManager" selected="Python.main">
<component name="RunManager" selected="Python.PECRender-main">
<configuration name="PECRender-main" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="PES-Embroidery" />
<option name="INTERPRETER_OPTIONS" value="" />
@ -385,7 +382,7 @@
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/main.py" />
<option name="PARAMETERS" value="-i &quot;../Tests/simplePath.svg&quot; -o ../TestOutput/simple.pes -d" />
<option name="PARAMETERS" value="-i &quot;../Tests/tux.svg&quot; -o ../TestOutput/simple.pes -d" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
@ -393,7 +390,7 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="svgImport" type="PythonConfigurationType" factoryName="Python" temporary="true">
<configuration name="svgImport" type="PythonConfigurationType" factoryName="Python">
<module name="PES-Embroidery" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
@ -427,7 +424,6 @@
<item itemvalue="Python.PECRender-main" />
<item itemvalue="Python.PESDump" />
<item itemvalue="Python.getColors" />
<item itemvalue="Python.svgImport" />
</list>
</recent_temporary>
</component>
@ -632,20 +628,10 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/PECRender/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="600">
<caret line="40" column="45" lean-forward="true" selection-start-line="40" selection-start-column="45" selection-end-line="40" selection-end-column="45" />
<folding>
<element signature="e#0#10#0" expanded="true" />
</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="209">
<caret line="92" column="49" lean-forward="true" selection-start-line="92" selection-start-column="49" selection-end-line="92" selection-end-column="49" />
<state relative-caret-position="75">
<caret line="5" column="35" selection-start-line="5" selection-start-column="35" selection-end-line="5" selection-end-column="35" />
<folding>
<element signature="e#0#29#0" expanded="true" />
<marker date="1543625107768" expanded="true" signature="139:2608" ph="..." />
@ -665,7 +651,7 @@
</entry>
<entry file="file://$PROJECT_DIR$/src/PES.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="305">
<state relative-caret-position="299">
<caret line="238" column="32" lean-forward="true" selection-start-line="238" selection-start-column="32" selection-end-line="238" selection-end-column="32" />
<folding>
<element signature="e#0#23#0" expanded="true" />
@ -680,26 +666,36 @@
</entry>
<entry file="file://$PROJECT_DIR$/src/svgFunctions.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="351">
<caret line="227" column="47" selection-start-line="227" selection-start-column="47" selection-end-line="227" selection-end-column="47" />
<state relative-caret-position="225">
<caret line="360" column="55" selection-start-line="360" selection-start-column="55" selection-end-line="360" selection-end-column="55" />
<folding>
<element signature="e#0#19#0" expanded="true" />
<marker date="1543977959007" expanded="true" signature="143:2224" ph="..." />
<marker date="1543977959007" expanded="true" signature="8439:8962" ph="..." />
<marker date="1543977959007" expanded="true" signature="8991:8996" ph="..." />
<marker date="1543979114206" expanded="true" signature="143:2224" ph="..." />
<marker date="1543979114206" expanded="true" signature="8439:8962" ph="..." />
<marker date="1543979114206" expanded="true" signature="8991:8996" ph="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="53" lean-forward="true" selection-start-line="53" selection-end-line="53" />
<state relative-caret-position="11">
<caret line="35" column="33" lean-forward="true" selection-start-line="35" selection-start-column="33" selection-end-line="35" selection-end-column="33" />
<folding>
<element signature="e#0#15#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/PECRender/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" column="76" lean-forward="true" selection-start-line="15" selection-start-column="76" selection-end-line="15" selection-end-column="76" />
<folding>
<element signature="e#0#10#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 1.0 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.7 KiB

74
Tests/tux.svg 100644

File diff suppressed because one or more lines are too long

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 17 KiB

Wyświetl plik

@ -48,7 +48,7 @@ for i, shape in enumerate(paths):
# Make the stitches into continuous groups.
# This also breaks the long stitches up into little ones.
subshapeLineGroups = createSubshapeLineGroups(subshapeLevelGroups, fillColors=fillColors, threadWidth=threadWidth, maxStitchDistance=maxStitchDistance)
subshapeLineGroups = createSubshapeLineGroups(subshapeLevelGroups, mode="closest", fillColors=fillColors, threadWidth=threadWidth, maxStitchDistance=maxStitchDistance)
# Creates stitch outlines for each shape

Wyświetl plik

@ -245,7 +245,7 @@ def pointWithinPoint(p1, p2, dist):
# on a per sub-shape basis.
# This should return a list of sublists, with each sublist
# containing an array of continuous stitch lines.
def createSubshapeLineGroups(subshapeLevelGroups, fillColors, threadWidth=2, maxStitchDistance=10.0):
def createSubshapeLineGroups(subshapeLevelGroups, mode, fillColors, threadWidth=2, maxStitchDistance=10.0):
subshapeLineGroups = []
lastUsedGroups = []
@ -321,22 +321,54 @@ def createSubshapeLineGroups(subshapeLevelGroups, fillColors, threadWidth=2, max
# Holds groups for every subshape
shortenedSubshapeLineGroups = []
for lineGroups in subshapeLineGroups:
# Holds the groups for a single subshhape
shortenedLineGroups = []
shortenedSubshapeLineGroups.append(shortenedLineGroups)
for lineGroup in lineGroups:
# Holds shortened lines for a single continuous region
shortenedLines = []
shortenedLineGroups.append(shortenedLines)
lastLine = None
for line in lineGroup:
if lastLine is not None:
# Make a line connecting this line and the previous one.
l = Line(lastLine.end, line.start)
shortenedLines.extend( breakUpBigStitchLine(l) )
shortenedLines.extend(breakUpBigStitchLine(line))
lastLine = line
if mode == "zigzag":
for lineGroups in subshapeLineGroups:
# Holds the groups for a single subshhape
shortenedLineGroups = []
shortenedSubshapeLineGroups.append(shortenedLineGroups)
for lineGroup in lineGroups:
# Holds shortened lines for a single continuous region
shortenedLines = []
shortenedLineGroups.append(shortenedLines)
lastLine = None
for line in lineGroup:
if lastLine is not None:
# Make a line connecting this line and the previous one.
l = Line(lastLine.end, line.start)
shortenedLines.extend( breakUpBigStitchLine(l) )
shortenedLines.extend(breakUpBigStitchLine(line))
lastLine = line
elif mode == "closest":
for lineGroups in subshapeLineGroups:
# Holds the groups for a single subshhape
shortenedLineGroups = []
shortenedSubshapeLineGroups.append(shortenedLineGroups)
for lineGroup in lineGroups:
# Holds shortened lines for a single continuous region
shortenedLines = []
shortenedLineGroups.append(shortenedLines)
lastLine = None
for line in lineGroup:
if lastLine is not None:
# Which point on the next line is closest?
d1 = Line(lastLine.end, line.start).length()
d2 = Line(lastLine.end, line.end).length()
# Make a line connecting this line and the previous one.
if d2 < d1:
# Invert the line
line = Line(line.end, line.start)
l = Line(lastLine.end, line.start)
shortenedLines.extend(breakUpBigStitchLine(l))
else:
l = Line(lastLine.end, line.start)
shortenedLines.extend( breakUpBigStitchLine(l) )
else:
# The first line.
shortenedLines.extend(breakUpBigStitchLine(line))
shortenedLines.extend(breakUpBigStitchLine(line))
lastLine = line
# Render the lines
GenericRenderer.globalRenderer.clearAll()

Plik binarny nie jest wyświetlany.