ENH: refine the logic of shared mesh

when the original shared_mesh can not be found
we will insert the first one as shared

Change-Id: Iea2f505584fcc8fc1f9bbd3882209b042b007a92
This commit is contained in:
lane.wei 2023-02-15 17:20:36 +08:00 committed by Lane.Wei
parent 10432abf27
commit 385854ff2a
1 changed files with 9 additions and 1 deletions

View File

@ -3840,6 +3840,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
//add the shared mesh logic //add the shared mesh logic
shared_mesh_id = ::atoi(metadata.value.c_str()); shared_mesh_id = ::atoi(metadata.value.c_str());
found_count++; found_count++;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": line %1%, shared_mesh_id %2%")%__LINE__%shared_mesh_id;
} }
if (found_count >= 2) if (found_count >= 2)
@ -3857,6 +3858,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
std::map<int, ModelVolume*>::iterator iter = m_shared_meshes.find(shared_mesh_id); std::map<int, ModelVolume*>::iterator iter = m_shared_meshes.find(shared_mesh_id);
if (iter != m_shared_meshes.end()) { if (iter != m_shared_meshes.end()) {
shared_volume = iter->second; shared_volume = iter->second;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": line %1%, found shared mesh, id %2%, mesh %3%")%__LINE__%shared_mesh_id%shared_volume;
} }
} }
@ -3909,11 +3911,17 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
volume = object.add_volume(std::move(triangle_mesh)); volume = object.add_volume(std::move(triangle_mesh));
m_shared_meshes[sub_object->id] = volume; if (shared_mesh_id != -1)
//for some cases the shared mesh is in other plate and not loaded in cli slicing
//we need to use the first one in the same plate instead
m_shared_meshes[shared_mesh_id] = volume;
else
m_shared_meshes[sub_object->id] = volume;
} }
else { else {
//create volume to use shared mesh //create volume to use shared mesh
volume = object.add_volume_with_shared_mesh(*shared_volume); volume = object.add_volume_with_shared_mesh(*shared_volume);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": line %1%, create volume using shared_mesh %2%")%__LINE__%shared_volume;
} }
// stores the volume matrix taken from the metadata, if present // stores the volume matrix taken from the metadata, if present
if (has_transform) if (has_transform)