Merge branch 'master' of https://github.com/prusa3d/Slic3r into et_copy_and_paste

This commit is contained in:
Enrico Turri 2019-04-18 13:35:59 +02:00
commit 1ffc6b5e64
8 changed files with 817 additions and 797 deletions

View File

@ -321,7 +321,7 @@ include_directories(${GLEW_INCLUDE_DIRS})
# l10n # l10n
set(L10N_DIR "${SLIC3R_RESOURCES_DIR}/localization") set(L10N_DIR "${SLIC3R_RESOURCES_DIR}/localization")
add_custom_target(pot add_custom_target(pot
COMMAND xgettext --keyword=L --from-code=UTF-8 --debug COMMAND xgettext --keyword=L --add-comments=TRN --from-code=UTF-8 --debug
-f "${L10N_DIR}/list.txt" -f "${L10N_DIR}/list.txt"
-o "${L10N_DIR}/Slic3rPE.pot" -o "${L10N_DIR}/Slic3rPE.pot"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}

View File

@ -46,7 +46,7 @@ https://github.com/prusa3d/Slic3r/tree/master/resources/localization/list.txt.
2. Create template file(*.POT) with GNUgettext command: 2. Create template file(*.POT) with GNUgettext command:
``` ```
xgettext --keyword=L --from-code=UTF-8 --debug -o Slic3rPE.pot -f list.txt xgettext --keyword=L --add-comments=TRN --from-code=UTF-8 --debug -o Slic3rPE.pot -f list.txt
``` ```
Use flag `--from-code=UTF-8` to specify that the source strings are in UTF-8 encoding Use flag `--from-code=UTF-8` to specify that the source strings are in UTF-8 encoding

File diff suppressed because it is too large Load Diff

View File

@ -943,7 +943,7 @@ BoundingBoxf3 ModelObject::instance_bounding_box(size_t instance_idx, bool dont_
// Calculate 2D convex hull of of a projection of the transformed printable volumes into the XY plane. // Calculate 2D convex hull of of a projection of the transformed printable volumes into the XY plane.
// This method is cheap in that it does not make any unnecessary copy of the volume meshes. // This method is cheap in that it does not make any unnecessary copy of the volume meshes.
// This method is used by the auto arrange function. // This method is used by the auto arrange function.
Polygon ModelObject::convex_hull_2d(const Transform3d &trafo_instance) Polygon ModelObject::convex_hull_2d(const Transform3d &trafo_instance) const
{ {
Points pts; Points pts;
for (const ModelVolume *v : this->volumes) for (const ModelVolume *v : this->volumes)

View File

@ -234,7 +234,7 @@ public:
// Calculate 2D convex hull of of a projection of the transformed printable volumes into the XY plane. // Calculate 2D convex hull of of a projection of the transformed printable volumes into the XY plane.
// This method is cheap in that it does not make any unnecessary copy of the volume meshes. // This method is cheap in that it does not make any unnecessary copy of the volume meshes.
// This method is used by the auto arrange function. // This method is used by the auto arrange function.
Polygon convex_hull_2d(const Transform3d &trafo_instance); Polygon convex_hull_2d(const Transform3d &trafo_instance) const;
#if ENABLE_VOLUMES_CENTERING_FIXES #if ENABLE_VOLUMES_CENTERING_FIXES
void center_around_origin(bool include_modifiers = true); void center_around_origin(bool include_modifiers = true);

View File

@ -1,5 +1,6 @@
#include "ModelArrange.hpp" #include "ModelArrange.hpp"
#include "Model.hpp" #include "Model.hpp"
#include "Geometry.hpp"
#include "SVG.hpp" #include "SVG.hpp"
#include <libnest2d.h> #include <libnest2d.h>
@ -551,7 +552,7 @@ ShapeData2D projectModelFromTop(const Slic3r::Model &model) {
ret.reserve(s); ret.reserve(s);
for(ModelObject* objptr : model.objects) { for(ModelObject* objptr : model.objects) {
if(objptr) { if (! objptr->instances.empty()) {
// TODO export the exact 2D projection. Cannot do it as libnest2d // TODO export the exact 2D projection. Cannot do it as libnest2d
// does not support concave shapes (yet). // does not support concave shapes (yet).
@ -572,23 +573,23 @@ ShapeData2D projectModelFromTop(const Slic3r::Model &model) {
clpath = Slic3rMultiPoint_to_ClipperPath(p); clpath = Slic3rMultiPoint_to_ClipperPath(p);
} }
Vec3d rotation0 = objptr->instances.front()->get_rotation();
rotation0(2) = 0.;
for(ModelInstance* objinst : objptr->instances) { for(ModelInstance* objinst : objptr->instances) {
if(objinst) { ClipperLib::Polygon pn;
ClipperLib::Polygon pn; pn.Contour = clpath;
pn.Contour = clpath;
// Efficient conversion to item. // Efficient conversion to item.
Item item(std::move(pn)); Item item(std::move(pn));
// Invalid geometries would throw exceptions when arranging // Invalid geometries would throw exceptions when arranging
if(item.vertexCount() > 3) { if(item.vertexCount() > 3) {
item.rotation(objinst->get_rotation(Z)); item.rotation(float(Geometry::rotation_diff_z(rotation0, objinst->get_rotation()))),
item.translation({ item.translation({
ClipperLib::cInt(objinst->get_offset(X)/SCALING_FACTOR), ClipperLib::cInt(objinst->get_offset(X)/SCALING_FACTOR),
ClipperLib::cInt(objinst->get_offset(Y)/SCALING_FACTOR) ClipperLib::cInt(objinst->get_offset(Y)/SCALING_FACTOR)
}); });
ret.emplace_back(objinst, item); ret.emplace_back(objinst, item);
}
} }
} }
} }

View File

@ -1139,31 +1139,29 @@ std::string Print::validate() const
// Check horizontal clearance. // Check horizontal clearance.
{ {
Polygons convex_hulls_other; Polygons convex_hulls_other;
for (const PrintObject *object : m_objects) { for (const PrintObject *print_object : m_objects) {
assert(! print_object->model_object()->instances.empty());
assert(! print_object->copies().empty());
// Get convex hull of all meshes assigned to this print object. // Get convex hull of all meshes assigned to this print object.
Polygon convex_hull; ModelInstance *model_instance0 = print_object->model_object()->instances.front();
{ Vec3d rotation = model_instance0->get_rotation();
Polygons mesh_convex_hulls; rotation.z() = 0.;
for (const std::vector<int> &volumes : object->region_volumes) // Calculate the convex hull of a printable object centered around X=0,Y=0.
for (int volume_id : volumes)
mesh_convex_hulls.emplace_back(object->model_object()->volumes[volume_id]->mesh.convex_hull());
// make a single convex hull for all of them
convex_hull = Slic3r::Geometry::convex_hull(mesh_convex_hulls);
}
// Apply the same transformations we apply to the actual meshes when slicing them.
object->model_object()->instances.front()->transform_polygon(&convex_hull);
// Grow convex hull with the clearance margin. // Grow convex hull with the clearance margin.
// FIXME: Arrangement has different parameters for offsetting (jtMiter, limit 2) // FIXME: Arrangement has different parameters for offsetting (jtMiter, limit 2)
// which causes that the warning will be showed after arrangement with the // which causes that the warning will be showed after arrangement with the
// appropriate object distance. Even if I set this to jtMiter the warning still shows up. // appropriate object distance. Even if I set this to jtMiter the warning still shows up.
convex_hull = offset(convex_hull, scale_(m_config.extruder_clearance_radius.value)/2, jtRound, scale_(0.1)).front(); Polygon convex_hull0 = offset(
print_object->model_object()->convex_hull_2d(
Geometry::assemble_transform(Vec3d::Zero(), rotation, model_instance0->get_scaling_factor(), model_instance0->get_mirror())),
scale_(m_config.extruder_clearance_radius.value) / 2., jtRound, scale_(0.1)).front();
// Now we check that no instance of convex_hull intersects any of the previously checked object instances. // Now we check that no instance of convex_hull intersects any of the previously checked object instances.
for (const Point &copy : object->m_copies) { for (const Point &copy : print_object->m_copies) {
Polygon p = convex_hull; Polygon convex_hull = convex_hull0;
p.translate(copy); convex_hull.translate(copy);
if (! intersection(convex_hulls_other, p).empty()) if (! intersection(convex_hulls_other, convex_hull).empty())
return L("Some objects are too close; your extruder will collide with them."); return L("Some objects are too close; your extruder will collide with them.");
polygons_append(convex_hulls_other, p); polygons_append(convex_hulls_other, convex_hull);
} }
} }
} }

View File

@ -697,6 +697,7 @@ void SLAPrint::process()
po.closest_slice_record(po.m_slice_index, float(bb3d.min(Z))); po.closest_slice_record(po.m_slice_index, float(bb3d.min(Z)));
if(slindex_it == po.m_slice_index.end()) if(slindex_it == po.m_slice_index.end())
//TRN To be shown at the status bar on SLA slicing error.
throw std::runtime_error(L("Slicing had to be stopped " throw std::runtime_error(L("Slicing had to be stopped "
"due to an internal error.")); "due to an internal error."));