Skip to content
Snippets Groups Projects
Commit c4f4b0ea authored by Jingyan Ling's avatar Jingyan Ling
Browse files

update 0703 journal and code

parent 8c989c10
Branches
No related merge requests found
...@@ -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
...@@ -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=(210,270) self.matrix_shape=(270,210)
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'})
......
...@@ -53,11 +53,11 @@ $HANDLING ...@@ -53,11 +53,11 @@ $HANDLING
9 9
$TDUPDATE $TDUPDATE
40 40
2458668.61425 2458668.67993
9 9
$HANDSEED $HANDSEED
5 5
30B 322
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
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment