forked from Ultimaker/CuraEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
205 lines (190 loc) · 6.82 KB
/
main.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <signal.h>
#if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__))
#include <execinfo.h>
#include <sys/resource.h>
#endif
#include <stddef.h>
#include "utils/gettime.h"
#include "utils/logoutput.h"
#include "sliceDataStorage.h"
#include "modelFile/modelFile.h"
#include "settings.h"
#include "optimizedModel.h"
#include "multiVolumes.h"
#include "polygonOptimizer.h"
#include "slicer.h"
#include "layerPart.h"
#include "inset.h"
#include "skin.h"
#include "infill.h"
#include "bridge.h"
#include "support.h"
#include "pathOrderOptimizer.h"
#include "skirt.h"
#include "raft.h"
#include "comb.h"
#include "gcodeExport.h"
#include "fffProcessor.h"
void print_usage()
{
log("usage: CuraEngine [-h] [-v] [-m 3x3matrix] [-s <settingkey>=<value>] -o <output.gcode> <model.stl>\n");
}
void signal_FPE(int n)
{
(void)n;
logError("Arithmetic exception.\n");
exit(1);
}
int main(int argc, char **argv)
{
#if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__))
//Lower the process priority on linux and mac.
setpriority(PRIO_PROCESS, 0, 10);
#endif
signal(SIGFPE, signal_FPE);
ConfigSettings config;
fffProcessor processor(config);
config.filamentDiameter = 2890;
config.filamentFlow = 100;
config.initialLayerThickness = 300;
config.layerThickness = 100;
config.extrusionWidth = 400;
config.insetCount = 2;
config.downSkinCount = 6;
config.upSkinCount = 6;
config.initialSpeedupLayers = 4;
config.initialLayerSpeed = 20;
config.printSpeed = 50;
config.infillSpeed = 50;
config.inset0Speed = 50;
config.insetXSpeed = 50;
config.moveSpeed = 200;
config.fanFullOnLayerNr = 2;
config.skirtDistance = 6000;
config.skirtLineCount = 1;
config.skirtMinLength = 0;
config.sparseInfillLineDistance = 100 * config.extrusionWidth / 20;
config.infillOverlap = 15;
config.objectPosition.X = 102500;
config.objectPosition.Y = 102500;
config.objectSink = 0;
config.supportAngle = -1;
config.supportEverywhere = 0;
config.supportLineDistance = config.sparseInfillLineDistance;
config.supportExtruder = -1;
config.supportXYDistance = 700;
config.supportZDistance = 150;
config.retractionAmount = 4500;
config.retractionSpeed = 45;
config.retractionAmountExtruderSwitch = 14500;
config.retractionMinimalDistance = 1500;
config.minimalExtrusionBeforeRetraction = 100;
config.enableOozeShield = 0;
config.enableCombing = 1;
config.wipeTowerSize = 0;
config.multiVolumeOverlap = 0;
config.minimalLayerTime = 5;
config.minimalFeedrate = 10;
config.coolHeadLift = 1;
config.fanSpeedMin = 100;
config.fanSpeedMax = 100;
config.raftMargin = 5000;
config.raftLineSpacing = 1000;
config.raftBaseThickness = 0;
config.raftBaseLinewidth = 0;
config.raftInterfaceThickness = 0;
config.raftInterfaceLinewidth = 0;
config.spiralizeMode = 0;
config.fixHorrible = 0;
config.gcodeFlavor = GCODE_FLAVOR_REPRAP;
memset(config.extruderOffset, 0, sizeof(config.extruderOffset));
config.startCode =
"M109 S210 ;Heatup to 210C\n"
"G21 ;metric values\n"
"G90 ;absolute positioning\n"
"G28 ;Home\n"
"G1 Z15.0 F300 ;move the platform down 15mm\n"
"G92 E0 ;zero the extruded length\n"
"G1 F200 E5 ;extrude 5mm of feed stock\n"
"G92 E0 ;zero the extruded length again\n";
config.endCode =
"M104 S0 ;extruder heater off\n"
"M140 S0 ;heated bed heater off (if you have it)\n"
"G91 ;relative positioning\n"
"G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\n"
"G1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\n"
"G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\n"
"M84 ;steppers off\n"
"G90 ;absolute positioning\n";
fprintf(stderr,"Cura_SteamEngine version %s\n", VERSION);
for(int argn = 1; argn < argc; argn++)
{
char* str = argv[argn];
if (str[0] == '-')
{
for(str++; *str; str++)
{
switch(*str)
{
case 'h':
print_usage();
exit(1);
case 'v':
verbose_level++;
break;
case 'g':
argn++;
processor.guiConnect(atoi(argv[argn]));
break;
case 'b':
argn++;
binaryMeshBlob = fopen(argv[argn], "rb");
break;
case 'o':
argn++;
if (!processor.setTargetFile(argv[argn]))
{
logError("Failed to open %s for output.\n", argv[argn]);
exit(1);
}
break;
case 's':
{
argn++;
char* valuePtr = strchr(argv[argn], '=');
if (valuePtr)
{
*valuePtr++ = '\0';
if (!config.setSetting(argv[argn], valuePtr))
logError("Setting not found: %s %s\n", argv[argn], valuePtr);
}
}
break;
case 'm':
argn++;
sscanf(argv[argn], "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
&config.matrix.m[0][0], &config.matrix.m[0][1], &config.matrix.m[0][2],
&config.matrix.m[1][0], &config.matrix.m[1][1], &config.matrix.m[1][2],
&config.matrix.m[2][0], &config.matrix.m[2][1], &config.matrix.m[2][2]);
break;
default:
logError("Unknown option: %c\n", *str);
break;
}
}
}else{
try {
processor.processFile(argv[argn]);
}catch(...){
logError("Unknown exception\n");
exit(1);
}
}
}
processor.finalize();
}