mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
SPE-1103 Added menu items for the conversation of the volumes from/to meters
Related to #4521
This commit is contained in:
parent
8049dd1f72
commit
e664100bf6
8 changed files with 84 additions and 42 deletions
|
@ -491,7 +491,7 @@ void Model::convert_from_meters(bool only_small_volumes)
|
|||
if (! only_small_volumes || obj->get_object_stl_stats().volume < 0.001) { // 0.001 = 0.1*0.1*0.1;
|
||||
obj->scale_mesh_after_creation(Vec3d(m_to_mm, m_to_mm, m_to_mm));
|
||||
for (ModelVolume* v : obj->volumes)
|
||||
v->source.is_converted_from_inches = true;
|
||||
v->source.is_converted_from_meters = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1046,13 +1046,14 @@ void ModelObject::scale_mesh_after_creation(const Vec3d &versor)
|
|||
this->invalidate_bounding_box();
|
||||
}
|
||||
|
||||
void ModelObject::convert_units(ModelObjectPtrs& new_objects, bool from_imperial, std::vector<int> volume_idxs)
|
||||
void ModelObject::convert_units(ModelObjectPtrs& new_objects, ConversionType conv_type, std::vector<int> volume_idxs)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(trace) << "ModelObject::convert_units - start";
|
||||
|
||||
ModelObject* new_object = new_clone(*this);
|
||||
|
||||
double koef = from_imperial ? 25.4 : 0.0393700787;
|
||||
double koef = conv_type == ConversionType::CONV_FROM_INCH ? 25.4 : conv_type == ConversionType::CONV_TO_INCH ? 0.0393700787 :
|
||||
conv_type == ConversionType::CONV_FROM_METER ? 1000 : conv_type == ConversionType::CONV_TO_METER ? 0.001 : 1;
|
||||
const Vec3d versor = Vec3d(koef, koef, koef);
|
||||
|
||||
new_object->set_model(nullptr);
|
||||
|
@ -1080,6 +1081,8 @@ void ModelObject::convert_units(ModelObjectPtrs& new_objects, bool from_imperial
|
|||
vol->source.input_file = volume->source.input_file;
|
||||
vol->source.object_idx = (int)new_objects.size();
|
||||
vol->source.volume_idx = vol_idx;
|
||||
vol->source.is_converted_from_inches = volume->source.is_converted_from_inches;
|
||||
vol->source.is_converted_from_meters = volume->source.is_converted_from_meters;
|
||||
|
||||
vol->supported_facets.assign(volume->supported_facets);
|
||||
vol->seam_facets.assign(volume->seam_facets);
|
||||
|
@ -1091,7 +1094,10 @@ void ModelObject::convert_units(ModelObjectPtrs& new_objects, bool from_imperial
|
|||
std::find(volume_idxs.begin(), volume_idxs.end(), vol_idx) != volume_idxs.end())) {
|
||||
vol->scale_geometry_after_creation(versor);
|
||||
vol->set_offset(versor.cwiseProduct(volume->get_offset()));
|
||||
vol->source.is_converted_from_inches = from_imperial;
|
||||
if (conv_type == ConversionType::CONV_FROM_INCH || conv_type == ConversionType::CONV_TO_INCH)
|
||||
vol->source.is_converted_from_inches = conv_type == ConversionType::CONV_FROM_INCH;
|
||||
if (conv_type == ConversionType::CONV_FROM_METER || conv_type == ConversionType::CONV_TO_METER)
|
||||
vol->source.is_converted_from_meters = conv_type == ConversionType::CONV_FROM_METER;
|
||||
}
|
||||
else
|
||||
vol->set_offset(volume->get_offset());
|
||||
|
@ -1841,6 +1847,14 @@ void ModelVolume::convert_from_imperial_units()
|
|||
this->source.is_converted_from_inches = true;
|
||||
}
|
||||
|
||||
void ModelVolume::convert_from_meters()
|
||||
{
|
||||
double m_to_mm = 1000;
|
||||
this->scale_geometry_after_creation(Vec3d(m_to_mm, m_to_mm, m_to_mm));
|
||||
this->set_offset(Vec3d(0, 0, 0));
|
||||
this->source.is_converted_from_meters = true;
|
||||
}
|
||||
|
||||
void ModelInstance::transform_mesh(TriangleMesh* mesh, bool dont_translate) const
|
||||
{
|
||||
mesh->transform(get_matrix(dont_translate));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue