Working with lots of lines

pull/4/head
Reenforcements 2018-11-06 21:53:24 -05:00
rodzic 944db60d86
commit 3126b25985
9 zmienionych plików z 188 dodań i 21 usunięć

Wyświetl plik

@ -2,7 +2,11 @@
<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$/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" />
@ -12,7 +16,7 @@
</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="1541532884520" 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="1541559002277" 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">
@ -25,25 +29,25 @@
<usages-collector id="statistics.vcs.git.usages" />
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="Python" value="981" />
<entry key="Python" value="4031" />
</counts>
</usages-collector>
<usages-collector id="statistics.js.language.service.starts" />
<usages-collector id="statistics.file.types.open">
<counts>
<entry key="Python" value="8" />
<entry key="Python" value="10" />
<entry key="UML" value="1" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.open">
<counts>
<entry key="JavaScript-modules-diagram//Users/imaustyn/Documents/MiamiUniversity/ECE 487/Project/PES-Embroidery" value="1" />
<entry key="py" value="8" />
<entry key="py" value="10" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.edit">
<counts>
<entry key="py" value="981" />
<entry key="py" value="4031" />
</counts>
</usages-collector>
</session>
@ -53,8 +57,8 @@
<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="285">
<caret line="19" selection-start-line="19" selection-end-line="19" />
<state relative-caret-position="300">
<caret line="20" column="16" lean-forward="true" selection-start-line="20" selection-start-column="16" selection-end-line="20" selection-end-column="16" />
<folding>
<element signature="e#0#15#0" expanded="true" />
</folding>
@ -64,14 +68,44 @@
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/PES.py">
<provider selected="true" editor-type-id="text-editor" />
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="22" column="22" lean-forward="true" selection-start-line="22" selection-start-column="22" selection-end-line="22" selection-end-column="22" />
<folding>
<marker date="1541543300298" expanded="true" signature="156:195" ph="..." />
<marker date="1541543300298" expanded="true" signature="209:214" ph="..." />
</folding>
</state>
</provider>
</entry>
</file>
<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="420">
<caret line="28" lean-forward="true" selection-start-line="28" selection-end-line="28" />
<folding>
<element signature="e#0#19#0" expanded="true" />
<marker date="1541556976665" expanded="true" signature="330:331" ph="..." />
<marker date="1541556976665" expanded="true" signature="330:335" ph="..." />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/svgFunctions.py">
<entry file="file://$PROJECT_DIR$/src/PES_Emb_mathutils.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="11" column="4" selection-start-line="11" selection-start-column="4" selection-end-line="11" selection-end-column="4" />
<state relative-caret-position="240">
<caret line="16" column="26" lean-forward="true" selection-start-line="16" selection-start-column="26" selection-end-line="16" selection-end-column="26" />
<folding>
<element signature="e#0#29#0" expanded="true" />
<marker date="1541559146180" expanded="true" signature="57:347" ph="..." />
<marker date="1541559146180" expanded="true" signature="398:474" ph="..." />
<marker date="1541559146180" expanded="true" signature="542:547" ph="..." />
<marker date="1541559146180" expanded="true" signature="542:801" ph="..." />
<marker date="1541559146180" expanded="true" signature="960:970" ph="..." />
</folding>
</state>
</provider>
</entry>
@ -92,12 +126,14 @@
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/learning/PES.py" />
<option value="$PROJECT_DIR$/src/PES.py" />
<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/main.py" />
<option value="$PROJECT_DIR$/src/PES.py" />
<option value="$PROJECT_DIR$/src/PES-Emb-mathutils.py" />
<option value="$PROJECT_DIR$/src/svgFunctions.py" />
<option value="$PROJECT_DIR$/src/PES_Emb_mathutils.py" />
</list>
</option>
</component>
@ -246,7 +282,7 @@
<editor active="true" />
<layout>
<window_info id="Favorites" side_tool="true" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24969475" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.24969475" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Docker" show_stripe_button="false" />
<window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
@ -256,7 +292,7 @@
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" visible="true" weight="0.32941177" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.32941177" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@ -306,10 +342,17 @@
</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="75">
<caret line="5" column="8" selection-start-line="5" selection-start-column="8" selection-end-line="5" selection-end-column="8" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="285">
<caret line="19" selection-start-line="19" selection-end-line="19" />
<state relative-caret-position="300">
<caret line="20" column="16" lean-forward="true" selection-start-line="20" selection-start-column="16" selection-end-line="20" selection-end-column="16" />
<folding>
<element signature="e#0#15#0" expanded="true" />
</folding>
@ -317,12 +360,40 @@
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/PES.py">
<provider selected="true" editor-type-id="text-editor" />
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="22" column="22" lean-forward="true" selection-start-line="22" selection-start-column="22" selection-end-line="22" selection-end-column="22" />
<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="165">
<caret line="11" column="4" selection-start-line="11" selection-start-column="4" selection-end-line="11" selection-end-column="4" />
<state relative-caret-position="420">
<caret line="28" lean-forward="true" selection-start-line="28" selection-end-line="28" />
<folding>
<element signature="e#0#19#0" expanded="true" />
<marker date="1541556976665" expanded="true" signature="330:331" ph="..." />
<marker date="1541556976665" expanded="true" signature="330:335" 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="240">
<caret line="16" column="26" lean-forward="true" selection-start-line="16" selection-start-column="26" selection-end-line="16" selection-end-column="26" />
<folding>
<element signature="e#0#29#0" expanded="true" />
<marker date="1541559146180" expanded="true" signature="57:347" ph="..." />
<marker date="1541559146180" expanded="true" signature="398:474" ph="..." />
<marker date="1541559146180" expanded="true" signature="542:547" ph="..." />
<marker date="1541559146180" expanded="true" signature="542:801" ph="..." />
<marker date="1541559146180" expanded="true" signature="960:970" ph="..." />
</folding>
</state>
</provider>
</entry>

