Xinqi Bao's Git

README.md: updated paper url
[XbSlicer.git] / src / STL.hh
1 #pragma once
2
3 /*
4 @author: Xinqi Bao
5 For reading in stl file, both ASCII and binary.
6 In stl file, the model represented as many triangles.
7 Store every triangles and assign to several groups with a constant high,
8 then send to Slicing.o to slice to defferent layers.
9 */
10
11 #include <unistd.h>
12
13 #include <string>
14 #include <vector>
15
16 #include "Triangle.hh"
17
18 class Stl
19 {
20 private:
21 int numLevels;
22 double xmin, xmax, ymin, ymax, zmin, zmax;
23 int readASCII(std::string& fileTarget);
24 int readBinary(std::string& fileTarget);
25 void assignTriangles();
26 void setMinAndMax();
27 void moveToCenter();
28
29 public:
30 std::vector<Triangle> triangles; // contain all the triangles
31 std::vector<std::vector<Triangle>>
32 levels; // each element is a group of assigned triangles by a range of
33 // high
34 double getZmax() const;
35 double getZmin() const;
36 std::vector<Triangle>& getLevel(double z);
37 int read(std::string& stl_target, bool isBinary);
38 Stl();
39 Stl(std::string& stl_target, bool isBinary);
40
41 void printSTL();
42 };