trying to fix broken arrange on master
This commit is contained in:
commit
87b96f4c09
4 changed files with 38 additions and 29 deletions
|
@ -508,32 +508,36 @@ ShapeData2D projectModelFromTop(const Slic3r::Model &model) {
|
||||||
|
|
||||||
ret.reserve(s);
|
ret.reserve(s);
|
||||||
|
|
||||||
for(auto objptr : model.objects) {
|
for(ModelObject* objptr : model.objects) {
|
||||||
if(objptr) {
|
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) {
|
if(objinst) {
|
||||||
Slic3r::TriangleMesh tmpmesh = rmesh;
|
|
||||||
ClipperLib::PolygonImpl pn;
|
ClipperLib::PolygonImpl pn;
|
||||||
|
pn.Contour = clpath;
|
||||||
// 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 );
|
|
||||||
|
|
||||||
// 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) {
|
||||||
// CHECK_ME -> is the following correct or it should take in account all three rotations ?
|
|
||||||
item.rotation(objinst->get_rotation(Z));
|
item.rotation(objinst->get_rotation(Z));
|
||||||
item.translation({
|
item.translation({
|
||||||
ClipperLib::cInt(objinst->get_offset(X)/SCALING_FACTOR),
|
ClipperLib::cInt(objinst->get_offset(X)/SCALING_FACTOR),
|
||||||
|
@ -565,9 +569,10 @@ void applyResult(
|
||||||
// appropriately
|
// appropriately
|
||||||
auto off = item.translation();
|
auto off = item.translation();
|
||||||
Radians rot = item.rotation();
|
Radians rot = item.rotation();
|
||||||
|
|
||||||
Vec3d foff(off.X*SCALING_FACTOR + batch_offset,
|
Vec3d foff(off.X*SCALING_FACTOR + batch_offset,
|
||||||
off.Y*SCALING_FACTOR,
|
off.Y*SCALING_FACTOR,
|
||||||
inst_ptr->get_offset()(2));
|
inst_ptr->get_offset()(Z));
|
||||||
|
|
||||||
// write the transformation data into the model instance
|
// write the transformation data into the model instance
|
||||||
inst_ptr->set_rotation(Z, rot);
|
inst_ptr->set_rotation(Z, rot);
|
||||||
|
|
|
@ -133,6 +133,15 @@ void SLAPrint::process()
|
||||||
double ilhd = m_material_config.initial_layer_height.getFloat();
|
double ilhd = m_material_config.initial_layer_height.getFloat();
|
||||||
auto ilh = float(ilhd);
|
auto ilh = float(ilhd);
|
||||||
|
|
||||||
|
// The slicing will be performed on an imaginary 1D grid which starts from
|
||||||
|
// the bottom of the bounding box created around the supported model. So
|
||||||
|
// the first layer which is usually thicker will be part of the supports
|
||||||
|
// not the model geometry. Exception is when the model is not in the air
|
||||||
|
// (elevation is zero) and no pad creation was requested. In this case the
|
||||||
|
// model geometry starts on the ground level and the initial layer is part
|
||||||
|
// of it. In any case, the model and the supports have to be sliced in the
|
||||||
|
// same imaginary grid (the height vector argument to TriangleMeshSlicer).
|
||||||
|
|
||||||
// Slicing the model object. This method is oversimplified and needs to
|
// Slicing the model object. This method is oversimplified and needs to
|
||||||
// be compared with the fff slicing algorithm for verification
|
// be compared with the fff slicing algorithm for verification
|
||||||
auto slice_model = [this, ilh, ilhd](SLAPrintObject& po) {
|
auto slice_model = [this, ilh, ilhd](SLAPrintObject& po) {
|
||||||
|
@ -152,7 +161,7 @@ void SLAPrint::process()
|
||||||
std::vector<float> heights;
|
std::vector<float> heights;
|
||||||
|
|
||||||
// The first layer (the one before the initial height) is added only
|
// The first layer (the one before the initial height) is added only
|
||||||
// if the there is no pad and no elevation value
|
// if there is no pad and no elevation value
|
||||||
if(minZ >= gnd) heights.emplace_back(minZ);
|
if(minZ >= gnd) heights.emplace_back(minZ);
|
||||||
|
|
||||||
for(float h = minZ + ilh; h < maxZ; h += flh)
|
for(float h = minZ + ilh; h < maxZ; h += flh)
|
||||||
|
|
|
@ -123,12 +123,6 @@ class TriangleMesh;
|
||||||
* metadata for the support geometries and their slicing. It should also
|
* metadata for the support geometries and their slicing. It should also
|
||||||
* dispatch the SLA printing configuration values to the appropriate calculation
|
* dispatch the SLA printing configuration values to the appropriate calculation
|
||||||
* steps.
|
* steps.
|
||||||
*
|
|
||||||
* TODO (decide): The last important feature is the support for visualization
|
|
||||||
* which (at least for now) will be implemented as a method(s) returning the
|
|
||||||
* triangle meshes or receiving the rendering canvas and drawing on that
|
|
||||||
* directly.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class SLAPrint : public PrintBaseWithState<SLAPrintStep, slapsCount>
|
class SLAPrint : public PrintBaseWithState<SLAPrintStep, slapsCount>
|
||||||
{
|
{
|
||||||
|
|
|
@ -1589,6 +1589,7 @@ void Plater::priv::arrange()
|
||||||
// Guard the arrange process
|
// Guard the arrange process
|
||||||
arranging.store(true);
|
arranging.store(true);
|
||||||
|
|
||||||
|
// Disable the arrange button (to prevent reentrancies, we will call wxYied)
|
||||||
_3DScene::enable_toolbar_item(canvas3D, "arrange", can_arrange());
|
_3DScene::enable_toolbar_item(canvas3D, "arrange", can_arrange());
|
||||||
|
|
||||||
this->background_process.stop();
|
this->background_process.stop();
|
||||||
|
@ -1608,7 +1609,8 @@ void Plater::priv::arrange()
|
||||||
statusbar()->set_status_text(msg);
|
statusbar()->set_status_text(msg);
|
||||||
|
|
||||||
// ok, this is dangerous, but we are protected by the atomic flag
|
// 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();
|
wxYieldIfNeeded();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1657,12 +1659,11 @@ void Plater::priv::arrange()
|
||||||
statusbar()->set_cancel_callback(); // remove cancel button
|
statusbar()->set_cancel_callback(); // remove cancel button
|
||||||
arranging.store(false);
|
arranging.store(false);
|
||||||
|
|
||||||
this->schedule_background_process();
|
// We enable back the arrange button
|
||||||
|
|
||||||
// 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
|
|
||||||
|
|
||||||
_3DScene::enable_toolbar_item(canvas3D, "arrange", can_arrange());
|
_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();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue