Fix of #5007 - "Reload from disk" causes objects converted to inches to revert to mm
1) Storing and reloading the "source_in_inches" source flag from AMF and 3MF
2) When converting objects with mixed "inches" volumes, do the right thing
   and do not convert those that do not need conversion.
This commit is contained in:
Vojtech Bubnik 2020-12-12 12:06:15 +01:00
parent b62a781417
commit 5605088aad
3 changed files with 70 additions and 56 deletions

View file

@ -778,6 +778,9 @@ void AMFParserContext::endElement(const char * /* name */)
else if (strcmp(opt_key, "source_offset_z") == 0) {
m_volume->source.mesh_offset(2) = ::atof(m_value[1].c_str());
}
else if (strcmp(opt_key, "source_in_inches") == 0) {
m_volume->source.is_converted_from_inches = m_value[1] == "1";
}
}
} else if (m_path.size() == 3) {
if (m_path[1] == NODE_TYPE_MATERIAL) {
@ -1204,6 +1207,8 @@ bool store_amf(const char* path, Model* model, const DynamicPrintConfig* config,
stream << " <metadata type=\"slic3r.source_offset_x\">" << volume->source.mesh_offset(0) << "</metadata>\n";
stream << " <metadata type=\"slic3r.source_offset_y\">" << volume->source.mesh_offset(1) << "</metadata>\n";
stream << " <metadata type=\"slic3r.source_offset_z\">" << volume->source.mesh_offset(2) << "</metadata>\n";
if (volume->source.is_converted_from_inches)
stream << " <metadata type=\"slic3r.source_in_inches\">1</metadata>\n";
}
stream << std::setprecision(std::numeric_limits<float>::max_digits10);
const indexed_triangle_set &its = volume->mesh().its;