-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setting.cpp
165 lines (155 loc) · 4.72 KB
/
Setting.cpp
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include "stdafx.h"
#include "Setting.h"
void Setting::Readin_configure(std::string CONGFIGPATH) {
char buffer[256];//读取文件缓存
std::string inputbuffer;//为了读入文件的便于格式转化
//错误检查,确保文件打开正确
std::ifstream in(CONGFIGPATH);
if (!in.is_open())
{
std::cout << "Error opening Configure file!";
return;
}
while (!in.eof())
{
in.getline(buffer, 200);
inputbuffer = buffer;
//以斜杠开头的是文件中的注释,忽略并读入下一行
if (inputbuffer[0] == '/') continue;
else if (inputbuffer == "Texture types")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_TextureName = inputbuffer;
std::cout << "Texture types: " << g_TextureName << std::endl;
}
//水平方向纹理周期的数目
else if (inputbuffer == "Number of periods of horizontal texture")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_HorizontalCyclesNumber = stod(inputbuffer);
std::cout << "Number of periods of horizontal texture: " << g_HorizontalCyclesNumber << std::endl;
}
else if (inputbuffer == "Number of periods of vertical texture")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_VerticalCyclesNumber = stod(inputbuffer);
std::cout << "Number of periods of vertical texture: " << g_VerticalCyclesNumber << std::endl;
}
else if (inputbuffer == "The density of points")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_PointDensity = stod(inputbuffer);
std::cout << "The density of points: " << g_PointDensity << std::endl;
}
else if (inputbuffer == "Amplitude of texture")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_TextureAmplitude = stod(inputbuffer);
std::cout << "Amplitude of texture: " << g_TextureAmplitude << std::endl;
}
else if (inputbuffer == "The width of the wall tiles")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_BrickWidth = stod(inputbuffer);
std::cout << "The width of the wall tiles: " << g_BrickWidth << std::endl;
}
else if (inputbuffer == "The height of the wall tiles")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_BrickHeight = stod(inputbuffer);
std::cout << "The height of the wall tiles: " << g_BrickHeight << std::endl;
}
else if (inputbuffer == "The thickness of the wall tiles")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_BrickThickness = stod(inputbuffer);
std::cout << "The thickness of the wall tiles: " << g_BrickThickness << std::endl;
}
else if (inputbuffer == "Number of supports of wall tiles")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_SupportsNumber = stod(inputbuffer);
std::cout << "Number of supports of wall tiles: " << g_SupportsNumber << std::endl;
}
else if (inputbuffer == "The radius of the circle")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_CircleRadius = stod(inputbuffer);
std::cout << "The radius of the circle: " << g_CircleRadius << std::endl;
}
else if (inputbuffer == "Line width")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_LineWidth = stod(inputbuffer);
std::cout << "Line width: " << g_LineWidth << std::endl;
}
else if (inputbuffer == "Layer thick")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_LayerThickness = stod(inputbuffer);
std::cout << "Layer thick: " << g_LayerThickness << std::endl;
}
else if (inputbuffer == "Output path")
{
in.getline(buffer, 100);
inputbuffer = buffer;
outputFilePath = inputbuffer;
std::cout << "Output path: " << outputFilePath << std::endl;
}
else if (inputbuffer == "Printer types")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_PrinterID = inputbuffer;
std::cout << "Printer types: " << g_PrinterID << std::endl;
}
else if (inputbuffer == "Extruder Diameter")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_ExtruderDiameter = stod(inputbuffer);
std::cout << "Extruder Diameter: " << g_ExtruderDiameter << std::endl;
}
else if (inputbuffer == "Printer speed")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_PrinterSpeed = stod(inputbuffer);
std::cout << "The radius of the circle: " << g_PrinterSpeed << std::endl;
}
else if (inputbuffer == "Printer center X")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_CentralX = stod(inputbuffer);
std::cout << "Printer center X" << g_CentralX << std::endl;
}
else if (inputbuffer == "Printer center Y")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_CentralY = stod(inputbuffer);
std::cout << "Printer center Y: " << g_CentralY << std::endl;
}
else if (inputbuffer == "Extrusion rate")
{
in.getline(buffer, 100);
inputbuffer = buffer;
g_ExtrusionRate = stod(inputbuffer);
std::cout << "Extrusion rate: " << g_ExtrusionRate << std::endl;
}
}
in.close();
}