mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Removed duplicated method GLVolumeCollection::check_outside_state()
This commit is contained in:
		
							parent
							
								
									ff82c82f52
								
							
						
					
					
						commit
						8bd0f8ada9
					
				
					 7 changed files with 22 additions and 73 deletions
				
			
		|  | @ -827,6 +827,12 @@ GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCo | |||
| 
 | ||||
| void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func) const | ||||
| { | ||||
| #if ENABLE_SINKING_CONTOURS | ||||
|     GLVolumeWithIdAndZList to_render = volumes_to_render(volumes, type, view_matrix, filter_func); | ||||
|     if (to_render.empty()) | ||||
|         return; | ||||
| #endif // ENABLE_SINKING_CONTOURS
 | ||||
| 
 | ||||
|     GLShaderProgram* shader = GUI::wxGetApp().get_current_shader(); | ||||
|     if (shader == nullptr) | ||||
|         return; | ||||
|  | @ -841,7 +847,6 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab | |||
|         glsafe(::glDisable(GL_CULL_FACE)); | ||||
| 
 | ||||
| #if ENABLE_SINKING_CONTOURS | ||||
|     GLVolumeWithIdAndZList to_render = volumes_to_render(volumes, type, view_matrix, filter_func); | ||||
|     for (GLVolumeWithIdAndZ& volume : to_render) { | ||||
|         volume.first->set_render_color(); | ||||
| 
 | ||||
|  | @ -961,8 +966,10 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, M | |||
|     if (opt == nullptr) | ||||
|         return false; | ||||
| 
 | ||||
|     BoundingBox bed_box_2D = get_extents(Polygon::new_scale(opt->values)); | ||||
|     BoundingBoxf3 print_volume({ unscale<double>(bed_box_2D.min(0)), unscale<double>(bed_box_2D.min(1)), 0.0 }, { unscale<double>(bed_box_2D.max(0)), unscale<double>(bed_box_2D.max(1)), config->opt_float("max_print_height") }); | ||||
|     const BoundingBox bed_box_2D = get_extents(Polygon::new_scale(opt->values)); | ||||
|     BoundingBoxf3 print_volume({ unscale<double>(bed_box_2D.min.x()), unscale<double>(bed_box_2D.min.y()), 0.0 },  | ||||
|                                { unscale<double>(bed_box_2D.max.x()), unscale<double>(bed_box_2D.max.y()), | ||||
|                                config->opt_float("max_print_height") }); | ||||
|     // Allow the objects to protrude below the print bed
 | ||||
|     print_volume.min(2) = -1e10; | ||||
|     print_volume.min(0) -= BedEpsilon; | ||||
|  | @ -975,7 +982,7 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, M | |||
|     bool contained_min_one = false; | ||||
| 
 | ||||
|     for (GLVolume* volume : this->volumes) { | ||||
|         if (volume == nullptr || volume->is_modifier || (volume->is_wipe_tower && !volume->shader_outside_printer_detection_enabled) || (volume->composite_id.volume_id < 0 && !volume->shader_outside_printer_detection_enabled)) | ||||
|         if (volume->is_modifier || (!volume->shader_outside_printer_detection_enabled && (volume->is_wipe_tower || volume->composite_id.volume_id < 0))) | ||||
|             continue; | ||||
| 
 | ||||
|         const BoundingBoxf3& bb = volume->transformed_convex_hull_bounding_box(); | ||||
|  | @ -985,8 +992,7 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, M | |||
|         if (!volume->printable) | ||||
|             continue; | ||||
| 
 | ||||
|         if (contained) | ||||
|             contained_min_one = true; | ||||
|         contained_min_one |= contained; | ||||
| 
 | ||||
|         if (state == ModelInstancePVS_Inside && volume->is_outside) | ||||
|             state = ModelInstancePVS_Fully_Outside; | ||||
|  | @ -1001,56 +1007,6 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, M | |||
|     return contained_min_one; | ||||
| } | ||||
| 
 | ||||
| bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, bool& partlyOut, bool& fullyOut) const | ||||
| { | ||||
|     if (config == nullptr) | ||||
|         return false; | ||||
| 
 | ||||
|     const ConfigOptionPoints* opt = dynamic_cast<const ConfigOptionPoints*>(config->option("bed_shape")); | ||||
|     if (opt == nullptr) | ||||
|         return false; | ||||
| 
 | ||||
|     const BoundingBox bed_box_2D = get_extents(Polygon::new_scale(opt->values)); | ||||
|     BoundingBoxf3 print_volume(Vec3d(unscale<double>(bed_box_2D.min.x()), unscale<double>(bed_box_2D.min.y()), 0.0), Vec3d(unscale<double>(bed_box_2D.max.x()), unscale<double>(bed_box_2D.max.y()), config->opt_float("max_print_height"))); | ||||
|     // Allow the objects to protrude below the print bed
 | ||||
|     print_volume.min(2) = -1e10; | ||||
|     print_volume.min(0) -= BedEpsilon; | ||||
|     print_volume.min(1) -= BedEpsilon; | ||||
|     print_volume.max(0) += BedEpsilon; | ||||
|     print_volume.max(1) += BedEpsilon; | ||||
| 
 | ||||
|     bool contained_min_one = false; | ||||
| 
 | ||||
|     partlyOut = false; | ||||
|     fullyOut = false; | ||||
|     for (GLVolume* volume : this->volumes) { | ||||
|         if (volume == nullptr || volume->is_modifier || (volume->is_wipe_tower && !volume->shader_outside_printer_detection_enabled) || (volume->composite_id.volume_id < 0 && !volume->shader_outside_printer_detection_enabled)) | ||||
|             continue; | ||||
| 
 | ||||
|         const BoundingBoxf3& bb = volume->transformed_convex_hull_bounding_box(); | ||||
|         bool contained = print_volume.contains(bb); | ||||
| 
 | ||||
|         volume->is_outside = !contained; | ||||
|         if (!volume->printable) | ||||
|             continue; | ||||
| 
 | ||||
|         if (contained) | ||||
|             contained_min_one = true; | ||||
| 
 | ||||
|         if (volume->is_outside) { | ||||
|             if (print_volume.intersects(bb)) | ||||
|                 partlyOut = true; | ||||
|             else  | ||||
|                 fullyOut = true; | ||||
|         } | ||||
|     } | ||||
|     /*
 | ||||
|     if (out_state != nullptr) | ||||
|         *out_state = state; | ||||
|     */ | ||||
|     return contained_min_one; | ||||
| } | ||||
| 
 | ||||
| void GLVolumeCollection::reset_outside_state() | ||||
| { | ||||
|     for (GLVolume* volume : this->volumes) | ||||
|  |  | |||
|  | @ -614,7 +614,6 @@ public: | |||
|     // returns true if all the volumes are completely contained in the print volume
 | ||||
|     // returns the containment state in the given out_state, if non-null
 | ||||
|     bool check_outside_state(const DynamicPrintConfig* config, ModelInstanceEPrintVolumeState* out_state) const; | ||||
|     bool check_outside_state(const DynamicPrintConfig* config, bool& partlyOut, bool& fullyOut) const; | ||||
|     void reset_outside_state(); | ||||
| 
 | ||||
|     void update_colors_by_extruder(const DynamicPrintConfig* config); | ||||
|  |  | |||
|  | @ -1107,11 +1107,11 @@ void GLCanvas3D::reset_volumes() | |||
|     _set_warning_notification(EWarning::ObjectOutside, false); | ||||
| } | ||||
| 
 | ||||
| int GLCanvas3D::check_volumes_outside_state() const | ||||
| ModelInstanceEPrintVolumeState GLCanvas3D::check_volumes_outside_state() const | ||||
| { | ||||
|     ModelInstanceEPrintVolumeState state; | ||||
|     m_volumes.check_outside_state(m_config, &state); | ||||
|     return (int)state; | ||||
|     return state; | ||||
| } | ||||
| 
 | ||||
| void GLCanvas3D::toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo, int instance_idx) | ||||
|  | @ -2039,9 +2039,10 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re | |||
| 
 | ||||
