mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-13 14:49:03 +08:00
Changes required by update of libbgcode library interface
This commit is contained in:
parent
0bea17c128
commit
8e391d00da
@ -741,7 +741,8 @@ ConfigSubstitutions ConfigBase::load(const std::string& filename, ForwardCompati
|
||||
if (file == nullptr)
|
||||
throw Slic3r::RuntimeError("Error opening the file: " + filename + "\n");
|
||||
|
||||
file_type = (bgcode::core::is_valid_binary_gcode(*file, true) == bgcode::core::EResult::Success) ? EFileType::BinaryGCode : EFileType::AsciiGCode;
|
||||
std::vector<uint8_t> cs_buffer(65536);
|
||||
file_type = (bgcode::core::is_valid_binary_gcode(*file, true, cs_buffer.data(), cs_buffer.size()) == bgcode::core::EResult::Success) ? EFileType::BinaryGCode : EFileType::AsciiGCode;
|
||||
fclose(file);
|
||||
}
|
||||
else
|
||||
@ -1070,7 +1071,8 @@ ConfigSubstitutions ConfigBase::load_from_binary_gcode_file(const std::string& f
|
||||
if (file.f == nullptr)
|
||||
throw Slic3r::RuntimeError(format("Error opening the file: %1%", filename));
|
||||
|
||||
bgcode::core::EResult res = bgcode::core::is_valid_binary_gcode(*file.f);
|
||||
std::vector<uint8_t> cs_buffer(65536);
|
||||
bgcode::core::EResult res = bgcode::core::is_valid_binary_gcode(*file.f, true, cs_buffer.data(), cs_buffer.size());
|
||||
if (res != bgcode::core::EResult::Success)
|
||||
throw Slic3r::RuntimeError(format("The selected file is not a valid binary gcode.\nError: %1%",
|
||||
std::string(bgcode::core::translate_result(res))));
|
||||
@ -1083,7 +1085,7 @@ ConfigSubstitutions ConfigBase::load_from_binary_gcode_file(const std::string& f
|
||||
throw Slic3r::RuntimeError(format("Error while reading file '%1%': %2%", filename, std::string(bgcode::core::translate_result(res))));
|
||||
|
||||
bgcode::core::BlockHeader block_header;
|
||||
res = read_next_block_header(*file.f, file_header, block_header, bgcode::core::EBlockType::SlicerMetadata, true);
|
||||
res = read_next_block_header(*file.f, file_header, block_header, bgcode::core::EBlockType::SlicerMetadata, cs_buffer.data(), cs_buffer.size());
|
||||
if (res != bgcode::core::EResult::Success)
|
||||
throw Slic3r::RuntimeError(format("Error while reading file '%1%': %2%", filename, std::string(bgcode::core::translate_result(res))));
|
||||
if ((bgcode::core::EBlockType)block_header.type != bgcode::core::EBlockType::SlicerMetadata)
|
||||
|
@ -1041,7 +1041,8 @@ void GCodeProcessor::process_file(const std::string& filename, std::function<voi
|
||||
if (file == nullptr)
|
||||
throw Slic3r::RuntimeError("Error opening the file: " + filename + "\n");
|
||||
|
||||
const bool is_binary = bgcode::core::is_valid_binary_gcode(*file, true) == bgcode::core::EResult::Success;
|
||||
std::vector<uint8_t> cs_buffer(65536);
|
||||
const bool is_binary = bgcode::core::is_valid_binary_gcode(*file, true, cs_buffer.data(), cs_buffer.size()) == bgcode::core::EResult::Success;
|
||||
fclose(file);
|
||||
|
||||
if (is_binary)
|
||||
@ -1134,8 +1135,6 @@ void GCodeProcessor::process_binary_file(const std::string& filename, std::funct
|
||||
const long file_size = ftell(file.f);
|
||||
rewind(file.f);
|
||||
|
||||
bgcode::core::set_checksum_max_cache_size(1024);
|
||||
|
||||
// read file header
|
||||
bgcode::core::FileHeader file_header;
|
||||
bgcode::core::EResult res = bgcode::core::read_header(*file.f, file_header, nullptr);
|
||||
@ -1143,11 +1142,10 @@ void GCodeProcessor::process_binary_file(const std::string& filename, std::funct
|
||||
throw Slic3r::RuntimeError("File: " + filename + "does not contain a valid binary gcode\n Error: " +
|
||||
std::string(bgcode::core::translate_result(res)) + "\n");
|
||||
|
||||
const bool verify_checksum = true;
|
||||
|
||||
// read file metadata block
|
||||
bgcode::core::BlockHeader block_header;
|
||||
res = bgcode::core::read_next_block_header(*file.f, file_header, block_header, verify_checksum);
|
||||
std::vector<uint8_t> cs_buffer(65536);
|
||||
res = bgcode::core::read_next_block_header(*file.f, file_header, block_header, cs_buffer.data(), cs_buffer.size());
|
||||
if (res != bgcode::core::EResult::Success)
|
||||
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(bgcode::core::translate_result(res)) + "\n");
|
||||
if ((bgcode::core::EBlockType)block_header.type != bgcode::core::EBlockType::FileMetadata)
|
||||
@ -1164,7 +1162,7 @@ void GCodeProcessor::process_binary_file(const std::string& filename, std::funct
|
||||
m_producer = EProducer::Unknown;
|
||||
|
||||
// read printer metadata block
|
||||
res = bgcode::core::read_next_block_header(*file.f, file_header, block_header, verify_checksum);
|
||||
res = bgcode::core::read_next_block_header(*file.f, file_header, block_header, cs_buffer.data(), cs_buffer.size());
|
||||
if (res != bgcode::core::EResult::Success)
|
||||
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(bgcode::core::translate_result(res)) + "\n");
|
||||
if ((bgcode::core::EBlockType)block_header.type != bgcode::core::EBlockType::PrinterMetadata)
|
||||
@ -1184,7 +1182,7 @@ void GCodeProcessor::process_binary_file(const std::string& filename, std::funct
|
||||
#endif // ENABLE_BINARIZED_GCODE_WIN_DEBUG
|
||||
|
||||
// read thumbnail blocks
|
||||
res = bgcode::core::read_next_block_header(*file.f, file_header, block_header, verify_checksum);
|
||||
res = bgcode::core::read_next_block_header(*file.f, file_header, block_header, cs_buffer.data(), cs_buffer.size());
|
||||
if (res != bgcode::core::EResult::Success)
|
||||
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(bgcode::core::translate_result(res)) + "\n");
|
||||
|
||||
@ -1217,7 +1215,7 @@ void GCodeProcessor::process_binary_file(const std::string& filename, std::funct
|
||||
}
|
||||
#endif // ENABLE_BINARIZED_GCODE_DEBUG
|
||||
|
||||
res = bgcode::core::read_next_block_header(*file.f, file_header, block_header, verify_checksum);
|
||||
res = bgcode::core::read_next_block_header(*file.f, file_header, block_header, cs_buffer.data(), cs_buffer.size());
|
||||
if (res != bgcode::core::EResult::Success)
|
||||
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(bgcode::core::translate_result(res)) + "\n");
|
||||
}
|
||||
@ -1240,7 +1238,7 @@ void GCodeProcessor::process_binary_file(const std::string& filename, std::funct
|
||||
#endif // ENABLE_BINARIZED_GCODE_WIN_DEBUG
|
||||
|
||||
// read slicer metadata block
|
||||
res = bgcode::core::read_next_block_header(*file.f, file_header, block_header, verify_checksum);
|
||||
res = bgcode::core::read_next_block_header(*file.f, file_header, block_header, cs_buffer.data(), cs_buffer.size());
|
||||
if (res != bgcode::core::EResult::Success)
|
||||
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(bgcode::core::translate_result(res)) + "\n");
|
||||
if ((bgcode::core::EBlockType)block_header.type != bgcode::core::EBlockType::SlicerMetadata)
|
||||
@ -1275,7 +1273,7 @@ void GCodeProcessor::process_binary_file(const std::string& filename, std::funct
|
||||
initialize_result_moves();
|
||||
|
||||
// read gcodes block
|
||||
res = bgcode::core::read_next_block_header(*file.f, file_header, block_header, verify_checksum);
|
||||
res = bgcode::core::read_next_block_header(*file.f, file_header, block_header, cs_buffer.data(), cs_buffer.size());
|
||||
if (res != bgcode::core::EResult::Success)
|
||||
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(bgcode::core::translate_result(res)) + "\n");
|
||||
if ((bgcode::core::EBlockType)block_header.type != bgcode::core::EBlockType::GCode)
|
||||
@ -1295,7 +1293,7 @@ void GCodeProcessor::process_binary_file(const std::string& filename, std::funct
|
||||
if (ftell(file.f) == file_size)
|
||||
break;
|
||||
|
||||
res = bgcode::core::read_next_block_header(*file.f, file_header, block_header, verify_checksum);
|
||||
res = bgcode::core::read_next_block_header(*file.f, file_header, block_header, cs_buffer.data(), cs_buffer.size());
|
||||
if (res != bgcode::core::EResult::Success)
|
||||
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(bgcode::core::translate_result(res)) + "\n");
|
||||
}
|
||||
|
@ -883,7 +883,8 @@ ConfigSubstitutions PresetBundle::load_config_file(const std::string &path, Forw
|
||||
FILE* file = boost::nowide::fopen(path.c_str(), "rb");
|
||||
if (file == nullptr)
|
||||
throw Slic3r::RuntimeError("Error opening the file: " + path + "\n");
|
||||
const bool is_binary = bgcode::core::is_valid_binary_gcode(*file, true) == bgcode::core::EResult::Success;
|
||||
std::vector<uint8_t> cs_buffer(65536);
|
||||
const bool is_binary = bgcode::core::is_valid_binary_gcode(*file, true, cs_buffer.data(), cs_buffer.size()) == bgcode::core::EResult::Success;
|
||||
fclose(file);
|
||||
|
||||
DynamicPrintConfig config;
|
||||
|
Loading…
x
Reference in New Issue
Block a user