Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rocoelectrical
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Repository analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rocoelec
rocoelectrical
Commits
c4f4b0ea
Commit
c4f4b0ea
authored
5 years ago
by
Jingyan Ling
Browse files
Options
Downloads
Patches
Plain Diff
update 0703 journal and code
parent
8c989c10
Branches
Branches containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+16
-1
16 additions, 1 deletion
README.md
analyze_dxf.py
+36
-7
36 additions, 7 deletions
analyze_dxf.py
silhouette_ele.dxf
+416
-2
416 additions, 2 deletions
silhouette_ele.dxf
with
468 additions
and
10 deletions
README.md
+
16
−
1
View file @
c4f4b0ea
...
@@ -130,4 +130,19 @@
...
@@ -130,4 +130,19 @@
-
Resolution problem: single point does not represented as a pixel in
`png`
-
Resolution problem: single point does not represented as a pixel in
`png`
-
TODO:
-
TODO:
-
create an empty matrix and fill in numbers with the information of each lines' start and end point
-
create an empty matrix and fill in numbers with the information of each lines' start and end point
### 07/03/2019 (Wed)
\ No newline at end of file
-
dxf processing completed
-
Convert dxf to matrix with resolution (270X210) (mm)
-
Potential issue:
-
the
`pathfinding`
package is based on pixel
-
When round up the line's start and end point, the accuracy of pin position is low
-
Apply single point to point path finding
-
Able to draw the path on matrix
-
Able to draw the path on original dxf file
-
TODO:
-
Write out algorithm for muli-node path finding
-
break single circuit trace to parallel traces
-
solve the accuracy problem
\ No newline at end of file
This diff is collapsed.
Click to expand it.
analyze_dxf.py
+
36
−
7
View file @
c4f4b0ea
...
@@ -6,6 +6,9 @@ import random
...
@@ -6,6 +6,9 @@ import random
from
math
import
sqrt
from
math
import
sqrt
import
cv2
import
cv2
import
os
import
os
from
pathfinding.core.diagonal_movement
import
DiagonalMovement
from
pathfinding.core.grid
import
Grid
from
pathfinding.finder.a_star
import
AStarFinder
class
dxf_editor
:
class
dxf_editor
:
def
__init__
(
self
,
path
,
dxf_file
):
def
__init__
(
self
,
path
,
dxf_file
):
...
@@ -28,9 +31,17 @@ class dxf_editor:
...
@@ -28,9 +31,17 @@ class dxf_editor:
isolength
=
2.6
#mm
isolength
=
2.6
#mm
self
.
draw_on_pin
(
isolength
)
self
.
draw_on_pin
(
isolength
)
self
.
matrix_shape
=
(
2
1
0
,
2
7
0
)
self
.
matrix_shape
=
(
2
7
0
,
2
1
0
)
self
.
read_dxf_as_matrix
()
self
.
read_dxf_as_matrix
()
start_point_arr
=
np
.
rint
(
self
.
center_arr
[
0
])
end_point_arr
=
np
.
rint
(
self
.
center_arr
[
-
30
])
start_point
=
[
int
(
start_point_arr
[
0
]),
int
(
start_point_arr
[
1
])]
end_point
=
[
int
(
end_point_arr
[
0
]),
int
(
end_point_arr
[
1
])]
self
.
path
=
self
.
find_a_path
(
start_point
,
end_point
)
self
.
draw_a_path
(
self
.
path
)
self
.
dwg
.
saveas
(
self
.
dxf_name
)
self
.
dwg
.
saveas
(
self
.
dxf_name
)
...
@@ -115,24 +126,42 @@ class dxf_editor:
...
@@ -115,24 +126,42 @@ class dxf_editor:
j
=
int
(
start
[
1
])
j
=
int
(
start
[
1
])
#can draw horizontal or vertical lines only
#can draw horizontal or vertical lines only
if
j
==
end
[
1
]:
#this line is a horizontal line
if
j
==
end
[
1
]:
#this line is a horizontal line
self
.
matrix
[
i
,
j
]
=
0
self
.
matrix
[
j
,
i
]
=
0
while
i
!=
end
[
0
]:
while
i
!=
end
[
0
]:
if
i
<
end
[
0
]:
if
i
<
end
[
0
]:
i
+=
1
i
+=
1
else
:
else
:
i
-=
1
i
-=
1
self
.
matrix
[
i
,
j
]
=
0
self
.
matrix
[
j
,
i
]
=
0
elif
i
==
end
[
0
]:
#this line is a vertical line
elif
i
==
end
[
0
]:
#this line is a vertical line
self
.
matrix
[
i
,
j
]
=
0
self
.
matrix
[
j
,
i
]
=
0
while
j
!=
end
[
1
]:
while
j
!=
end
[
1
]:
if
j
<
end
[
1
]:
if
j
<
end
[
1
]:
j
+=
1
j
+=
1
else
:
else
:
j
-=
1
j
-=
1
self
.
matrix
[
i
,
j
]
=
0
self
.
matrix
[
j
,
i
]
=
0
def
find_a_path
(
self
,
start_point
,
end_point
):
grid
=
Grid
(
matrix
=
self
.
matrix
)
start
=
grid
.
node
(
start_point
[
0
],
start_point
[
1
])
end
=
grid
.
node
(
end_point
[
0
],
end_point
[
1
])
finder
=
AStarFinder
(
diagonal_movement
=
DiagonalMovement
.
always
)
path
,
runs
=
finder
.
find_path
(
start
,
end
,
grid
)
return
path
def
draw_a_path
(
self
,
path
):
#draw on matrix:
for
point
in
path
:
self
.
matrix
[
point
[
1
],
point
[
0
]]
=-
1
#draw on dxf:
for
i
in
range
(
len
(
path
)
-
1
):
self
.
msp
.
add_line
(
path
[
i
],
path
[
i
+
1
],
dxfattribs
=
{
'
layer
'
:
'
Circuit
'
,
'
linetype
'
:
'
DASHDOT
'
})
...
...
This diff is collapsed.
Click to expand it.
silhouette_ele.dxf
+
416
−
2
View file @
c4f4b0ea
...
@@ -53,11 +53,11 @@ $HANDLING
...
@@ -53,11 +53,11 @@ $HANDLING
9
9
$TDUPDATE
$TDUPDATE
40
40
2458668.6
1425
2458668.6
7993
9
9
$HANDSEED
$HANDSEED
5
5
3
0B
3
22
9
9
$DWGCODEPAGE
$DWGCODEPAGE
3
3
...
@@ -10513,6 +10513,420 @@ ISO_BLK
...
@@ -10513,6 +10513,420 @@ ISO_BLK
67
67
0
0
0
0
LINE
5
30B
8
Circuit
10
86.0
20
35.0
11
86.0
21
36.0
6
DASHDOT
67
0
0
LINE
5
30C
8
Circuit
10
86.0
20
36.0
11
86.0
21
37.0
6
DASHDOT
67
0
0
LINE
5
30D
8
Circuit
10
86.0
20
37.0
11
87.0
21
38.0
6
DASHDOT
67
0
0
LINE
5
30E
8
Circuit
10
87.0
20
38.0
11
88.0
21
39.0
6
DASHDOT
67
0
0
LINE
5
30F
8
Circuit
10
88.0
20
39.0
11
88.0
21
40.0
6
DASHDOT
67
0
0
LINE
5
310
8
Circuit
10
88.0
20
40.0
11
89.0
21
41.0
6
DASHDOT
67
0
0
LINE
5
311
8
Circuit
10
89.0
20
41.0
11
89.0
21
42.0
6
DASHDOT
67
0
0
LINE
5
312
8
Circuit
10
89.0
20
42.0
11
89.0
21
43.0
6
DASHDOT
67
0
0
LINE
5
313
8
Circuit
10
89.0
20
43.0
11
89.0
21
44.0
6
DASHDOT
67
0
0
LINE
5
314
8
Circuit
10
89.0
20
44.0
11
89.0
21
45.0
6
DASHDOT
67
0
0
LINE
5
315
8
Circuit
10
89.0
20
45.0
11
90.0
21
46.0
6
DASHDOT
67
0
0
LINE
5
316
8
Circuit
10
90.0
20
46.0
11
91.0
21
47.0
6
DASHDOT
67
0
0
LINE
5
317
8
Circuit
10
91.0
20
47.0
11
92.0
21
48.0
6
DASHDOT
67
0
0
LINE
5
318
8
Circuit
10
92.0
20
48.0
11
93.0
21
49.0
6
DASHDOT
67
0
0
LINE
5
319
8
Circuit
10
93.0
20
49.0
11
94.0
21
50.0
6
DASHDOT
67
0
0
LINE
5
31A
8
Circuit
10
94.0
20
50.0
11
95.0
21
51.0
6
DASHDOT
67
0
0
LINE
5
31B
8
Circuit
10
95.0
20
51.0
11
95.0
21
52.0
6
DASHDOT
67
0
0
LINE
5
31C
8
Circuit
10
95.0
20
52.0
11
96.0
21
53.0
6
DASHDOT
67
0
0
LINE
5
31D
8
Circuit
10
96.0
20
53.0
11
97.0
21
54.0
6
DASHDOT
67
0
0
LINE
5
31E
8
Circuit
10
97.0
20
54.0
11
98.0
21
55.0
6
DASHDOT
67
0
0
LINE
5
31F
8
Circuit
10
98.0
20
55.0
11
99.0
21
56.0
6
DASHDOT
67
0
0
LINE
5
320
8
Circuit
10
99.0
20
56.0
11
100.0
21
57.0
6
DASHDOT
67
0
0
LINE
5
321
8
Circuit
10
100.0
20
57.0
11
101.0
21
58.0
6
DASHDOT
67
0
0
VIEWPORT
VIEWPORT
5
5
27
27
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment