-
Notifications
You must be signed in to change notification settings - Fork 7
/
geometry.h
104 lines (76 loc) · 1.95 KB
/
geometry.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
#ifndef __GEOMETRYH
#define __GEOMETRYH
#include "basegeo.h"
class DxfNgc_PositionList
{
public:
DxfNgc_PositionList();
PosNumber newpos(const float x[2],BaseGeo *owner);
PosNumber doesExist(const float x[2]);
std::vector<Position> pos;
float epsilon;
};
class DxfNgc_Path //coninous list of segments
{
public:
DxfNgc_Path();
std::vector<BaseGeo*> segment;
void calculatePos(DxfNgc_PositionList *pl);
float posEntry[2];
float posExit[2];
float length;
bool reverse;
};
class DxfNgc_Layer
{
public:
DxfNgc_Layer();
void setName(std::string _name);
std::string name;
void addLine(const float x1[2],const float x2[2],bool dropduplicates=false);
void addArc(const float angle1,const float angle2,const float radius,const float c[2]);
void addVertex(float x1[2]);
std::vector<Line*> line;
std::vector<Arc*> arc;
std::vector<Vertex*> vertex;
DxfNgc_PositionList pl;
std::list<DxfNgc_Path> path;
void findPaths();
void startPath(BaseGeo *start,DxfNgc_Path &p);
void applyBackwards();
bool trySimplifyLine(DxfNgc_Path &p, int seg_from, int seg_to);
void simplifyPaths();
void optiPaths(float _addupdown);
void trySwap();
void tryReverse();
void setEpsilon(float epsilon) {pl.epsilon=epsilon;};
bool tryGreed();
float calcLength(std::list<DxfNgc_Path> &path);
float curlength;
float addupdown;
bool hidden;
public: //exporting
float curpos[3],oldpos[3];
void exportgcode(std::ofstream *_out );
void exportgcodeDepthfirst(std::ofstream *_out);
void exportSegment(std::ofstream &out,BaseGeo *bg);
std::ofstream *out;
float safeheight;
float finaldepth;
float startdepth;
float stepdepth;
bool forcefirst;
float feedrate_dive;
float feedrate_lift;
float feedside;
float curz;
};
class DxfNgc_Construct
{
public:
DxfNgc_Construct();
std::vector <DxfNgc_Layer> layer;
DxfNgc_Layer *curlayer;
void createLayer(const char * name,int flags);
};
#endif