diff options
author | enricoturri1966 <enricoturri@seznam.cz> | 2020-05-27 15:29:54 +0300 |
---|---|---|
committer | enricoturri1966 <enricoturri@seznam.cz> | 2020-05-27 15:29:54 +0300 |
commit | 448d92df6865d14ca1d0e601a25f6294d49e5ff5 (patch) | |
tree | 9774aa89f9ae1eea8d4c42826743a936a02d126c /src/libslic3r/Model.cpp | |
parent | a0acf24ab8067e14acf977b920d93933f51efb4f (diff) | |
parent | d9b764bd10239c866e24ff5155f4fa9a86c0e850 (diff) |
Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_gcode_viewer
Diffstat (limited to 'src/libslic3r/Model.cpp')
-rw-r--r-- | src/libslic3r/Model.cpp | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 0f1c346a6..19973cb9b 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -455,24 +455,19 @@ bool Model::looks_like_imperial_units() const if (this->objects.size() == 0) return false; - stl_vertex size = this->objects[0]->get_object_stl_stats().size; - - for (ModelObject* o : this->objects) { - auto sz = o->get_object_stl_stats().size; - - if (size[0] < sz[0]) size[0] = sz[0]; - if (size[1] < sz[1]) size[1] = sz[1]; - if (size[2] < sz[2]) size[2] = sz[2]; - } + for (ModelObject* obj : this->objects) + if (obj->get_object_stl_stats().volume < 9.0) // 9 = 3*3*3; + return true; - return (size[0] < 3 && size[1] < 3 && size[2] < 3); + return false; } void Model::convert_from_imperial_units() { double in_to_mm = 25.4; - for (ModelObject* o : this->objects) - o->scale_mesh_after_creation(Vec3d(in_to_mm, in_to_mm, in_to_mm)); + for (ModelObject* obj : this->objects) + if (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)); } void Model::adjust_min_z() @@ -1273,6 +1268,27 @@ void ModelObject::split(ModelObjectPtrs* new_objects) return; } +void ModelObject::merge() +{ + if (this->volumes.size() == 1) { + // We can't merge meshes if there's just one volume + return; + } + + TriangleMesh mesh; + + for (ModelVolume* volume : volumes) + if (!volume->mesh().empty()) + mesh.merge(volume->mesh()); + mesh.repair(); + + this->clear_volumes(); + ModelVolume* vol = this->add_volume(mesh); + + if (!vol) + return; +} + // Support for non-uniform scaling of instances. If an instance is rotated by angles, which are not multiples of ninety degrees, // then the scaling in world coordinate system is not representable by the Geometry::Transformation structure. // This situation is solved by baking in the instance transformation into the mesh vertices. |