-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcnc_code.h
124 lines (112 loc) · 4 KB
/
cnc_code.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#ifndef CNC_CODE_H
#define CNC_CODE_H
#include "src/dl_creationadapter.h"
#include "src/dl_codes.h"
#include "src/dl_global.h"
#include "src/dl_dxf.h"
#include <QPoint>
struct PointInsert{
int x1;
int y1;
int x2;
int y2;
};
class dxfReader : public DL_CreationAdapter {
public:
std::vector<DL_LineData> lines_{};
std::vector<DL_ArcData> arcs_{};
std::vector<DL_ArcData> draw_arcs_{};
std::vector<DL_PointData> points_{};
std::vector<DL_CircleData> circles_{};
virtual void addLine(const DL_LineData& d);
virtual void addPoint(const DL_PointData & data);
virtual void addArc(const DL_ArcData& data);
virtual void addCircle(const DL_CircleData & data);
void messageOutput();
DL_PointData getArcStartPoint(DL_ArcData arc);
DL_PointData getArcEndPoint(DL_ArcData arc);
DL_LineData swapLinePoints(DL_LineData line);
DL_ArcData swapArcPoints(DL_ArcData arc);
std::vector<DL_LineData> deleteIndexLine(std::vector<DL_LineData> data,int index);
std::vector<DL_ArcData> deleteIndexArc(std::vector<DL_ArcData> data,int index);
int judgeStartPoint(DL_PointData point,std::vector<DL_LineData> lines,std::vector<DL_ArcData> arcs,int line_index,int arc_index);
};
class lineInserter{
public:
lineInserter(DL_LineData line);
void lineInsert();
std::vector<QPoint> getPoints();
std::vector<int> getFm();
private:
int Fm_,Xm_,Ym_,step_,Xe_,Ye_;
int X0,Y0;
std::vector<QPoint> points_;
std::vector<int> Fms_;
};
class circleInserter{
public:
circleInserter(DL_ArcData circles);
void circleInsert();
std::vector<QPoint> getPoints();
std::vector<int> getFm();
private:
int Fm_,Xe_,Ye_,Xm_,Ym_,step_;
int X0,Y0;
int clock_;
std::vector<QPoint> points_;
std::vector<int> Fms_;
};
class Insertion{
public:
std::vector<DL_LineData> lines_{};
std::vector<DL_ArcData> arcs_{};
std::vector<DL_PointData> points_{};
std::vector<DL_CircleData> circles_{};
std::vector<std::vector<QPoint>> all_points_;
std::vector<std::vector<QPoint>> all_offset_points_;
Insertion(dxfReader *reader);
std::vector<std::vector<QPoint>> lineInsert(std::vector<DL_LineData> lines,std::vector<std::vector<QPoint>> points);
std::vector<std::vector<QPoint>> circleInsert(std::vector<DL_ArcData> arcs,std::vector<std::vector<QPoint>> points);
std::vector<std::vector<QPoint>> getPoints();
std::vector<std::vector<int>> getFm();
std::vector<std::vector<QPoint>> getOffsetPoints();
private:
std::vector<std::vector<int>> all_fms_;
};
struct contour{
DL_LineData line = DL_LineData(-1,-1,-1,-1,-1,-1);
DL_ArcData arc = DL_ArcData(-1,-1,-1,-1,-1,-1);
};
class cutterOffset{
public:
cutterOffset(int radius,int status,dxfReader *reader);
std::vector<std::vector<contour>> reorderPattern();
int getVectorAngle(contour tour1,contour tour2);
int countVectorAngle(DL_LineData line1,DL_LineData line2);
DL_LineData pulseOffset(DL_LineData line);
DL_LineData lineOffset(DL_LineData line);
DL_ArcData arcOffset(DL_ArcData arc);
contour contourOffset(contour path);
DL_PointData getCrossPoint(DL_LineData line1,DL_LineData line2);
std::vector<DL_PointData> getCrossPoint(DL_ArcData arc1,double k1, double b1);
std::vector<DL_PointData> getCrossPoint(DL_ArcData arc1,DL_ArcData arc2);
std::vector<DL_PointData> getCrossPoint(DL_ArcData arc1,DL_LineData line2);
double getCloseAngle(double angle,double compare);
std::vector<contour> fixOffsetPath(contour offset1,contour offset2,int angle);
void fixOffset(std::vector<std::vector<contour>> path);
std::vector<DL_ArcData> getOffsetArcs(){
return offset_arcs_;
}
std::vector<DL_LineData> getOffsetLines(){
return offset_lines_;
}
private:
dxfReader *reader_;
int radius_;
int left_status_;
std::vector<DL_LineData> offset_lines_;
std::vector<DL_ArcData> offset_arcs_;
DL_LineData getArcLine1(DL_ArcData arc);
DL_LineData getArcLine2(DL_ArcData arc);
};
#endif // CNC_CODE_H