|     // checks for geometry outside the print volume to render it accordingly
 | ||||
|     if (!m_volumes.empty()) { | ||||
|         bool partlyOut = false; | ||||
|         bool fullyOut = false; | ||||
|         const bool contained_min_one = m_volumes.check_outside_state(m_config, partlyOut, fullyOut); | ||||
|         ModelInstanceEPrintVolumeState state; | ||||
|         const bool contained_min_one = m_volumes.check_outside_state(m_config, &state); | ||||
|         const bool partlyOut = (state == ModelInstanceEPrintVolumeState::ModelInstancePVS_Partly_Outside); | ||||
|         const bool fullyOut = (state == ModelInstanceEPrintVolumeState::ModelInstancePVS_Fully_Outside); | ||||
| 
 | ||||
|         _set_warning_notification(EWarning::ObjectClashed, partlyOut); | ||||
|         _set_warning_notification(EWarning::ObjectOutside, fullyOut); | ||||
|  | @ -2121,7 +2122,7 @@ void GLCanvas3D::load_sla_preview() | |||
|     if (m_canvas != nullptr && print != nullptr) { | ||||
|         _set_current(); | ||||
| 	    // Release OpenGL data before generating new data.
 | ||||
| 	    this->reset_volumes(); | ||||
| 	    reset_volumes(); | ||||
|         _load_sla_shells(); | ||||
|         _update_sla_shells_outside_state(); | ||||
|         _set_warning_notification_if_needed(EWarning::SlaSupportsOutside); | ||||
|  |  | |||
|  | @ -615,7 +615,7 @@ public: | |||
|     unsigned int get_volumes_count() const; | ||||
|     const GLVolumeCollection& get_volumes() const { return m_volumes; } | ||||
|     void reset_volumes(); | ||||
|     int check_volumes_outside_state() const; | ||||
|     ModelInstanceEPrintVolumeState check_volumes_outside_state() const; | ||||
| 
 | ||||
|     void reset_gcode_toolpaths() { m_gcode_viewer.reset(); } | ||||
|     const GCodeViewer::SequentialView& get_gcode_sequential_view() const { return m_gcode_viewer.get_sequential_view(); } | ||||
|  |  | |||
|  | @ -128,11 +128,6 @@ void View3D::mirror_selection(Axis axis) | |||
|         m_canvas->mirror_selection(axis); | ||||
| } | ||||
| 
 | ||||
| int View3D::check_volumes_outside_state() const | ||||
| { | ||||
|     return (m_canvas != nullptr) ? m_canvas->check_volumes_outside_state() : false; | ||||
| } | ||||
| 
 | ||||
| bool View3D::is_layers_editing_enabled() const | ||||
| { | ||||
|     return (m_canvas != nullptr) ? m_canvas->is_layers_editing_enabled() : false; | ||||
|  |  | |||
|  | @ -59,8 +59,6 @@ public: | |||
|     void delete_selected(); | ||||
|     void mirror_selection(Axis axis); | ||||
| 
 | ||||
|     int check_volumes_outside_state() const; | ||||
| 
 | ||||
|     bool is_layers_editing_enabled() const; | ||||
|     bool is_layers_editing_allowed() const; | ||||
|     void enable_layers_editing(bool enable); | ||||
|  |  | |||
|  | @ -2724,7 +2724,7 @@ void Plater::priv::object_list_changed() | |||
| { | ||||
|     const bool export_in_progress = this->background_process.is_export_scheduled(); // || ! send_gcode_file.empty());
 | ||||
|     // XXX: is this right?
 | ||||
|     const bool model_fits = view3D->check_volumes_outside_state() == ModelInstancePVS_Inside; | ||||
|     const bool model_fits = view3D->get_canvas3d()->check_volumes_outside_state() == ModelInstancePVS_Inside; | ||||
| 
 | ||||
|     sidebar->enable_buttons(!model.objects.empty() && !export_in_progress && model_fits); | ||||
| } | ||||
|  | @ -3664,7 +3664,7 @@ void Plater::priv::set_current_panel(wxPanel* panel) | |||
|         // see: Plater::priv::object_list_changed()
 | ||||
|         // FIXME: it may be better to have a single function making this check and let it be called wherever needed
 | ||||
|         bool export_in_progress = this->background_process.is_export_scheduled(); | ||||
|         bool model_fits = view3D->check_volumes_outside_state() != ModelInstancePVS_Partly_Outside; | ||||
|         bool model_fits = view3D->get_canvas3d()->check_volumes_outside_state() != ModelInstancePVS_Partly_Outside; | ||||
|         if (!model.objects.empty() && !export_in_progress && model_fits) | ||||
|             this->q->reslice(); | ||||
|         // keeps current gcode preview, if any
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 enricoturri1966
						enricoturri1966