4
LOG.md
Wyświetl plik

@ -4,6 +4,10 @@ Trying to make sense of the "d" string in the path object. I need to be able to
Found svgpathtools Python library. This can load SVG files and even do intersections. I'm going to try it. I don't regret the research I did on Bezier curves though. Its always cool to know more. Prerequisites are numpy and svgwrite.
I think I'll need to sort the stitches so the regular ones go together and the **jump stitches are minimized**. This sounds like a ROUTING PROBLEM!
Stitches can be made from the start to end or from the end to the start. The stitch doesn't care and it will look the same in the end. I should use this to my advantage when filling shapes with stitches and also jumping from one stitch group to another. I might want a renderer that shows all this in detail, like how Simplify3D has a GCode visualizer that shows all lines but also retractions and movements.
# 11/5
It turns out Bezier paths are just interpolations between mutliple points. They're much simpler than I thought.

Wyświetl plik

@ -0,0 +1,23 @@
import struct
class PES:
def __init__(self):
self.version = "#PES0001"
# PEC seek value (4 byte little endian integer)
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.")
if type(end) != complex:
raise Exception("Stitch - end point not a point object.")
self.start = start
self.end = end

BIN
src/PES.pyc 100644

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -0,0 +1,35 @@
from svgpathtools import Line
import math
class InfLine:
def __init__(self, m, b):
self.m = m
self.b = b
def x_for_y(self, y):
return (y - self.b) / m;
def y_for_x(self, x):
return (self.m * x) + self.b
def to_svg_Line(self, center, length):
h = length / 2.0
ext1 = complex( )
def getBoxDiagonalLength(left, right, top, bottom):
return math.sqrt( math.pow(left-right, 2) + math.pow(top-bottom, 2) )
def getStartAndEndPointsOfLineInBox(m, b, left, right, top, bottom):
# Intersect the line with all the sides of the box and
# take the two points inside the box.
# This will always be the top and bottom
# or the left and right sides.
p1 = complex((top - b) / m, top);
p2 = complex(left, m*left + b)
# Creates a line with the given y intercept (b) that covers
# the given bounding box.
def defineLine(length=1000, m=45.0, b=0, upperLeft=(0+0j), size=(0+0j)):
None

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -17,5 +17,5 @@ if paths is None or attributes is None:
# Enumerate the shapes in the SVG to find where stitches should go.
for shape in paths:
stitchLines = makeStitchLines(shape)
print(shape)

Wyświetl plik

@ -1,4 +1,6 @@
import svgpathtools
from PES_Emb_mathutils import *
from PES import Stitch
def loadVectorGraphic(filename):
svg = None
@ -9,4 +11,36 @@ def loadVectorGraphic(filename):
return svg
def
def makeStitchLines(shape, threadWidth=0.04, slope=1):
stitchLines = []
# Get the bounds of the shape
left, right, bottom, top = shape.bbox()
width = right - left
height = top - bottom
center = complex( (left + right) / 2, (top + bottom) / 2)
# Intersect a line with the given angle over and over
# to find where stitches should start/end.
# If the shape isn't convex, the line might intersect
# more than once but should always intersect an even
# number of times (as long as the shape is closed.)
# Pick the origin based on whether or not the slope is positive
if slope > 0:
origin = complex(left, top)
else:
origin = complex(right, top)
# Place the intersection line at various points along
# a straight path that has the opposite slope.
if slope is not 0:
pSlope = 1 / slope
else:
pSlope = 0
# The path should cross through the center of the bounding-
# box square.
return stitchLines

Plik binarny nie jest wyświetlany.