WIP: SLAPrintObjectConfig, SLAPrint / SLAPrintObject initialization.

This commit is contained in:
bubnikv 2018-11-09 12:02:42 +01:00
parent 06a51f9ed3
commit 870c435e1b
6 changed files with 92 additions and 20 deletions

View file

@ -453,7 +453,7 @@ namespace client
param1.data.d = d; param1.data.d = d;
param1.type = TYPE_DOUBLE; param1.type = TYPE_DOUBLE;
} else { } else {
int i = 0.; int i = 0;
switch (fun) { switch (fun) {
case FUNCTION_MIN: i = std::min(param1.as_i(), param2.as_i()); break; case FUNCTION_MIN: i = std::min(param1.as_i(), param2.as_i()); break;
case FUNCTION_MAX: i = std::max(param1.as_i(), param2.as_i()); break; case FUNCTION_MAX: i = std::max(param1.as_i(), param2.as_i()); break;

View file

@ -270,8 +270,8 @@ template<typename PrintType, typename PrintObjectStepEnum, const size_t COUNT>
class PrintObjectBaseWithState : public PrintObjectBase class PrintObjectBaseWithState : public PrintObjectBase
{ {
public: public:
Print* print() { return m_print; } PrintType* print() { return m_print; }
const Print* print() const { return m_print; } const PrintType* print() const { return m_print; }
bool is_step_done(PrintObjectStepEnum step) const { return m_state.is_done(step); } bool is_step_done(PrintObjectStepEnum step) const { return m_state.is_done(step); }

View file

@ -2770,10 +2770,10 @@ StaticPrintConfig::StaticCache<class Slic3r::HostConfig> HostConfig::s_ca
StaticPrintConfig::StaticCache<class Slic3r::FullPrintConfig> FullPrintConfig::s_cache_FullPrintConfig; StaticPrintConfig::StaticCache<class Slic3r::FullPrintConfig> FullPrintConfig::s_cache_FullPrintConfig;
StaticPrintConfig::StaticCache<class Slic3r::SLAMaterialConfig> SLAMaterialConfig::s_cache_SLAMaterialConfig; StaticPrintConfig::StaticCache<class Slic3r::SLAMaterialConfig> SLAMaterialConfig::s_cache_SLAMaterialConfig;
StaticPrintConfig::StaticCache<class Slic3r::SLAPrintObjectConfig> SLAPrintObjectConfig::s_cache_SLAPrintObjectConfig;
StaticPrintConfig::StaticCache<class Slic3r::SLAPrinterConfig> SLAPrinterConfig::s_cache_SLAPrinterConfig; StaticPrintConfig::StaticCache<class Slic3r::SLAPrinterConfig> SLAPrinterConfig::s_cache_SLAPrinterConfig;
StaticPrintConfig::StaticCache<class Slic3r::SLAFullPrintConfig> SLAFullPrintConfig::s_cache_SLAFullPrintConfig; StaticPrintConfig::StaticCache<class Slic3r::SLAFullPrintConfig> SLAFullPrintConfig::s_cache_SLAFullPrintConfig;
CLIConfigDef::CLIConfigDef() CLIConfigDef::CLIConfigDef()
{ {
ConfigOptionDef *def; ConfigOptionDef *def;

View file

@ -898,11 +898,23 @@ protected:
} }
}; };
class SLAPrintObjectConfig : public StaticPrintConfig
{
STATIC_PRINT_CONFIG_CACHE(SLAPrintObjectConfig)
public:
ConfigOptionFloat layer_height;
// supports
protected:
void initialize(StaticCacheBase &cache, const char *base_ptr)
{
OPT_PTR(layer_height);
}
};
class SLAMaterialConfig : public StaticPrintConfig class SLAMaterialConfig : public StaticPrintConfig
{ {
STATIC_PRINT_CONFIG_CACHE(SLAMaterialConfig) STATIC_PRINT_CONFIG_CACHE(SLAMaterialConfig)
public: public:
ConfigOptionFloat layer_height;
ConfigOptionFloat initial_layer_height; ConfigOptionFloat initial_layer_height;
ConfigOptionFloat exposure_time; ConfigOptionFloat exposure_time;
ConfigOptionFloat initial_exposure_time; ConfigOptionFloat initial_exposure_time;
@ -911,7 +923,6 @@ public:
protected: protected:
void initialize(StaticCacheBase &cache, const char *base_ptr) void initialize(StaticCacheBase &cache, const char *base_ptr)
{ {
OPT_PTR(layer_height);
OPT_PTR(initial_layer_height); OPT_PTR(initial_layer_height);
OPT_PTR(exposure_time); OPT_PTR(exposure_time);
OPT_PTR(initial_exposure_time); OPT_PTR(initial_exposure_time);
@ -946,10 +957,10 @@ protected:
} }
}; };
class SLAFullPrintConfig : public SLAPrinterConfig, public SLAMaterialConfig class SLAFullPrintConfig : public SLAPrinterConfig, public SLAPrintObjectConfig, public SLAMaterialConfig
{ {
STATIC_PRINT_CONFIG_CACHE_DERIVED(SLAFullPrintConfig) STATIC_PRINT_CONFIG_CACHE_DERIVED(SLAFullPrintConfig)
SLAFullPrintConfig() : SLAPrinterConfig(0), SLAMaterialConfig(0) { initialize_cache(); *this = s_cache_SLAFullPrintConfig.defaults(); } SLAFullPrintConfig() : SLAPrinterConfig(0), SLAPrintObjectConfig(0), SLAMaterialConfig(0) { initialize_cache(); *this = s_cache_SLAFullPrintConfig.defaults(); }
public: public:
// Validate the SLAFullPrintConfig. Returns an empty string on success, otherwise an error message is returned. // Validate the SLAFullPrintConfig. Returns an empty string on success, otherwise an error message is returned.
@ -957,10 +968,11 @@ public:
protected: protected:
// Protected constructor to be called to initialize ConfigCache::m_default. // Protected constructor to be called to initialize ConfigCache::m_default.
SLAFullPrintConfig(int) : SLAPrinterConfig(0), SLAMaterialConfig(0) {} SLAFullPrintConfig(int) : SLAPrinterConfig(0), SLAPrintObjectConfig(0), SLAMaterialConfig(0) {}
void initialize(StaticCacheBase &cache, const char *base_ptr) void initialize(StaticCacheBase &cache, const char *base_ptr)
{ {
this->SLAPrinterConfig ::initialize(cache, base_ptr); this->SLAPrinterConfig ::initialize(cache, base_ptr);
this->SLAPrintObjectConfig::initialize(cache, base_ptr);
this->SLAMaterialConfig ::initialize(cache, base_ptr); this->SLAMaterialConfig ::initialize(cache, base_ptr);
} }
}; };

View file

@ -4,10 +4,38 @@ namespace Slic3r {
void SLAPrint::clear() void SLAPrint::clear()
{ {
tbb::mutex::scoped_lock lock(this->cancel_mutex());
// The following call should stop background processing if it is running.
this->invalidate_all_steps();
for (SLAPrintObject *object : m_objects)
delete object;
m_objects.clear();
} }
SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, const DynamicPrintConfig &config) SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, const DynamicPrintConfig &config)
{ {
if (m_objects.empty())
return APPLY_STATUS_UNCHANGED;
// Grab the lock for the Print / PrintObject milestones.
tbb::mutex::scoped_lock lock(this->cancel_mutex());
// Temporary quick fix, just invalidate everything.
{
for (SLAPrintObject *print_object : m_objects) {
print_object->invalidate_all_steps();
delete print_object;
}
m_objects.clear();
this->invalidate_all_steps();
// Copy the model by value (deep copy), keep the Model / ModelObject / ModelInstance / ModelVolume IDs.
m_model.assign_copy(model);
// Generate new SLAPrintObjects.
for (const ModelObject *model_object : m_model.objects) {
//TODO
}
}
return APPLY_STATUS_INVALIDATED; return APPLY_STATUS_INVALIDATED;
} }

View file

@ -8,32 +8,64 @@
namespace Slic3r { namespace Slic3r {
enum SLAPrintStep { enum SLAPrintStep {
// slapsSliceModel,
// slapsSliceSupports,
slapsRasterize, slapsRasterize,
slapsValidate,
slapsCount slapsCount
}; };
enum SLAPrintObjectStep { enum SLAPrintObjectStep {
slaposObjectSlice,
slaposSupportIslands,
slaposSupportPoints, slaposSupportPoints,
slaposSupportTree, slaposSupportTree,
slaposBasePool, slaposBasePool,
slaposSliceSupports,
slaposCount slaposCount
}; };
class SLAPrint; class SLAPrint;
class SLAPrintObject : public PrintObjectBaseWithState<Print, SLAPrintObjectStep, slaposCount> class SLAPrintObject : public PrintObjectBaseWithState<SLAPrint, SLAPrintObjectStep, slaposCount>
{ {
private: // Prevents erroneous use by other classes. private: // Prevents erroneous use by other classes.
typedef PrintObjectBaseWithState<Print, SLAPrintObjectStep, slaposCount> Inherited; typedef PrintObjectBaseWithState<Print, SLAPrintObjectStep, slaposCount> Inherited;
public: public:
const ModelObject* model_object() const { return m_model_object; }
ModelObject* model_object() { return m_model_object; }
protected:
// to be called from SLAPrint only.
friend class SLAPrint;
SLAPrintObject(SLAPrint* print, ModelObject* model_object);
~SLAPrintObject() {}
void config_apply(const ConfigBase &other, bool ignore_nonexistent = false) { this->m_config.apply(other, ignore_nonexistent); }
void config_apply_only(const ConfigBase &other, const t_config_option_keys &keys, bool ignore_nonexistent = false)
{ this->m_config.apply_only(other, keys, ignore_nonexistent); }
void set_trafo(const Transform3d& trafo) { m_trafo = trafo; }
struct Instance {
// Slic3r::Point objects in scaled G-code coordinates
Point shift;
// Rotation along the Z axis, in radians.
float rotation;
};
bool set_instances(const std::vector<Instance> &instances);
// Invalidates the step, and its depending steps in SLAPrintObject and SLAPrint.
bool invalidate_step(SLAPrintObjectStep step);
private: private:
// Points to the instance owned by a Model stored at the parent SLAPrint instance.
ModelObject *m_model_object;
// Object specific configuration, pulled from the configuration layer.
SLAPrintObjectConfig m_config;
// Translation in Z + Rotation by Y and Z + Scaling / Mirroring.
Transform3d m_trafo = Transform3d::Identity();
std::vector<Instance> m_instances;
// sla::EigenMesh3D emesh; // sla::EigenMesh3D emesh;
std::vector<Vec2f> instances;
// Transform3f tr;
// std::unique_ptr<sla::SLASupportTree> support_tree_ptr; // std::unique_ptr<sla::SLASupportTree> support_tree_ptr;
// SlicedSupports slice_cache; // SlicedSupports slice_cache;