mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Added calculation of the material consumption
This commit is contained in:
parent
589ac889a3
commit
88f04e0fae
3 changed files with 64 additions and 13 deletions
|
@ -1033,16 +1033,52 @@ bool SLAPrint::invalidate_state_by_config_options(const std::vector<t_config_opt
|
||||||
|
|
||||||
void SLAPrint::fill_statistics()
|
void SLAPrint::fill_statistics()
|
||||||
{
|
{
|
||||||
|
float supports_volume = 0.0;
|
||||||
|
float models_volume = 0.0;
|
||||||
|
|
||||||
|
int max_layers_cnt = 0;
|
||||||
|
|
||||||
|
const float init_layer_height = m_material_config.initial_layer_height.getFloat();
|
||||||
|
const float layer_height = m_default_object_config.layer_height.getFloat();
|
||||||
|
|
||||||
|
// Used material
|
||||||
|
for (SLAPrintObject * po : m_objects) {
|
||||||
|
// Calculate full volume of the supports (+pad)
|
||||||
|
for (const ExPolygons& polygons : po->get_support_slices())
|
||||||
|
for (const ExPolygon& polygon : polygons)
|
||||||
|
supports_volume += polygon.area() *layer_height;
|
||||||
|
|
||||||
|
// Calculate full volume of the object
|
||||||
|
for (const ExPolygons& polygons : po->get_model_slices())
|
||||||
|
for (const ExPolygon& polygon : polygons)
|
||||||
|
models_volume += polygon.area() *layer_height;
|
||||||
|
|
||||||
|
const SLAPrintObject::SliceIndex& slice_index = po->get_slice_index();
|
||||||
|
|
||||||
|
// If init_layer_height isn't equivalent to the layer_height,
|
||||||
|
// let correct volume of the first(initial) layer
|
||||||
|
if (init_layer_height != layer_height)
|
||||||
|
{
|
||||||
|
const auto index = slice_index.begin();
|
||||||
|
if (index->second.support_slices_idx != SLAPrintObject::SliceRecord::NONE)
|
||||||
|
for (const ExPolygon& polygon : po->get_support_slices().front())
|
||||||
|
supports_volume += polygon.area() *(init_layer_height - layer_height);
|
||||||
|
if (index->second.model_slices_idx != SLAPrintObject::SliceRecord::NONE)
|
||||||
|
for (const ExPolygon& polygon : po->get_model_slices().front())
|
||||||
|
models_volume += polygon.area() *(init_layer_height - layer_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (max_layers_cnt < slice_index.size())
|
||||||
|
max_layers_cnt = slice_index.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_print_statistics.support_used_material = supports_volume * SCALING_FACTOR * SCALING_FACTOR;
|
||||||
|
m_print_statistics.objects_used_material = models_volume * SCALING_FACTOR * SCALING_FACTOR;
|
||||||
|
|
||||||
// Estimated printing time
|
// Estimated printing time
|
||||||
// A layers count o the highest object
|
// A layers count o the highest object
|
||||||
int max_layers_cnt = 0;
|
|
||||||
for (SLAPrintObject * po : m_objects) {
|
|
||||||
if (max_layers_cnt < po->get_slice_index().size())
|
|
||||||
max_layers_cnt = po->get_slice_index().size();
|
|
||||||
}
|
|
||||||
if (max_layers_cnt == 0)
|
if (max_layers_cnt == 0)
|
||||||
return;
|
m_print_statistics.estimated_print_time = "N/A";
|
||||||
|
|
||||||
float init_exp_time = m_material_config.initial_exposure_time.getFloat();//35;
|
float init_exp_time = m_material_config.initial_exposure_time.getFloat();//35;
|
||||||
float exp_time = m_material_config.exposure_time.getFloat();//8;
|
float exp_time = m_material_config.exposure_time.getFloat();//8;
|
||||||
|
|
||||||
|
@ -1308,7 +1344,8 @@ DynamicConfig SLAPrintStatistics::config() const
|
||||||
DynamicConfig config;
|
DynamicConfig config;
|
||||||
const std::string print_time = Slic3r::short_time(this->estimated_print_time);
|
const std::string print_time = Slic3r::short_time(this->estimated_print_time);
|
||||||
config.set_key_value("print_time", new ConfigOptionString(print_time));
|
config.set_key_value("print_time", new ConfigOptionString(print_time));
|
||||||
config.set_key_value("used_material", new ConfigOptionFloat(this->total_used_material/* / 1000.*/));
|
config.set_key_value("objects_used_material", new ConfigOptionFloat(this->objects_used_material));
|
||||||
|
config.set_key_value("support_used_material", new ConfigOptionFloat(this->support_used_material));
|
||||||
config.set_key_value("total_cost", new ConfigOptionFloat(this->total_cost));
|
config.set_key_value("total_cost", new ConfigOptionFloat(this->total_cost));
|
||||||
config.set_key_value("total_weight", new ConfigOptionFloat(this->total_weight));
|
config.set_key_value("total_weight", new ConfigOptionFloat(this->total_weight));
|
||||||
return config;
|
return config;
|
||||||
|
@ -1318,7 +1355,8 @@ DynamicConfig SLAPrintStatistics::placeholders()
|
||||||
{
|
{
|
||||||
DynamicConfig config;
|
DynamicConfig config;
|
||||||
for (const std::string &key : {
|
for (const std::string &key : {
|
||||||
"print_time", "used_material", "total_cost", "total_weight" })
|
"print_time", "total_cost", "total_weight",
|
||||||
|
"objects_used_material", "support_used_material" })
|
||||||
config.set_key_value(key, new ConfigOptionString(std::string("{") + key + "}"));
|
config.set_key_value(key, new ConfigOptionString(std::string("{") + key + "}"));
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,8 @@ struct SLAPrintStatistics
|
||||||
{
|
{
|
||||||
SLAPrintStatistics() { clear(); }
|
SLAPrintStatistics() { clear(); }
|
||||||
std::string estimated_print_time;
|
std::string estimated_print_time;
|
||||||
double total_used_material;
|
double objects_used_material;
|
||||||
|
double support_used_material;
|
||||||
double total_cost;
|
double total_cost;
|
||||||
double total_weight;
|
double total_weight;
|
||||||
|
|
||||||
|
@ -188,7 +189,8 @@ struct SLAPrintStatistics
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
estimated_print_time.clear();
|
estimated_print_time.clear();
|
||||||
total_used_material = 0.;
|
objects_used_material = 0.;
|
||||||
|
support_used_material = 0.;
|
||||||
total_cost = 0.;
|
total_cost = 0.;
|
||||||
total_weight = 0.;
|
total_weight = 0.;
|
||||||
}
|
}
|
||||||
|
|
|
@ -822,8 +822,19 @@ void Sidebar::show_sliced_info_sizer(const bool show)
|
||||||
if (p->plater->printer_technology() == ptSLA)
|
if (p->plater->printer_technology() == ptSLA)
|
||||||
{
|
{
|
||||||
const SLAPrintStatistics& ps = p->plater->sla_print().print_statistics();
|
const SLAPrintStatistics& ps = p->plater->sla_print().print_statistics();
|
||||||
p->sliced_info->SetTextAndShow(siMateril_unit, wxString::Format("%.2f", ps.total_used_material));
|
wxString new_label = _(L("Used Material (mm³)")) + " :";
|
||||||
p->sliced_info->SetTextAndShow(siCost, wxString::Format("%.2f", ps.total_cost));
|
const bool is_supports = ps.support_used_material > 0.0;
|
||||||
|
if (is_supports)
|
||||||
|
new_label += wxString::Format("\n - %s\n - %s", _(L("object(s)")), _(L("supports and pad")));
|
||||||
|
|
||||||
|
wxString info_text = is_supports ?
|
||||||
|
wxString::Format("%.2f \n%.2f \n%.2f", ps.objects_used_material + ps.support_used_material/* / 1000*/,
|
||||||
|
ps.objects_used_material/* / 1000*/,
|
||||||
|
ps.support_used_material/* / 1000*/) :
|
||||||
|
wxString::Format("%.2f", ps.objects_used_material + ps.support_used_material/* / 1000*/);
|
||||||
|
p->sliced_info->SetTextAndShow(siMateril_unit, info_text, new_label);
|
||||||
|
|
||||||
|
p->sliced_info->SetTextAndShow(siCost, "N/A"/*wxString::Format("%.2f", ps.total_cost)*/);
|
||||||
p->sliced_info->SetTextAndShow(siEstimatedTime, ps.estimated_print_time, _(L("Estimated printing time")) + " :");
|
p->sliced_info->SetTextAndShow(siEstimatedTime, ps.estimated_print_time, _(L("Estimated printing time")) + " :");
|
||||||
|
|
||||||
// Hide non-SLA sliced info parameters
|
// Hide non-SLA sliced info parameters
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue