Merge remote-tracking branch 'origin/dev_native' into tm_sla_supports_backend

This commit is contained in:
tamasmeszaros 2018-11-09 18:35:32 +01:00
commit e05063c8b1
3 changed files with 68 additions and 38 deletions

View File

@ -497,7 +497,7 @@ using ShapeData2D =
ShapeData2D projectModelFromTop(const Slic3r::Model &model) { ShapeData2D projectModelFromTop(const Slic3r::Model &model) {
ShapeData2D ret; ShapeData2D ret;
auto s = std::accumulate(model.objects.begin(), model.objects.end(), 0, auto s = std::accumulate(model.objects.begin(), model.objects.end(), size_t(0),
[](size_t s, ModelObject* o){ [](size_t s, ModelObject* o){
return s + o->instances.size(); return s + o->instances.size();
}); });

View File

@ -635,6 +635,31 @@ void Print::model_volume_list_update_supports(ModelObject &model_object_dst, con
} }
} }
static inline void model_volume_list_copy_configs(ModelObject &model_object_dst, const ModelObject &model_object_src, const ModelVolume::Type type)
{
size_t i_src, i_dst;
for (i_src = 0, i_dst = 0; i_src < model_object_src.volumes.size() && i_dst < model_object_dst.volumes.size();) {
const ModelVolume &mv_src = *model_object_src.volumes[i_src];
ModelVolume &mv_dst = *model_object_dst.volumes[i_dst];
if (mv_src.type() != type) {
++ i_src;
continue;
}
if (mv_dst.type() != type) {
++ i_dst;
continue;
}
assert(mv_src.id() == mv_dst.id());
// Copy the ModelVolume data.
mv_dst.name = mv_src.name;
mv_dst.config = mv_src.config;
//FIXME what to do with the materials?
// mv_dst.m_material_id = mv_src.m_material_id;
++ i_src;
++ i_dst;
}
}
static inline bool transform3d_lower(const Transform3d &lhs, const Transform3d &rhs) static inline bool transform3d_lower(const Transform3d &lhs, const Transform3d &rhs)
{ {
typedef Transform3d::Scalar T; typedef Transform3d::Scalar T;
@ -786,7 +811,6 @@ Print::ApplyStatus Print::apply(const Model &model, const DynamicPrintConfig &co
ModelObjectStatus(ModelID id, Status status = Unknown) : id(id), status(status) {} ModelObjectStatus(ModelID id, Status status = Unknown) : id(id), status(status) {}
ModelID id; ModelID id;
Status status; Status status;
t_config_option_keys object_config_diff;
// Search by id. // Search by id.
bool operator<(const ModelObjectStatus &rhs) const { return id < rhs.id; } bool operator<(const ModelObjectStatus &rhs) const { return id < rhs.id; }
}; };
@ -946,15 +970,13 @@ Print::ApplyStatus Print::apply(const Model &model, const DynamicPrintConfig &co
model_volume_list_update_supports(model_object, model_object_new); model_volume_list_update_supports(model_object, model_object_new);
} }
if (! model_parts_differ && ! modifiers_differ) { if (! model_parts_differ && ! modifiers_differ) {
// Synchronize the remaining data of ModelVolumes (name, config, m_type, m_material_id)
// Synchronize Object's config. // Synchronize Object's config.
t_config_option_keys &this_object_config_diff = const_cast<ModelObjectStatus&>(*it_status).object_config_diff; bool object_config_changed = model_object.config != model_object_new.config;
this_object_config_diff = model_object.config.diff(model_object_new.config); if (object_config_changed)
if (! this_object_config_diff.empty()) model_object.config = model_object_new.config;
model_object.config.apply_only(model_object_new.config, this_object_config_diff, true); if (! object_diff.empty() || object_config_changed) {
if (! object_diff.empty() || ! this_object_config_diff.empty()) {
PrintObjectConfig new_config = m_default_object_config; PrintObjectConfig new_config = m_default_object_config;
normalize_and_apply_config(new_config, model_object.config); normalize_and_apply_config(new_config, model_object.config);
auto range = print_object_status.equal_range(PrintObjectStatus(model_object.id())); auto range = print_object_status.equal_range(PrintObjectStatus(model_object.id()));
for (auto it = range.first; it != range.second; ++ it) { for (auto it = range.first; it != range.second; ++ it) {
t_config_option_keys diff = it->print_object->config().diff(new_config); t_config_option_keys diff = it->print_object->config().diff(new_config);
@ -964,6 +986,11 @@ Print::ApplyStatus Print::apply(const Model &model, const DynamicPrintConfig &co
} }
} }
} }
// Synchronize (just copy) the remaining data of ModelVolumes (name, config).
//FIXME What to do with m_material_id?
model_volume_list_copy_configs(model_object /* dst */, model_object_new /* src */, ModelVolume::MODEL_PART);
model_volume_list_copy_configs(model_object /* dst */, model_object_new /* src */, ModelVolume::PARAMETER_MODIFIER);
// Copy the ModelObject name, input_file and instances. The instances will compared against PrintObject instances in the next step.
model_object.name = model_object_new.name; model_object.name = model_object_new.name;
model_object.input_file = model_object_new.input_file; model_object.input_file = model_object_new.input_file;
model_object.clear_instances(); model_object.clear_instances();

View File

@ -905,59 +905,60 @@ public:
ConfigOptionFloat layer_height; ConfigOptionFloat layer_height;
// Radius in mm of the pointing side of the head. // Radius in mm of the pointing side of the head.
ConfigOptionFloat head_front_radius_mm /*= 0.2*/; ConfigOptionFloat support_head_front_radius /*= 0.2*/;
// How much the pinhead has to penetrate the model surface // How much the pinhead has to penetrate the model surface
ConfigOptionFloat head_penetraiton /*= 0.2*/; ConfigOptionFloat support_head_penetraiton /*= 0.2*/;
// Radius of the back side of the 3d arrow. // Radius of the back side of the 3d arrow.
ConfigOptionFloat head_back_radius_mm /*= 0.5*/; ConfigOptionFloat support_head_back_radius /*= 0.5*/;
// Width in mm from the back sphere center to the front sphere center. // Width in mm from the back sphere center to the front sphere center.
ConfigOptionFloat head_width_mm /*= 1.0*/; ConfigOptionFloat support_head_width /*= 1.0*/;
// Radius in mm of the support pillars. // Radius in mm of the support pillars.
// TODO: This parameter is invalid. The pillar radius will be dynamic in // TODO: This parameter is invalid. The pillar radius will be dynamic in
// nature. Merged pillars will have an increased thickness. This parameter // nature. Merged pillars will have an increased thickness. This parameter
// may serve as the maximum radius, or maybe an increase when two are merged // may serve as the maximum radius, or maybe an increase when two are merged
// The default radius will be derived from head_back_radius_mm // The default radius will be derived from head_back_radius_mm
ConfigOptionFloat pillar_radius_mm /*= 0.8*/; ConfigOptionFloat support_pillar_radius /*= 0.8*/;
// Radius in mm of the pillar base. // Radius in mm of the pillar base.
ConfigOptionFloat base_radius_mm /*= 2.0*/; ConfigOptionFloat support_base_radius /*= 2.0*/;
// The height of the pillar base cone in mm. // The height of the pillar base cone in mm.
ConfigOptionFloat base_height_mm /*= 1.0*/; ConfigOptionFloat support_base_height /*= 1.0*/;
// The default angle for connecting support sticks and junctions. // The default angle for connecting support sticks and junctions.
ConfigOptionFloat tilt /*= M_PI/4*/; ConfigOptionFloat support_critical_angle /*= M_PI/4*/;
// The max length of a bridge in mm // The max length of a bridge in mm
ConfigOptionFloat max_bridge_length_mm /*= 15.0*/; ConfigOptionFloat support_max_bridge_length /*= 15.0*/;
// Now for the base pool (plate) /////////////////////////////////////////// // Now for the base pool (plate) ///////////////////////////////////////////
ConfigOptionFloat pool_wall_thickness_mm /*= 2*/; ConfigOptionFloat pad_wall_thickness /*= 2*/;
ConfigOptionFloat pool_wall_height_mm /*= 5*/; ConfigOptionFloat pad_wall_height /*= 5*/;
ConfigOptionFloat pool_max_merge_distance_mm /*= 50*/; ConfigOptionFloat pad_max_merge_distance /*= 50*/;
ConfigOptionFloat pool_edge_radius_mm /*= 1*/; ConfigOptionFloat pad_edge_radius /*= 1*/;
protected: protected:
void initialize(StaticCacheBase &cache, const char *base_ptr) void initialize(StaticCacheBase &cache, const char *base_ptr)
{ {
OPT_PTR(layer_height); OPT_PTR(layer_height);
OPT_PTR(head_front_radius_mm); OPT_PTR(support_head_front_radius);
OPT_PTR(head_penetraiton); OPT_PTR(support_head_penetraiton);
OPT_PTR(head_back_radius_mm); OPT_PTR(support_head_back_radius);
OPT_PTR(head_width_mm); OPT_PTR(support_head_width);
OPT_PTR(pillar_radius_mm); OPT_PTR(support_pillar_radius);
OPT_PTR(base_radius_mm); OPT_PTR(support_base_radius);
OPT_PTR(base_height_mm); OPT_PTR(support_base_height);
OPT_PTR(tilt); OPT_PTR(support_critical_angle);
OPT_PTR(max_bridge_length_mm); OPT_PTR(support_max_bridge_length);
OPT_PTR(pool_wall_thickness_mm); OPT_PTR(pad_wall_thickness);
OPT_PTR(pool_wall_height_mm); OPT_PTR(pad_wall_height);
OPT_PTR(pool_max_merge_distance_mm); OPT_PTR(pad_max_merge_distance);
OPT_PTR(pool_edge_radius_mm); OPT_PTR(pad_edge_radius);
} }
}; };
@ -1070,9 +1071,10 @@ public:
}; };
// Overrides ConfigBase::def(). Static configuration definition. Any value stored into this ConfigBase shall have its definition here. // Overrides ConfigBase::def(). Static configuration definition. Any value stored into this ConfigBase shall have its definition here.
const ConfigDef* def() const override { return &cli_config_def; } const ConfigDef* def() const override { return &cli_config_def; }
t_config_option_keys keys() const override { return cli_config_def.keys(); }
ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) override ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) override
{ {
OPT_PTR(cut); OPT_PTR(cut);
OPT_PTR(datadir); OPT_PTR(datadir);
@ -1105,7 +1107,8 @@ public:
DynamicPrintAndCLIConfig(const DynamicPrintAndCLIConfig &other) : DynamicPrintConfig(other) {} DynamicPrintAndCLIConfig(const DynamicPrintAndCLIConfig &other) : DynamicPrintConfig(other) {}
// Overrides ConfigBase::def(). Static configuration definition. Any value stored into this ConfigBase shall have its definition here. // Overrides ConfigBase::def(). Static configuration definition. Any value stored into this ConfigBase shall have its definition here.
const ConfigDef* def() const override { return &s_def; } const ConfigDef* def() const override { return &s_def; }
t_config_option_keys keys() const override { return s_def.keys(); }
private: private:
class PrintAndCLIConfigDef : public ConfigDef class PrintAndCLIConfigDef : public ConfigDef