-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLayer.cc
74 lines (61 loc) · 1.31 KB
/
Layer.cc
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
#include "Layer.hh"
#include <cmath>
#include "Configurations.hh"
using namespace std;
double Command::e = 0;
void Command::G0_high(std::ostream& s, double z) {
s << "G0 F6600 Z" << z << '\n';
}
void Command::resetE(std::ostream& s) {
e = 0;
s << "G92 E0 ; reset the expected extruder position\n";
}
void Command::G0_high(BufferWrite& buf, double z) {
buf << "G0 F6600 Z" << z << '\n';
}
void Command::resetE(BufferWrite& buf) {
e = 0;
buf << "G92 E0 ; reset the expected extruder position\n";
}
double Layer::getZ() const {
return z;
}
double& Layer::getMinX() {
return minX;
}
double& Layer::getMaxX() {
return maxX;
}
vector<Loop>& Layer::getLoops() {
return loops;
}
vector<Command>& Layer::getCommands() {
return commands;
}
vector<vector<Cross>>& Layer::getParts() {
return parts;
}
void Layer::commandsOut(ostream& s) const {
Command::G0_high(s, z);
Command::resetE(s);
for (const auto& c : commands)
s << c;
s.flush();
}
void Layer::commandsOut(BufferWrite& buf) const {
Command::G0_high(buf, z);
Command::resetE(buf);
for (const auto& c : commands)
buf << c;
//buf.flush();
}
void Layer::generateDe() {
tx = commands.front().x;
ty = commands.front().y;
for (auto& tc : commands) {
if (tc.cmd == 1)
tc.de = sqrt(pow(tc.x - tx, 2) + pow(tc.y - ty, 2)) * ef;
tx = tc.x;
ty = tc.y;
}
}