Arrangement is still not working, update is probably broken.

This commit is contained in:
tamasmeszaros 2018-11-21 11:07:08 +01:00
parent 897ca1aa44
commit 2fffb0c2ff
2 changed files with 28 additions and 22 deletions

View File

@ -508,32 +508,36 @@ ShapeData2D projectModelFromTop(const Slic3r::Model &model) {
ret.reserve(s);
for(auto objptr : model.objects) {
for(ModelObject* objptr : model.objects) {
if(objptr) {
auto rmesh = objptr->raw_mesh();
TriangleMesh rmesh = objptr->raw_mesh();
for(auto objinst : objptr->instances) {
ModelInstance * finst = objptr->instances.front();
// Object instances should carry the same scaling and
// x, y rotation that is why we use the first instance
rmesh.scale(finst->get_scaling_factor());
rmesh.rotate_x(float(finst->get_rotation()(X)));
rmesh.rotate_y(float(finst->get_rotation()(Y)));
// TODO export the exact 2D projection
auto p = rmesh.convex_hull();
p.make_clockwise();
p.append(p.first_point());
auto clpath = Slic3rMultiPoint_to_ClipperPath(p);
for(ModelInstance* objinst : objptr->instances) {
if(objinst) {
Slic3r::TriangleMesh tmpmesh = rmesh;
ClipperLib::PolygonImpl pn;
// CHECK_ME -> is the following correct ?
tmpmesh.scale(objinst->get_scaling_factor());
// TODO export the exact 2D projection
auto p = tmpmesh.convex_hull();
p.make_clockwise();
p.append(p.first_point());
pn.Contour = Slic3rMultiPoint_to_ClipperPath( p );
pn.Contour = clpath;
// Efficient conversion to item.
Item item(std::move(pn));
// Invalid geometries would throw exceptions when arranging
if(item.vertexCount() > 3) {
// CHECK_ME -> is the following correct or it should take in account all three rotations ?
item.rotation(objinst->get_rotation(Z));
item.translation({
ClipperLib::cInt(objinst->get_offset(X)/SCALING_FACTOR),
@ -565,9 +569,10 @@ void applyResult(
// appropriately
auto off = item.translation();
Radians rot = item.rotation();
Vec3d foff(off.X*SCALING_FACTOR + batch_offset,
off.Y*SCALING_FACTOR,
inst_ptr->get_offset()(2));
inst_ptr->get_offset()(Z));
// write the transformation data into the model instance
inst_ptr->set_rotation(Z, rot);

View File

@ -1589,6 +1589,7 @@ void Plater::priv::arrange()
// Guard the arrange process
arranging.store(true);
// Disable the arrange button (to prevent reentrancies, we will call wxYied)
_3DScene::enable_toolbar_item(canvas3D, "arrange", can_arrange());
this->background_process.stop();
@ -1608,7 +1609,8 @@ void Plater::priv::arrange()
statusbar()->set_status_text(msg);
// ok, this is dangerous, but we are protected by the atomic flag
// 'arranging'. This call is needed for the cancel button to work.
// 'arranging' and the arrange button is also disabled.
// This call is needed for the cancel button to work.
wxYieldIfNeeded();
};
@ -1657,12 +1659,11 @@ void Plater::priv::arrange()
statusbar()->set_cancel_callback(); // remove cancel button
arranging.store(false);
this->schedule_background_process();
// ignore arrange failures on purpose: user has visual feedback and we
// don't need to warn him when parts don't fit in print bed
// We enable back the arrange button
_3DScene::enable_toolbar_item(canvas3D, "arrange", can_arrange());
// FIXME: none of the following seem to work now. (update did the job previously)
// _3DScene::reload_scene(canvas3D, false);
update();
}