mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-11-02 20:51:23 -07:00
Method selection implemented
This commit is contained in:
parent
4eb13a407f
commit
0194094afa
6 changed files with 181 additions and 18 deletions
|
|
@ -8,8 +8,29 @@
|
|||
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "libslic3r/AppConfig.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
void RotoptimizeJob::prepare()
|
||||
{
|
||||
std::string accuracy_str =
|
||||
wxGetApp().app_config->get("rotoptimize", "accuracy");
|
||||
|
||||
std::string method_str =
|
||||
wxGetApp().app_config->get("rotoptimize", "method_id");
|
||||
|
||||
if (!accuracy_str.empty())
|
||||
m_accuracy = std::stof(accuracy_str);
|
||||
|
||||
if (!method_str.empty())
|
||||
m_method_id = std::stoi(method_str);
|
||||
|
||||
m_accuracy = std::max(0.f, std::min(m_accuracy, 1.f));
|
||||
m_method_id = std::max(size_t(0), std::min(get_methods_count() - 1, m_method_id));
|
||||
}
|
||||
|
||||
void RotoptimizeJob::process()
|
||||
{
|
||||
int obj_idx = m_plater->get_selected_object_idx();
|
||||
|
|
@ -21,7 +42,7 @@ void RotoptimizeJob::process()
|
|||
|
||||
if (!o || !po) return;
|
||||
|
||||
Vec2d r = sla::find_best_rotation(*po, 0.75f, [this](int s) {
|
||||
Vec2d r = Methods[m_method_id].findfn(*po, m_accuracy, [this](int s) {
|
||||
if (s > 0 && s < 100)
|
||||
update_status(s, _(L("Searching for optimal orientation")));
|
||||
|
||||
|
|
|
|||
|
|
@ -3,17 +3,58 @@
|
|||
|
||||
#include "PlaterJob.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
#include "libslic3r/SLA/Rotfinder.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class SLAPrintObject;
|
||||
|
||||
namespace GUI {
|
||||
|
||||
class RotoptimizeJob : public PlaterJob
|
||||
{
|
||||
using FindFn = std::function<Vec2d(const SLAPrintObject & po,
|
||||
float accuracy,
|
||||
sla::RotOptimizeStatusCB statuscb)>;
|
||||
|
||||
struct FindMethod { std::string name; FindFn findfn; };
|
||||
|
||||
static inline const FindMethod Methods[] = {
|
||||
{ L("Best misalignment"), sla::find_best_misalignment_rotation },
|
||||
{ L("Least supports"), sla::find_best_misalignment_rotation }
|
||||
};
|
||||
|
||||
size_t m_method_id = 0;
|
||||
float m_accuracy = 0.75;
|
||||
protected:
|
||||
|
||||
void prepare() override;
|
||||
|
||||
public:
|
||||
|
||||
RotoptimizeJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater)
|
||||
: PlaterJob{std::move(pri), plater}
|
||||
{}
|
||||
|
||||
void process() override;
|
||||
void finalize() override;
|
||||
|
||||
static constexpr size_t get_methods_count() { return std::size(Methods); }
|
||||
static const auto & get_method_names()
|
||||
{
|
||||
static bool m_method_names_valid = false;
|
||||
static std::array<std::string, std::size(Methods)> m_method_names;
|
||||
|
||||
if (!m_method_names_valid) {
|
||||
|
||||
for (size_t i = 0; i < std::size(Methods); ++i)
|
||||
m_method_names[i] = _utf8(Methods[i].name);
|
||||
|
||||
m_method_names_valid = true;
|
||||
}
|
||||
|
||||
return m_method_names;
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue