mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
WIP: SLAPrintObjectConfig, SLAPrint / SLAPrintObject initialization.
This commit is contained in:
parent
06a51f9ed3
commit
870c435e1b
6 changed files with 92 additions and 20 deletions
|
@ -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;
|
||||
|
|
|
@ -270,8 +270,8 @@ template<typename PrintType, typename PrintObjectStepEnum, const size_t COUNT>
|
|||
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); }
|
||||
|
||||
|
|
|
@ -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::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::SLAFullPrintConfig> SLAFullPrintConfig::s_cache_SLAFullPrintConfig;
|
||||
|
||||
|
||||
CLIConfigDef::CLIConfigDef()
|
||||
{
|
||||
ConfigOptionDef *def;
|
||||
|
|
|
@ -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,10 +968,11 @@ 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->SLAPrintObjectConfig::initialize(cache, base_ptr);
|
||||
this->SLAMaterialConfig ::initialize(cache, base_ptr);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Print, SLAPrintObjectStep, slaposCount>
|
||||
class SLAPrintObject : public PrintObjectBaseWithState<SLAPrint, SLAPrintObjectStep, slaposCount>
|
||||
{
|
||||
private: // Prevents erroneous use by other classes.
|
||||
typedef PrintObjectBaseWithState<Print, SLAPrintObjectStep, slaposCount> 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<Instance> &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<Instance> m_instances;
|
||||
|
||||
// sla::EigenMesh3D emesh;
|
||||
std::vector<Vec2f> instances;
|
||||
// Transform3f tr;
|
||||
// std::unique_ptr<sla::SLASupportTree> support_tree_ptr;
|
||||
// SlicedSupports slice_cache;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue