Comments and SLA stage definitions.
This commit is contained in:
parent
97b3d94760
commit
d7baac59ef
3 changed files with 74 additions and 25 deletions
|
@ -1624,28 +1624,27 @@ void GLGizmoSlaSupports::update_mesh()
|
||||||
void GLGizmoSlaSupports::on_deactivate() {
|
void GLGizmoSlaSupports::on_deactivate() {
|
||||||
if(!m_model_object) return;
|
if(!m_model_object) return;
|
||||||
|
|
||||||
sla::Controller supportctl;
|
// sla::Controller supportctl;
|
||||||
std::cout << "Generating supports:" << std::endl;
|
// std::cout << "Generating supports:" << std::endl;
|
||||||
|
|
||||||
// TODO: somehow get the global status indicator
|
// // TODO: somehow get the global status indicator
|
||||||
supportctl.statuscb = [] (unsigned st, const std::string& msg) {
|
// supportctl.statuscb = [] (unsigned st, const std::string& msg) {
|
||||||
std::cout << st << "% " << msg << std::endl;
|
// std::cout << st << "% " << msg << std::endl;
|
||||||
};
|
// };
|
||||||
|
|
||||||
TriangleMesh&& m = m_model_object->raw_mesh();
|
// TriangleMesh&& m = m_model_object->raw_mesh();
|
||||||
auto&& trafo = m_model_object_matrix.cast<float>();
|
// m.transform(m_model_object_matrix);
|
||||||
m.transform(trafo);
|
// auto emesh = sla::to_eigenmesh(m);
|
||||||
auto emesh = sla::to_eigenmesh(m);
|
|
||||||
|
|
||||||
sla::SupportConfig cfg;
|
// sla::SupportConfig cfg;
|
||||||
sla::PointSet input = sla::support_points(*m_model_object, 0 /*instance*/);
|
// sla::PointSet input = sla::support_points(*m_model_object, 0 /*instance*/);
|
||||||
|
|
||||||
sla::SLASupportTree stree(input, emesh, cfg, supportctl);
|
// sla::SLASupportTree stree(input, emesh, cfg, supportctl);
|
||||||
|
|
||||||
TriangleMesh output;
|
// TriangleMesh output;
|
||||||
stree.merged_mesh(output);
|
// stree.merged_mesh(output);
|
||||||
|
|
||||||
_3DScene::reload_scene(m_parent.get_wxglcanvas(), false);
|
// _3DScene::reload_scene(m_parent.get_wxglcanvas(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3f GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos)
|
Vec3f GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos)
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
#include "SLAPrint.hpp"
|
#include "SLAPrint.hpp"
|
||||||
|
#include "GUI.hpp"
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
const std::string SLAPrint::m_stage_labels[] = {
|
||||||
|
"", // IDLE,
|
||||||
|
L("Finding best rotation"), // FIND_ROTATION,
|
||||||
|
L("Scanning model structure"), // SUPPORT_POINTS,
|
||||||
|
L("Generating support tree"), // SUPPORT_TREE,
|
||||||
|
L("Generating base pool"), // BASE_POOL,
|
||||||
|
L("Slicing model"), // SLICE_MODEL,
|
||||||
|
L("Slicing supports"), // SLICE_SUPPORTS,
|
||||||
|
L("Exporting layers"), // EXPORT,
|
||||||
|
L("Prepared for printing"), // DONE,
|
||||||
|
L("SLA print preparation aborted") // ABORT,
|
||||||
|
};
|
||||||
|
|
||||||
void SLAPrint::synch() {
|
void SLAPrint::synch() {
|
||||||
m_gcfg = m_config_reader();
|
m_gcfg = m_config_reader();
|
||||||
// TODO: check model objects and instances
|
// TODO: check model objects and instances
|
||||||
|
|
|
@ -15,7 +15,7 @@ class ModelInstance;
|
||||||
class GLCanvas3D;
|
class GLCanvas3D;
|
||||||
class DynamicPrintConfig;
|
class DynamicPrintConfig;
|
||||||
|
|
||||||
// Ok, this will be the driver to create background threads. Possibly
|
// This will be the driver to create background threads. Possibly
|
||||||
// implemented using a BackgroundSlicingProcess or something derived from that
|
// implemented using a BackgroundSlicingProcess or something derived from that
|
||||||
// The methods should be thread safe, obviously...
|
// The methods should be thread safe, obviously...
|
||||||
class BackgroundProcess {
|
class BackgroundProcess {
|
||||||
|
@ -23,14 +23,23 @@ public:
|
||||||
|
|
||||||
virtual ~BackgroundProcess() {}
|
virtual ~BackgroundProcess() {}
|
||||||
|
|
||||||
|
/// schedule a task on the background
|
||||||
virtual void schedule(std::function<void()> fn) = 0;
|
virtual void schedule(std::function<void()> fn) = 0;
|
||||||
|
|
||||||
|
/// Report status change, used inside the worker thread
|
||||||
virtual void status(unsigned st, const std::string& msg) = 0;
|
virtual void status(unsigned st, const std::string& msg) = 0;
|
||||||
|
|
||||||
|
/// Check whether the calculation was canceled from the UI. Called by the
|
||||||
|
/// worker thread
|
||||||
virtual bool is_canceled() = 0;
|
virtual bool is_canceled() = 0;
|
||||||
|
|
||||||
|
/// Setting up a callback that transfers the input parameters to the worker
|
||||||
|
/// thread. Appropriate synchronization has to be implemented here. A simple
|
||||||
|
/// condition variable and mutex pair should do the job.
|
||||||
virtual void on_input_changed(std::function<void()> synchfn) = 0;
|
virtual void on_input_changed(std::function<void()> synchfn) = 0;
|
||||||
|
|
||||||
|
/// Determine the state of the background process. If something is running
|
||||||
|
/// returns true. If no job is running, returns false.
|
||||||
virtual bool is_running() = 0;
|
virtual bool is_running() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -47,8 +56,9 @@ public:
|
||||||
* triangle meshes or receiving the rendering canvas and drawing on that
|
* triangle meshes or receiving the rendering canvas and drawing on that
|
||||||
* directly.
|
* directly.
|
||||||
*
|
*
|
||||||
* TODO: This class has to be implement the Print interface (not defined yet)
|
* TODO: This class uses the BackgroundProcess interface to create workers and
|
||||||
* to be usable as the input to the BackgroundSlicingProcess.
|
* manage input change events. An appropriate implementation can be derived
|
||||||
|
* from BackgroundSlicingProcess which is now working only with the FDM Print.
|
||||||
*/
|
*/
|
||||||
class SLAPrint /* : public Print */ {
|
class SLAPrint /* : public Print */ {
|
||||||
public:
|
public:
|
||||||
|
@ -57,6 +67,7 @@ public:
|
||||||
BLOCKING, NON_BLOCKING
|
BLOCKING, NON_BLOCKING
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Global SLA printing configuration
|
||||||
struct GlobalConfig {
|
struct GlobalConfig {
|
||||||
double width_mm;
|
double width_mm;
|
||||||
double height_mm;
|
double height_mm;
|
||||||
|
@ -67,6 +78,9 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
// There will be a support tree for every instance of every ModelObject
|
||||||
|
// because if the object is rotated differently, the support should also be
|
||||||
|
// very different
|
||||||
struct PrintObjectInstance {
|
struct PrintObjectInstance {
|
||||||
Transform3f tr;
|
Transform3f tr;
|
||||||
std::unique_ptr<sla::SLASupportTree> support_tree_ptr;
|
std::unique_ptr<sla::SLASupportTree> support_tree_ptr;
|
||||||
|
@ -75,11 +89,14 @@ private:
|
||||||
|
|
||||||
using InstanceMap = std::unordered_map<ModelInstance*, PrintObjectInstance>;
|
using InstanceMap = std::unordered_map<ModelInstance*, PrintObjectInstance>;
|
||||||
|
|
||||||
|
// Every ModelObject will have its PrintObject here. It will contain the
|
||||||
|
// cached index-triangle structure (emesh) and the map of the instance cache
|
||||||
struct PrintObject {
|
struct PrintObject {
|
||||||
sla::EigenMesh3D emesh;
|
sla::EigenMesh3D emesh;
|
||||||
InstanceMap instances;
|
InstanceMap instances;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Map definition for the print objects
|
||||||
using ObjectMap = std::unordered_map<ModelObject*, PrintObject>;
|
using ObjectMap = std::unordered_map<ModelObject*, PrintObject>;
|
||||||
|
|
||||||
// Input data channels: ***************************************************
|
// Input data channels: ***************************************************
|
||||||
|
@ -88,11 +105,12 @@ private:
|
||||||
|
|
||||||
// something to read out the config profiles and return the values we need.
|
// something to read out the config profiles and return the values we need.
|
||||||
std::function<GlobalConfig()> m_config_reader;
|
std::function<GlobalConfig()> m_config_reader;
|
||||||
|
|
||||||
// ************************************************************************
|
// ************************************************************************
|
||||||
|
|
||||||
GlobalConfig m_gcfg;
|
GlobalConfig m_gcfg; // The global SLA print config instance
|
||||||
ObjectMap m_data;
|
ObjectMap m_data; // The model data cache (PrintObject's)
|
||||||
std::shared_ptr<BackgroundProcess> m_process;
|
std::shared_ptr<BackgroundProcess> m_process; // The scheduler
|
||||||
|
|
||||||
// For now it will just stop the whole process and invalidate everything
|
// For now it will just stop the whole process and invalidate everything
|
||||||
void synch();
|
void synch();
|
||||||
|
@ -108,11 +126,29 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum Stages {
|
||||||
|
IDLE,
|
||||||
|
FIND_ROTATION,
|
||||||
|
SUPPORT_POINTS,
|
||||||
|
SUPPORT_TREE,
|
||||||
|
BASE_POOL,
|
||||||
|
SLICE_MODEL,
|
||||||
|
SLICE_SUPPORTS,
|
||||||
|
EXPORT,
|
||||||
|
DONE,
|
||||||
|
ABORT,
|
||||||
|
NUM_STAGES
|
||||||
|
};
|
||||||
|
|
||||||
|
static const std::string m_stage_labels[NUM_STAGES];
|
||||||
|
|
||||||
|
bool run();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SLAPrint(const Model * model,
|
SLAPrint(const Model * model,
|
||||||
std::function<SLAPrint::GlobalConfig(void)> cfgreader = [](){ return SLAPrint::GlobalConfig(); },
|
std::function<SLAPrint::GlobalConfig(void)> cfgreader =
|
||||||
std::shared_ptr<BackgroundProcess> scheduler = {}):
|
[](){ return SLAPrint::GlobalConfig(); },
|
||||||
|
std::shared_ptr<BackgroundProcess> scheduler = {}):
|
||||||
m_model(model), m_config_reader(cfgreader)
|
m_model(model), m_config_reader(cfgreader)
|
||||||
{
|
{
|
||||||
synch();
|
synch();
|
||||||
|
@ -123,7 +159,7 @@ public:
|
||||||
// This will start the calculation using the
|
// This will start the calculation using the
|
||||||
bool start(std::shared_ptr<BackgroundProcess> scheduler);
|
bool start(std::shared_ptr<BackgroundProcess> scheduler);
|
||||||
|
|
||||||
// Get the full support structure (including the supports)
|
// Get the full support structure (including the base pool)
|
||||||
// This should block until the supports are not ready?
|
// This should block until the supports are not ready?
|
||||||
bool support_mesh(TriangleMesh& output, CallType calltype = BLOCKING);
|
bool support_mesh(TriangleMesh& output, CallType calltype = BLOCKING);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue