Mostly working, inefficiencies remain, status indication partly broken

This commit is contained in:
tamasmeszaros 2020-09-04 17:51:22 +02:00
parent 9f3e7617d8
commit 0d4c67b9a3
5 changed files with 264 additions and 124 deletions

View file

@ -200,6 +200,8 @@ void GLGizmoRotate::on_render_for_picking() const
glsafe(::glPopMatrix());
}
GLGizmoRotate3D::RotoptimzeWindow::RotoptimzeWindow(ImGuiWrapper * imgui,
State & state,
const Alignment &alignment)
@ -215,20 +217,26 @@ GLGizmoRotate3D::RotoptimzeWindow::RotoptimzeWindow(ImGuiWrapper * imgui,
y = std::min(y, alignment.bottom_limit - win_h);
ImGui::SetWindowPos(ImVec2(x, y), ImGuiCond_Always);
ImGui::SliderFloat(_L("Accuracy").c_str(), &state.accuracy, 0.01f, 1.f, "%.1f");
static constexpr const char * button_txt = L("Optimize orientation");
static constexpr const char * slider_txt = L("Accuracy");
if (imgui->button(_L("Optimize orientation"))) {
float button_width = imgui->calc_text_size(_(button_txt)).x;
ImGui::PushItemWidth(100.);
//if (imgui->button(_(button_txt))) {
if (ImGui::ArrowButton(_(button_txt).c_str(), ImGuiDir_Down)){
std::cout << "Blip" << std::endl;
}
ImGui::SliderFloat(_(slider_txt).c_str(), &state.accuracy, 0.01f, 1.f, "%.1f");
static const std::vector<std::string> options = {
_L("Least supports").ToStdString(),
_L("Suface quality").ToStdString()
};
if (imgui->combo(_L("Choose method"), options, state.method) ) {
std::cout << "method: " << state.method << std::endl;
}
// if (imgui->combo(_L("Choose method"), options, state.method) ) {
// std::cout << "method: " << state.method << std::endl;
// }
}
@ -243,18 +251,10 @@ void GLGizmoRotate3D::on_render_input_window(float x, float y, float bottom_limi
if (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA)
return;
// m_rotoptimizewin_state.mobj = ;
RotoptimzeWindow popup{m_imgui, m_rotoptimizewin_state, {x, y, bottom_limit}};
// TODO:
// if ((last_h != win_h) || (last_y != y))
// {
// // ask canvas for another frame to render the window in the correct position
// m_parent.request_extra_frame();
// if (last_h != win_h)
// last_h = win_h;
// if (last_y != y)
// last_y = y;
// }
// m_rotoptimizewin_state.mobj = ?;
// RotoptimzeWindow popup{m_imgui, m_rotoptimizewin_state, {x, y, bottom_limit}};
}

View file

@ -136,12 +136,14 @@ protected:
}
void on_render_input_window(float x, float y, float bottom_limit) override;
private:
class RotoptimzeWindow {
ImGuiWrapper *m_imgui = nullptr;
public:
struct State {
enum Metods { mMinSupportPoints, mLegacy };
@ -152,7 +154,10 @@ private:
struct Alignment { float x, y, bottom_limit; };
RotoptimzeWindow(ImGuiWrapper *imgui, State &settings, const Alignment &bottom_limit);
RotoptimzeWindow(ImGuiWrapper * imgui,
State & state,
const Alignment &bottom_limit);
~RotoptimzeWindow();
RotoptimzeWindow(const RotoptimzeWindow&) = delete;

View file

@ -4,6 +4,7 @@
#include "libslic3r/SLA/Rotfinder.hpp"
#include "libslic3r/MinAreaBoundingBox.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/SLAPrint.hpp"
#include "slic3r/GUI/Plater.hpp"
@ -15,9 +16,26 @@ void RotoptimizeJob::process()
if (obj_idx < 0) { return; }
ModelObject *o = m_plater->model().objects[size_t(obj_idx)];
const SLAPrintObject *po = m_plater->sla_print().objects()[size_t(obj_idx)];
if (!o || !po) return;
TriangleMesh mesh = o->raw_mesh();
mesh.require_shared_vertices();
// for (auto inst : o->instances) {
// Transform3d tr = Transform3d::Identity();
// tr.rotate(Eigen::AngleAxisd(inst->get_rotation(Z), Vec3d::UnitZ()));
// tr.rotate(Eigen::AngleAxisd(inst->get_rotation(Y), Vec3d::UnitY()));
// tr.rotate(Eigen::AngleAxisd(inst->get_rotation(X), Vec3d::UnitX()));
// double score = sla::get_model_supportedness(*po, tr);
// std::cout << "Model supportedness before: " << score << std::endl;
// }
auto r = sla::find_best_rotation(
*o,
*po,
1.f,
[this](unsigned s) {
if (s < 100)