mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-29 19:53:44 -06:00 
			
		
		
		
	ENH: separate the simplifying of infill and wall
This can avoid to simplify wall twice when the only invalid step is infill. Signed-off-by: salt.wei <salt.wei@bambulab.com> Change-Id: Ie5a9ccc10d5331c29c716aece08cdb195352cfe3
This commit is contained in:
		
							parent
							
								
									e6070fc607
								
							
						
					
					
						commit
						3a1e112d49
					
				
					 5 changed files with 40 additions and 23 deletions
				
			
		|  | @ -95,7 +95,8 @@ public: | |||
|     // Is there any valid extrusion assigned to this LayerRegion?
 | ||||
|     bool    has_extrusions() const { return ! this->perimeters.entities.empty() || ! this->fills.entities.empty(); } | ||||
|     //BBS
 | ||||
|     void    simplify_extrusion_entity(); | ||||
|     void    simplify_infill_extrusion_entity() { simplify_entity_collection(&fills); } | ||||
|     void    simplify_wall_extrusion_entity() { simplify_entity_collection(&perimeters); } | ||||
| private: | ||||
|     void    simplify_entity_collection(ExtrusionEntityCollection* entity_collection); | ||||
|     void    simplify_path(ExtrusionPath* path); | ||||
|  | @ -190,7 +191,8 @@ public: | |||
|     virtual bool            has_extrusions() const { for (auto layerm : m_regions) if (layerm->has_extrusions()) return true; return false; } | ||||
| 
 | ||||
|     //BBS
 | ||||
|     void simplify_extrusion_path() { for (auto layerm : m_regions) layerm->simplify_extrusion_entity();} | ||||
|     void simplify_wall_extrusion_path() { for (auto layerm : m_regions) layerm->simplify_wall_extrusion_entity();} | ||||
|     void simplify_infill_extrusion_path() { for (auto layerm : m_regions) layerm->simplify_infill_extrusion_entity(); } | ||||
|     //BBS: this function calculate the maximum void grid area of sparse infill of this layer. Just estimated value
 | ||||
|     coordf_t get_sparse_infill_max_void_area(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -526,13 +526,6 @@ void LayerRegion::export_region_fill_surfaces_to_svg_debug(const char *name) con | |||
|     this->export_region_fill_surfaces_to_svg(debug_out_path("LayerRegion-fill_surfaces-%s-%d.svg", name, idx ++).c_str()); | ||||
| } | ||||
| 
 | ||||
| //BBS
 | ||||
| void LayerRegion::simplify_extrusion_entity() | ||||
| { | ||||
|     simplify_entity_collection(&perimeters); | ||||
|     simplify_entity_collection(&fills); | ||||
| } | ||||
| 
 | ||||
