FIX: fix the cached id related issue after 3mf format adjust

Change-Id: Ie3da4a672d166f0cf23efc29faf02de633b3484e
(cherry picked from commit 842fe9310c0cdb18e7a491dae2c8ebc7a5753136)
This commit is contained in:
lane.wei 2023-05-05 15:52:34 +08:00 committed by Lane.Wei
parent c720e1eb0f
commit 53dc1694a3
2 changed files with 22 additions and 16 deletions

View file

@ -2896,7 +2896,7 @@ bool CLI::export_project(Model *model, std::string& path, PlateDataPtrs &partpla
store_params.pick_thumbnail_data = pick_thumbnails; store_params.pick_thumbnail_data = pick_thumbnails;
store_params.calibration_thumbnail_data = calibration_thumbnails; store_params.calibration_thumbnail_data = calibration_thumbnails;
store_params.id_bboxes = plate_bboxes; store_params.id_bboxes = plate_bboxes;
store_params.strategy = SaveStrategy::Silence|SaveStrategy::WithGcode|SaveStrategy::SplitModel|SaveStrategy::UseLoadedId; store_params.strategy = SaveStrategy::Silence|SaveStrategy::WithGcode|SaveStrategy::SplitModel|SaveStrategy::UseLoadedId|SaveStrategy::ShareMesh;
success = Slic3r::store_bbs_3mf(store_params); success = Slic3r::store_bbs_3mf(store_params);

View file

@ -2343,7 +2343,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
if (cut_connector.first != "connector") continue; if (cut_connector.first != "connector") continue;
pt::ptree connector_tree = cut_connector.second; pt::ptree connector_tree = cut_connector.second;
CutObjectInfo::Connector connector = {connector_tree.get<int>("<xmlattr>.volume_id"), connector_tree.get<int>("<xmlattr>.type"), CutObjectInfo::Connector connector = {connector_tree.get<int>("<xmlattr>.volume_id"), connector_tree.get<int>("<xmlattr>.type"),
connector_tree.get<float>("<xmlattr>.radius", 0.f), connector_tree.get<float>("<xmlattr>.height", 0.f), connector_tree.get<float>("<xmlattr>.radius", 0.f), connector_tree.get<float>("<xmlattr>.height", 0.f),
connector_tree.get<float>("<xmlattr>.r_tolerance"), connector_tree.get<float>("<xmlattr>.h_tolerance")}; connector_tree.get<float>("<xmlattr>.r_tolerance"), connector_tree.get<float>("<xmlattr>.h_tolerance")};
connectors.emplace_back(connector); connectors.emplace_back(connector);
} }
@ -2609,7 +2609,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
} }
} }
} }
void _BBS_3MF_Importer::_extract_layer_config_ranges_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, ConfigSubstitutionContext& config_substitutions) void _BBS_3MF_Importer::_extract_layer_config_ranges_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, ConfigSubstitutionContext& config_substitutions)
{ {
if (stat.m_uncomp_size > 0) { if (stat.m_uncomp_size > 0) {
@ -3182,7 +3182,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
} }
else { else {
if (m_is_bbl_3mf && boost::ends_with(m_curr_object->uuid, OBJECT_UUID_SUFFIX) && m_load_restore) { if (m_is_bbl_3mf && boost::ends_with(m_curr_object->uuid, OBJECT_UUID_SUFFIX) && m_load_restore) {
// Adjust backup object/volume id // Adjust backup object/volume id
std::istringstream iss(m_curr_object->uuid); std::istringstream iss(m_curr_object->uuid);
int backup_id; int backup_id;
bool need_replace = false; bool need_replace = false;
@ -3201,7 +3201,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
Component& component = m_curr_object->components[index]; Component& component = m_curr_object->components[index];
Id new_id = component.object_id; Id new_id = component.object_id;
new_id.second = (index + 1) << 16 | backup_id; new_id.second = (index + 1) << 16 | backup_id;
if (current_object != m_current_objects.end() if (current_object != m_current_objects.end()
&& (new_id.first.empty() || new_id.first == current_object->first.first)) { && (new_id.first.empty() || new_id.first == current_object->first.first)) {
current_object->second.id = new_id.second; current_object->second.id = new_id.second;
new_map.insert({new_id, std::move(current_object->second)}); new_map.insert({new_id, std::move(current_object->second)});
@ -3819,7 +3819,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
if (key == PLATERID_ATTR) if (key == PLATERID_ATTR)
{ {
m_curr_plater->plate_index = atoi(value.c_str()); m_curr_plater->plate_index = atoi(value.c_str());
} }
else if (key == PLATER_NAME_ATTR) { else if (key == PLATER_NAME_ATTR) {
m_curr_plater->plate_name = encode_path(value.c_str()); m_curr_plater->plate_name = encode_path(value.c_str());
} }
@ -6052,6 +6052,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
// all the object instances of all ModelObjects are stored and indexed in a 1 based linear fashion. // all the object instances of all ModelObjects are stored and indexed in a 1 based linear fashion.
// Therefore the list of object_ids here may not be continuous. // Therefore the list of object_ids here may not be continuous.
unsigned int object_id = 1; unsigned int object_id = 1;
unsigned int object_index = 0;
bool cb_cancel = false; bool cb_cancel = false;
std::vector<std::string> object_paths; std::vector<std::string> object_paths;
@ -6060,7 +6061,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
if (sub_model && obj != objects_data.begin()->second.object) continue; if (sub_model && obj != objects_data.begin()->second.object) continue;
if (proFn) { if (proFn) {
proFn(EXPORT_STAGE_ADD_MODELS, object_id, model.objects.size(), cb_cancel); proFn(EXPORT_STAGE_ADD_MODELS, object_index++, model.objects.size(), cb_cancel);
if (cb_cancel) if (cb_cancel)
return false; return false;
} }
@ -6092,14 +6093,19 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
volume_count++; volume_count++;
if (m_share_mesh) { if (m_share_mesh) {
auto iter = m_shared_meshes.find(volume->mesh_ptr()); auto iter = m_shared_meshes.find(volume->mesh_ptr());
if (iter != m_shared_meshes.end() && volume->supported_facets.empty() if (iter != m_shared_meshes.end())
&& volume->seam_facets.empty() {
&& volume->mmu_segmentation_facets.empty()) { const ModelVolume* shared_volume = iter->second.second;
auto data = iter->second.first; if ((shared_volume->supported_facets.equals(volume->supported_facets))
const_cast<_BBS_3MF_Exporter *>(this)->m_volume_paths.insert({volume, {data->sub_path, data->volumes_objectID.find(iter->second.second)->second}}); && (shared_volume->seam_facets.equals(volume->seam_facets))
volumes_objectID.insert({volume, 0}); && (shared_volume->mmu_segmentation_facets.equals(volume->mmu_segmentation_facets)))
object_data.share_mesh = true; {
continue; auto data = iter->second.first;
const_cast<_BBS_3MF_Exporter *>(this)->m_volume_paths.insert({volume, {data->sub_path, data->volumes_objectID.find(iter->second.second)->second}});
volumes_objectID.insert({volume, 0});
object_data.share_mesh = true;
continue;
}
} }
const_cast<_BBS_3MF_Exporter *>(this)->m_shared_meshes.insert({volume->mesh_ptr(), {&object_data, volume}}); const_cast<_BBS_3MF_Exporter *>(this)->m_shared_meshes.insert({volume->mesh_ptr(), {&object_data, volume}});
} }
@ -6239,7 +6245,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
stream << " <" << OBJECT_TAG << " id=\"" << object_data.object_id; stream << " <" << OBJECT_TAG << " id=\"" << object_data.object_id;
if (m_production_ext) if (m_production_ext)
stream << "\" " << PUUID_ATTR << "=\"" << hex_wrap<boost::uint32_t>{(boost::uint32_t)object_data.backup_id} stream << "\" " << PUUID_ATTR << "=\"" << hex_wrap<boost::uint32_t>{(boost::uint32_t)object_data.backup_id}
<< (object_data.share_mesh ? OBJECT_UUID_SUFFIX2 : OBJECT_UUID_SUFFIX); << (object_data.share_mesh ? OBJECT_UUID_SUFFIX2 : OBJECT_UUID_SUFFIX);
stream << "\" type=\"model\">\n"; stream << "\" type=\"model\">\n";