bool FffProcessor::processFiles(const std::vector< std::string >& files) { time_keeper.restart(); MeshGroup* meshgroup = new MeshGroup(this); for(std::string filename : files) { log("Loading %s from disk...\n", filename.c_str()); FMatrix3x3 matrix; if (!loadMeshIntoMeshGroup(meshgroup, filename.c_str(), matrix)) { logError("Failed to load model: %s\n", filename.c_str()); return false; } } meshgroup->finalize(); log("Loaded from disk in %5.3fs\n", time_keeper.restart()); return processMeshGroup(meshgroup); }
void slice(fffProcessor& processor, int argc, char **argv) { processor.time_keeper.restart(); FMatrix3x3 transformation; // the transformation applied to a model when loaded MeshGroup meshgroup(&processor); int extruder_train_nr = 0; SettingsBase* last_extruder_train = meshgroup.getExtruderTrain(0); SettingsBase* last_settings_object = &processor; for(int argn = 2; argn < argc; argn++) { char* str = argv[argn]; if (str[0] == '-') { if (str[1] == '-') { if (stringcasecompare(str, "--next") == 0) { try { //Catch all exceptions, this prevents the "something went wrong" dialog on windows to pop up on a thrown exception. // Only ClipperLib currently throws exceptions. And only in case that it makes an internal error. meshgroup.finalize(); log("Loaded from disk in %5.3fs\n", processor.time_keeper.restart()); for (int extruder_nr = 0; extruder_nr < processor.getSettingAsCount("machine_extruder_count"); extruder_nr++) { // initialize remaining extruder trains and load the defaults meshgroup.getExtruderTrain(extruder_nr)->setExtruderTrainDefaults(extruder_nr); // also initializes yet uninitialized extruder trains } //start slicing processor.processMeshGroup(&meshgroup); // initialize loading of new meshes processor.time_keeper.restart(); meshgroup = MeshGroup(&processor); last_settings_object = &meshgroup; }catch(...){ cura::logError("Unknown exception\n"); exit(1); } break; }else{ cura::logError("Unknown option: %s\n", str); } }else{ for(str++; *str; str++) { switch(*str) { case 'v': cura::increaseVerboseLevel(); break; case 'p': cura::enableProgressLogging(); break; case 'j': argn++; if (SettingRegistry::getInstance()->loadJSON(argv[argn])) { cura::logError("ERROR: Failed to load json file: %s\n", argv[argn]); } break; case 'e': str++; extruder_train_nr = int(*str - '0'); // TODO: parse int instead (now "-e10"="-e:" , "-e11"="-e;" , "-e12"="-e<" .. etc) last_settings_object = meshgroup.getExtruderTrain(extruder_train_nr); last_extruder_train = meshgroup.getExtruderTrain(extruder_train_nr); break; case 'l': argn++; log("Loading %s from disk...\n", argv[argn]); // transformation = // TODO: get a transformation from somewhere if (!loadMeshIntoMeshGroup(&meshgroup, argv[argn], transformation, last_extruder_train)) { logError("Failed to load model: %s\n", argv[argn]); } else { last_settings_object = &(meshgroup.meshes.back()); // pointer is valid until a new object is added, so this is OK } break; case 'o': argn++; if (!processor.setTargetFile(argv[argn])) { cura::logError("Failed to open %s for output.\n", argv[argn]); exit(1); } break; case 's': { //Parse the given setting and store it. argn++; char* valuePtr = strchr(argv[argn], '='); if (valuePtr) { *valuePtr++ = '\0'; last_settings_object->setSetting(argv[argn], valuePtr); } } break; default: cura::logError("Unknown option: %c\n", *str); print_usage(); exit(1); break; } } } } else { cura::logError("Unknown option: %s\n", argv[argn]); print_usage(); exit(1); } } for (extruder_train_nr = 0; extruder_train_nr < processor.getSettingAsCount("machine_extruder_count"); extruder_train_nr++) { // initialize remaining extruder trains and load the defaults meshgroup.getExtruderTrain(extruder_train_nr)->setExtruderTrainDefaults(extruder_train_nr); // also initializes yet uninitialized extruder trains } #ifndef DEBUG try { #endif //Catch all exceptions, this prevents the "something went wrong" dialog on windows to pop up on a thrown exception. // Only ClipperLib currently throws exceptions. And only in case that it makes an internal error. meshgroup.finalize(); log("Loaded from disk in %5.3fs\n", processor.time_keeper.restart()); //start slicing processor.processMeshGroup(&meshgroup); #ifndef DEBUG }catch(...){ cura::logError("Unknown exception\n"); exit(1); } #endif //Finalize the processor, this adds the end.gcode. And reports statistics. processor.finalize(); }