diff --git a/src/libslic3r/PlaceholderParser.cpp b/src/libslic3r/PlaceholderParser.cpp index 2b11269a03..198872b1d1 100644 --- a/src/libslic3r/PlaceholderParser.cpp +++ b/src/libslic3r/PlaceholderParser.cpp @@ -453,7 +453,7 @@ namespace client param1.data.d = d; param1.type = TYPE_DOUBLE; } else { - int i = 0.; + int i = 0; switch (fun) { 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; diff --git a/src/libslic3r/PrintBase.hpp b/src/libslic3r/PrintBase.hpp index 171afce10c..8e9a6693a9 100644 --- a/src/libslic3r/PrintBase.hpp +++ b/src/libslic3r/PrintBase.hpp @@ -270,8 +270,8 @@ template class PrintObjectBaseWithState : public PrintObjectBase { public: - Print* print() { return m_print; } - const Print* print() const { return m_print; } + PrintType* print() { return m_print; } + const PrintType* print() const { return m_print; } bool is_step_done(PrintObjectStepEnum step) const { return m_state.is_done(step); } diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 20b9c9e9f1..8e8a494926 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2769,10 +2769,10 @@ StaticPrintConfig::StaticCache PrintConfig::s_c StaticPrintConfig::StaticCache HostConfig::s_cache_HostConfig; StaticPrintConfig::StaticCache FullPrintConfig::s_cache_FullPrintConfig; -StaticPrintConfig::StaticCache SLAMaterialConfig::s_cache_SLAMaterialConfig; -StaticPrintConfig::StaticCache SLAPrinterConfig::s_cache_SLAPrinterConfig; -StaticPrintConfig::StaticCache SLAFullPrintConfig::s_cache_SLAFullPrintConfig; - +StaticPrintConfig::StaticCache SLAMaterialConfig::s_cache_SLAMaterialConfig; +StaticPrintConfig::StaticCache SLAPrintObjectConfig::s_cache_SLAPrintObjectConfig; +StaticPrintConfig::StaticCache SLAPrinterConfig::s_cache_SLAPrinterConfig; +StaticPrintConfig::StaticCache SLAFullPrintConfig::s_cache_SLAFullPrintConfig; CLIConfigDef::CLIConfigDef() { diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 87a882c641..ce8a68a2df 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -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 { STATIC_PRINT_CONFIG_CACHE(SLAMaterialConfig) public: - ConfigOptionFloat layer_height; ConfigOptionFloat initial_layer_height; ConfigOptionFloat exposure_time; ConfigOptionFloat initial_exposure_time; @@ -911,7 +923,6 @@ public: protected: void initialize(StaticCacheBase &cache, const char *base_ptr) { - OPT_PTR(layer_height); OPT_PTR(initial_layer_height); OPT_PTR(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) - 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: // Validate the SLAFullPrintConfig. Returns an empty string on success, otherwise an error message is returned. @@ -957,11 +968,12 @@ public: protected: // 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) { - this->SLAPrinterConfig ::initialize(cache, base_ptr); - this->SLAMaterialConfig::initialize(cache, base_ptr); + this->SLAPrinterConfig ::initialize(cache, base_ptr); + this->SLAPrintObjectConfig::initialize(cache, base_ptr); + this->SLAMaterialConfig ::initialize(cache, base_ptr); } }; diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 0366490c5c..73b423a3f5 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -4,10 +4,38 @@ namespace Slic3r { 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) { + 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; } @@ -15,4 +43,4 @@ void SLAPrint::process() { } -} // namespace Slic3r \ No newline at end of file +} // namespace Slic3r diff --git a/src/libslic3r/SLAPrint.hpp b/src/libslic3r/SLAPrint.hpp index 0d45c17046..4a2c621ea1 100644 --- a/src/libslic3r/SLAPrint.hpp +++ b/src/libslic3r/SLAPrint.hpp @@ -8,32 +8,64 @@ namespace Slic3r { enum SLAPrintStep { -// slapsSliceModel, -// slapsSliceSupports, slapsRasterize, + slapsValidate, slapsCount }; enum SLAPrintObjectStep { + slaposObjectSlice, + slaposSupportIslands, slaposSupportPoints, slaposSupportTree, slaposBasePool, + slaposSliceSupports, slaposCount }; class SLAPrint; -class SLAPrintObject : public PrintObjectBaseWithState +class SLAPrintObject : public PrintObjectBaseWithState { private: // Prevents erroneous use by other classes. typedef PrintObjectBaseWithState Inherited; 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 &instances); + // Invalidates the step, and its depending steps in SLAPrintObject and SLAPrint. + bool invalidate_step(SLAPrintObjectStep step); 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 m_instances; + // sla::EigenMesh3D emesh; - std::vector instances; -// Transform3f tr; // std::unique_ptr support_tree_ptr; // SlicedSupports slice_cache;