mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 12:41:20 -06:00 
			
		
		
		
	Fixed retrieving of the "saved in inches" flag from 3MF.
Fixed "import STL from Inches" - it should always scale up even if the object is bigger than 3x3x3mm.
This commit is contained in:
		
							parent
							
								
									3795f6b779
								
							
						
					
					
						commit
						9fdf8c8b8d
					
				
					 4 changed files with 11 additions and 9 deletions
				
			
		|  | @ -1928,7 +1928,7 @@ namespace Slic3r { | |||
|                 else if (metadata.key == SOURCE_OFFSET_Z_KEY) | ||||
|                     volume->source.mesh_offset(2) = ::atof(metadata.value.c_str()); | ||||
|                 else if (metadata.key == SOURCE_IN_INCHES) | ||||
|                     volume->source.is_converted_from_inches = metadata.value.c_str() == "1"; | ||||
|                     volume->source.is_converted_from_inches = metadata.value == "1"; | ||||
|                 else | ||||
|                     volume->config.set_deserialize(metadata.key, metadata.value); | ||||
|             } | ||||
|  |  | |||
|  | @ -461,11 +461,11 @@ bool Model::looks_like_imperial_units() const | |||
|     return false; | ||||
| } | ||||
| 
 | ||||
| void Model::convert_from_imperial_units() | ||||
| void Model::convert_from_imperial_units(bool only_small_volumes) | ||||
| { | ||||
|     double in_to_mm = 25.4; | ||||
|     for (ModelObject* obj : this->objects) | ||||
|         if (obj->get_object_stl_stats().volume < 9.0) { // 9 = 3*3*3;
 | ||||
|         if (! only_small_volumes || obj->get_object_stl_stats().volume < 9.0) { // 9 = 3*3*3;
 | ||||
|             obj->scale_mesh_after_creation(Vec3d(in_to_mm, in_to_mm, in_to_mm)); | ||||
|             for (ModelVolume* v : obj->volumes) | ||||
|                 v->source.is_converted_from_inches = true; | ||||
|  | @ -1062,7 +1062,7 @@ void ModelObject::convert_units(ModelObjectPtrs& new_objects, bool from_imperial | |||
| 
 | ||||
|             // Perform conversion only if the target "imperial" state is different from the current one.
 | ||||
|             // This check supports conversion of "mixed" set of volumes, each with different "imperial" state.
 | ||||
|             if (vol->source.is_converted_from_inches != from_imperial &&  | ||||
|             if (//vol->source.is_converted_from_inches != from_imperial && 
 | ||||
|                 (volume_idxs.empty() ||  | ||||
|                  std::find(volume_idxs.begin(), volume_idxs.end(), vol_idx) != volume_idxs.end())) { | ||||
|                 vol->scale_geometry_after_creation(versor); | ||||
|  |  | |||
|  | @ -1018,7 +1018,7 @@ public: | |||
|     bool 		  looks_like_multipart_object() const; | ||||
|     void 		  convert_multipart_object(unsigned int max_extruders); | ||||
|     bool          looks_like_imperial_units() const; | ||||
|     void          convert_from_imperial_units(); | ||||
|     void          convert_from_imperial_units(bool only_small_volumes); | ||||
| 
 | ||||
|     // Ensures that the min z of the model is not negative
 | ||||
|     void 		  adjust_min_z(); | ||||
|  |  | |||
|  | @ -2393,22 +2393,24 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_ | |||
|         { | ||||
|             // The model should now be initialized
 | ||||
| 
 | ||||
|             auto convert_from_imperial_units = [](Model& model) { | ||||
|                 model.convert_from_imperial_units(); | ||||
|             auto convert_from_imperial_units = [](Model& model, bool only_small_volumes) { | ||||
|                 model.convert_from_imperial_units(only_small_volumes); | ||||
|                 wxGetApp().app_config->set("use_inches", "1"); | ||||
|                 wxGetApp().sidebar().update_ui_from_settings(); | ||||
|             }; | ||||
| 
 | ||||
|             if (!is_project_file) { | ||||
|                 if (imperial_units) | ||||
|                     convert_from_imperial_units(model); | ||||
|                     // Convert even if the object is big.
 | ||||
|                     convert_from_imperial_units(model, false); | ||||
|                 else if (model.looks_like_imperial_units()) { | ||||
|                     wxMessageDialog msg_dlg(q, format_wxstr(_L( | ||||
|                         "Some object(s) in file %s looks like saved in inches.\n" | ||||
|                         "Should I consider them as a saved in inches and convert them?"), from_path(filename)) + "\n", | ||||
|                         _L("The object appears to be saved in inches"), wxICON_WARNING | wxYES | wxNO); | ||||
|                     if (msg_dlg.ShowModal() == wxID_YES) | ||||
|                         convert_from_imperial_units(model); | ||||
|                         //FIXME up-scale only the small parts?
 | ||||
|                         convert_from_imperial_units(model, true); | ||||
|                 } | ||||
| 
 | ||||
|                 if (model.looks_like_multipart_object()) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vojtech Bubnik
						Vojtech Bubnik