ENH: add new arrangement features for wrapping detection area

Jira: STUDIO-13735

Change-Id: I198d19f5e6ef70f0adfa6370269290c81d21a557
(cherry picked from commit dc83637652526111611d0833d5f5798aaa3e7be7)
This commit is contained in:
shan.chang
2025-08-04 21:44:39 +08:00
committed by Noisyfox
parent 942d023a1e
commit bd066e7f96
11 changed files with 127 additions and 31 deletions

View File

@@ -3982,7 +3982,7 @@ void PartPlateList::reset_size(int width, int depth, int height, bool reload_obj
m_plate_height = height;
update_all_plates_pos_and_size(false, false, true);
if (update_shapes) {
set_shapes(m_shape, m_exclude_areas, m_extruder_areas, m_extruder_heights, m_logo_texture_filename, m_height_to_lid, m_height_to_rod);
set_shapes(m_shape, m_exclude_areas, m_wrapping_exclude_areas, m_extruder_areas, m_extruder_heights, m_logo_texture_filename, m_height_to_lid, m_height_to_rod);
}
if (reload_objects)
reload_all_objects();
@@ -4084,7 +4084,7 @@ void PartPlateList::reinit()
void PartPlateList::update_plates()
{
update_all_plates_pos_and_size(true, false);
set_shapes(m_shape, m_exclude_areas, m_extruder_areas, m_extruder_heights, m_logo_texture_filename, m_height_to_lid, m_height_to_rod);
set_shapes(m_shape, m_exclude_areas, m_wrapping_exclude_areas, m_extruder_areas, m_extruder_heights, m_logo_texture_filename, m_height_to_lid, m_height_to_rod);
}
int PartPlateList::create_plate(bool adjust_position)
@@ -4125,7 +4125,7 @@ int PartPlateList::create_plate(bool adjust_position)
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(":old_cols %1% -> new_cols %2%") % old_cols % cols;
//update the origin of each plate
update_all_plates_pos_and_size(adjust_position, false);
set_shapes(m_shape, m_exclude_areas, m_extruder_areas, m_extruder_heights, m_logo_texture_filename, m_height_to_lid, m_height_to_rod);
set_shapes(m_shape, m_exclude_areas, m_wrapping_exclude_areas, m_extruder_areas, m_extruder_heights, m_logo_texture_filename, m_height_to_lid, m_height_to_rod);
if (m_plater) {
Vec2d pos = compute_shape_position(m_current_plate, cols);
@@ -4319,7 +4319,7 @@ int PartPlateList::delete_plate(int index)
{
//update the origin of each plate
update_all_plates_pos_and_size();
set_shapes(m_shape, m_exclude_areas, m_extruder_areas, m_extruder_heights, m_logo_texture_filename, m_height_to_lid, m_height_to_rod);
set_shapes(m_shape, m_exclude_areas, m_wrapping_exclude_areas, m_extruder_areas, m_extruder_heights, m_logo_texture_filename, m_height_to_lid, m_height_to_rod);
}
else
{
@@ -5134,10 +5134,40 @@ bool PartPlateList::preprocess_arrange_polygon_other_locked(int obj_index, int i
return locked;
}
bool PartPlateList::preprocess_exclude_areas(arrangement::ArrangePolygons& unselected, int num_plates, float inflation)
bool PartPlateList::preprocess_exclude_areas(arrangement::ArrangePolygons &unselected, bool enable_wrapping_detect, int num_plates, float inflation)
{
bool added = false;
// wrapping detection area
if (enable_wrapping_detect)
{
if (!m_wrapping_exclude_areas.empty())
{
Polygon ap{};
for (const Vec2d &p : m_wrapping_exclude_areas)
{
ap.append({scale_(p(0)), scale_(p(1))});
}
for(int j = 0; j < num_plates; j++)
{
arrangement::ArrangePolygon ret;
ret.poly.contour = ap;
ret.translation = Vec2crd(0, 0);
ret.rotation = 0.0f;
ret.is_virt_object = true;
ret.bed_idx = j;
ret.height = 1;
ret.name = "WrappingRegion";
ret.inflation = inflation;
unselected.emplace_back(std::move(ret));
}
}
added = true;
}
// excluded area
if (m_exclude_areas.size() > 0)
{
//has exclude areas
@@ -5442,11 +5472,19 @@ void PartPlateList::select_plate_view()
m_plater->get_camera().select_view("topfront");
}
bool PartPlateList::set_shapes(const Pointfs& shape, const Pointfs& exclude_areas, const std::vector<Pointfs>& extruder_areas, const std::vector<double>& extruder_heights, const std::string& texture_filename, float height_to_lid, float height_to_rod)
bool PartPlateList::set_shapes(const Pointfs &shape,
const Pointfs &exclude_areas,
const Pointfs &wrapping_exclude_areas,
const std::vector<Pointfs> &extruder_areas,
const std::vector<double> &extruder_heights,
const std::string &texture_filename,
float height_to_lid,
float height_to_rod)
{
const std::lock_guard<std::mutex> local_lock(m_plates_mutex);
m_shape = shape;
m_exclude_areas = exclude_areas;
m_wrapping_exclude_areas = wrapping_exclude_areas;
m_extruder_areas = extruder_areas;
m_extruder_heights = extruder_heights;
m_height_to_lid = height_to_lid;
@@ -5642,7 +5680,7 @@ int PartPlateList::rebuild_plates_after_deserialize(std::vector<bool>& previous_
}
update_plate_cols();
update_all_plates_pos_and_size(false, false, false, false);
set_shapes(m_shape, m_exclude_areas, m_extruder_areas, m_extruder_heights, m_logo_texture_filename, m_height_to_lid, m_height_to_rod);
set_shapes(m_shape, m_exclude_areas, m_wrapping_exclude_areas, m_extruder_areas, m_extruder_heights, m_logo_texture_filename, m_height_to_lid, m_height_to_rod);
for (unsigned int i = 0; i < (unsigned int)m_plate_list.size(); ++i)
{
bool need_reset_print = false;