-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGCode.hh
45 lines (41 loc) · 1.21 KB
/
GCode.hh
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
#pragma once
/*
@author: Xinqi Bao
After having loops for one layer, can use this class to generate the gcode
*/
#include <vector>
#include "Cross.hh"
#include "Loop.hh"
#include "Layer.hh"
static double dp = 1;
class Gcode {
private:
int numParts;
double& minX, &maxX;
std::vector<Loop>& loops;
std::vector<Command>& commands; //contain each line of gcode, stored to layer
std::vector<std::vector<Cross>>& parts;
void G0(double x, double y, double z);
void G0(double x, double y);
void G0_high(double z);
void G1(double x, double y);
void resetE();
void outline(); //method before implement subLoops
void fill(); //method before implement subLoops
void doLoops(); //***method using implement subLoops***
void fillLoop(Loop& lp); //***method using implement subLoops***
public:
Gcode(Layer& layer) :loops(layer.getLoops()), commands(layer.getCommands()), parts(layer.getParts()), minX(layer.getMinX()), maxX(layer.getMaxX()) {
if (loops.empty())
return;
int reserveSize = 0;
for (const auto& lp : loops)
reserveSize += lp.size() + int((lp.getmaxX() - lp.getminX()) / dp) * 2;
commands.reserve(reserveSize);
G0_high(layer.getZ());
//outline();
//fill();
doLoops();
layer.generateDe();
}
};