ENH:is_bbl_3mf pointer should determine if it is empty
jira: STUDIO-11031 Change-Id: I14c6daeb275a82d019f88246b23013163a14ded1
This commit is contained in:
parent
b48d52feeb
commit
aa7fbd4926
|
@ -66,7 +66,7 @@ struct AMFParserContext
|
|||
{
|
||||
AMFParserContext(XML_Parser parser, DynamicPrintConfig* config, ConfigSubstitutionContext* config_substitutions, Model* model) :
|
||||
m_parser(parser),
|
||||
m_model(*model),
|
||||
m_model(*model),
|
||||
m_config(config),
|
||||
m_config_substitutions(config_substitutions)
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ struct AMFParserContext
|
|||
static void XMLCALL characters(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
AMFParserContext *ctx = (AMFParserContext*)userData;
|
||||
ctx->characters(s, len);
|
||||
ctx->characters(s, len);
|
||||
}
|
||||
|
||||
static const char* get_attribute(const char **atts, const char *id) {
|
||||
|
@ -326,7 +326,7 @@ void AMFParserContext::startElement(const char *name, const char **atts)
|
|||
this->stop();
|
||||
else {
|
||||
m_object_instances_map[object_id].instances.push_back(AMFParserContext::Instance());
|
||||
m_instance = &m_object_instances_map[object_id].instances.back();
|
||||
m_instance = &m_object_instances_map[object_id].instances.back();
|
||||
node_type_new = NODE_TYPE_INSTANCE;
|
||||
}
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ void AMFParserContext::startElement(const char *name, const char **atts)
|
|||
else
|
||||
{
|
||||
// It means that data was saved in old version (2.2.0 and older) of PrusaSlicer
|
||||
// read old data ...
|
||||
// read old data ...
|
||||
std::string gcode = get_attribute(atts, "gcode");
|
||||
// ... and interpret them to the new data
|
||||
CustomGCode::Type type= gcode == "M600" ? CustomGCode::ColorChange :
|
||||
|
@ -379,7 +379,7 @@ void AMFParserContext::startElement(const char *name, const char **atts)
|
|||
else if (m_path[2] == NODE_TYPE_INSTANCE) {
|
||||
assert(m_instance);
|
||||
if (strcmp(name, "deltax") == 0)
|
||||
node_type_new = NODE_TYPE_DELTAX;
|
||||
node_type_new = NODE_TYPE_DELTAX;
|
||||
else if (strcmp(name, "deltay") == 0)
|
||||
node_type_new = NODE_TYPE_DELTAY;
|
||||
else if (strcmp(name, "deltaz") == 0)
|
||||
|
@ -415,7 +415,7 @@ void AMFParserContext::startElement(const char *name, const char **atts)
|
|||
case 4:
|
||||
if (m_path[3] == NODE_TYPE_VERTICES) {
|
||||
if (strcmp(name, "vertex") == 0)
|
||||
node_type_new = NODE_TYPE_VERTEX;
|
||||
node_type_new = NODE_TYPE_VERTEX;
|
||||
} else if (m_path[3] == NODE_TYPE_VOLUME) {
|
||||
if (strcmp(name, "metadata") == 0) {
|
||||
const char *type = get_attribute(atts, "type");
|
||||
|
@ -436,7 +436,7 @@ void AMFParserContext::startElement(const char *name, const char **atts)
|
|||
case 5:
|
||||
if (strcmp(name, "coordinates") == 0) {
|
||||
if (m_path[4] == NODE_TYPE_VERTEX) {
|
||||
node_type_new = NODE_TYPE_COORDINATES;
|
||||
node_type_new = NODE_TYPE_COORDINATES;
|
||||
} else
|
||||
this->stop();
|
||||
} else if (name[0] == 'v' && name[1] >= '1' && name[1] <= '3' && name[2] == 0) {
|
||||
|
@ -663,7 +663,7 @@ void AMFParserContext::endElement(const char * /* name */)
|
|||
m_volume->source.volume_idx = (int)m_model.objects.back()->volumes.size() - 1;
|
||||
m_volume->center_geometry_after_creation();
|
||||
} else
|
||||
// pass false if the mesh offset has been already taken from the data
|
||||
// pass false if the mesh offset has been already taken from the data
|
||||
m_volume->center_geometry_after_creation(m_volume->source.input_file.empty());
|
||||
|
||||
m_volume->calculate_convex_hull();
|
||||
|
@ -778,7 +778,7 @@ void AMFParserContext::endElement(const char * /* name */)
|
|||
}
|
||||
m_object->sla_points_status = sla::PointsStatus::UserModified;
|
||||
}
|
||||
else if (m_path.size() == 5 && m_path[1] == NODE_TYPE_OBJECT && m_path[3] == NODE_TYPE_RANGE &&
|
||||
else if (m_path.size() == 5 && m_path[1] == NODE_TYPE_OBJECT && m_path[3] == NODE_TYPE_RANGE &&
|
||||
m_object && strcmp(opt_key, "layer_height_range") == 0) {
|
||||
// Parse object's layer_height_range, a semicolon separated doubles.
|
||||
char* p = m_value[1].data();
|
||||
|
@ -824,7 +824,7 @@ void AMFParserContext::endElement(const char * /* name */)
|
|||
m_volume->source.is_converted_from_meters = m_value[1] == "1";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else */if (m_path.size() == 3) {
|
||||
if (m_path[1] == NODE_TYPE_MATERIAL) {
|
||||
if (m_material)
|
||||
|
@ -930,8 +930,9 @@ bool load_amf_file(const char *path, DynamicPrintConfig *config, ConfigSubstitut
|
|||
|
||||
if (result)
|
||||
ctx.endDocument();
|
||||
|
||||
*use_inches = ctx.m_use_inches;
|
||||
if (use_inches) {
|
||||
*use_inches = ctx.m_use_inches;
|
||||
}
|
||||
|
||||
for (ModelObject* o : model->objects)
|
||||
{
|
||||
|
@ -1009,7 +1010,9 @@ bool extract_model_from_archive(mz_zip_archive& archive, const mz_zip_archive_fi
|
|||
}
|
||||
|
||||
ctx.endDocument();
|
||||
*use_inches = ctx.m_use_inches;
|
||||
if (use_inches) {
|
||||
*use_inches = ctx.m_use_inches;
|
||||
}
|
||||
//if (check_version && (ctx.m_version > VERSION_AMF_COMPATIBLE))
|
||||
//{
|
||||
// std::string msg = _(L("The selected amf file has been saved with a newer version of " + std::string(SLIC3R_APP_NAME) + " and is not compatible."));
|
||||
|
@ -1326,7 +1329,7 @@ bool load_amf(const char *path, DynamicPrintConfig *config, ConfigSubstitutionCo
|
|||
for (const CustomGCode::Item& code : model->custom_gcode_per_print_z.gcodes)
|
||||
{
|
||||
pt::ptree& code_tree = main_tree.add("code", "");
|
||||
// store custom_gcode_per_print_z gcodes information
|
||||
// store custom_gcode_per_print_z gcodes information
|
||||
code_tree.put("<xmlattr>.print_z" , code.print_z );
|
||||
code_tree.put("<xmlattr>.type" , static_cast<int>(code.type));
|
||||
code_tree.put("<xmlattr>.extruder" , code.extruder );
|
||||
|
@ -1337,14 +1340,14 @@ bool load_amf(const char *path, DynamicPrintConfig *config, ConfigSubstitutionCo
|
|||
std::string gcode = //code.type == CustomGCode::ColorChange ? config->opt_string("color_change_gcode") :
|
||||
code.type == CustomGCode::PausePrint ? config->opt_string("machine_pause_gcode") :
|
||||
code.type == CustomGCode::Template ? config->opt_string("template_custom_gcode") :
|
||||
code.type == CustomGCode::ToolChange ? "tool_change" : code.extra;
|
||||
code.type == CustomGCode::ToolChange ? "tool_change" : code.extra;
|
||||
code_tree.put("<xmlattr>.gcode" , gcode );
|
||||
}
|
||||
|
||||
pt::ptree& mode_tree = main_tree.add("mode", "");
|
||||
// store mode of a custom_gcode_per_print_z
|
||||
mode_tree.put("<xmlattr>.value",
|
||||
model->custom_gcode_per_print_z.mode == CustomGCode::Mode::SingleExtruder ? CustomGCode::SingleExtruderMode :
|
||||
// store mode of a custom_gcode_per_print_z
|
||||
mode_tree.put("<xmlattr>.value",
|
||||
model->custom_gcode_per_print_z.mode == CustomGCode::Mode::SingleExtruder ? CustomGCode::SingleExtruderMode :
|
||||
model->custom_gcode_per_print_z.mode == CustomGCode::Mode::MultiAsSingle ?
|
||||
CustomGCode::MultiAsSingleMode : CustomGCode::MultiExtruderMode);
|
||||
|
||||
|
|
|
@ -1067,7 +1067,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
//BBS: add plate data related logic
|
||||
// add backup & restore logic
|
||||
bool load_model_from_file(const std::string& filename, Model& model, PlateDataPtrs& plate_data_list, std::vector<Preset*>& project_presets, DynamicPrintConfig& config,
|
||||
ConfigSubstitutionContext& config_substitutions, LoadStrategy strategy, bool& is_bbl_3mf, Semver& file_version, Import3mfProgressFn proFn = nullptr, BBLProject *project = nullptr, int plate_id = 0);
|
||||
ConfigSubstitutionContext& config_substitutions, LoadStrategy strategy, bool* is_bbl_3mf, Semver& file_version, Import3mfProgressFn proFn = nullptr, BBLProject *project = nullptr, int plate_id = 0);
|
||||
bool get_thumbnail(const std::string &filename, std::string &data);
|
||||
bool load_gcode_3mf_from_stream(std::istream & data, Model& model, PlateDataPtrs& plate_data_list, DynamicPrintConfig& config, Semver& file_version);
|
||||
unsigned int version() const { return m_version; }
|
||||
|
@ -1274,7 +1274,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
//BBS: add plate data related logic
|
||||
// add backup & restore logic
|
||||
bool _BBS_3MF_Importer::load_model_from_file(const std::string& filename, Model& model, PlateDataPtrs& plate_data_list, std::vector<Preset*>& project_presets, DynamicPrintConfig& config,
|
||||
ConfigSubstitutionContext& config_substitutions, LoadStrategy strategy, bool& is_bbl_3mf, Semver& file_version, Import3mfProgressFn proFn, BBLProject *project, int plate_id)
|
||||
ConfigSubstitutionContext& config_substitutions, LoadStrategy strategy, bool* is_bbl_3mf, Semver& file_version, Import3mfProgressFn proFn, BBLProject *project, int plate_id)
|
||||
{
|
||||
m_version = 0;
|
||||
m_fdm_supports_painting_version = 0;
|
||||
|
@ -1327,7 +1327,9 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
m_backup_path = model.get_backup_path();
|
||||
}
|
||||
bool result = _load_model_from_file(filename, model, plate_data_list, project_presets, config, config_substitutions, proFn, project, plate_id);
|
||||
is_bbl_3mf = m_is_bbl_3mf;
|
||||
if (is_bbl_3mf) {
|
||||
*is_bbl_3mf = m_is_bbl_3mf;
|
||||
}
|
||||
if (m_bambuslicer_generator_version)
|
||||
file_version = *m_bambuslicer_generator_version;
|
||||
// save for restore
|
||||
|
@ -8518,7 +8520,7 @@ bool load_bbs_3mf(const char* path, DynamicPrintConfig* config, ConfigSubstituti
|
|||
// All import should use "C" locales for number formatting.
|
||||
CNumericLocalesSetter locales_setter;
|
||||
_BBS_3MF_Importer importer;
|
||||
bool res = importer.load_model_from_file(path, *model, *plate_data_list, *project_presets, *config, *config_substitutions, strategy, *is_bbl_3mf, *file_version, proFn, project, plate_id);
|
||||
bool res = importer.load_model_from_file(path, *model, *plate_data_list, *project_presets, *config, *config_substitutions, strategy, is_bbl_3mf, *file_version, proFn, project, plate_id);
|
||||
importer.log_errors();
|
||||
//BBS: remove legacy project logic currently
|
||||
//handle_legacy_project_loaded(importer.version(), *config);
|
||||
|
|
Loading…
Reference in New Issue