mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-27 12:52:07 +00:00
ENH: Use the real prime tower model after slicing.
1. set wipe tower real height 2. fix wipe tower small arc error 3. add rib_width constraint to ensure that the rib wall of the wipetower are attached to the infill. jira: STUDIO-10540 Change-Id: Idfdc809f0236121d98587ac2a09a2ebbf5caf945 (cherry picked from commit 3a7dcfd23249571224a4d538c55907a0a5c6154d)
This commit is contained in:
@@ -816,6 +816,49 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
||||
return int(volumes.size() - 1);
|
||||
}
|
||||
|
||||
int GLVolumeCollection::load_real_wipe_tower_preview(
|
||||
int obj_idx, float pos_x, float pos_y, const TriangleMesh& wt_mesh,const TriangleMesh &brim_mesh,bool render_brim, float rotation_angle, bool size_unknown, bool opengl_initialized)
|
||||
{
|
||||
int plate_idx = obj_idx - 1000;
|
||||
if (wt_mesh.its.vertices.empty()) return int(this->volumes.size() - 1);
|
||||
|
||||
std::vector<Slic3r::ColorRGBA> extruder_colors = GUI::wxGetApp().plater()->get_extruders_colors();
|
||||
std::vector<Slic3r::ColorRGBA> colors;
|
||||
GUI::PartPlateList &ppl = GUI::wxGetApp().plater()->get_partplate_list();
|
||||
std::vector<int> plate_extruders = ppl.get_plate(plate_idx)->get_extruders(true);
|
||||
|
||||
for (int extruder_id : plate_extruders) {
|
||||
if (extruder_id <= extruder_colors.size())
|
||||
colors.push_back(extruder_colors[extruder_id - 1]);
|
||||
else
|
||||
colors.push_back(extruder_colors[0]);
|
||||
}
|
||||
|
||||
volumes.emplace_back(new GLWipeTowerVolume(colors));
|
||||
GLWipeTowerVolume &v = *dynamic_cast<GLWipeTowerVolume *>(volumes.back());
|
||||
v.model_per_colors.resize(colors.size());
|
||||
auto mesh = wt_mesh;
|
||||
if (render_brim) {
|
||||
mesh.merge(brim_mesh);
|
||||
}
|
||||
if (!colors.empty()) {
|
||||
v.model_per_colors[0].init_from(mesh);
|
||||
}
|
||||
TriangleMesh wipe_tower_shell = mesh.convex_hull_3d();
|
||||
v.model.init_from(wipe_tower_shell);
|
||||
v.mesh_raycaster = std::make_unique<GUI::MeshRaycaster>(std::make_shared<const TriangleMesh>(wipe_tower_shell));
|
||||
v.set_convex_hull(wipe_tower_shell);
|
||||
v.set_volume_offset(Vec3d(pos_x, pos_y, 0.0));
|
||||
v.set_volume_rotation(Vec3d(0., 0., (M_PI / 180.) * rotation_angle));
|
||||
v.composite_id = GLVolume::CompositeID(obj_idx, 0, 0);
|
||||
v.geometry_id.first = 0;
|
||||
v.geometry_id.second = wipe_tower_instance_id().id + (obj_idx - 1000);
|
||||
v.is_wipe_tower = true;
|
||||
v.shader_outside_printer_detection_enabled = !size_unknown;
|
||||
return int(volumes.size() - 1);
|
||||
}
|
||||
|
||||
|
||||
GLVolume* GLVolumeCollection::new_toolpath_volume(const ColorRGBA& rgba)
|
||||
{
|
||||
GLVolume* out = new_nontoolpath_volume(rgba);
|
||||
|
||||
@@ -481,7 +481,8 @@ public:
|
||||
|
||||
int load_wipe_tower_preview(
|
||||
int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool size_unknown, float brim_width);
|
||||
|
||||
int load_real_wipe_tower_preview(
|
||||
int obj_idx, float pos_x, float pos_y,const TriangleMesh& wt_mesh,const TriangleMesh &brim_mesh,bool render_brim, float rotation_angle, bool size_unknown, bool opengl_initialized);
|
||||
GLVolume* new_toolpath_volume(const ColorRGBA& rgba);
|
||||
GLVolume* new_nontoolpath_volume(const ColorRGBA& rgba);
|
||||
|
||||
|
||||
@@ -2925,6 +2925,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
||||
Vec3d plate_origin = ppl.get_plate(plate_id)->get_origin();
|
||||
|
||||
const Print* print = m_process->fff_print();
|
||||
const Print* current_print = part_plate->fff_print();
|
||||
const auto& wipe_tower_data = print->wipe_tower_data(filaments_count);
|
||||
float brim_width = wipe_tower_data.brim_width;
|
||||
const DynamicPrintConfig &print_cfg = wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||
@@ -2932,55 +2933,81 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
||||
int nozzle_nums = wxGetApp().preset_bundle->get_printer_extruder_count();
|
||||
Vec3d wipe_tower_size = ppl.get_plate(plate_id)->estimate_wipe_tower_size(print_cfg, w, wipe_tower_data.depth, nozzle_nums);
|
||||
|
||||
{ // update for wipe tower position
|
||||
part_plate->get_extruder_areas();
|
||||
{
|
||||
const float margin = WIPE_TOWER_MARGIN + tower_brim_width;
|
||||
BoundingBoxf3 plate_bbox = part_plate->get_bounding_box();
|
||||
BoundingBoxf plate_bbox_2d(Vec2d(plate_bbox.min(0), plate_bbox.min(1)), Vec2d(plate_bbox.max(0), plate_bbox.max(1)));
|
||||
const std::vector<Pointfs>& extruder_areas = part_plate->get_extruder_areas();
|
||||
BoundingBoxf3 plate_bbox = part_plate->get_bounding_box();
|
||||
BoundingBoxf plate_bbox_2d(Vec2d(plate_bbox.min(0), plate_bbox.min(1)), Vec2d(plate_bbox.max(0), plate_bbox.max(1)));
|
||||
const std::vector<Pointfs> &extruder_areas = part_plate->get_extruder_areas();
|
||||
for (Pointfs points : extruder_areas) {
|
||||
BoundingBoxf bboxf(points);
|
||||
plate_bbox_2d.min = plate_bbox_2d.min(0) >= bboxf.min(0) ? plate_bbox_2d.min : bboxf.min;
|
||||
plate_bbox_2d.max = plate_bbox_2d.max(0) <= bboxf.max(0) ? plate_bbox_2d.max : bboxf.max;
|
||||
}
|
||||
|
||||
coordf_t plate_bbox_x_min_local_coord = plate_bbox_2d.min(0) - plate_origin(0);
|
||||
coordf_t plate_bbox_x_max_local_coord = plate_bbox_2d.max(0) - plate_origin(0);
|
||||
coordf_t plate_bbox_y_max_local_coord = plate_bbox_2d.max(1) - plate_origin(1);
|
||||
bool need_update = false;
|
||||
if (x + margin + wipe_tower_size(0) > plate_bbox_x_max_local_coord) {
|
||||
x = plate_bbox_x_max_local_coord - wipe_tower_size(0) - margin;
|
||||
need_update = true;
|
||||
} else if (x < margin + plate_bbox_x_min_local_coord) {
|
||||
x = margin + plate_bbox_x_min_local_coord;
|
||||
need_update = true;
|
||||
}
|
||||
if (need_update) {
|
||||
ConfigOptionFloat wt_x_opt(x);
|
||||
dynamic_cast<ConfigOptionFloats *>(proj_cfg.option("wipe_tower_x"))->set_at(&wt_x_opt, plate_id, 0);
|
||||
need_update = false;
|
||||
}
|
||||
coordf_t plate_bbox_x_min_local_coord = plate_bbox_2d.min(0) - plate_origin(0);
|
||||
coordf_t plate_bbox_x_max_local_coord = plate_bbox_2d.max(0) - plate_origin(0);
|
||||
coordf_t plate_bbox_y_max_local_coord = plate_bbox_2d.max(1) - plate_origin(1);
|
||||
|
||||
if (y + margin + wipe_tower_size(1) > plate_bbox_y_max_local_coord) {
|
||||
y = plate_bbox_y_max_local_coord - wipe_tower_size(1) - margin;
|
||||
need_update = true;
|
||||
} else if (y < margin) {
|
||||
y = margin;
|
||||
need_update = true;
|
||||
}
|
||||
if (need_update) {
|
||||
ConfigOptionFloat wt_y_opt(y);
|
||||
dynamic_cast<ConfigOptionFloats *>(proj_cfg.option("wipe_tower_y"))->set_at(&wt_y_opt, plate_id, 0);
|
||||
if (!current_print->is_step_done(psWipeTower)) {
|
||||
// update for wipe tower position
|
||||
{
|
||||
bool need_update = false;
|
||||
if (x + margin + wipe_tower_size(0) > plate_bbox_x_max_local_coord) {
|
||||
x = plate_bbox_x_max_local_coord - wipe_tower_size(0) - margin;
|
||||
need_update = true;
|
||||
} else if (x < margin + plate_bbox_x_min_local_coord) {
|
||||
x = margin + plate_bbox_x_min_local_coord;
|
||||
need_update = true;
|
||||
}
|
||||
if (need_update) {
|
||||
ConfigOptionFloat wt_x_opt(x);
|
||||
dynamic_cast<ConfigOptionFloats *>(proj_cfg.option("wipe_tower_x"))->set_at(&wt_x_opt, plate_id, 0);
|
||||
need_update = false;
|
||||
}
|
||||
|
||||
if (y + margin + wipe_tower_size(1) > plate_bbox_y_max_local_coord) {
|
||||
y = plate_bbox_y_max_local_coord - wipe_tower_size(1) - margin;
|
||||
need_update = true;
|
||||
} else if (y < margin) {
|
||||
y = margin;
|
||||
need_update = true;
|
||||
}
|
||||
if (need_update) {
|
||||
ConfigOptionFloat wt_y_opt(y);
|
||||
dynamic_cast<ConfigOptionFloats *>(proj_cfg.option("wipe_tower_y"))->set_at(&wt_y_opt, plate_id, 0);
|
||||
}
|
||||
int volume_idx_wipe_tower_new = m_volumes.load_wipe_tower_preview(1000 + plate_id, x + plate_origin(0), y + plate_origin(1),
|
||||
(float) wipe_tower_size(0), (float) wipe_tower_size(1), (float) wipe_tower_size(2),
|
||||
a,
|
||||
/*!print->is_step_done(psWipeTower)*/ true, brim_width);
|
||||
int volume_idx_wipe_tower_old = volume_idxs_wipe_tower_old[plate_id];
|
||||
if (volume_idx_wipe_tower_old != -1) map_glvolume_old_to_new[volume_idx_wipe_tower_old] = volume_idx_wipe_tower_new;
|
||||
}
|
||||
} else {
|
||||
const float margin = 2.f;
|
||||
auto tower_bottom = current_print->wipe_tower_data().wipe_tower_mesh_data->bottom;
|
||||
tower_bottom.translate(scaled(Vec2d{x, y}));
|
||||
tower_bottom.translate(scaled(Vec2d{plate_origin[0], plate_origin[1]}));
|
||||
auto tower_bottom_bbox = get_extents(tower_bottom);
|
||||
BoundingBoxf3 plate_bbox = wxGetApp().plater()->get_partplate_list().get_plate(plate_id)->get_build_volume(true);
|
||||
BoundingBox plate_bbox2d = BoundingBox(scaled(Vec2f(plate_bbox.min[0], plate_bbox.min[1])), scaled(Vec2f(plate_bbox.max[0], plate_bbox.max[1])));
|
||||
Vec2f offset = WipeTower::move_box_inside_box(tower_bottom_bbox, plate_bbox2d, scaled(margin));
|
||||
if (!is_approx(offset[0], 0.f)) {
|
||||
ConfigOptionFloat wt_x_opt(x + offset[0]);
|
||||
dynamic_cast<ConfigOptionFloats *>(proj_cfg.option("wipe_tower_x"))->set_at(&wt_x_opt, plate_id, 0);
|
||||
}
|
||||
if (!is_approx(offset[1], 0.f)) {
|
||||
ConfigOptionFloat wt_y_opt(y + offset[1]);
|
||||
dynamic_cast<ConfigOptionFloats *>(proj_cfg.option("wipe_tower_y"))->set_at(&wt_y_opt, plate_id, 0);
|
||||
}
|
||||
int volume_idx_wipe_tower_new = m_volumes.load_real_wipe_tower_preview(1000 + plate_id, x + plate_origin(0) + offset[0], y + plate_origin(1) + offset[1],
|
||||
current_print->wipe_tower_data().wipe_tower_mesh_data->real_wipe_tower_mesh,
|
||||
current_print->wipe_tower_data().wipe_tower_mesh_data->real_brim_mesh,
|
||||
true,a,/*!print->is_step_done(psWipeTower)*/ true, m_initialized);
|
||||
int volume_idx_wipe_tower_old = volume_idxs_wipe_tower_old[plate_id];
|
||||
if (volume_idx_wipe_tower_old != -1) map_glvolume_old_to_new[volume_idx_wipe_tower_old] = volume_idx_wipe_tower_new;
|
||||
}
|
||||
}
|
||||
|
||||
int volume_idx_wipe_tower_new = m_volumes.load_wipe_tower_preview(
|
||||
1000 + plate_id, x + plate_origin(0), y + plate_origin(1),
|
||||
(float)wipe_tower_size(0), (float)wipe_tower_size(1), (float)wipe_tower_size(2), a,
|
||||
/*!print->is_step_done(psWipeTower)*/ true, brim_width);
|
||||
int volume_idx_wipe_tower_old = volume_idxs_wipe_tower_old[plate_id];
|
||||
if (volume_idx_wipe_tower_old != -1)
|
||||
map_glvolume_old_to_new[volume_idx_wipe_tower_old] = volume_idx_wipe_tower_new;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1190,28 +1190,32 @@ void Selection::translate(const Vec3d &displacement, TransformationType transfor
|
||||
if (v.is_wipe_tower) {//in world cs
|
||||
int plate_idx = v.object_idx() - 1000;
|
||||
BoundingBoxf3 plate_bbox = wxGetApp().plater()->get_partplate_list().get_plate(plate_idx)->get_build_volume(true);
|
||||
|
||||
BoundingBox plate_bbox2d = BoundingBox(scaled(Vec2f(plate_bbox.min[0], plate_bbox.min[1])), scaled(Vec2f(plate_bbox.max[0], plate_bbox.max[1])));
|
||||
Vec3d tower_size = v.bounding_box().size();
|
||||
Vec3d tower_origin = m_cache.volumes_data[i].get_volume_position();
|
||||
Vec3d actual_displacement = displacement;
|
||||
const double margin = WIPE_TOWER_MARGIN;
|
||||
const double margin = wxGetApp().plater()->get_partplate_list().get_plate(plate_idx)->fff_print()->is_step_done(psWipeTower)?2.:WIPE_TOWER_MARGIN;
|
||||
|
||||
actual_displacement = (m_cache.volumes_data[i].get_instance_rotation_matrix() * m_cache.volumes_data[i].get_instance_scale_matrix() *
|
||||
m_cache.volumes_data[i].get_instance_mirror_matrix())
|
||||
.inverse() *
|
||||
displacement;
|
||||
if (tower_origin(0) + actual_displacement(0) - margin < plate_bbox.min(0)) {
|
||||
actual_displacement(0) = plate_bbox.min(0) - tower_origin(0) + margin;
|
||||
} else if (tower_origin(0) + actual_displacement(0) + tower_size(0) + margin > plate_bbox.max(0)) {
|
||||
actual_displacement(0) = plate_bbox.max(0) - tower_origin(0) - tower_size(0) - margin;
|
||||
}
|
||||
|
||||
if (tower_origin(1) + actual_displacement(1) - margin < plate_bbox.min(1)) {
|
||||
actual_displacement(1) = plate_bbox.min(1) - tower_origin(1) + margin;
|
||||
} else if (tower_origin(1) + actual_displacement(1) + tower_size(1) + margin > plate_bbox.max(1)) {
|
||||
actual_displacement(1) = plate_bbox.max(1) - tower_origin(1) - tower_size(1) - margin;
|
||||
}
|
||||
BoundingBoxf3 tower_bbox = v.bounding_box();
|
||||
tower_bbox.translate(actual_displacement + tower_origin);
|
||||
BoundingBox tower_bbox2d = BoundingBox(scaled(Vec2f(tower_bbox.min[0], tower_bbox.min[1])), scaled(Vec2f(tower_bbox.max[0], tower_bbox.max[1])));
|
||||
Vec2f offset = WipeTower::move_box_inside_box(tower_bbox2d, plate_bbox2d,scaled(margin));
|
||||
//if (tower_origin(0) + actual_displacement(0) - margin < plate_bbox.min(0)) {
|
||||
// actual_displacement(0) = plate_bbox.min(0) - tower_origin(0) + margin;
|
||||
//} else if (tower_origin(0) + actual_displacement(0) + tower_size(0) + margin > plate_bbox.max(0)) {
|
||||
// actual_displacement(0) = plate_bbox.max(0) - tower_origin(0) - tower_size(0) - margin;
|
||||
//}
|
||||
|
||||
//if (tower_origin(1) + actual_displacement(1) - margin < plate_bbox.min(1)) {
|
||||
// actual_displacement(1) = plate_bbox.min(1) - tower_origin(1) + margin;
|
||||
//} else if (tower_origin(1) + actual_displacement(1) + tower_size(1) + margin > plate_bbox.max(1)) {
|
||||
// actual_displacement(1) = plate_bbox.max(1) - tower_origin(1) - tower_size(1) - margin;
|
||||
//}
|
||||
actual_displacement += Vec3d(offset[0], offset[1],0);
|
||||
v.set_volume_offset(m_cache.volumes_data[i].get_volume_position() + actual_displacement);
|
||||
}
|
||||
else if (transformation_type.local() && transformation_type.absolute()) {
|
||||
|
||||
Reference in New Issue
Block a user