| void LayerRegion::simplify_entity_collection(ExtrusionEntityCollection* entity_collection) | ||||
| { | ||||
|     for (size_t i = 0; i < entity_collection->entities.size(); i++) { | ||||
|  |  | |||
|  | @ -228,7 +228,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n | |||
|             osteps.emplace_back(posPerimeters); | ||||
|             osteps.emplace_back(posInfill); | ||||
|             osteps.emplace_back(posSupportMaterial); | ||||
|             osteps.emplace_back(posSimplifyPath); | ||||
|             osteps.emplace_back(posSimplifyWall); | ||||
|             osteps.emplace_back(posSimplifyInfill); | ||||
|             osteps.emplace_back(posSimplifySupportPath); | ||||
|             steps.emplace_back(psSkirtBrim); | ||||
|         } | ||||
|  | @ -1682,8 +1683,10 @@ void Print::process(bool use_cache) | |||
|             obj->simplify_extrusion_path(); | ||||
|         } | ||||
|         else { | ||||
|             if (obj->set_started(posSimplifyPath)) | ||||
|                 obj->set_done(posSimplifyPath); | ||||
|             if (obj->set_started(posSimplifyWall)) | ||||
|                 obj->set_done(posSimplifyWall); | ||||
|             if (obj->set_started(posSimplifyInfill)) | ||||
|                 obj->set_done(posSimplifyInfill); | ||||
|             if (obj->set_started(posSimplifySupportPath)) | ||||
|                 obj->set_done(posSimplifySupportPath); | ||||
|         } | ||||
|  |  | |||
|  | @ -87,8 +87,9 @@ enum PrintStep { | |||
| 
 | ||||
| enum PrintObjectStep { | ||||
|     posSlice, posPerimeters, posPrepareInfill, | ||||
|     posInfill, posIroning, posSupportMaterial, posSimplifyPath, posSimplifySupportPath, | ||||
|     posInfill, posIroning, posSupportMaterial, | ||||
|     // BBS
 | ||||
|     posSimplifyWall, posSimplifyInfill, posSimplifySupportPath, | ||||
|     posDetectOverhangsForLift, | ||||
|     posCount, | ||||
| }; | ||||
|  |  | |||
|  | @ -495,22 +495,40 @@ void PrintObject::generate_support_material() | |||
| 
 | ||||
| void PrintObject::simplify_extrusion_path() | ||||
| { | ||||
|     if (this->set_started(posSimplifyPath)) { | ||||
|     if (this->set_started(posSimplifyWall)) { | ||||
|         m_print->set_status(75, L("Optimizing toolpath")); | ||||
|         BOOST_LOG_TRIVIAL(debug) << "Simplify extrusion path of object in parallel - start"; | ||||
|         //BBS: infill and walls
 | ||||
|         BOOST_LOG_TRIVIAL(debug) << "Simplify wall extrusion path of object in parallel - start"; | ||||
|         //BBS: walls
 | ||||
|         tbb::parallel_for( | ||||
|             tbb::blocked_range<size_t>(0, m_layers.size()), | ||||
|             [this](const tbb::blocked_range<size_t>& range) { | ||||
|                 for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++ layer_idx) { | ||||
|                     m_print->throw_if_canceled(); | ||||
|                     m_layers[layer_idx]->simplify_extrusion_path(); | ||||
|                     m_layers[layer_idx]->simplify_wall_extrusion_path(); | ||||
|                 } | ||||
|             } | ||||
|         ); | ||||
|         m_print->throw_if_canceled(); | ||||
|         BOOST_LOG_TRIVIAL(debug) << "Simplify extrusion path of object in parallel - end"; | ||||
|         this->set_done(posSimplifyPath); | ||||
|         BOOST_LOG_TRIVIAL(debug) << "Simplify wall extrusion path of object in parallel - end"; | ||||
|         this->set_done(posSimplifyWall); | ||||
|     } | ||||
| 
 | ||||
|     if (this->set_started(posSimplifyInfill)) { | ||||
|         m_print->set_status(75, L("Optimizing toolpath")); | ||||
|         BOOST_LOG_TRIVIAL(debug) << "Simplify infill extrusion path of object in parallel - start"; | ||||
|         //BBS: infills
 | ||||
|         tbb::parallel_for( | ||||
|             tbb::blocked_range<size_t>(0, m_layers.size()), | ||||
|             [this](const tbb::blocked_range<size_t>& range) { | ||||
|                 for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++layer_idx) { | ||||
|                     m_print->throw_if_canceled(); | ||||
|                     m_layers[layer_idx]->simplify_infill_extrusion_path(); | ||||
|                 } | ||||
|             } | ||||
|         ); | ||||
|         m_print->throw_if_canceled(); | ||||
|         BOOST_LOG_TRIVIAL(debug) << "Simplify infill extrusion path of object in parallel - end"; | ||||
|         this->set_done(posSimplifyInfill); | ||||
|     } | ||||
| 
 | ||||
|     if (this->set_started(posSimplifySupportPath)) { | ||||
|  | @ -911,15 +929,15 @@ bool PrintObject::invalidate_step(PrintObjectStep step) | |||
| 
 | ||||
|     // propagate to dependent steps
 | ||||
|     if (step == posPerimeters) { | ||||
| 		invalidated |= this->invalidate_steps({ posPrepareInfill, posInfill, posIroning, posSimplifyPath }); | ||||
| 		invalidated |= this->invalidate_steps({ posPrepareInfill, posInfill, posIroning, posSimplifyWall, posSimplifyInfill }); | ||||
|         invalidated |= m_print->invalidate_steps({ psSkirtBrim }); | ||||
|     } else if (step == posPrepareInfill) { | ||||
|         invalidated |= this->invalidate_steps({ posInfill, posIroning, posSimplifyPath }); | ||||
|         invalidated |= this->invalidate_steps({ posInfill, posIroning, posSimplifyWall, posSimplifyInfill }); | ||||
|     } else if (step == posInfill) { | ||||
|         invalidated |= this->invalidate_steps({ posIroning, posSimplifyPath }); | ||||
|         invalidated |= this->invalidate_steps({ posIroning, posSimplifyInfill }); | ||||
|         invalidated |= m_print->invalidate_steps({ psSkirtBrim }); | ||||
|     } else if (step == posSlice) { | ||||
| 		invalidated |= this->invalidate_steps({ posPerimeters, posPrepareInfill, posInfill, posIroning, posSupportMaterial, posSimplifyPath }); | ||||
| 		invalidated |= this->invalidate_steps({ posPerimeters, posPrepareInfill, posInfill, posIroning, posSupportMaterial, posSimplifyWall, posSimplifyInfill }); | ||||
|         invalidated |= m_print->invalidate_steps({ psSkirtBrim }); | ||||
|         m_slicing_params.valid = false; | ||||
|     } else if (step == posSupportMaterial) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 salt.wei
						salt.wei