mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	#5415 - Fixed preview when volumetric extrusion is turned on
This commit is contained in:
		
							parent
							
								
									82fe571cdc
								
							
						
					
					
						commit
						dcd69b4ef8
					
				
					 3 changed files with 39 additions and 2 deletions
				
			
		|  | @ -562,6 +562,10 @@ void GCodeProcessor::apply_config(const PrintConfig& config) | |||
|     } | ||||
| 
 | ||||
|     m_time_processor.export_remaining_time_enabled = config.remaining_times.value; | ||||
| 
 | ||||
| #if ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING | ||||
|     m_use_volumetric_e = config.use_volumetric_e; | ||||
| #endif // ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING
 | ||||
| } | ||||
| 
 | ||||
| void GCodeProcessor::apply_config(const DynamicPrintConfig& config) | ||||
|  | @ -719,6 +723,12 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config) | |||
|         m_time_processor.machines[i].max_acceleration = max_acceleration; | ||||
|         m_time_processor.machines[i].acceleration = (max_acceleration > 0.0f) ? max_acceleration : DEFAULT_ACCELERATION; | ||||
|     } | ||||
| 
 | ||||
| #if ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING | ||||
|     const ConfigOptionBool* use_volumetric_e = config.option<ConfigOptionBool>("use_volumetric_e"); | ||||
|     if (use_volumetric_e != nullptr) | ||||
|         m_use_volumetric_e = use_volumetric_e->value; | ||||
| #endif // ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING
 | ||||
| } | ||||
| 
 | ||||
| void GCodeProcessor::enable_stealth_time_estimator(bool enabled) | ||||
|  | @ -773,6 +783,10 @@ void GCodeProcessor::reset() | |||
|     m_result.reset(); | ||||
|     m_result.id = ++s_result_id; | ||||
| 
 | ||||
| #if ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING | ||||
|     m_use_volumetric_e = false; | ||||
| #endif // ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING
 | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER_DATA_CHECKING | ||||
|     m_mm3_per_mm_compare.reset(); | ||||
|     m_height_compare.reset(); | ||||
|  | @ -1653,8 +1667,14 @@ void GCodeProcessor::process_G0(const GCodeReader::GCodeLine& line) | |||
| 
 | ||||
| void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) | ||||
| { | ||||
|     auto absolute_position = [this](Axis axis, const GCodeReader::GCodeLine& lineG1) | ||||
|     { | ||||
| #if ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING | ||||
|     float filament_diameter = (static_cast<size_t>(m_extruder_id) < m_filament_diameters.size()) ? m_filament_diameters[m_extruder_id] : m_filament_diameters.back(); | ||||
|     float filament_radius = 0.5f * filament_diameter; | ||||
|     float area_filament_cross_section = static_cast<float>(M_PI) * sqr(filament_radius); | ||||
|     auto absolute_position = [this, area_filament_cross_section](Axis axis, const GCodeReader::GCodeLine& lineG1) { | ||||
| #else | ||||
|     auto absolute_position = [this](Axis axis, const GCodeReader::GCodeLine& lineG1) { | ||||
| #endif // ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING
 | ||||
|         bool is_relative = (m_global_positioning_type == EPositioningType::Relative); | ||||
|         if (axis == E) | ||||
|             is_relative |= (m_e_local_positioning_type == EPositioningType::Relative); | ||||
|  | @ -1662,6 +1682,10 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) | |||
|         if (lineG1.has(Slic3r::Axis(axis))) { | ||||
|             float lengthsScaleFactor = (m_units == EUnits::Inches) ? INCHES_TO_MM : 1.0f; | ||||
|             float ret = lineG1.value(Slic3r::Axis(axis)) * lengthsScaleFactor; | ||||
| #if ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING | ||||
|             if (axis == E && m_use_volumetric_e) | ||||
|                 ret /= area_filament_cross_section; | ||||
| #endif // ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING
 | ||||
|             return is_relative ? m_start_position[axis] + ret : m_origin[axis] + ret; | ||||
|         } | ||||
|         else | ||||
|  | @ -1719,9 +1743,11 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) | |||
| 
 | ||||
|     if (type == EMoveType::Extrude) { | ||||
|         float delta_xyz = std::sqrt(sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z])); | ||||
| #if !ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING | ||||
|         float filament_diameter = (static_cast<size_t>(m_extruder_id) < m_filament_diameters.size()) ? m_filament_diameters[m_extruder_id] : m_filament_diameters.back(); | ||||
|         float filament_radius = 0.5f * filament_diameter; | ||||
|         float area_filament_cross_section = static_cast<float>(M_PI) * sqr(filament_radius); | ||||
| #endif // !ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING
 | ||||
|         float volume_extruded_filament = area_filament_cross_section * delta_pos[E]; | ||||
|         float area_toolpath_cross_section = volume_extruded_filament / delta_xyz; | ||||
| 
 | ||||
|  |  | |||
|  | @ -421,6 +421,9 @@ namespace Slic3r { | |||
|         unsigned int m_g1_line_id; | ||||
|         unsigned int m_layer_id; | ||||
|         CpColor m_cp_color; | ||||
| #if ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING | ||||
|         bool m_use_volumetric_e; | ||||
| #endif // ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING
 | ||||
| 
 | ||||
|         enum class EProducer | ||||
|         { | ||||
|  |  | |||
|  | @ -99,4 +99,12 @@ | |||
| #define ENABLE_TOOLPATHS_WIDTH_HEIGHT_FROM_GCODE (1 && ENABLE_2_3_0_BETA3) | ||||
| #define ENABLE_RENDER_PATH_REFRESH_AFTER_OPTIONS_CHANGE (1 && ENABLE_2_3_0_BETA3) | ||||
| 
 | ||||
| 
 | ||||
| //=================
 | ||||
| // 2.3.0.rc1 techs
 | ||||
| //=================
 | ||||
| #define ENABLE_2_3_0_RC1 1 | ||||
| 
 | ||||
| #define ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING (1 && ENABLE_2_3_0_RC1) | ||||
| 
 | ||||
| #endif // _prusaslicer_technologies_h_
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 enricoturri1966
						enricoturri1966