mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Allow auto-rotation of objects not completely inside bed.
Don't use SLAPrintObject as the input for optimization. Use ModelObject and pass the print config to the optimization in RotoptimizeJob::prepare()
This commit is contained in:
		
							parent
							
								
									5443f77489
								
							
						
					
					
						commit
						773116b777
					
				
					 4 changed files with 77 additions and 37 deletions
				
			
		|  | @ -7,6 +7,7 @@ | |||
| #include "libslic3r/SLAPrint.hpp" | ||||
| 
 | ||||
| #include "slic3r/GUI/Plater.hpp" | ||||
| #include "libslic3r/PresetBundle.hpp" | ||||
| 
 | ||||
| #include "slic3r/GUI/GUI_App.hpp" | ||||
| #include "libslic3r/AppConfig.hpp" | ||||
|  | @ -29,25 +30,32 @@ void RotoptimizeJob::prepare() | |||
| 
 | ||||
|     m_accuracy = std::max(0.f, std::min(m_accuracy, 1.f)); | ||||
|     m_method_id = std::max(size_t(0), std::min(get_methods_count() - 1, m_method_id)); | ||||
| 
 | ||||
|     m_default_print_cfg = wxGetApp().preset_bundle->full_config(); | ||||
| } | ||||
| 
 | ||||
| void RotoptimizeJob::process() | ||||
| { | ||||
|     int obj_idx = m_plater->get_selected_object_idx(); | ||||
|     if (obj_idx < 0 || int(m_plater->sla_print().objects().size()) <= obj_idx) | ||||
|     if (obj_idx < 0) | ||||
|         return; | ||||
|      | ||||
|     ModelObject *o = m_plater->model().objects[size_t(obj_idx)]; | ||||
|     const SLAPrintObject *po = m_plater->sla_print().objects()[size_t(obj_idx)]; | ||||
| 
 | ||||
|     if (!o || !po) return; | ||||
|     if (!o) return; | ||||
| 
 | ||||
|     Vec2d r = Methods[m_method_id].findfn(*po, m_accuracy, [this](int s) { | ||||
|         if (s > 0 && s < 100) | ||||
|             update_status(s, _(L("Searching for optimal orientation"))); | ||||
|     auto params = | ||||
|         sla::RotOptimizeParams{} | ||||
|             .accuracy(m_accuracy) | ||||
|             .print_config(&m_default_print_cfg) | ||||
|             .statucb([this](int s) { | ||||
|             if (s > 0 && s < 100) | ||||
|                 update_status(s, _(L("Searching for optimal orientation"))); | ||||
| 
 | ||||
|         return !was_canceled(); | ||||
|     }); | ||||
|             return !was_canceled(); | ||||
|         }); | ||||
| 
 | ||||
|     Vec2d r = Methods[m_method_id].findfn(*o, params); | ||||
| 
 | ||||
|     double mindist = 6.0; // FIXME
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -4,18 +4,16 @@ | |||
| #include "PlaterJob.hpp" | ||||
| 
 | ||||
| #include "libslic3r/SLA/Rotfinder.hpp" | ||||
| #include "libslic3r/PrintConfig.hpp" | ||||
| 
 | ||||
| namespace Slic3r { | ||||
| 
 | ||||
| class SLAPrintObject; | ||||
| 
 | ||||
| namespace GUI { | ||||
| 
 | ||||
| class RotoptimizeJob : public PlaterJob | ||||
| { | ||||
|     using FindFn = std::function<Vec2d(const SLAPrintObject &   po, | ||||
|                                        float                    accuracy, | ||||
|                                        sla::RotOptimizeStatusCB statuscb)>; | ||||
|     using FindFn = std::function<Vec2d(const ModelObject &           mo, | ||||
|                                        const sla::RotOptimizeParams ¶ms)>; | ||||
| 
 | ||||
|     struct FindMethod { std::string name; FindFn findfn; }; | ||||
| 
 | ||||
|  | @ -26,6 +24,9 @@ class RotoptimizeJob : public PlaterJob | |||
| 
 | ||||
|     size_t m_method_id = 0; | ||||
|     float  m_accuracy  = 0.75; | ||||
| 
 | ||||
|     DynamicPrintConfig m_default_print_cfg; | ||||
| 
 | ||||
| protected: | ||||
| 
 | ||||
|     void prepare() override; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 tamasmeszaros
						tamasmeszaros