From b5ac8f4d53cb13c0ee941c17ee796df86b39ba06 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Mon, 9 Oct 2023 09:55:06 +0200 Subject: [PATCH 1/8] Upload PUT read file in binary mode --- src/slic3r/Utils/Http.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/Utils/Http.cpp b/src/slic3r/Utils/Http.cpp index d41419ebf0..797207552c 100644 --- a/src/slic3r/Utils/Http.cpp +++ b/src/slic3r/Utils/Http.cpp @@ -314,7 +314,7 @@ void Http::priv::set_put_body(const fs::path &path) boost::system::error_code ec; boost::uintmax_t filesize = file_size(path, ec); if (!ec) { - putFile = std::make_unique(path); + putFile = std::make_unique(path, std::ios::binary); ::curl_easy_setopt(curl, CURLOPT_READDATA, (void *) (putFile.get())); ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, filesize); } From 56a24af0a5c113ee40456a9d085cde54fa8a0b2a Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Mon, 9 Oct 2023 08:24:55 +0200 Subject: [PATCH 2/8] SPE-1948: Fixed missing update of raycaster when mirroring objects --- src/slic3r/GUI/GLCanvas3D.cpp | 3 ++- src/slic3r/GUI/GLCanvas3D.hpp | 1 + src/slic3r/GUI/Plater.cpp | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 4e90b94572..62f09016ae 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1029,6 +1029,7 @@ wxDEFINE_EVENT(EVT_GLCANVAS_INSTANCE_MOVED, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_INSTANCE_ROTATED, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_RESET_SKEW, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_INSTANCE_SCALED, SimpleEvent); +wxDEFINE_EVENT(EVT_GLCANVAS_INSTANCE_MIRRORED, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_FORCE_UPDATE, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_WIPETOWER_MOVED, Vec3dEvent); wxDEFINE_EVENT(EVT_GLCANVAS_WIPETOWER_ROTATED, Vec3dEvent); @@ -4319,7 +4320,7 @@ void GLCanvas3D::do_mirror(const std::string& snapshot_type) for (int id : obj_idx_for_update_info_items) wxGetApp().obj_list()->update_info_items(static_cast(id)); - post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS)); + post_event(SimpleEvent(EVT_GLCANVAS_INSTANCE_MIRRORED)); m_dirty = true; } diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 1425b314bc..99935fa166 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -167,6 +167,7 @@ wxDECLARE_EVENT(EVT_GLCANVAS_WIPETOWER_MOVED, Vec3dEvent); wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_ROTATED, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_RESET_SKEW, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_SCALED, SimpleEvent); +wxDECLARE_EVENT(EVT_GLCANVAS_INSTANCE_MIRRORED, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_WIPETOWER_ROTATED, Vec3dEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, Event); wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index dacbc22df4..16334b2c87 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2133,6 +2133,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) view3D_canvas->Bind(EVT_GLCANVAS_INSTANCE_ROTATED, [this](SimpleEvent&) { update(); }); view3D_canvas->Bind(EVT_GLCANVAS_RESET_SKEW, [this](SimpleEvent&) { update(); }); view3D_canvas->Bind(EVT_GLCANVAS_INSTANCE_SCALED, [this](SimpleEvent&) { update(); }); + view3D_canvas->Bind(EVT_GLCANVAS_INSTANCE_MIRRORED, [this](SimpleEvent&) { update(); }); view3D_canvas->Bind(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, [this](Event& evt) { this->sidebar->enable_buttons(evt.data); }); view3D_canvas->Bind(EVT_GLCANVAS_UPDATE_GEOMETRY, &priv::on_update_geometry, this); view3D_canvas->Bind(EVT_GLCANVAS_MOUSE_DRAGGING_STARTED, &priv::on_3dcanvas_mouse_dragging_started, this); From cfcb4f7925a04932e1a673969ed7d753438992e3 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Wed, 11 Oct 2023 08:36:32 +0200 Subject: [PATCH 3/8] SPE-1960: Associate .bgcode files to GCodeViewer on Windows --- src/libslic3r/AppConfig.cpp | 2 ++ src/slic3r/GUI/GUI_App.cpp | 9 +++++++++ src/slic3r/GUI/GUI_App.hpp | 1 + src/slic3r/GUI/Preferences.cpp | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index f79f48c279..426cc53309 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -175,6 +175,8 @@ void AppConfig::set_defaults() #ifdef _WIN32 if (get("associate_gcode").empty()) set("associate_gcode", "0"); + if (get("associate_bgcode").empty()) + set("associate_bgcode", "0"); #endif // _WIN32 } diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 1728bc3c6b..d69f5b33de 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1290,6 +1290,8 @@ bool GUI_App::on_init_inner() #ifdef __WXMSW__ if (app_config->get_bool("associate_gcode")) associate_gcode_files(); + if (app_config->get_bool("associate_bgcode")) + associate_bgcode_files(); #endif // __WXMSW__ } @@ -2583,6 +2585,8 @@ void GUI_App::open_preferences(const std::string& highlight_option /*= std::stri else { if (app_config->get_bool("associate_gcode")) associate_gcode_files(); + if (app_config->get_bool("associate_bgcode")) + associate_bgcode_files(); } #endif // _WIN32 @@ -3370,6 +3374,11 @@ void GUI_App::associate_gcode_files() { associate_file_type(L".gcode", L"PrusaSlicer.GCodeViewer.1", L"PrusaSlicerGCodeViewer", true); } + +void GUI_App::associate_bgcode_files() +{ + associate_file_type(L".bgcode", L"PrusaSlicer.GCodeViewer.1", L"PrusaSlicerGCodeViewer", true); +} #endif // __WXMSW__ void GUI_App::on_version_read(wxCommandEvent& evt) diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 467c2aaeb6..6951f654b6 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -368,6 +368,7 @@ public: void associate_3mf_files(); void associate_stl_files(); void associate_gcode_files(); + void associate_bgcode_files(); #endif // __WXMSW__ diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index ecb1d152eb..6fb2f23258 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -367,6 +367,10 @@ void PreferencesDialog::build() L("Associate .gcode files to PrusaSlicer G-code Viewer"), L("If enabled, sets PrusaSlicer G-code Viewer as default application to open .gcode files."), app_config->get_bool("associate_gcode")); + append_bool_option(m_optgroup_general, "associate_bgcode", + L("Associate .bgcode files to PrusaSlicer G-code Viewer"), + L("If enabled, sets PrusaSlicer G-code Viewer as default application to open .bgcode files."), + app_config->get_bool("associate_bgcode")); } #endif // _WIN32 From 319454c2593271b003d2e8abcff515a4f2f9780e Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 6 Oct 2023 14:27:40 +0200 Subject: [PATCH 4/8] SPE-1937: Fixed rendering of sequential clearance contours when dragging an object while the collision detection is running --- src/slic3r/GUI/GLCanvas3D.cpp | 4 +++- src/slic3r/GUI/GLCanvas3D.hpp | 20 ++++++++++++++++++-- src/slic3r/GUI/Plater.cpp | 4 ---- src/slic3r/GUI/Selection.cpp | 5 +---- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 62f09016ae..f29424b4cd 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -981,7 +981,7 @@ void GLCanvas3D::SequentialPrintClearance::render() glsafe(::glEnable(GL_BLEND)); glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); - if (!m_evaluating) + if (!m_evaluating && !m_dragging) m_fill.render(); #if ENABLE_GL_CORE_PROFILE @@ -3733,6 +3733,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) if (!evt.CmdDown()) m_mouse.drag.start_position_3D = m_mouse.scene_position; m_sequential_print_clearance_first_displacement = true; + m_sequential_print_clearance.start_dragging(); } } } @@ -3857,6 +3858,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) else if (m_mouse.drag.move_volume_idx != -1 && m_mouse.dragging) { do_move(L("Move Object")); wxGetApp().obj_manipul()->set_dirty(); + m_sequential_print_clearance.stop_dragging(); // Let the plater know that the dragging finished, so a delayed refresh // of the scene with the background processing data should be performed. post_event(SimpleEvent(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED)); diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 99935fa166..6c1b74f815 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -619,6 +619,7 @@ private: // list of transforms used to render the contours std::vector> m_instances; bool m_evaluating{ false }; + bool m_dragging{ false }; std::vector> m_hulls_2d_cache; @@ -628,6 +629,10 @@ private: void render(); bool empty() const { return m_contours.empty(); } + void start_dragging() { m_dragging = true; } + bool is_dragging() const { return m_dragging; } + void stop_dragging() { m_dragging = false; } + friend class GLCanvas3D; }; @@ -966,11 +971,18 @@ public: void reset_sequential_print_clearance() { m_sequential_print_clearance.m_evaluating = false; - m_sequential_print_clearance.set_contours(ContoursList(), false); + if (m_sequential_print_clearance.is_dragging()) + m_sequential_print_clearance_first_displacement = true; + else + m_sequential_print_clearance.set_contours(ContoursList(), false); + set_as_dirty(); + request_extra_frame(); } void set_sequential_print_clearance_contours(const ContoursList& contours, bool generate_fill) { m_sequential_print_clearance.set_contours(contours, generate_fill); + set_as_dirty(); + request_extra_frame(); } bool is_sequential_print_clearance_empty() const { @@ -982,7 +994,11 @@ public: } void update_sequential_clearance(bool force_contours_generation); - void set_sequential_clearance_as_evaluating() { m_sequential_print_clearance.m_evaluating = true; } + void set_sequential_clearance_as_evaluating() { + m_sequential_print_clearance.m_evaluating = true; + set_as_dirty(); + request_extra_frame(); + } const Print* fff_print() const; const SLAPrint* sla_print() const; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 16334b2c87..65933ee4f7 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3349,8 +3349,6 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool GLCanvas3D::ContoursList contours; contours.contours = background_process.fff_print()->get_sequential_print_clearance_contours(); canvas->set_sequential_print_clearance_contours(contours, true); - canvas->set_as_dirty(); - canvas->request_extra_frame(); } } } @@ -3365,8 +3363,6 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool GLCanvas3D::ContoursList contours; contours.contours = background_process.fff_print()->get_sequential_print_clearance_contours(); canvas->set_sequential_print_clearance_contours(contours, true); - canvas->set_as_dirty(); - canvas->request_extra_frame(); } } std::vector warnings; diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index aa006281d9..b6847859eb 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -1550,10 +1550,7 @@ void Selection::erase() ensure_not_below_bed(); } - GLCanvas3D* canvas = wxGetApp().plater()->canvas3D(); - canvas->set_sequential_clearance_as_evaluating(); - canvas->set_as_dirty(); - canvas->request_extra_frame(); + wxGetApp().plater()->canvas3D()->set_sequential_clearance_as_evaluating(); } void Selection::render(float scale_factor) From c12eeee12f9e2c91a9dfe7905f1370143805f038 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Mon, 2 Oct 2023 14:26:36 +0200 Subject: [PATCH 5/8] SPE-1926: Tech ENABLE_CGAL_BOUNDING_SPHERE - Use selection's bounding sphere center as pivot for rotations --- src/libslic3r/Technologies.hpp | 3 ++ src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp | 10 ++++ src/slic3r/GUI/Selection.cpp | 61 +++++++++++++++++++++++++ src/slic3r/GUI/Selection.hpp | 15 ++++++ 4 files changed, 89 insertions(+) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 6c295279ad..c46570c839 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -61,4 +61,7 @@ // Enable imgui dialog which allows to set the parameters used to export binarized gcode #define ENABLE_BINARIZED_GCODE_DEBUG_WINDOW 0 +// Enable use selection's bounding sphere center as pivot for rotations +#define ENABLE_CGAL_BOUNDING_SPHERE 1 + #endif // _prusaslicer_technologies_h_ diff --git a/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp b/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp index 053f24418c..686f1f0c1e 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp @@ -204,10 +204,20 @@ void GLGizmoRotate::init_data_from_selection(const Selection& selection) const auto [box, box_trafo] = m_force_local_coordinate ? selection.get_bounding_box_in_reference_system(ECoordinatesType::Local) : selection.get_bounding_box_in_current_reference_system(); m_bounding_box = box; +#if ENABLE_CGAL_BOUNDING_SPHERE + const std::pair sphere = selection.get_bounding_sphere(); + m_center = sphere.first; + m_radius = Offset + sphere.second; +#else m_center = box_trafo.translation(); +#endif // ENABLE_CGAL_BOUNDING_SPHERE m_orient_matrix = box_trafo; +#if ENABLE_CGAL_BOUNDING_SPHERE + m_orient_matrix.translation() = m_center; +#else m_radius = Offset + m_bounding_box.radius(); +#endif // ENABLE_CGAL_BOUNDING_SPHERE m_snap_coarse_in_radius = m_radius / 3.0f; m_snap_coarse_out_radius = 2.0f * m_snap_coarse_in_radius; m_snap_fine_in_radius = m_radius; diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index b6847859eb..d659f5cd29 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -29,6 +29,12 @@ #include #include +#if ENABLE_CGAL_BOUNDING_SPHERE +#include +#include +#include +#endif // ENABLE_CGAL_BOUNDING_SPHERE + static const Slic3r::ColorRGBA UNIFORM_SCALE_COLOR = Slic3r::ColorRGBA::ORANGE(); static const Slic3r::ColorRGBA SOLID_PLANE_COLOR = Slic3r::ColorRGBA::ORANGE(); static const Slic3r::ColorRGBA TRANSPARENT_PLANE_COLOR = { 0.8f, 0.8f, 0.8f, 0.5f }; @@ -906,6 +912,41 @@ BoundingBoxf Selection::get_screen_space_bounding_box() return ss_box; } +#if ENABLE_CGAL_BOUNDING_SPHERE +const std::pair Selection::get_bounding_sphere() const +{ + if (!m_bounding_sphere.has_value()) { + std::optional>* sphere = const_cast>*>(&m_bounding_sphere); + *sphere = { Vec3d::Zero(), 0.0 }; + + using K = CGAL::Simple_cartesian; + using Traits = CGAL::Min_sphere_of_points_d_traits_3; + using Min_sphere = CGAL::Min_sphere_of_spheres_d; + using Point = K::Point_3; + using Sphere = Traits::Sphere; + + std::vector points; + if (m_valid) { + for (unsigned int i : m_list) { + const TriangleMesh* hull = (*m_volumes)[i]->convex_hull(); + const Transform3d& matrix = (*m_volumes)[i]->world_matrix(); + for (const Vec3f& v : hull->its.vertices) { + const Vec3d vv = matrix * v.cast(); + points.push_back(Point(vv.x(), vv.y(), vv.z())); + } + } + + Min_sphere ms(points.begin(), points.end()); + const float* center_x = ms.center_cartesian_begin(); + (*sphere)->first = { *center_x, *(center_x + 1), *(center_x + 2) }; + (*sphere)->second = ms.radius(); + } + } + + return *m_bounding_sphere; +} +#endif // ENABLE_CGAL_BOUNDING_SPHERE + void Selection::setup_cache() { if (!m_valid) @@ -993,15 +1034,27 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_ rotation_matrix = inst_matrix_no_offset.inverse() * inst_rotation_matrix * rotation_matrix * inst_rotation_matrix.inverse() * inst_matrix_no_offset; // rotate around selection center +#if ENABLE_CGAL_BOUNDING_SPHERE + const Vec3d inst_pivot = inst_trafo.get_matrix_no_offset().inverse() * (m_cache.rotation_pivot - inst_trafo.get_offset()); +#else const Vec3d inst_pivot = inst_trafo.get_matrix_no_offset().inverse() * (m_cache.dragging_center - inst_trafo.get_offset()); +#endif // ENABLE_CGAL_BOUNDING_SPHERE rotation_matrix = Geometry::translation_transform(inst_pivot) * rotation_matrix * Geometry::translation_transform(-inst_pivot); } +#if ENABLE_CGAL_BOUNDING_SPHERE + transform_instance_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.rotation_pivot); +#else transform_instance_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center); +#endif // ENABLE_CGAL_BOUNDING_SPHERE } else { if (!is_single_volume_or_modifier()) { assert(transformation_type.world()); +#if ENABLE_CGAL_BOUNDING_SPHERE + transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.rotation_pivot); +#else transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center); +#endif // ENABLE_CGAL_BOUNDING_SPHERE } else { if (transformation_type.instance()) { @@ -1027,7 +1080,11 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_ vol_rotation_matrix.inverse() * inst_scale_matrix * vol_matrix_no_offset; } } +#if ENABLE_CGAL_BOUNDING_SPHERE + transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.rotation_pivot); +#else transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center); +#endif // ENABLE_CGAL_BOUNDING_SPHERE } } } @@ -2036,6 +2093,10 @@ void Selection::set_caches() m_cache.sinking_volumes.push_back(i); } m_cache.dragging_center = get_bounding_box().center(); +#if ENABLE_CGAL_BOUNDING_SPHERE + m_cache.rotation_pivot = get_bounding_sphere().first; +// m_cache.dragging_center = m_cache.rotation_pivot; +#endif // ENABLE_CGAL_BOUNDING_SPHERE } void Selection::do_add_volume(unsigned int volume_idx) diff --git a/src/slic3r/GUI/Selection.hpp b/src/slic3r/GUI/Selection.hpp index d4b7326afd..1a2c67ecf6 100644 --- a/src/slic3r/GUI/Selection.hpp +++ b/src/slic3r/GUI/Selection.hpp @@ -114,6 +114,9 @@ private: ObjectIdxsToInstanceIdxsMap content; // List of ids of the volumes which are sinking when starting dragging std::vector sinking_volumes; +#if ENABLE_CGAL_BOUNDING_SPHERE + Vec3d rotation_pivot; +#endif // ENABLE_CGAL_BOUNDING_SPHERE }; // Volumes owned by GLCanvas3D. @@ -150,6 +153,10 @@ private: // and transform to place and orient it in world coordinates std::optional> m_bounding_box_in_current_reference_system; +#if ENABLE_CGAL_BOUNDING_SPHERE + std::optional> m_bounding_sphere; +#endif // ENABLE_CGAL_BOUNDING_SPHERE + #if ENABLE_RENDER_SELECTION_CENTER GLModel m_vbo_sphere; #endif // ENABLE_RENDER_SELECTION_CENTER @@ -295,6 +302,11 @@ public: // Returns the screen space bounding box BoundingBoxf get_screen_space_bounding_box(); +#if ENABLE_CGAL_BOUNDING_SPHERE + // Returns the bounding sphere + const std::pair get_bounding_sphere() const; +#endif // ENABLE_CGAL_BOUNDING_SPHERE + void setup_cache(); void translate(const Vec3d& displacement, TransformationType transformation_type); @@ -360,6 +372,9 @@ private: m_full_unscaled_instance_bounding_box.reset(); m_full_scaled_instance_bounding_box.reset(); m_full_unscaled_instance_local_bounding_box.reset(); m_bounding_box_in_current_reference_system.reset(); +#if ENABLE_CGAL_BOUNDING_SPHERE + m_bounding_sphere.reset(); +#endif // ENABLE_CGAL_BOUNDING_SPHERE } void render_synchronized_volumes(); void render_bounding_box(const BoundingBoxf3& box, const Transform3d& trafo, const ColorRGB& color); From c31906b0d15c010cbfdce660c814bdb36d05e7e1 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Thu, 12 Oct 2023 13:30:58 +0200 Subject: [PATCH 6/8] SPE-1926: Fixed crash introduced with 85e567788badabf7f9e89103a2333624814a5dd5 --- src/slic3r/GUI/Selection.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index d659f5cd29..29102d64d3 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -928,9 +928,12 @@ const std::pair Selection::get_bounding_sphere() const std::vector points; if (m_valid) { for (unsigned int i : m_list) { - const TriangleMesh* hull = (*m_volumes)[i]->convex_hull(); - const Transform3d& matrix = (*m_volumes)[i]->world_matrix(); - for (const Vec3f& v : hull->its.vertices) { + const GLVolume& volume = *(*m_volumes)[i]; + const TriangleMesh* hull = volume.convex_hull(); + const indexed_triangle_set& its = (hull != nullptr) ? + hull->its : m_model->objects[volume.object_idx()]->volumes[volume.volume_idx()]->mesh().its; + const Transform3d& matrix = volume.world_matrix(); + for (const Vec3f& v : its.vertices) { const Vec3d vv = matrix * v.cast(); points.push_back(Point(vv.x(), vv.y(), vv.z())); } From 6a9deeb080cf35b424e556f75475765ef1d5d323 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Thu, 12 Oct 2023 13:56:47 +0200 Subject: [PATCH 7/8] Fixed warning --- src/slic3r/GUI/Selection.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index 29102d64d3..8ff3ab4b18 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -923,7 +923,6 @@ const std::pair Selection::get_bounding_sphere() const using Traits = CGAL::Min_sphere_of_points_d_traits_3; using Min_sphere = CGAL::Min_sphere_of_spheres_d; using Point = K::Point_3; - using Sphere = Traits::Sphere; std::vector points; if (m_valid) { From 39a9b47b0713fe783d7eb5ad530a436f670a98c8 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Mon, 16 Oct 2023 11:27:55 +0200 Subject: [PATCH 8/8] Tech ENABLE_CGAL_BOUNDING_SPHERE set as default --- src/libslic3r/Technologies.hpp | 2 -- src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp | 9 --------- src/slic3r/GUI/Selection.cpp | 23 ----------------------- src/slic3r/GUI/Selection.hpp | 10 +--------- 4 files changed, 1 insertion(+), 43 deletions(-) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index c46570c839..3989eab3d2 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -61,7 +61,5 @@ // Enable imgui dialog which allows to set the parameters used to export binarized gcode #define ENABLE_BINARIZED_GCODE_DEBUG_WINDOW 0 -// Enable use selection's bounding sphere center as pivot for rotations -#define ENABLE_CGAL_BOUNDING_SPHERE 1 #endif // _prusaslicer_technologies_h_ diff --git a/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp b/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp index 686f1f0c1e..72ca3e3cf9 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp @@ -204,20 +204,11 @@ void GLGizmoRotate::init_data_from_selection(const Selection& selection) const auto [box, box_trafo] = m_force_local_coordinate ? selection.get_bounding_box_in_reference_system(ECoordinatesType::Local) : selection.get_bounding_box_in_current_reference_system(); m_bounding_box = box; -#if ENABLE_CGAL_BOUNDING_SPHERE const std::pair sphere = selection.get_bounding_sphere(); m_center = sphere.first; m_radius = Offset + sphere.second; -#else - m_center = box_trafo.translation(); -#endif // ENABLE_CGAL_BOUNDING_SPHERE m_orient_matrix = box_trafo; - -#if ENABLE_CGAL_BOUNDING_SPHERE m_orient_matrix.translation() = m_center; -#else - m_radius = Offset + m_bounding_box.radius(); -#endif // ENABLE_CGAL_BOUNDING_SPHERE m_snap_coarse_in_radius = m_radius / 3.0f; m_snap_coarse_out_radius = 2.0f * m_snap_coarse_in_radius; m_snap_fine_in_radius = m_radius; diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index 8ff3ab4b18..087ce33cc5 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -29,11 +29,9 @@ #include #include -#if ENABLE_CGAL_BOUNDING_SPHERE #include #include #include -#endif // ENABLE_CGAL_BOUNDING_SPHERE static const Slic3r::ColorRGBA UNIFORM_SCALE_COLOR = Slic3r::ColorRGBA::ORANGE(); static const Slic3r::ColorRGBA SOLID_PLANE_COLOR = Slic3r::ColorRGBA::ORANGE(); @@ -912,7 +910,6 @@ BoundingBoxf Selection::get_screen_space_bounding_box() return ss_box; } -#if ENABLE_CGAL_BOUNDING_SPHERE const std::pair Selection::get_bounding_sphere() const { if (!m_bounding_sphere.has_value()) { @@ -947,7 +944,6 @@ const std::pair Selection::get_bounding_sphere() const return *m_bounding_sphere; } -#endif // ENABLE_CGAL_BOUNDING_SPHERE void Selection::setup_cache() { @@ -1036,27 +1032,15 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_ rotation_matrix = inst_matrix_no_offset.inverse() * inst_rotation_matrix * rotation_matrix * inst_rotation_matrix.inverse() * inst_matrix_no_offset; // rotate around selection center -#if ENABLE_CGAL_BOUNDING_SPHERE const Vec3d inst_pivot = inst_trafo.get_matrix_no_offset().inverse() * (m_cache.rotation_pivot - inst_trafo.get_offset()); -#else - const Vec3d inst_pivot = inst_trafo.get_matrix_no_offset().inverse() * (m_cache.dragging_center - inst_trafo.get_offset()); -#endif // ENABLE_CGAL_BOUNDING_SPHERE rotation_matrix = Geometry::translation_transform(inst_pivot) * rotation_matrix * Geometry::translation_transform(-inst_pivot); } -#if ENABLE_CGAL_BOUNDING_SPHERE transform_instance_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.rotation_pivot); -#else - transform_instance_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center); -#endif // ENABLE_CGAL_BOUNDING_SPHERE } else { if (!is_single_volume_or_modifier()) { assert(transformation_type.world()); -#if ENABLE_CGAL_BOUNDING_SPHERE transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.rotation_pivot); -#else - transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center); -#endif // ENABLE_CGAL_BOUNDING_SPHERE } else { if (transformation_type.instance()) { @@ -1082,11 +1066,7 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_ vol_rotation_matrix.inverse() * inst_scale_matrix * vol_matrix_no_offset; } } -#if ENABLE_CGAL_BOUNDING_SPHERE transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.rotation_pivot); -#else - transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center); -#endif // ENABLE_CGAL_BOUNDING_SPHERE } } } @@ -2095,10 +2075,7 @@ void Selection::set_caches() m_cache.sinking_volumes.push_back(i); } m_cache.dragging_center = get_bounding_box().center(); -#if ENABLE_CGAL_BOUNDING_SPHERE m_cache.rotation_pivot = get_bounding_sphere().first; -// m_cache.dragging_center = m_cache.rotation_pivot; -#endif // ENABLE_CGAL_BOUNDING_SPHERE } void Selection::do_add_volume(unsigned int volume_idx) diff --git a/src/slic3r/GUI/Selection.hpp b/src/slic3r/GUI/Selection.hpp index 1a2c67ecf6..c9fe54ea94 100644 --- a/src/slic3r/GUI/Selection.hpp +++ b/src/slic3r/GUI/Selection.hpp @@ -114,9 +114,7 @@ private: ObjectIdxsToInstanceIdxsMap content; // List of ids of the volumes which are sinking when starting dragging std::vector sinking_volumes; -#if ENABLE_CGAL_BOUNDING_SPHERE Vec3d rotation_pivot; -#endif // ENABLE_CGAL_BOUNDING_SPHERE }; // Volumes owned by GLCanvas3D. @@ -153,9 +151,7 @@ private: // and transform to place and orient it in world coordinates std::optional> m_bounding_box_in_current_reference_system; -#if ENABLE_CGAL_BOUNDING_SPHERE std::optional> m_bounding_sphere; -#endif // ENABLE_CGAL_BOUNDING_SPHERE #if ENABLE_RENDER_SELECTION_CENTER GLModel m_vbo_sphere; @@ -302,10 +298,8 @@ public: // Returns the screen space bounding box BoundingBoxf get_screen_space_bounding_box(); -#if ENABLE_CGAL_BOUNDING_SPHERE - // Returns the bounding sphere + // Returns the bounding sphere: first = center, second = radius const std::pair get_bounding_sphere() const; -#endif // ENABLE_CGAL_BOUNDING_SPHERE void setup_cache(); @@ -372,9 +366,7 @@ private: m_full_unscaled_instance_bounding_box.reset(); m_full_scaled_instance_bounding_box.reset(); m_full_unscaled_instance_local_bounding_box.reset(); m_bounding_box_in_current_reference_system.reset(); -#if ENABLE_CGAL_BOUNDING_SPHERE m_bounding_sphere.reset(); -#endif // ENABLE_CGAL_BOUNDING_SPHERE } void render_synchronized_volumes(); void render_bounding_box(const BoundingBoxf3& box, const Transform3d& trafo, const ColorRGB& color);