Xinqi Bao's Git
6 #include "Configurations.hh"
10 void Command::G0_high(std::ostream
& s
, double z
)
12 s
<< "G0 F6600 Z" << z
<< '\n';
15 void Command::resetE(std::ostream
& s
)
18 s
<< "G92 E0 ; reset the expected extruder position\n";
21 std::ostream
& operator<<(std::ostream
& s
, const Command
& c
)
24 { // TODO: figure out the more efficient way, without switch!!
26 return s
<< "G0 F6600 X" << c
.x
<< " Y" << c
.y
<< '\n';
29 return s
<< "G1 F783 X" << c
.x
<< " Y" << c
.y
<< " E" << Command::e
34 void Command::G0_high(BufferWrite
& buf
, double z
)
36 buf
<< "G0 F6600 Z" << z
<< '\n';
39 void Command::resetE(BufferWrite
& buf
)
42 buf
<< "G92 E0 ; reset the expected extruder position\n";
45 BufferWrite
& operator<<(BufferWrite
& buf
, const Command
& c
)
48 { // TODO: figure out the more efficient way, without switch!!
50 buf
.writeG0(c
.x
, c
.y
);
54 buf
.writeG1(c
.x
, c
.y
, Command::e
);
59 Command::Command(uint16_t cmd
, double x
, double y
) : cmd(cmd
), x(x
), y(y
) {}
61 Layer::Layer(double z
) : z(z
) {}
63 double Layer::getZ() const { return z
; }
65 double& Layer::getMinX() { return minX
; }
67 double& Layer::getMaxX() { return maxX
; }
69 vector
<Loop
>& Layer::getLoops() { return loops
; }
71 vector
<Command
>& Layer::getCommands() { return commands
; }
73 vector
<vector
<Cross
>>& Layer::getParts() { return parts
; }
75 void Layer::commandsOut(ostream
& s
) const
77 Command::G0_high(s
, z
);
79 for (const auto& c
: commands
) s
<< c
;
83 void Layer::commandsOut(BufferWrite
& buf
) const
85 Command::G0_high(buf
, z
);
87 for (const auto& c
: commands
) buf
<< c
;
91 void Layer::generateDe()
93 tx
= commands
.front().x
;
94 ty
= commands
.front().y
;
95 for (auto& tc
: commands
)
98 tc
.de
= sqrt(pow(tc
.x
- tx
, 2) + pow(tc
.y
- ty
, 2)) * ef
;