Xinqi Bao's Git

README.md: updated paper url
[XbSlicer.git] / src / Layer.hh
1 #pragma once
2 #include <iostream>
3 #include <vector>
4
5 #include "BufferWrite.hh"
6 #include "Cross.hh"
7 #include "Loop.hh"
8
9 class Command
10 {
11 public:
12 uint16_t cmd;
13 double x, y, de = 0;
14 Command(uint16_t cmd, double x, double y);
15 /*************************************************************************/
16 /*
17 part for to file directly
18 */
19 static double e;
20 static void G0_high(std::ostream& s, double z);
21 static void resetE(std::ostream& s);
22 friend std::ostream& operator<<(std::ostream& s, const Command& c);
23 /*************************************************************************/
24 /*************************************************************************/
25 /*
26 part for to writing buffer
27 */
28 static void G0_high(BufferWrite& buf, double z);
29 static void resetE(BufferWrite& buf);
30 friend BufferWrite& operator<<(BufferWrite& buf, const Command& c);
31 /*************************************************************************/
32 };
33
34 /*
35 Each sliced layer
36 */
37 class Layer
38 {
39 private:
40 double z;
41 double tx, ty;
42 double minX, maxX;
43 std::vector<Loop> loops;
44 std::vector<Command> commands;
45 std::vector<std::vector<Cross>> parts;
46
47 public:
48 double getZ() const;
49 double& getMinX();
50 double& getMaxX();
51 std::vector<Loop>& getLoops();
52 std::vector<Command>& getCommands();
53 std::vector<std::vector<Cross>>& getParts();
54 void commandsOut(std::ostream& s) const; // output to gcode file
55 void commandsOut(BufferWrite& buf) const; // output to writing buffer
56 void generateDe(); // Calculate how much to extrude
57 Layer(double z);
58 };